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