Salome HOME
cece9bbf8bf343184a03c0dad663281e650463ae
[modules/paravis.git] / src / PVGUI / PVGUI_Module.h
1 // PARAVIS : ParaView wrapper SALOME module
2 //
3 // Copyright (C) 2010-2012  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.
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
117          // Menu "Help" 
118          AboutParaViewId,
119          ParaViewHelpId,
120          EnableTooltipsId,
121
122          // Menu "Window" - "New Window"
123          ParaViewNewWindowId,
124
125          // "Save state" ParaVis module root object popup
126          SaveStatePopupId,
127
128          // "Add state" and "Reload state" popups
129          AddStatePopupId,
130          CleanAndAddStatePopupId,
131
132          // "Rename" and "Delete" popups (Object Browser)
133          ParaVisRenameId,
134          ParaVisDeleteId
135   };
136
137 public:
138   PVGUI_Module();
139   ~PVGUI_Module();
140
141   virtual void           initialize( CAM_Application* );
142   virtual void           windows( QMap<int, int>& ) const;
143
144   pqTabbedMultiViewWidget*         getMultiViewManager() const;
145
146   virtual QString engineIOR() const;
147
148   void openFile(const char* theName);
149   void executeScript(const char *script);
150   void saveParaviewState(const char* theFileName);
151   void loadParaviewState(const char* theFileName);
152   void clearParaviewState();
153
154   QString getTraceString();
155   void saveTrace(const char* theName);
156
157   pqServer* getActiveServer();
158
159   virtual void createPreferences();
160
161   virtual void contextMenuPopup(const QString& theClient, QMenu* theMenu, QString& theTitle);
162
163 public slots:
164   void onImportFromVisu(QString theEntry);
165
166 private:
167   //! Initialize ParaView if not yet done (once per session)
168   static bool            pvInit();  
169  
170   //! Create actions for ParaView GUI operations
171   void                   pvCreateActions();
172
173   //! Create menus for ParaView GUI operations duplicating menus in pqMainWindow ParaView class
174   void                   pvCreateMenus();
175
176   //! Create toolbars for ParaView GUI operations duplicating toolbars in pqMainWindow ParaView class
177   void                   pvCreateToolBars();
178
179   //! Create dock widgets for ParaView widgets
180   void                   setupDockWidgets();
181
182   //! Save states of dockable ParaView widgets
183   void                   saveDockWidgetsState();
184
185   //! Restore states of dockable ParaView widgets
186   void                   restoreDockWidgetsState();
187
188   //! Shows or hides ParaView view window
189   void                   showView( bool );    
190
191   //! Returns QMenu object for a given menu id
192   QMenu*                 getMenu( const int );
193   
194   //! Discover help project files from the resources.
195   QString getHelpFileName();
196
197   void                   deleteTemporaryFiles();
198   
199   //QList<QToolBar*>       getParaViewToolbars();
200
201   //! Create actions for ParaViS
202   void createActions();
203
204   //! Create menus for ParaViS
205   void createMenus();
206
207   //! Load selected state
208   void loadSelectedState(bool toClear);
209
210   //! update macros state
211   void updateMacros();
212
213 private slots:
214
215   void showHelpForProxy( const QString&, const QString& );
216   
217   void onPreAccept();
218   void onPostAccept();
219   void endWaitCursor();
220
221   //  void buildToolbarsMenu();
222
223   //void showParaViewHelp();
224   //void showHelp(const QString& url);
225
226   void onFinishedAddingServer(pqServer*);
227   void onDataRepresentationCreated(pqDataRepresentation*);
228   void onDataRepresentationUpdated();
229   void onVariableChanged(pqVariableType, const QString);
230   void onRepresentationChanged(pqRepresentation*);
231
232   void onStartProgress();
233   void onEndProgress();
234   void onShowTrace();
235
236   void onNewParaViewWindow();
237
238   void onSaveMultiState();
239   void onAddState();
240   void onCleanAddState();
241
242   void onRename();
243   void onDelete();
244
245 public slots:
246   virtual bool           activateModule( SUIT_Study* );
247   virtual bool           deactivateModule( SUIT_Study* );
248   virtual void           onApplicationClosed( SUIT_Application* );
249   virtual void           studyClosed( SUIT_Study* );
250
251 protected slots:
252   virtual void           onModelOpened();
253
254 protected:
255   void timerEvent(QTimerEvent *event);
256
257 private:
258   class pqImplementation;
259   pqImplementation*      Implementation;
260
261   int                    mySelectionControlsTb;
262   int                    mySourcesMenuId;
263   int                    myFiltersMenuId;
264   int                    myToolbarsMenuId;
265   int                    myMacrosMenuId;
266   int                    myRecentMenuId;
267   
268   typedef QMap<QWidget*, bool> WgMap;
269   WgMap                  myDockWidgets;
270   WgMap                  myToolbars;
271   WgMap                  myToolbarBreaks;
272   QList<QMenu*>          myMenus;
273
274   QStringList            myTemporaryFiles;
275
276   QtMsgHandler           myOldMsgHandler;
277
278   vtkEventQtSlotConnect *VTKConnect;
279
280   pqPythonScriptEditor* myTraceWindow;
281
282   int myStateCounter;
283
284   static pqPVApplicationCore* MyCoreApp;
285 };
286
287 #endif // PVGUI_Module_H