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/
19 //=============================================================================
20 // File : SALOME_PYQT_Module.h
22 // Author : Vadim SANDLER
24 // Copyright : 2003-2005 CEA/DEN, EDF R&D
26 //=============================================================================
28 #ifndef SALOME_PYQT_MODULE_H
29 #define SALOME_PYQT_MODULE_H
31 #include "SALOME_PYQT_GUI.h"
33 #include "SALOME_PYQT_PyInterp.h" // this include must be first (see PyInterp_base.h)!
34 #include "SalomeApp_Module.h"
38 #include <qstringlist.h>
41 #include <SALOMEconfig.h>
42 #include CORBA_CLIENT_HEADER(SALOME_Component)
44 class SALOME_PYQT_XmlHandler;
46 class SALOME_PYQT_EXPORT SALOME_PYQT_Module: public SalomeApp_Module
50 /******************************
52 ******************************/
55 typedef std::map<int, SALOME_PYQT_PyInterp*> InterpMap;
57 /* study-to-subinterpreter map */
58 static InterpMap myInterpMap;
59 /* current Python subinterpreter */
60 SALOME_PYQT_PyInterp* myInterp;
61 /* Python GUI module loaded */
62 PyObjWrapper myModule;
63 /* Python GUI being initialized (not zero only during the initialization)*/
64 static SALOME_PYQT_Module* myInitModule;
71 MenuId() : id( -1 ), constantMenu( false ) {}
72 MenuId( const int _id, const bool _constantMenu )
73 : id( _id ), constantMenu( _constantMenu ) {}
75 typedef QValueList<MenuId> MenuIdList;
76 typedef QMap<int,MenuIdList> MenuMap;
79 /* XML resource file parser */
80 SALOME_PYQT_XmlHandler* myXmlHandler;
82 QMap<int, int> myWindowsMap;
83 /* compatible view managers list */
84 QStringList myViewMgrList;
86 /******************************
87 * Construction/destruction
88 ******************************/
94 ~SALOME_PYQT_Module();
96 /* get module engine */
97 Engines::Component_var getEngine() const;
99 /******************************
100 * Inherited from SalomeApp_Module
101 ******************************/
104 /* little trick : provide an access to being activated Python module from outside;
105 needed by the SalomePyQt library :(
107 static SALOME_PYQT_Module* getInitModule();
110 void initialize ( CAM_Application* );
112 /* getting windows list */
113 void windows ( QMap<int, int>& ) const;
114 /* getting compatible viewer managers list */
115 void viewManagers( QStringList& ) const;
117 /* context popup menu request */
118 void contextMenuPopup( const QString&, QPopupMenu*, QString& );
120 /* get module engine IOR */
121 virtual QString engineIOR() const;
123 /* called when study desktop is activated */
124 virtual void studyActivated();
126 /* returns default menu group */
127 static int defaultMenuGroup();
129 /* working with toolbars : open protected methods */
130 int createTool( const QString& );
131 int createTool( const int, const int, const int = -1 );
132 int createTool( const int, const QString&, const int = -1 );
133 int createTool( QAction*, const int, const int = -1, const int = -1 );
134 int createTool( QAction*, const QString&, const int = -1, const int = -1 );
136 /* working with menus : open protected methods */
137 int createMenu( const QString&, const int, const int = -1, const int = -1, const int = -1, const bool = false );
138 int createMenu( const QString&, const QString&, const int = -1, const int = -1, const int = -1, const bool = false );
139 int createMenu( const int, const int, const int = -1, const int = -1, const bool = false );
140 int createMenu( const int, const QString&, const int = -1, const int = -1, const bool = false );
141 int createMenu( QAction*, const int, const int = -1, const int = -1, const int = -1, const bool = false );
142 int createMenu( QAction*, const QString&, const int = -1, const int = -1, const int = -1, const bool = false );
144 /* clear given menu */
145 bool clearMenu( const int = 0, const int = 0, const bool = true );
147 /* create separator : open protected method */
148 QAction* createSeparator();
150 /* working with actions : open protected methods */
151 QAction* action( const int ) const;
152 int actionId( const QAction* ) const;
153 QAction* createAction( const int, const QString&, const QString&, const QString&,
154 const QString&, const int, const bool = false );
156 /* Show/hide menus/toolbars */
157 void setMenuShown( const bool );
158 void setToolShown( const bool );
162 virtual bool activateModule( SUIT_Study* );
164 virtual bool deactivateModule( SUIT_Study* );
166 /******************************
168 ******************************/
171 /* GUI action processing slots */
173 void onGUIEvent( int );
176 /* Menu processing */
177 bool hasMenu( const QString&, const int );
178 void registerMenu( const int, const int, const bool = false );
179 void unregisterMenu( const int, const int );
180 bool registered( const int, const int = 0 );
181 bool isConstantMenu( const int, const int );
184 void onMenuHighlighted( int, int );
187 /* internal initizalition */
188 void init ( CAM_Application* );
189 /* internal activation */
190 void activate ( SUIT_Study* );
191 /* internal deactivation */
192 void deactivate ( SUIT_Study* );
193 /* study activation */
194 void studyChanged( SUIT_Study* );
195 /* context popup menu processing */
196 void contextMenu( const QString&, QPopupMenu* );
197 /* GUI event processing */
198 void guiEvent( const int );
199 /* Menu highlight processing */
200 void menuHighlight( const int, const int );
202 /* initialize a Python subinterpreter */
203 void initInterp ( int );
204 /* import a Python GUI module */
206 /* set workspace to Python GUI module */
209 friend class SALOME_PYQT_XmlHandler;
212 #endif // SALOME_PYQT_MODULE_H