]> SALOME platform Git repositories - modules/paravis.git/blob - src/PVGUI/PVGUI_Module.h
Salome HOME
Prepare move of the view part to 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 #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 saveTrace(const char* theName);
164
165   pqServer* getActiveServer();
166
167   virtual void createPreferences();
168
169   virtual void contextMenuPopup(const QString& theClient, QMenu* theMenu, QString& theTitle);
170
171 public slots:
172   //void onImportFromVisu(QString theEntry);
173
174 private:
175   void deleteTemporaryFiles();
176
177   //! Initialize ParaView if not yet done (once per session)
178   static bool            pvInit();  
179  
180   //! Create actions for ParaView GUI operations
181   void                   pvCreateActions();
182
183   //! Create menus for ParaView GUI operations duplicating menus in pqMainWindow ParaView class
184   void                   pvCreateMenus();
185
186   //! Create toolbars for ParaView GUI operations duplicating toolbars in pqMainWindow ParaView class
187   void                   pvCreateToolBars();
188
189   //! Create dock widgets for ParaView widgets
190   void                   setupDockWidgets();
191
192   //! Save states of dockable ParaView widgets
193   void                   saveDockWidgetsState();
194
195   //! Restore states of dockable ParaView widgets
196   void                   restoreDockWidgetsState();
197
198   //! Shows or hides ParaView view window
199   void                   showView( bool );    
200
201   //! Returns QMenu object for a given menu id
202   QMenu*                 getMenu( const int );
203   
204   //! Discover help project files from the resources.
205   QString getHelpFileName();
206
207   //! Create actions for ParaViS
208   void createActions();
209
210   //! Create menus for ParaViS
211   void createMenus();
212
213   //! Load selected state
214   void loadSelectedState(bool toClear);
215
216   //! Get list of embedded macros files
217   QStringList getEmbeddedMacrosList();
218
219   //! update macros state
220   void updateMacros();
221
222   //! store visibility of the common dockable windows (OB, PyConsole, ... etc.)
223   void storeCommonWindowsState();
224
225   //! restore visibility of the common dockable windows (OB, PyConsole, ... etc.)
226   void restoreCommonWindowsState();
227
228   //! run Python command (either in SALOME's Python interpreter, or in ParaView's Python's interpreter)
229   void execPythonCommand(const QString& cmd, bool inSalomeConsole=false);
230
231   //! Connect to the external PVServer, using the PARAVIS engine to launch it if it is not
232   //! already up.
233   bool connectToExternalPVServer();
234
235 private slots:
236
237   void showHelpForProxy( const QString&, const QString& );
238   
239   void onPreAccept();
240   void onPostAccept();
241   void endWaitCursor();
242
243   //  void buildToolbarsMenu();
244
245   //void showParaViewHelp();
246   //void showHelp(const QString& url);
247
248   void onFinishedAddingServer(pqServer*);
249   void onDataRepresentationCreated(pqDataRepresentation*);
250   void onDataRepresentationUpdated();
251   void onVariableChanged(pqVariableType, const QString);
252   void onRepresentationChanged(pqRepresentation*);
253
254   void onStartProgress();
255   void onEndProgress();
256   void onShowTrace();
257   void onRestartTrace();
258
259   void onNewParaViewWindow();
260
261   void onSaveMultiState();
262   void onAddState();
263   void onCleanAddState();
264
265   void onRename();
266   void onDelete();
267
268 public slots:
269   virtual bool           activateModule( SUIT_Study* );
270   virtual bool           deactivateModule( SUIT_Study* );
271   virtual void           onApplicationClosed( SUIT_Application* );
272   virtual void           studyClosed( SUIT_Study* );
273
274 protected slots:
275   virtual void           onModelOpened();
276   virtual void           onPushTraceTimer();
277   virtual void           onInitTimer();
278
279 private:
280   int                    mySelectionControlsTb;
281   int                    mySourcesMenuId;
282   int                    myFiltersMenuId;
283   int                    myToolbarsMenuId;
284   int                    myMacrosMenuId;
285   int                    myRecentMenuId;
286   
287   typedef QMap<QWidget*, bool> WgMap;
288   WgMap                  myDockWidgets;
289   WgMap                  myToolbars;
290   WgMap                  myToolbarBreaks;
291   QList<QMenu*>          myMenus;
292
293   typedef QMap<int, bool> DockWindowMap;         
294   DockWindowMap           myCommonMap; 
295
296   QStringList            myTemporaryFiles;
297
298   QtMsgHandler           myOldMsgHandler;
299
300   vtkEventQtSlotConnect *VTKConnect;
301
302   static pqPVApplicationCore* MyCoreApp;
303   static PARAVIS_ORB::PARAVIS_Gen_var myEngine;
304
305
306   pqPythonScriptEditor* myTraceWindow;
307
308   int myStateCounter;
309
310   //! Single shot timer used to connect to the PVServer, and start the trace.
311   QTimer             * myInitTimer;
312
313   //! Timer used to regularly push the Python trace to the engine.
314   QTimer             * myPushTraceTimer;
315 };
316
317 #endif // PVGUI_Module_H