Salome HOME
Initial version
[modules/gui.git] / src / SALOME_PYQT / SALOME_PYQT_GUI / SALOME_PYQT_Module.h
1 //=============================================================================
2 // File      : SALOME_PYQT_Module.h
3 // Created   : 25/04/05
4 // Author    : Vadim SANDLER
5 // Project   : SALOME
6 // Copyright : 2003-2005 CEA/DEN, EDF R&D
7 // $Header   : $
8 //=============================================================================
9
10 #ifndef SALOME_PYQT_MODULE_H
11 #define SALOME_PYQT_MODULE_H
12
13 #include "SALOME_PYQT_GUI.h"
14
15 #include "SALOME_PYQT_PyInterp.h" // this include must be first (see PyInterp_base.h)!
16 #include "SalomeApp_Module.h"
17 #include <map>
18 #include <qaction.h>
19 #include <qptrlist.h>
20 #include <qstringlist.h>
21 #include <qmap.h>
22
23 class SALOME_PYQT_XmlHandler;
24
25 class SALOME_PYQT_EXPORT SALOME_PYQT_Module: public SalomeApp_Module
26 {
27   Q_OBJECT;
28
29   /******************************
30    * Data
31    ******************************/
32
33 private:
34   typedef std::map<int, SALOME_PYQT_PyInterp*> InterpMap;
35
36   /* study-to-subinterpreter map */
37   static InterpMap                 myInterpMap;
38   /* current Python subinterpreter */
39   SALOME_PYQT_PyInterp*            myInterp;
40   /* Python GUI module loaded */
41   PyObjWrapper                     myModule;
42
43   typedef QPtrList<QAction> ActionList;
44   
45   /* own actions list */
46   ActionList                       myMenuActionList;
47   ActionList                       myPopupActionList;
48   ActionList                       myToolbarActionList;
49  
50   enum PyQtGUIAction { PYQT_ACTION_MENU    = 10000000,
51                        PYQT_ACTION_TOOLBAL = 20000000,
52                        PYQT_ACTION_POPUP   = 30000000 };
53
54   /* XML resource file parser */
55   SALOME_PYQT_XmlHandler*          myXmlHandler;  
56   /* windows map*/
57   QMap<int, int>                   myWindowsMap;
58   /* compatible view managers list */
59   QStringList                      myViewMgrList;
60   
61   /******************************
62    * Construction/destruction
63    ******************************/
64
65 public:
66   /* constructor */
67   SALOME_PYQT_Module();
68   /* destructor */
69   ~SALOME_PYQT_Module();
70
71   /******************************
72    * Inherited from CAM_Module 
73    ******************************/
74
75 public:
76   /* initialization */
77   void           initialize  ( CAM_Application* );
78
79   /* getting windows list */
80   void           windows     ( QMap<int, int>& ) const;
81   /* getting compatible viewer managers list */
82   void           viewManagers( QStringList& ) const;
83
84   /* context popup menu request */
85   void           contextMenuPopup( const QString&, QPopupMenu* );
86   
87 protected:
88   /* data model creation */
89   CAM_DataModel* createDataModel();
90
91 public slots:
92   /* activation */
93   void           activateModule  ( SUIT_Study* );
94   /* deactivation */
95   void           deactivateModule( SUIT_Study* );
96
97   /******************************
98    * Internal methods
99    ******************************/
100
101 public slots:
102   /* GUI action processing slot */
103   void           onGUIEvent();
104   /* desktop activation slot */ 
105   void           onDesktopActivated();
106  
107 private:
108   /* internal initizalition */ 
109   void           init        ( CAM_Application* );
110   /* internal activation */ 
111   void           activate    ( SUIT_Study* );
112   /* internal deactivation */ 
113   void           deactivate  ( SUIT_Study* );
114   /* study activation */ 
115   void           studyChanged( SUIT_Study* );
116   /* context popup menu processing */
117   void           contextMenu( const QString&, QPopupMenu* );
118   /* GUI event processing */
119   void           guiEvent( const int );
120
121   /* add action to the private action map */ 
122   void           addAction   ( const PyQtGUIAction, QAction* );
123
124   /* initialize a Python subinterpreter */
125   void           initInterp  ( int );
126   /* import a Python GUI module */
127   void           importModule();
128   /* set workspace to Python GUI module */
129   void           setWorkSpace();
130
131 friend class SALOME_PYQT_XmlHandler;
132 };
133
134 #endif // SALOME_PYQT_MODULE_H