Version: 8.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SALOME_PYQT_PyModule.h
Go to the documentation of this file.
1 // Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 
20 // File : SALOME_PYQT_PyModule.h
21 // Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
22 //
23 
24 #ifndef SALOME_PYQT_PYMODULE_H
25 #define SALOME_PYQT_PYMODULE_H
26 
27 #include "SALOME_PYQT_GUILight.h"
28 
29 #include "PyInterp_Interp.h" // !!! WARNING !!! THIS INCLUDE MUST BE THE VERY FIRST !!!
30 
31 #include <QIcon>
32 #include <QList>
33 #include <QMap>
34 #include <QObject>
35 #include <QStringList>
36 
37 class CAM_Application;
39 class LightApp_Module;
40 class PyInterp_Interp;
41 class QAction;
42 class QMenu;
43 class SUIT_DataObject;
44 class SUIT_Study;
46 
48 
50 {
51  Q_OBJECT
52 
53 private:
54  class XmlHandler;
55  class InitLocker;
56 
57  typedef QMap<int, PyInterp_Interp*> InterpMap;
58 
61 
63  PyObject* myPyModule;
66  QMap<int, int> myWindowsMap;
67  QStringList myViewMgrList;
69 
70 public:
72  ~PyModuleHelper();
73 
74  static LightApp_Module* getInitModule();
75  static int defaultMenuGroup();
76 
77  LightApp_Module* module() const;
78  PyObject* pythonModule() const;
79 
80  void connectAction( QAction* );
81 
82  QMap<int, int> windows() const;
83  QStringList viewManagers() const;
84 
85 public slots:
86  void initialize( CAM_Application* );
87  bool activate( SUIT_Study* study );
88  bool deactivate( SUIT_Study* study );
89  void modelClosed( SUIT_Study* study );
90  void preferencesChanged( const QString&, const QString& setting );
91  void preferenceChanged( const QString&, const QString&, const QString& setting );
92  void studyActivated( SUIT_Study* );
93  void actionActivated();
94  void selectionUpdated(const QStringList&);
95  void contextMenu( const QString&, QMenu* );
96  void createPreferences();
97  void activeViewChanged( SUIT_ViewWindow* );
98  void tryCloseView( SUIT_ViewWindow* );
99  void closeView( SUIT_ViewWindow* );
100  void cloneView( SUIT_ViewWindow* );
101  void save( QStringList&, const QString& );
102  bool load( const QStringList&, const QString& );
103  void dumpPython( QStringList& files );
104  bool isDraggable( const SUIT_DataObject* ) const;
105  bool isDropAccepted( const SUIT_DataObject* ) const;
106  void dropObjects( const DataObjectList&, SUIT_DataObject*,
107  const int, Qt::DropAction );
108  QString engineIOR() const;
109 
110  void onObjectBrowserClicked(SUIT_DataObject*, int);
111 
112 private:
113  void initInterp( int );
114  void importModule();
115  void setWorkSpace();
116 
117  void internalInitialize( CAM_Application* );
118  void internalActivate( SUIT_Study* );
119  void internalCustomize( SUIT_Study* );
120  void internalDeactivate( SUIT_Study* );
121  void internalClosedStudy( SUIT_Study* );
122  void internalPreferencesChanged( const QString&, const QString& );
123  void internalStudyChanged( SUIT_Study* );
124  void internalActionActivated( int );
125  void internalSelectionUpdated(const QStringList&);
126  void internalContextMenu( const QString&, QMenu* );
127  void internalCreatePreferences();
128  void internalActiveViewChanged( SUIT_ViewWindow* );
129  void internalTryCloseView( SUIT_ViewWindow* );
130  void internalCloseView( SUIT_ViewWindow* );
131  void internalCloneView( SUIT_ViewWindow* );
132  void internalSave( QStringList&, const QString& );
133  void internalLoad( const QStringList&, const QString&, bool& );
134  void internalDumpPython( QStringList& );
135  bool internalIsDraggable( LightApp_DataObject* );
136  bool internalIsDropAccepted( LightApp_DataObject* );
137  void internalDropObjects( const DataObjectList&, SUIT_DataObject*,
138  const int, Qt::DropAction );
139  QString internalEngineIOR() const;
140  void internalOBClickedPython( const QString&, int );
141 
142  void connectView( SUIT_ViewWindow* );
143 };
144 
145 #endif // SALOME_PYQT_PYMODULE_H