1 // Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
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 // File : SALOME_PYQT_PyModule.h
21 // Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
24 #ifndef SALOME_PYQT_PYMODULE_H
25 #define SALOME_PYQT_PYMODULE_H
27 #include "SALOME_PYQT_GUILight.h"
29 #include "PyInterp_Interp.h" // !!! WARNING !!! THIS INCLUDE MUST BE THE VERY FIRST !!!
35 #include <QStringList>
37 class CAM_Application;
38 class LightApp_DataObject;
39 class LightApp_Module;
40 class PyInterp_Interp;
43 class SUIT_DataObject;
45 class SUIT_ViewWindow;
47 typedef QList<SUIT_DataObject*> DataObjectList;
49 class SALOME_PYQT_LIGHT_EXPORT PyModuleHelper : public QObject
57 typedef QMap<int, PyInterp_Interp*> InterpMap;
59 static InterpMap myInterpMap; //!< study to Python subinterpreter map
60 static LightApp_Module* myInitModule; //!< Python GUI being initialized (not zero only during the initialization)
62 LightApp_Module* myModule; //!< GUI module
63 PyObject* myPyModule; //!< Python GUI module
64 PyInterp_Interp* myInterp; //!< current Python subinterpreter
65 XmlHandler* myXmlHandler; //!< XML resource file parser
66 QMap<int, int> myWindowsMap; //!< windows map
67 QStringList myViewMgrList; //!< compatible view managers list
68 bool myLastActivateStatus; //!< latest module activation status
71 PyModuleHelper( LightApp_Module* );
74 static LightApp_Module* getInitModule();
75 static int defaultMenuGroup();
77 LightApp_Module* module() const;
78 PyObject* pythonModule() const;
80 void connectAction( QAction* );
82 QMap<int, int> windows() const;
83 QStringList viewManagers() const;
86 void initialize( CAM_Application* );
87 bool activate( SUIT_Study* study );
88 bool deactivate( SUIT_Study* study );
89 void preferencesChanged( const QString&, const QString& setting );
90 void preferenceChanged( const QString&, const QString&, const QString& setting );
91 void studyActivated( SUIT_Study* );
92 void actionActivated();
93 void contextMenu( const QString&, QMenu* );
94 void createPreferences();
95 void activeViewChanged( SUIT_ViewWindow* );
96 void tryCloseView( SUIT_ViewWindow* );
97 void closeView( SUIT_ViewWindow* );
98 void cloneView( SUIT_ViewWindow* );
99 void save( QStringList& );
100 bool load( const QStringList& );
101 void dumpPython( QStringList& files );
102 bool isDraggable( const SUIT_DataObject* ) const;
103 bool isDropAccepted( const SUIT_DataObject* ) const;
104 void dropObjects( const DataObjectList&, SUIT_DataObject*,
105 const int, Qt::DropAction );
106 QString engineIOR() const;
109 void initInterp( int );
113 void internalInitialize( CAM_Application* );
114 void internalActivate( SUIT_Study* );
115 void internalCustomize( SUIT_Study* );
116 void internalDeactivate( SUIT_Study* );
117 void internalPreferencesChanged( const QString&, const QString& );
118 void internalStudyChanged( SUIT_Study* );
119 void internalActionActivated( int );
120 void internalContextMenu( const QString&, QMenu* );
121 void internalCreatePreferences();
122 void internalActiveViewChanged( SUIT_ViewWindow* );
123 void internalTryCloseView( SUIT_ViewWindow* );
124 void internalCloseView( SUIT_ViewWindow* );
125 void internalCloneView( SUIT_ViewWindow* );
126 void internalSave( QStringList& );
127 void internalLoad( const QStringList&, bool& );
128 void internalDumpPython( QStringList& );
129 bool internalIsDraggable( LightApp_DataObject* );
130 bool internalIsDropAccepted( LightApp_DataObject* );
131 void internalDropObjects( const DataObjectList&, SUIT_DataObject*,
132 const int, Qt::DropAction );
133 QString internalEngineIOR() const;
135 void connectView( SUIT_ViewWindow* );
138 #endif // SALOME_PYQT_PYMODULE_H