Salome HOME
c9787b311c1f39ea64ec00197d4d6d0912abfcda
[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 startTrace();
159   void stopTrace();
160   void saveTrace(const char* theName);
161
162   pqServer* getActiveServer();
163
164   virtual void createPreferences();
165
166   virtual void contextMenuPopup(const QString& theClient, QMenu* theMenu, QString& theTitle);
167
168   inline static PARAVIS_ORB::PARAVIS_Gen_var GetEngine();
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
299 #endif // PVGUI_Module_H