]> SALOME platform Git repositories - modules/paravis.git/blob - src/PVGUI/PVGUI_Module.h
Salome HOME
Further clean-up and minor fix on wrongly connected Qt signals.
[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 onDataRepresentationUpdated();
248
249   void onStartProgress();
250   void onEndProgress();
251   void onShowTrace();
252   void onRestartTrace();
253
254   void onNewParaViewWindow();
255
256   void onSaveMultiState();
257   void onAddState();
258   void onCleanAddState();
259
260   void onRename();
261   void onDelete();
262
263 public slots:
264   virtual bool           activateModule( SUIT_Study* );
265   virtual bool           deactivateModule( SUIT_Study* );
266   virtual void           onApplicationClosed( SUIT_Application* );
267   virtual void           studyClosed( SUIT_Study* );
268
269 protected slots:
270   virtual void           onModelOpened();
271   virtual void           onPushTraceTimer();
272   virtual void           onInitTimer();
273
274 private:
275   int                    mySelectionControlsTb;
276   int                    mySourcesMenuId;
277   int                    myFiltersMenuId;
278   int                    myToolbarsMenuId;
279   int                    myMacrosMenuId;
280   int                    myRecentMenuId;
281   
282   typedef QMap<QWidget*, bool> WgMap;
283   WgMap                  myDockWidgets;
284   WgMap                  myToolbars;
285   WgMap                  myToolbarBreaks;
286   QList<QMenu*>          myMenus;
287
288   typedef QMap<int, bool> DockWindowMap;         
289   DockWindowMap           myCommonMap; 
290
291   QStringList            myTemporaryFiles;
292
293   QtMsgHandler           myOldMsgHandler;
294
295   vtkEventQtSlotConnect *VTKConnect;
296
297   static pqPVApplicationCore* MyCoreApp;
298   static PARAVIS_ORB::PARAVIS_Gen_var myEngine;
299
300
301   pqPythonScriptEditor* myTraceWindow;
302
303   int myStateCounter;
304
305   //! Single shot timer used to connect to the PVServer, and start the trace.
306   QTimer             * myInitTimer;
307
308   //! Timer used to regularly push the Python trace to the engine.
309   QTimer             * myPushTraceTimer;
310 };
311
312 #endif // PVGUI_Module_H