Salome HOME
Porting to PV4.1
[modules/paravis.git] / src / PVGUI / PVGUI_Module.h
1 // PARAVIS : ParaView wrapper SALOME module
2 //
3 // Copyright (C) 2010-2013  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.
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
31 #include <ostream>
32 #include <vtkType.h>
33
34 #include <pqVariableType.h>
35
36 class QMenu;
37 class QDockWidget;
38 class QToolBar;
39 class vtkPVMain;
40 class pqOptions;
41 class pqServer;
42 class pqTabbedMultiViewWidget;
43 class pqMainWindowCore;
44 class vtkEventQtSlotConnect;
45 class pqPythonScriptEditor;
46 class pqPVApplicationCore;
47 class pqDataRepresentation;
48 class pqRepresentation;
49
50 class PyConsole_Interp;
51
52 class PVGUI_Module : public SalomeApp_Module
53 {
54   Q_OBJECT
55    
56   //! Menu actions
57   enum { // Menu "File"
58      OpenFileId,
59
60      LoadStateId,
61      SaveStateId,
62
63      SaveDataId,
64      SaveScreenshotId,
65      ExportId,
66
67      SaveAnimationId,
68      SaveGeometryId,
69
70      ConnectId,
71      DisconnectId,
72
73      // Menu "Edit"
74      UndoId,
75      RedoId,
76
77      CameraUndoId,
78      CameraRedoId,
79
80      FindDataId,
81      ChangeInputId,
82      IgnoreTimeId,
83      DeleteId,
84      DeleteAllId,
85
86      SettingsId,
87      ViewSettingsId,
88
89      // Menu "View"
90      FullScreenId,
91
92      // Menu "Animation"
93      FirstFrameId,
94      PreviousFrameId,
95      PlayId,
96      NextFrameId,
97      LastFrameId,
98      LoopId,
99
100      // Menu "Tools"
101      CreateCustomFilterId,
102      ManageCustomFiltersId,
103      CreateLookmarkId,
104      ManageLinksId,
105      AddCameraLinkId,
106      ManagePluginsExtensionsId,
107      DumpWidgetNamesId,
108      RecordTestId,
109      RecordTestScreenshotId,
110      PlayTestId,
111      MaxWindowSizeId,
112      CustomWindowSizeId,
113      TimerLogId,
114      OutputWindowId,
115      PythonShellId,
116      ShowTraceId,
117      RestartTraceId,
118
119      // Menu "Help"
120      AboutParaViewId,
121      ParaViewHelpId,
122      EnableTooltipsId,
123
124      // Menu "Window" - "New Window"
125      ParaViewNewWindowId,
126
127      // "Save state" ParaVis module root object popup
128      SaveStatePopupId,
129
130      // "Add state" and "Reload state" popups
131      AddStatePopupId,
132      CleanAndAddStatePopupId,
133
134      // "Rename" and "Delete" popups (Object Browser)
135      ParaVisRenameId,
136      ParaVisDeleteId
137   };
138
139 public:
140   PVGUI_Module();
141   ~PVGUI_Module();
142
143   virtual void           initialize( CAM_Application* );
144   virtual void           windows( QMap<int, int>& ) const;
145
146   pqTabbedMultiViewWidget*         getMultiViewManager() const;
147
148   virtual QString engineIOR() const;
149
150   void openFile(const char* theName);
151   void executeScript(const char *script);
152   void saveParaviewState(const char* theFileName);
153   void loadParaviewState(const char* theFileName);
154   void clearParaviewState();
155
156   QString getTraceString();
157   void saveTrace(const char* theName);
158
159   pqServer* getActiveServer();
160
161   virtual void createPreferences();
162
163   virtual void contextMenuPopup(const QString& theClient, QMenu* theMenu, QString& theTitle);
164
165 public slots:
166   void onImportFromVisu(QString theEntry);
167
168 private:
169   //! Initialize ParaView if not yet done (once per session)
170   static bool            pvInit();  
171  
172   //! Create actions for ParaView GUI operations
173   void                   pvCreateActions();
174
175   //! Create menus for ParaView GUI operations duplicating menus in pqMainWindow ParaView class
176   void                   pvCreateMenus();
177
178   //! Create toolbars for ParaView GUI operations duplicating toolbars in pqMainWindow ParaView class
179   void                   pvCreateToolBars();
180
181   //! Create dock widgets for ParaView widgets
182   void                   setupDockWidgets();
183
184   //! Save states of dockable ParaView widgets
185   void                   saveDockWidgetsState();
186
187   //! Restore states of dockable ParaView widgets
188   void                   restoreDockWidgetsState();
189
190   //! Shows or hides ParaView view window
191   void                   showView( bool );    
192
193   //! Returns QMenu object for a given menu id
194   QMenu*                 getMenu( const int );
195   
196   //! Discover help project files from the resources.
197   QString getHelpFileName();
198
199   void                   deleteTemporaryFiles();
200   
201   //QList<QToolBar*>       getParaViewToolbars();
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   //! update macros state
213   void updateMacros();
214
215   //! store visibility of the common dockable windows (OB, PyConsole, ... etc.)
216   void storeCommonWindowsState();
217
218   //! restore visibility of the common dockable windows (OB, PyConsole, ... etc.)
219   void restoreCommonWindowsState();
220
221   //! run Python command (either in SALOME's Python interpreter, or in ParaView's Python's interpreter)
222   void execPythonCommand(const QString& cmd, bool inSalomeConsole=false);
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 onFinishedAddingServer(pqServer*);
238   void onDataRepresentationCreated(pqDataRepresentation*);
239   void onDataRepresentationUpdated();
240   void onVariableChanged(pqVariableType, const QString);
241   void onRepresentationChanged(pqRepresentation*);
242
243   void onStartProgress();
244   void onEndProgress();
245   void onShowTrace();
246   void onRestartTrace();
247
248   void onNewParaViewWindow();
249
250   void onSaveMultiState();
251   void onAddState();
252   void onCleanAddState();
253
254   void onRename();
255   void onDelete();
256
257 public slots:
258   virtual bool           activateModule( SUIT_Study* );
259   virtual bool           deactivateModule( SUIT_Study* );
260   virtual void           onApplicationClosed( SUIT_Application* );
261   virtual void           studyClosed( SUIT_Study* );
262
263 protected slots:
264   virtual void           onModelOpened();
265
266 protected:
267   void timerEvent(QTimerEvent *event);
268
269 private:
270   class pqImplementation;
271   pqImplementation*      Implementation;
272
273   int                    mySelectionControlsTb;
274   int                    mySourcesMenuId;
275   int                    myFiltersMenuId;
276   int                    myToolbarsMenuId;
277   int                    myMacrosMenuId;
278   int                    myRecentMenuId;
279   
280   typedef QMap<QWidget*, bool> WgMap;
281   WgMap                  myDockWidgets;
282   WgMap                  myToolbars;
283   WgMap                  myToolbarBreaks;
284   QList<QMenu*>          myMenus;
285
286   typedef QMap<int, bool> DockWindowMap;         
287   DockWindowMap           myCommonMap; 
288
289   QStringList            myTemporaryFiles;
290
291   QtMsgHandler           myOldMsgHandler;
292
293   vtkEventQtSlotConnect *VTKConnect;
294
295   pqPythonScriptEditor* myTraceWindow;
296
297   int myStateCounter;
298
299   static pqPVApplicationCore* MyCoreApp;
300 };
301
302 #endif // PVGUI_Module_H