]> SALOME platform Git repositories - modules/paravis.git/blob - src/PVGUI/PVGUI_Module.h
Salome HOME
Moved PVViewer code from PARAVIS into GUI
[modules/paravis.git] / src / PVGUI / PVGUI_Module.h
1 // PARAVIS : ParaView wrapper SALOME module
2 //
3 // Copyright (C) 2010-2014  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
23 //
24
25
26 #ifndef PVGUI_Module_H
27 #define PVGUI_Module_H
28
29 #include <SalomeApp_Module.h>
30 #include "SALOMEconfig.h"
31 #include CORBA_SERVER_HEADER(SALOMEDS)
32 #include CORBA_SERVER_HEADER(PARAVIS_Gen)
33
34 #include <ostream>
35 #include <vtkType.h>
36 #include <QTimer>
37
38 #include <pqVariableType.h>
39
40 class QMenu;
41 class QDockWidget;
42 class QToolBar;
43 class vtkPVMain;
44 class pqOptions;
45 class pqServer;
46 class pqMainWindowCore;
47 class vtkEventQtSlotConnect;
48 class pqPythonScriptEditor;
49 class pqPVApplicationCore;
50 class pqDataRepresentation;
51 class pqRepresentation;
52 class PVViewer_GUIElements;
53
54 class PVGUI_Module : public SalomeApp_Module
55 {
56   Q_OBJECT
57    
58   //! Menu actions
59   enum { // Menu "File"
60      OpenFileId,
61
62      LoadStateId,
63      SaveStateId,
64
65      SaveDataId,
66      SaveScreenshotId,
67      ExportId,
68
69      SaveAnimationId,
70      SaveGeometryId,
71
72      ConnectId,
73      DisconnectId,
74
75      // Menu "Edit"
76      UndoId,
77      RedoId,
78
79      CameraUndoId,
80      CameraRedoId,
81
82      FindDataId,
83      ChangeInputId,
84      IgnoreTimeId,
85      DeleteId,
86      DeleteAllId,
87
88      SettingsId,
89      ViewSettingsId,
90
91      // Menu "View"
92      FullScreenId,
93
94      // Menu "Animation"
95      FirstFrameId,
96      PreviousFrameId,
97      PlayId,
98      NextFrameId,
99      LastFrameId,
100      LoopId,
101
102      // Menu "Tools"
103      CreateCustomFilterId,
104      ManageCustomFiltersId,
105      CreateLookmarkId,
106      ManageLinksId,
107      AddCameraLinkId,
108      ManagePluginsExtensionsId,
109      DumpWidgetNamesId,
110      RecordTestId,
111      RecordTestScreenshotId,
112      PlayTestId,
113      MaxWindowSizeId,
114      CustomWindowSizeId,
115      TimerLogId,
116      OutputWindowId,
117      PythonShellId,
118      ShowTraceId,
119      RestartTraceId,
120
121      // Menu "Help"
122      AboutParaViewId,
123      ParaViewHelpId,
124      EnableTooltipsId,
125
126      // Menu "Window" - "New Window"
127      ParaViewNewWindowId,
128
129      // "Save state" ParaVis module root object popup
130      SaveStatePopupId,
131
132      // "Add state" and "Reload state" popups
133      AddStatePopupId,
134      CleanAndAddStatePopupId,
135
136      // "Rename" and "Delete" popups (Object Browser)
137      ParaVisRenameId,
138      ParaVisDeleteId
139   };
140
141 public:
142   PVGUI_Module();
143   ~PVGUI_Module();
144
145   virtual void           initialize( CAM_Application* );
146   virtual void           windows( QMap<int, int>& ) const;
147
148   virtual QString engineIOR() const;
149
150   void openFile(const char* theName);
151   void executeScript(const char *script);
152   void saveParaviewState(const char* theFileName);
153   void loadParaviewState(const char* theFileName);
154   void clearParaviewState();
155
156   QString getTraceString();
157   void startTrace();
158   void stopTrace();
159   void saveTrace(const char* theName);
160
161   pqServer* getActiveServer();
162
163   virtual void createPreferences();
164
165   virtual void contextMenuPopup(const QString& theClient, QMenu* theMenu, QString& theTitle);
166
167   // Get the unwrapped version of the engine - compare with PVViewer_EngineWrapper.
168   inline static PARAVIS_ORB::PARAVIS_Gen_var GetCPPEngine();
169   inline static pqPVApplicationCore * GetPVApplication();
170
171 public slots:
172   //void onImportFromVisu(QString theEntry);
173
174 private:
175   void deleteTemporaryFiles();
176  
177   //! Create actions for ParaView GUI operations
178   void                   pvCreateActions();
179
180   //! Create menus for ParaView GUI operations duplicating menus in pqMainWindow ParaView class
181   void                   pvCreateMenus();
182
183   //! Create toolbars for ParaView GUI operations duplicating toolbars in pqMainWindow ParaView class
184   void                   pvCreateToolBars();
185
186   //! Create dock widgets for ParaView widgets
187   void                   setupDockWidgets();
188
189   //! Save states of dockable ParaView widgets
190   void                   saveDockWidgetsState();
191
192   //! Restore states of dockable ParaView widgets
193   void                   restoreDockWidgetsState();
194
195   //! Shows or hides ParaView view window
196   void                   showView( bool );    
197
198   //! Returns QMenu object for a given menu id
199   QMenu*                 getMenu( const int );
200   
201   //! Discover help project files from the resources.
202   QString getHelpFileName();
203
204   //! Create actions for ParaViS
205   void createActions();
206
207   //! Create menus for ParaViS
208   void createMenus();
209
210   //! Load selected state
211   void loadSelectedState(bool toClear);
212
213   //! Get list of embedded macros files
214   QStringList getEmbeddedMacrosList();
215
216   //! update macros state
217   void updateMacros();
218
219   //! store visibility of the common dockable windows (OB, PyConsole, ... etc.)
220   void storeCommonWindowsState();
221
222   //! restore visibility of the common dockable windows (OB, PyConsole, ... etc.)
223   void restoreCommonWindowsState();
224
225 private slots:
226
227   void showHelpForProxy( const QString&, const QString& );
228   
229   void onPreAccept();
230   void onPostAccept();
231   void endWaitCursor();
232
233   //  void buildToolbarsMenu();
234
235   //void showParaViewHelp();
236   //void showHelp(const QString& url);
237
238   void onDataRepresentationUpdated();
239
240   void onStartProgress();
241   void onEndProgress();
242   void onShowTrace();
243   void onRestartTrace();
244
245   void onNewParaViewWindow();
246
247   void onSaveMultiState();
248   void onAddState();
249   void onCleanAddState();
250
251   void onRename();
252   void onDelete();
253
254 public slots:
255   virtual bool           activateModule( SUIT_Study* );
256   virtual bool           deactivateModule( SUIT_Study* );
257   virtual void           onApplicationClosed( SUIT_Application* );
258   virtual void           studyClosed( SUIT_Study* );
259
260 protected slots:
261   virtual void           onModelOpened();
262   virtual void           onPushTraceTimer();
263   virtual void           onInitTimer();
264
265 private:
266   int                    mySelectionControlsTb;
267   int                    mySourcesMenuId;
268   int                    myFiltersMenuId;
269   int                    myToolbarsMenuId;
270   int                    myMacrosMenuId;
271   int                    myRecentMenuId;
272   
273   typedef QMap<QWidget*, bool> WgMap;
274   WgMap                  myDockWidgets;
275   WgMap                  myToolbars;
276   WgMap                  myToolbarBreaks;
277   QList<QMenu*>          myMenus;
278
279   typedef QMap<int, bool> DockWindowMap;         
280   DockWindowMap           myCommonMap; 
281
282   QStringList            myTemporaryFiles;
283
284   QtMsgHandler           myOldMsgHandler;
285
286   vtkEventQtSlotConnect *VTKConnect;
287
288   pqPythonScriptEditor* myTraceWindow;
289
290   int myStateCounter;
291
292   //! Single shot timer used to connect to the PVServer, and start the trace.
293   QTimer             * myInitTimer;
294
295   //! Timer used to regularly push the Python trace to the engine.
296   QTimer             * myPushTraceTimer;
297
298   PVViewer_GUIElements * myGuiElements;
299
300   static PARAVIS_ORB::PARAVIS_Gen_var MyEngine;
301 };
302
303 #endif // PVGUI_Module_H