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