]> SALOME platform Git repositories - modules/paravis.git/blob - src/PVGUI/PVGUI_Module.h
Salome HOME
edda55245c5d221837a3cd7746b35e7aa77d7a02
[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 class PVViewer_GUIElements;
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   virtual void           initialize( CAM_Application* );
148   virtual void           windows( QMap<int, int>& ) const;
149
150   virtual QString engineIOR() const;
151
152   void openFile(const char* theName);
153   void executeScript(const char *script);
154   void saveParaviewState(const char* theFileName);
155   void loadParaviewState(const char* theFileName);
156   void clearParaviewState();
157
158   QString getTraceString();
159   void startTrace();
160   void stopTrace();
161   void saveTrace(const char* theName);
162
163   pqServer* getActiveServer();
164
165   virtual void createPreferences();
166
167   virtual void contextMenuPopup(const QString& theClient, QMenu* theMenu, QString& theTitle);
168
169   inline static PARAVIS_ORB::PARAVIS_Gen_var GetEngine();
170   inline static pqPVApplicationCore * GetPVApplication();
171
172 public slots:
173   //void onImportFromVisu(QString theEntry);
174
175 private:
176   void deleteTemporaryFiles();
177  
178   //! Create actions for ParaView GUI operations
179   void                   pvCreateActions();
180
181   //! Create menus for ParaView GUI operations duplicating menus in pqMainWindow ParaView class
182   void                   pvCreateMenus();
183
184   //! Create toolbars for ParaView GUI operations duplicating toolbars in pqMainWindow ParaView class
185   void                   pvCreateToolBars();
186
187   //! Create dock widgets for ParaView widgets
188   void                   setupDockWidgets();
189
190   //! Save states of dockable ParaView widgets
191   void                   saveDockWidgetsState();
192
193   //! Restore states of dockable ParaView widgets
194   void                   restoreDockWidgetsState();
195
196   //! Shows or hides ParaView view window
197   void                   showView( bool );    
198
199   //! Returns QMenu object for a given menu id
200   QMenu*                 getMenu( const int );
201   
202   //! Discover help project files from the resources.
203   QString getHelpFileName();
204
205   //! Create actions for ParaViS
206   void createActions();
207
208   //! Create menus for ParaViS
209   void createMenus();
210
211   //! Load selected state
212   void loadSelectedState(bool toClear);
213
214   //! Get list of embedded macros files
215   QStringList getEmbeddedMacrosList();
216
217   //! update macros state
218   void updateMacros();
219
220   //! store visibility of the common dockable windows (OB, PyConsole, ... etc.)
221   void storeCommonWindowsState();
222
223   //! restore visibility of the common dockable windows (OB, PyConsole, ... etc.)
224   void restoreCommonWindowsState();
225
226 private slots:
227
228   void showHelpForProxy( const QString&, const QString& );
229   
230   void onPreAccept();
231   void onPostAccept();
232   void endWaitCursor();
233
234   //  void buildToolbarsMenu();
235
236   //void showParaViewHelp();
237   //void showHelp(const QString& url);
238
239   void onDataRepresentationUpdated();
240
241   void onStartProgress();
242   void onEndProgress();
243   void onShowTrace();
244   void onRestartTrace();
245
246   void onNewParaViewWindow();
247
248   void onSaveMultiState();
249   void onAddState();
250   void onCleanAddState();
251
252   void onRename();
253   void onDelete();
254
255 public slots:
256   virtual bool           activateModule( SUIT_Study* );
257   virtual bool           deactivateModule( SUIT_Study* );
258   virtual void           onApplicationClosed( SUIT_Application* );
259   virtual void           studyClosed( SUIT_Study* );
260
261 protected slots:
262   virtual void           onModelOpened();
263   virtual void           onPushTraceTimer();
264   virtual void           onInitTimer();
265
266 private:
267   int                    mySelectionControlsTb;
268   int                    mySourcesMenuId;
269   int                    myFiltersMenuId;
270   int                    myToolbarsMenuId;
271   int                    myMacrosMenuId;
272   int                    myRecentMenuId;
273   
274   typedef QMap<QWidget*, bool> WgMap;
275   WgMap                  myDockWidgets;
276   WgMap                  myToolbars;
277   WgMap                  myToolbarBreaks;
278   QList<QMenu*>          myMenus;
279
280   typedef QMap<int, bool> DockWindowMap;         
281   DockWindowMap           myCommonMap; 
282
283   QStringList            myTemporaryFiles;
284
285   QtMsgHandler           myOldMsgHandler;
286
287   vtkEventQtSlotConnect *VTKConnect;
288
289   pqPythonScriptEditor* myTraceWindow;
290
291   int myStateCounter;
292
293   //! Single shot timer used to connect to the PVServer, and start the trace.
294   QTimer             * myInitTimer;
295
296   //! Timer used to regularly push the Python trace to the engine.
297   QTimer             * myPushTraceTimer;
298
299   PVViewer_GUIElements * myGuiElements;
300 };
301
302 #endif // PVGUI_Module_H