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