Salome HOME
Implement engineIOR() and getEngine() methods for Python modules GUI.
[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 #include <SALOMEconfig.h>
24 #include CORBA_CLIENT_HEADER(SALOME_Component)
25
26 class SALOME_PYQT_XmlHandler;
27
28 class SALOME_PYQT_EXPORT SALOME_PYQT_Module: public SalomeApp_Module
29 {
30   Q_OBJECT;
31
32   /******************************
33    * Data
34    ******************************/
35
36 private:
37   typedef std::map<int, SALOME_PYQT_PyInterp*> InterpMap;
38
39   /* study-to-subinterpreter map */
40   static InterpMap                 myInterpMap;
41   /* current Python subinterpreter */
42   SALOME_PYQT_PyInterp*            myInterp;
43   /* Python GUI module loaded */
44   PyObjWrapper                     myModule;
45
46   typedef QPtrList<QAction> ActionList;
47   
48   /* own actions list */
49   ActionList                       myMenuActionList;
50   ActionList                       myPopupActionList;
51   ActionList                       myToolbarActionList;
52  
53   enum PyQtGUIAction { PYQT_ACTION_MENU    = 10000000,
54                        PYQT_ACTION_TOOLBAL = 20000000,
55                        PYQT_ACTION_POPUP   = 30000000 };
56
57   /* XML resource file parser */
58   SALOME_PYQT_XmlHandler*          myXmlHandler;  
59   /* windows map*/
60   QMap<int, int>                   myWindowsMap;
61   /* compatible view managers list */
62   QStringList                      myViewMgrList;
63   
64   /******************************
65    * Construction/destruction
66    ******************************/
67
68 public:
69   /* constructor */
70   SALOME_PYQT_Module();
71   /* destructor */
72   ~SALOME_PYQT_Module();
73
74   /* get module engine */
75   Engines::Component_var getEngine() const;
76
77   /******************************
78    * Inherited from CAM_Module 
79    ******************************/
80
81 public:
82   /* initialization */
83   void            initialize  ( CAM_Application* );
84
85   /* getting windows list */
86   void            windows     ( QMap<int, int>& ) const;
87   /* getting compatible viewer managers list */
88   void            viewManagers( QStringList& ) const;
89
90   /* context popup menu request */
91   void            contextMenuPopup( const QString&, QPopupMenu*, QString& );
92
93   /* get module engine IOR */
94   virtual QString engineIOR() const;
95
96 protected:
97   /* data model creation */
98   CAM_DataModel*  createDataModel();
99
100 public slots:
101   /* activation */
102   void            activateModule( SUIT_Study* );
103   /* deactivation */
104   void            deactivateModule( SUIT_Study* );
105
106   /******************************
107    * Internal methods
108    ******************************/
109
110 public slots:
111   /* GUI action processing slot */
112   void            onGUIEvent();
113   /* desktop activation slot */ 
114   void            onDesktopActivated();
115
116 private:
117   /* internal initizalition */ 
118   void            init        ( CAM_Application* );
119   /* internal activation */ 
120   void            activate    ( SUIT_Study* );
121   /* internal deactivation */ 
122   void            deactivate  ( SUIT_Study* );
123   /* study activation */ 
124   void            studyChanged( SUIT_Study* );
125   /* context popup menu processing */
126   void            contextMenu( const QString&, QPopupMenu* );
127   /* GUI event processing */
128   void            guiEvent( const int );
129
130   /* add action to the private action map */ 
131   void            addAction   ( const PyQtGUIAction, QAction* );
132
133   /* initialize a Python subinterpreter */
134   void            initInterp  ( int );
135   /* import a Python GUI module */
136   void            importModule();
137   /* set workspace to Python GUI module */
138   void            setWorkSpace();
139
140   friend class SALOME_PYQT_XmlHandler;
141 };
142
143 #endif // SALOME_PYQT_MODULE_H