1 //=============================================================================
2 // File : SALOME_PYQT_Module.h
4 // Author : Vadim SANDLER
6 // Copyright : 2003-2005 CEA/DEN, EDF R&D
8 //=============================================================================
10 #ifndef SALOME_PYQT_MODULE_H
11 #define SALOME_PYQT_MODULE_H
13 #include "SALOME_PYQT_GUI.h"
15 #include "SALOME_PYQT_PyInterp.h" // this include must be first (see PyInterp_base.h)!
16 #include "SalomeApp_Module.h"
20 #include <qstringlist.h>
23 #include <SALOMEconfig.h>
24 #include CORBA_CLIENT_HEADER(SALOME_Component)
26 class SALOME_PYQT_XmlHandler;
28 class SALOME_PYQT_EXPORT SALOME_PYQT_Module: public SalomeApp_Module
32 /******************************
34 ******************************/
37 typedef std::map<int, SALOME_PYQT_PyInterp*> InterpMap;
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 /* Pytho GUI being initialized (not zero only during the initialization)*/
46 static SALOME_PYQT_Module* myInitModule;
48 typedef QPtrList<QAction> ActionList;
50 /* own actions list */
51 ActionList myMenuActionList;
52 ActionList myPopupActionList;
53 ActionList myToolbarActionList;
55 enum PyQtGUIAction { PYQT_ACTION_MENU = 10000000,
56 PYQT_ACTION_TOOLBAL = 20000000,
57 PYQT_ACTION_POPUP = 30000000 };
59 /* XML resource file parser */
60 SALOME_PYQT_XmlHandler* myXmlHandler;
62 QMap<int, int> myWindowsMap;
63 /* compatible view managers list */
64 QStringList myViewMgrList;
66 /******************************
67 * Construction/destruction
68 ******************************/
74 ~SALOME_PYQT_Module();
76 /* get module engine */
77 Engines::Component_var getEngine() const;
79 /******************************
80 * Inherited from SalomeApp_Module
81 ******************************/
84 /* little trick : provide an access to being activated Python module from outside;
85 needed by the SalomePyQt library :(
87 static SALOME_PYQT_Module* getInitModule();
90 void initialize ( CAM_Application* );
92 /* getting windows list */
93 void windows ( QMap<int, int>& ) const;
94 /* getting compatible viewer managers list */
95 void viewManagers( QStringList& ) const;
97 /* context popup menu request */
98 void contextMenuPopup( const QString&, QPopupMenu*, QString& );
100 /* get module engine IOR */
101 virtual QString engineIOR() const;
103 /* called when study desktop is activated */
104 virtual void studyActivated();
106 /* working with toolbars : open protected methods */
107 int createTool( const QString& );
108 int createTool( const int, const int, const int = -1 );
109 int createTool( const int, const QString&, const int = -1 );
110 int createTool( QAction*, const int, const int = -1, const int = -1 );
111 int createTool( QAction*, const QString&, const int = -1, const int = -1 );
113 /* working with menus : open protected methods */
114 int createMenu( const QString&, const int, const int = -1, const int = -1, const int = -1 );
115 int createMenu( const QString&, const QString&, const int = -1, const int = -1, const int = -1 );
116 int createMenu( const int, const int, const int = -1, const int = -1 );
117 int createMenu( const int, const QString&, const int = -1, const int = -1 );
118 int createMenu( QAction*, const int, const int = -1, const int = -1, const int = -1 );
119 int createMenu( QAction*, const QString&, const int = -1, const int = -1, const int = -1 );
121 /* create separator : open protected method */
122 QAction* createSeparator();
124 /* working with actions : open protected methods */
125 QAction* action( const int ) const;
126 int actionId( const QAction* ) const;
127 QAction* createAction( const int, const QString&, const QString&, const QString&,
128 const QString&, const int, const bool = false );
132 virtual bool activateModule( SUIT_Study* );
134 virtual bool deactivateModule( SUIT_Study* );
136 /******************************
138 ******************************/
141 /* GUI action processing slots */
143 void onGUIEvent( int );
146 /* internal initizalition */
147 void init ( CAM_Application* );
148 /* internal activation */
149 void activate ( SUIT_Study* );
150 /* internal deactivation */
151 void deactivate ( SUIT_Study* );
152 /* study activation */
153 void studyChanged( SUIT_Study* );
154 /* context popup menu processing */
155 void contextMenu( const QString&, QPopupMenu* );
156 /* GUI event processing */
157 void guiEvent( const int );
159 /* add action to the private action map */
160 void addAction ( const PyQtGUIAction, QAction* );
162 /* initialize a Python subinterpreter */
163 void initInterp ( int );
164 /* import a Python GUI module */
166 /* set workspace to Python GUI module */
169 friend class SALOME_PYQT_XmlHandler;
172 #endif // SALOME_PYQT_MODULE_H