Salome HOME
Merge branch 'abn/cleanup'
[modules/paravis.git] / src / PVGUI / PVGUI_Module.h
1 // PARAVIS : ParaView wrapper SALOME module
2 //
3 // Copyright (C) 2010-2015  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, Adrien BRUNETON
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(PVSERVER_Gen)
32
33 #include <ostream>
34 #include <vtkType.h>
35 #include <QTimer>
36
37 #include <pqVariableType.h>
38
39 class QMenu;
40 class QDockWidget;
41 class QToolBar;
42 class vtkPVMain;
43 class pqOptions;
44 class pqServer;
45 class pqMainWindowCore;
46 class vtkEventQtSlotConnect;
47 class pqPythonScriptEditor;
48 class pqPVApplicationCore;
49 class pqDataRepresentation;
50 class pqRepresentation;
51 class PVViewer_GUIElements;
52 class PVViewer_EngineWrapper;
53
54 class PVGUI_Module : public SalomeApp_Module
55 {
56   Q_OBJECT
57    
58   //! Menu actions
59   enum { // Menu "File"
60      OpenFileId,
61
62      LoadStateId,
63      SaveStateId,
64
65      SaveDataId,
66      SaveScreenshotId,
67      ExportId,
68
69      SaveAnimationId,
70      SaveGeometryId,
71
72      ConnectId,
73      DisconnectId,
74
75      // Menu "Edit"
76      UndoId,
77      RedoId,
78
79      CameraUndoId,
80      CameraRedoId,
81
82      FindDataId,
83      ChangeInputId,
84      IgnoreTimeId,
85      DeleteId,
86      DeleteAllId,
87
88      SettingsId,
89      ViewSettingsId,
90
91      // Menu "View"
92      FullScreenId,
93
94      // Menu "Animation"
95      FirstFrameId,
96      PreviousFrameId,
97      PlayId,
98      NextFrameId,
99      LastFrameId,
100      LoopId,
101
102      // Menu "Tools"
103      CreateCustomFilterId,
104      ManageCustomFiltersId,
105      CreateLookmarkId,
106      ManageLinksId,
107      AddCameraLinkId,
108      ManagePluginsExtensionsId,
109      DumpWidgetNamesId,
110      RecordTestId,
111      RecordTestScreenshotId,
112      PlayTestId,
113      MaxWindowSizeId,
114      CustomWindowSizeId,
115      TimerLogId,
116      OutputWindowId,
117      PythonShellId,
118      ShowTraceId,
119      RestartTraceId,
120
121      // Menu "Help"
122      AboutParaViewId,
123      ParaViewHelpId,
124      EnableTooltipsId,
125
126      // Menu "Window" - "New Window"
127      ParaViewNewWindowId,
128
129      // "Save state" ParaVis module root object popup
130      SaveStatePopupId,
131
132      // "Add state" and "Reload state" popups
133      AddStatePopupId,
134      CleanAndAddStatePopupId,
135
136      // "Rename" and "Delete" popups (Object Browser)
137      ParaVisRenameId,
138      ParaVisDeleteId
139   };
140
141 public:
142   PVGUI_Module();
143   ~PVGUI_Module();
144
145   virtual void           initialize( CAM_Application* );
146   virtual void           windows( QMap<int, int>& ) const;
147
148   virtual QString engineIOR() const;  // to be removed when becoming Light
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 startTrace();
158   void stopTrace();
159   void saveTrace(const char* theName);
160
161   pqServer* getActiveServer();
162
163   virtual void createPreferences();
164
165   virtual void contextMenuPopup(const QString& theClient, QMenu* theMenu, QString& theTitle);
166
167   inline static PVViewer_EngineWrapper * GetEngine();
168   inline static PVSERVER_ORB::PVSERVER_Gen_var GetCPPEngine();  // to be removed once light!
169   inline static pqPVApplicationCore * GetPVApplication();
170
171   virtual CAM_DataModel* createDataModel();
172   void  fixAnimationScene();
173
174 public slots:
175   //void onImportFromVisu(QString theEntry);
176
177 private:
178   void deleteTemporaryFiles();
179  
180   //! Create actions for ParaView GUI operations
181   void                   pvCreateActions();
182
183   //! Create menus for ParaView GUI operations duplicating menus in pqMainWindow ParaView class
184   void                   pvCreateMenus();
185
186   //! Create toolbars for ParaView GUI operations duplicating toolbars in pqMainWindow ParaView class
187   void                   pvCreateToolBars();
188
189   //! Create dock widgets for ParaView widgets
190   void                   setupDockWidgets();
191
192   //! Save states of dockable ParaView widgets
193   void                   saveDockWidgetsState();
194
195   //! Restore states of dockable ParaView widgets
196   void                   restoreDockWidgetsState();
197
198   //! Shows or hides ParaView view window
199   void                   showView( bool );    
200
201   //! Returns QMenu object for a given menu id
202   QMenu*                 getMenu( const int );
203   
204   //! Discover help project files from the resources.
205   QString getHelpFileName();
206
207   //! Create actions for ParaViS
208   void createActions();
209
210   //! Create menus for ParaViS
211   void createMenus();
212
213   //! Load selected state
214   void loadSelectedState(bool toClear);
215
216   //! Get list of embedded macros files
217   QStringList getEmbeddedMacrosList();
218
219   //! update macros state
220   void updateMacros();
221
222   //! store visibility of the common dockable windows (OB, PyConsole, ... etc.)
223   void storeCommonWindowsState();
224
225   //! restore visibility of the common dockable windows (OB, PyConsole, ... etc.)
226   void restoreCommonWindowsState();
227
228 private slots:
229
230   void showHelpForProxy( const QString&, const QString& );
231   
232   void onPreAccept();
233   void onPostAccept();
234   void endWaitCursor();
235
236   //  void buildToolbarsMenu();
237
238   //void showParaViewHelp();
239   //void showHelp(const QString& url);
240
241   void onDataRepresentationUpdated();
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   virtual void           onPushTraceTimer();
266   virtual void           onInitTimer();
267
268 private:
269   int                    mySelectionControlsTb;
270   int                    mySourcesMenuId;
271   int                    myFiltersMenuId;
272   int                    myToolbarsMenuId;
273   int                    myMacrosMenuId;
274   int                    myRecentMenuId;
275   
276   typedef QMap<QWidget*, bool> WgMap;
277   WgMap                  myDockWidgets;
278   WgMap                  myToolbars;
279   WgMap                  myToolbarBreaks;
280   QList<QMenu*>          myMenus;
281
282   typedef QMap<int, bool> DockWindowMap;         
283   DockWindowMap           myCommonMap; 
284
285   QStringList            myTemporaryFiles;
286
287   QtMsgHandler           myOldMsgHandler;
288
289   vtkEventQtSlotConnect *VTKConnect;
290
291   pqPythonScriptEditor* myTraceWindow;
292
293   int myStateCounter;
294
295   //! Single shot timer used to connect to the PVServer, and start the trace.
296   QTimer             * myInitTimer;
297
298   //! Timer used to regularly push the Python trace to the engine.
299   QTimer             * myPushTraceTimer;
300
301   PVViewer_GUIElements * myGuiElements;
302
303   static PVSERVER_ORB::PVSERVER_Gen_var MyEngine;
304
305 };
306
307 #endif // PVGUI_Module_H