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