Salome HOME
Copyright update 2022
[modules/paravis.git] / src / PVGUI / PVGUI_Module.h
1 // PARAVIS : ParaView wrapper SALOME module
2 //
3 // Copyright (C) 2010-2022  CEA/DEN, EDF R&D
4 //
5 // This library is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation; either
8 // version 2.1 of the License, or (at your option) any later version.
9 //
10 // This library is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 // Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public
16 // License along with this library; if not, write to the Free Software
17 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
18 //
19 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 //
21 // File   : PVGUI_Module.h
22 // Author : Sergey ANIKIN, Adrien BRUNETON
23 //
24
25
26 #ifndef PVGUI_Module_H
27 #define PVGUI_Module_H
28
29 #include <LightApp_Module.h>
30
31 class QMenu;
32 class QTimer;
33 class vtkEventQtSlotConnect;
34 class pqServer;
35 class pqPythonScriptEditor;
36 class pqPVApplicationCore;
37 class PVViewer_GUIElements;
38 class PVServer_ServiceWrapper;
39 class SUIT_ViewWindow;
40
41 class PVGUI_Module: public LightApp_Module
42 {
43   Q_OBJECT
44    
45   //! Menu actions
46   enum {
47     //-----------
48     // Menu "File"
49     OpenFileId,
50     //-
51     LoadStateId,
52     SaveStateId,
53     //-
54     SaveDataId,
55     SaveScreenshotId,
56     ExportId,
57     //-
58     SaveAnimationId,
59     SaveGeometryId,
60     //-
61     ConnectId,
62     DisconnectId,
63     //-----------
64     // Menu "Edit"
65     UndoId,
66     RedoId,
67     //-
68     CameraUndoId,
69     CameraRedoId,
70     //-
71     FindDataId,
72     ChangeInputId,
73     IgnoreTimeId,
74     DeleteId,
75     DeleteAllId,
76     //-
77     SettingsId,             // not used
78     ViewSettingsId,         // not used
79     //-----------
80     // Menu "View"
81     FullScreenId,           // not used
82     //-----------
83     // Menu "Animation"
84     FirstFrameId,           // not used
85     PreviousFrameId,        // not used
86     PlayId,                 // not used
87     NextFrameId,            // not used
88     LastFrameId,            // not used
89     LoopId,                 // not used
90     //-----------
91     // Menu "Tools"
92     CreateCustomFilterId,
93     ManageCustomFiltersId,
94     CreateLookmarkId,       // not used
95     ManageLinksId,
96     AddCameraLinkId,
97     ManagePluginsExtensionsId,
98     DumpWidgetNamesId,      //  not used
99     RecordTestId,
100     RecordTestScreenshotId, // not used
101     PlayTestId,
102     MaxWindowSizeId,
103     CustomWindowSizeId,
104     TimerLogId,
105     PythonShellId,
106     ShowTraceId,
107     RestartTraceId,
108     //-----------
109     // Menu "Help"
110     AboutParaViewId,
111     ParaViewHelpId,
112     EnableTooltipsId,       // not used
113   };
114
115 public:
116   PVGUI_Module();
117   ~PVGUI_Module();
118
119   virtual void initialize( CAM_Application* );
120   virtual void windows( QMap<int, int>& ) const;
121
122   void openFile( const char* );                   // not used inside PARAVIS
123   void executeScript( const char* );              // not used inside PARAVIS
124
125   void saveParaviewState( const QString& );
126   void loadParaviewState( const QString& );
127   void clearParaviewState();
128
129   QString getTraceString();
130   void startTrace();
131   void stopTrace();
132   void saveTrace( const char* );
133
134   pqServer* getActiveServer();
135
136   virtual void createPreferences();
137
138   inline static PVServer_ServiceWrapper* GetEngine();
139   inline static pqPVApplicationCore* GetPVApplication(); // not used inside PARAVIS
140
141   virtual CAM_DataModel* createDataModel();
142
143 private:
144   //! Create actions for ParaView GUI operations
145   void pvCreateActions();
146
147   //! Create menus for ParaView GUI operations duplicating menus in pqMainWindow ParaView class
148   void pvCreateMenus();
149
150   //! Create toolbars for ParaView GUI operations duplicating toolbars in pqMainWindow ParaView class
151   void pvCreateToolBars();
152
153   //! Create dock widgets for ParaView widgets
154   void setupDockWidgets();
155
156   //! Save states of dockable ParaView widgets
157   void saveDockWidgetsState( bool = true );
158
159   //! Restore states of dockable ParaView widgets
160   void restoreDockWidgetsState();
161
162   //! Shows or hides ParaView view window
163   void showView( bool );    
164
165   //! Get list of embedded macros files
166   QStringList getEmbeddedMacrosList();
167
168   //! update macros state
169   void updateMacros();
170
171   //! store visibility of the common dockable windows (OB, PyConsole, ... etc.)
172   void storeCommonWindowsState();
173
174   //! restore visibility of the common dockable windows (OB, PyConsole, ... etc.)
175   void restoreCommonWindowsState();
176
177 private slots:
178   void showHelpForProxy( const QString&, const QString& );
179   
180   void onPreAccept();    // not used inside PARAVIS
181   void onPostAccept();   // not used inside PARAVIS
182   void endWaitCursor();  // not used inside PARAVIS
183
184   void onDataRepresentationUpdated();
185
186   void onStartProgress();
187   void onEndProgress();
188   void onShowTrace();
189   void onRestartTrace();
190   void onStopTrace();
191
192 public slots:
193   virtual bool           activateModule( SUIT_Study* );
194   virtual bool           deactivateModule( SUIT_Study* );
195   virtual void           onApplicationClosed( SUIT_Application* );
196   virtual void           studyClosed( SUIT_Study* );
197
198 protected slots:
199   virtual void           onInitTimer();
200   virtual void           onViewManagerAdded( SUIT_ViewManager* );
201   virtual void           onViewManagerRemoved( SUIT_ViewManager* );
202   virtual void           onPVViewCreated( SUIT_ViewWindow* );
203   virtual void           onPVViewDelete( SUIT_ViewWindow* );
204
205 private:
206   int                    mySourcesMenuId;
207   int                    myFiltersMenuId;
208   int                    myMacrosMenuId;
209   int                    myRecentMenuId;
210   int                    myCatalystMenuId;
211   
212   typedef QMap<QWidget*, bool> WgMap;
213   WgMap                  myDockWidgets;
214   WgMap                  myToolbars;
215   WgMap                  myToolbarBreaks;
216   QList<QMenu*>          myMenus;
217
218   typedef QMap<int, bool> DockWindowMap;         
219   DockWindowMap           myCommonMap; 
220   QtMessageHandler        myOldMsgHandler;
221
222   vtkEventQtSlotConnect*  VTKConnect;
223
224   pqPythonScriptEditor*   myTraceWindow;
225
226   //! Single shot timer used to connect to the PVServer, and start the trace.
227   QTimer*                 myInitTimer;
228
229   PVViewer_GUIElements*   myGuiElements;
230 };
231
232 #endif // PVGUI_Module_H