Salome HOME
export preselected_id to client
[modules/paravis.git] / 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 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 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 public slots:
168   void onImportFromVisu(QString theEntry);
169
170 private:
171   //! Initialize ParaView if not yet done (once per session)
172   static bool            pvInit();  
173  
174   //! Create actions for ParaView GUI operations
175   void                   pvCreateActions();
176
177   //! Create menus for ParaView GUI operations duplicating menus in pqMainWindow ParaView class
178   void                   pvCreateMenus();
179
180   //! Create toolbars for ParaView GUI operations duplicating toolbars in pqMainWindow ParaView class
181   void                   pvCreateToolBars();
182
183   //! Create dock widgets for ParaView widgets
184   void                   setupDockWidgets();
185
186   //! Save states of dockable ParaView widgets
187   void                   saveDockWidgetsState();
188
189   //! Restore states of dockable ParaView widgets
190   void                   restoreDockWidgetsState();
191
192   //! Shows or hides ParaView view window
193   void                   showView( bool );    
194
195   //! Returns QMenu object for a given menu id
196   QMenu*                 getMenu( const int );
197   
198   //! Discover help project files from the resources.
199   QString getHelpFileName();
200
201   void                   deleteTemporaryFiles();
202   
203   //QList<QToolBar*>       getParaViewToolbars();
204
205   //! Create actions for ParaViS
206   void createActions();
207
208   //! Create menus for ParaViS
209   void createMenus();
210
211   //! Load selected state
212   void loadSelectedState(bool toClear);
213
214   //! Get list of embedded macros files
215   QStringList getEmbeddedMacrosList();
216
217   //! update macros state
218   void updateMacros();
219
220   //! store visibility of the common dockable windows (OB, PyConsole, ... etc.)
221   void storeCommonWindowsState();
222
223   //! restore visibility of the common dockable windows (OB, PyConsole, ... etc.)
224   void restoreCommonWindowsState();
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