1 // Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #ifndef SALOME_PYQT_MODULE_H
21 #define SALOME_PYQT_MODULE_H
23 #include "SALOME_PYQT_GUI.h"
25 #include "SALOME_PYQT_PyInterp.h" // this include must be first (see PyInterp_base.h)!
26 #include "SalomeApp_Module.h"
30 #include <qstringlist.h>
33 #include <SALOMEconfig.h>
34 #include CORBA_CLIENT_HEADER(SALOME_Component)
36 class SALOME_PYQT_XmlHandler;
38 class SALOME_PYQT_EXPORT SALOME_PYQT_Module: public SalomeApp_Module
42 /******************************
44 ******************************/
47 typedef std::map<int, SALOME_PYQT_PyInterp*> InterpMap;
49 /* study-to-subinterpreter map */
50 static InterpMap myInterpMap;
51 /* current Python subinterpreter */
52 SALOME_PYQT_PyInterp* myInterp;
53 /* Python GUI module loaded */
54 PyObjWrapper myModule;
55 /* Python GUI being initialized (not zero only during the initialization)*/
56 static SALOME_PYQT_Module* myInitModule;
63 MenuId() : id( -1 ), constantMenu( false ) {}
64 MenuId( const int _id, const bool _constantMenu )
65 : id( _id ), constantMenu( _constantMenu ) {}
67 typedef QValueList<MenuId> MenuIdList;
68 typedef QMap<int,MenuIdList> MenuMap;
71 /* XML resource file parser */
72 SALOME_PYQT_XmlHandler* myXmlHandler;
74 QMap<int, int> myWindowsMap;
75 /* compatible view managers list */
76 QStringList myViewMgrList;
78 /******************************
79 * Construction/destruction
80 ******************************/
86 ~SALOME_PYQT_Module();
88 /* get module engine */
89 Engines::Component_var getEngine() const;
91 /******************************
92 * Inherited from SalomeApp_Module
93 ******************************/
96 /* little trick : provide an access to being activated Python module from outside;
97 needed by the SalomePyQt library :(
99 static SALOME_PYQT_Module* getInitModule();
102 void initialize ( CAM_Application* );
104 /* getting windows list */
105 void windows ( QMap<int, int>& ) const;
106 /* getting compatible viewer managers list */
107 void viewManagers( QStringList& ) const;
109 /* context popup menu request */
110 void contextMenuPopup( const QString&, QPopupMenu*, QString& );
112 /* get module engine IOR */
113 virtual QString engineIOR() const;
115 /* called when study desktop is activated */
116 virtual void studyActivated();
118 /* returns default menu group */
119 static int defaultMenuGroup();
121 /* working with toolbars : open protected methods */
122 int createTool( const QString& );
123 int createTool( const int, const int, const int = -1 );
124 int createTool( const int, const QString&, const int = -1 );
125 int createTool( QAction*, const int, const int = -1, const int = -1 );
126 int createTool( QAction*, const QString&, const int = -1, const int = -1 );
128 /* working with menus : open protected methods */
129 int createMenu( const QString&, const int, const int = -1, const int = -1, const int = -1, const bool = false );
130 int createMenu( const QString&, const QString&, const int = -1, const int = -1, const int = -1, const bool = false );
131 int createMenu( const int, const int, const int = -1, const int = -1, const bool = false );
132 int createMenu( const int, const QString&, const int = -1, const int = -1, const bool = false );
133 int createMenu( QAction*, const int, const int = -1, const int = -1, const int = -1, const bool = false );
134 int createMenu( QAction*, const QString&, const int = -1, const int = -1, const int = -1, const bool = false );
136 /* clear given menu */
137 bool clearMenu( const int = 0, const int = 0, const bool = true );
139 /* create separator : open protected method */
140 QAction* createSeparator();
142 /* working with actions : open protected methods */
143 QAction* action( const int ) const;
144 int actionId( const QAction* ) const;
145 QAction* createAction( const int, const QString&, const QString&, const QString&,
146 const QString&, const int, const bool = false );
147 /* load icon from resource file */
148 QIconSet loadIcon( const QString& fileName );
150 /* Show/hide menus/toolbars */
151 void setMenuShown( const bool );
152 void setToolShown( const bool );
156 virtual bool activateModule( SUIT_Study* );
158 virtual bool deactivateModule( SUIT_Study* );
160 /******************************
162 ******************************/
165 /* GUI action processing slots */
167 void onGUIEvent( int );
170 /* Menu processing */
171 bool hasMenu( const QString&, const int );
172 void registerMenu( const int, const int, const bool = false );
173 void unregisterMenu( const int, const int );
174 bool registered( const int, const int = 0 );
175 bool isConstantMenu( const int, const int );
178 void onMenuHighlighted( int, int );
181 /* internal initizalition */
182 void init ( CAM_Application* );
183 /* internal activation */
184 void activate ( SUIT_Study* );
185 /* internal deactivation */
186 void deactivate ( SUIT_Study* );
188 void customize ( SUIT_Study* );
189 /* study activation */
190 void studyChanged( SUIT_Study* );
191 /* context popup menu processing */
192 void contextMenu( const QString&, QPopupMenu* );
193 /* GUI event processing */
194 void guiEvent( const int );
195 /* Menu highlight processing */
196 void menuHighlight( const int, const int );
198 /* initialize a Python subinterpreter */
199 void initInterp ( int );
200 /* import a Python GUI module */
202 /* set workspace to Python GUI module */
205 friend class SALOME_PYQT_XmlHandler;
208 #endif // SALOME_PYQT_MODULE_H