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