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