Version: 9.15.0
SALOME_PYQT_PyModule.h
Go to the documentation of this file.
1 // Copyright (C) 2007-2025 CEA, EDF, OPEN CASCADE
2 //
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, or (at your option) any later version.
7 //
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.
12 //
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
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 
20 // File : SALOME_PYQT_PyModule.h
21 // Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
22 //
23 
24 #ifndef SALOME_PYQT_PYMODULE_H
25 #define SALOME_PYQT_PYMODULE_H
26 
27 #include "SALOME_PYQT_GUILight.h"
28 
29 #include "PyInterp_Interp.h" // !!! WARNING !!! THIS INCLUDE MUST BE THE VERY FIRST !!!
30 
31 #include <QIcon>
32 #include <QList>
33 #include <QMap>
34 #include <QObject>
35 #include <QStringList>
36 
37 class CAM_Application;
39 class LightApp_Module;
40 class PyInterp_Interp;
41 class QAction;
42 class QMenu;
43 class SUIT_DataObject;
44 class SUIT_Study;
45 class SUIT_ViewWindow;
46 
48 
50 {
51  Q_OBJECT
52 
53 private:
54  class XmlHandler;
55  class InitLocker;
56 
58 
60  PyObject* myPyModule;
63  QMap<int, int> myWindowsMap;
64  QStringList myViewMgrList;
66 
67 public:
69  ~PyModuleHelper();
70 
71  static LightApp_Module* getInitModule();
72  static int defaultMenuGroup();
73 
74  LightApp_Module* module() const;
75  PyObject* pythonModule() const;
76 
77  void connectAction( QAction* );
78 
79  QMap<int, int> windows() const;
80  QStringList viewManagers() const;
81 
82 public slots:
83  void initialize( CAM_Application* );
84  bool activate( SUIT_Study* study );
85  bool deactivate( SUIT_Study* study );
86  void modelClosed( SUIT_Study* study );
87  void preferencesChanged( const QString&, const QString& setting );
88  void preferenceChanged( const QString&, const QString&, const QString& setting );
89  void studyActivated( SUIT_Study* );
90  void actionActivated();
91  void selectionUpdated(const QStringList&);
92  void contextMenu( const QString&, QMenu* );
93  void createPreferences();
94  void activeViewChanged( SUIT_ViewWindow* );
95  void tryCloseView( SUIT_ViewWindow* );
96  void closeView( SUIT_ViewWindow* );
97  void cloneView( SUIT_ViewWindow* );
98  void save( QStringList&, const QString& );
99  bool load( const QStringList&, const QString& );
100  void dumpPython( QStringList& files );
101  bool isDraggable( const SUIT_DataObject* ) const;
102  bool isDropAccepted( const SUIT_DataObject* ) const;
103  void dropObjects( const DataObjectList&, SUIT_DataObject*,
104  const int, Qt::DropAction );
105  QString engineIOR() const;
106 
107  void onObjectBrowserClicked(SUIT_DataObject*, int);
108 
109 private:
110  void initInterp();
111  void importModule();
112  void setWorkSpace();
113 
114  void internalInitialize( CAM_Application* );
115  void internalActivate( SUIT_Study* );
116  void internalCustomize( SUIT_Study* );
117  void internalDeactivate( SUIT_Study* );
118  void internalClosedStudy( SUIT_Study* );
119  void internalPreferencesChanged( const QString&, const QString& );
120  void internalStudyChanged( SUIT_Study* );
121  void internalActionActivated( int );
122  void internalSelectionUpdated(const QStringList&);
123  void internalContextMenu( const QString&, QMenu* );
124  void internalCreatePreferences();
125  void internalActiveViewChanged( SUIT_ViewWindow* );
126  void internalTryCloseView( SUIT_ViewWindow* );
127  void internalCloseView( SUIT_ViewWindow* );
128  void internalCloneView( SUIT_ViewWindow* );
129  void internalSave( QStringList&, const QString& );
130  void internalLoad( const QStringList&, const QString&, bool& );
131  void internalDumpPython( QStringList& );
132  bool internalIsDraggable( LightApp_DataObject* );
133  bool internalIsDropAccepted( LightApp_DataObject* );
134  void internalDropObjects( const DataObjectList&, SUIT_DataObject*,
135  const int, Qt::DropAction );
136  QString internalEngineIOR() const;
137  void internalOBClickedPython( const QString&, int );
138 
139  void connectView( SUIT_ViewWindow* );
140 };
141 
142 #endif // SALOME_PYQT_PYMODULE_H
#define SALOME_PYQT_LIGHT_EXPORT
Definition: SALOME_PYQT_GUILight.h:38
QList< SUIT_DataObject * > DataObjectList
Definition: SALOME_PYQT_PyModule.h:45
Introduces an application class which provides modular architecture.
Definition: CAM_Application.h:39
Base data object class to build the data model for all the SALOME modules.
Definition: LightApp_DataObject.h:36
Definition: LightApp_Module.h:64
Initialization locker.
Definition: SALOME_PYQT_PyModule.cxx:196
XML resource files parser.
Definition: SALOME_PYQT_PyModule.cxx:233
This class implements API helper for all the Python-based SALOME GUI modules.
Definition: SALOME_PYQT_PyModule.h:50
LightApp_Module * myModule
GUI module.
Definition: SALOME_PYQT_PyModule.h:59
static LightApp_Module * myInitModule
Python GUI being initialized (not zero only during the initialization)
Definition: SALOME_PYQT_PyModule.h:55
XmlHandler * myXmlHandler
XML resource file parser.
Definition: SALOME_PYQT_PyModule.h:62
PyObject * myPyModule
Python GUI module.
Definition: SALOME_PYQT_PyModule.h:60
QMap< int, int > myWindowsMap
windows map
Definition: SALOME_PYQT_PyModule.h:63
bool myLastActivateStatus
latest module activation status
Definition: SALOME_PYQT_PyModule.h:65
QStringList myViewMgrList
compatible view managers list
Definition: SALOME_PYQT_PyModule.h:64
PyInterp_Interp * myInterp
current Python subinterpreter
Definition: SALOME_PYQT_PyModule.h:61
For more information see QT documentation.
Definition: SUIT_Application.h:42
Data object representing the data instance in the tree-like hierarchy.
Definition: SUIT_DataObject.h:49
Definition: SUIT_Study.h:41
Definition: SUIT_ViewWindow.h:42