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