Salome HOME
Merge from V6_main 11/02/2013
[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 onVariableChanged(pqVariableType, const QString);
229   void onRepresentationChanged(pqRepresentation*);
230
231   void onStartProgress();
232   void onEndProgress();
233   void onShowTrace();
234
235   void onNewParaViewWindow();
236
237   void onSaveMultiState();
238   void onAddState();
239   void onCleanAddState();
240
241   void onRename();
242   void onDelete();
243
244 public slots:
245   virtual bool           activateModule( SUIT_Study* );
246   virtual bool           deactivateModule( SUIT_Study* );
247   virtual void           onApplicationClosed( SUIT_Application* );
248   virtual void           studyClosed( SUIT_Study* );
249
250 protected slots:
251   virtual void           onModelOpened();
252
253 protected:
254   void timerEvent(QTimerEvent *event);
255
256 private:
257   class pqImplementation;
258   pqImplementation*      Implementation;
259
260   int                    mySelectionControlsTb;
261   int                    mySourcesMenuId;
262   int                    myFiltersMenuId;
263   int                    myToolbarsMenuId;
264   int                    myMacrosMenuId;
265   int                    myRecentMenuId;
266   
267   typedef QMap<QWidget*, bool> WgMap;
268   WgMap                  myDockWidgets;
269   WgMap                  myToolbars;
270   WgMap                  myToolbarBreaks;
271
272   QStringList            myTemporaryFiles;
273
274   QtMsgHandler           myOldMsgHandler;
275
276   vtkEventQtSlotConnect *VTKConnect;
277
278   pqPythonScriptEditor* myTraceWindow;
279
280   int myStateCounter;
281
282   static pqPVApplicationCore* MyCoreApp;
283 };
284
285 #endif // PVGUI_Module_H