Salome HOME
f586e07cf661500161f2755394f5ec4df4dbb42f
[modules/paravis.git] / src / PVGUI / PVGUI_Module.h
1 // PARAVIS : ParaView wrapper SALOME module
2 //
3 // Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 // File   : PVGUI_Module.h
23 // Author : Sergey ANIKIN
24 //
25
26
27 #ifndef PVGUI_Module_H
28 #define PVGUI_Module_H
29
30 #include <SalomeApp_Module.h>
31
32 #include <ostream>
33
34 class QMenu;
35 class QDockWidget;
36 //class LightApp_Selection;
37 //class LightApp_SelectionMgr;
38 class PVGUI_ProcessModuleHelper;
39 class vtkPVMain;
40 class pqOptions;
41 class pqServer;
42 class pqViewManager;
43 class pqMainWindowCore;
44
45 class PVGUI_Module : public SalomeApp_Module
46 {
47   Q_OBJECT
48    
49   //! Menu actions
50   enum { // Menu "File"
51          OpenFileId,
52
53          LoadStateId,
54          SaveStateId,
55
56          SaveDataId,
57          SaveScreenshotId,
58          ExportId,
59
60          SaveAnimationId,
61          SaveGeometryId,
62
63          ConnectId,
64          DisconnectId,
65
66          // Menu "Edit"
67          UndoId,
68          RedoId,
69
70          CameraUndoId,
71          CameraRedoId,
72
73          ChangeInputId,
74          DeleteId,
75          DeleteAllId,
76
77          InteractId,
78          SelectCellsOnId,
79          SelectPointsOnId,
80          SelectCellsThroughId,
81          SelectPointsThroughId,
82          SelectBlockId,
83
84          SettingsId,
85          ViewSettingsId,
86
87          // Menu "View"
88          ResetCameraId,
89          PositiveXId,
90          NegativeXId,
91          PositiveYId,
92          NegativeYId,
93          PositiveZId,
94          NegativeZId,
95
96          ShowCenterId,
97          ResetCenterId,
98          PickCenterId,
99          ShowColorLegendId,
100          EditColorMapId,
101          ResetRangeId,
102
103          AnimationInspectorId,
104          AnimationViewId,
105          ComparativeViewInspectorId,
106          SelectionInspectorId,
107          LookmarkBrowserId,
108          LookmarkInspectorId,
109          ObjectInspectorId,
110          PipelineBrowserId,
111          StatisticsViewId,
112
113          // Menu "Sources"
114          // TODO...
115
116          // Menu "Filters"
117          // TODO...
118
119          // Menu "Animation"
120          FirstFrameId,
121          PreviousFrameId,
122          PlayId,
123          NextFrameId,
124          LastFrameId,
125          LoopId,
126
127          // Menu "Tools" 
128          CreateCustomFilterId,
129          ManageCustomFiltersId,
130          CreateLookmarkId,
131          ManageLinksId,
132          AddCameraLinkId,
133          ManagePluginsExtensionsId,
134          DumpWidgetNamesId,
135          RecordTestId,
136          RecordTestScreenshotId,
137          PlayTestId,
138          MaxWindowSizeId,
139          TimerLogId,
140          OutputWindowId,
141          PythonShellId,
142
143          // Menu "Help" 
144          AboutParaViewId,
145          ParaViewHelpId,
146          EnableTooltipsId
147   };
148
149 public:
150   PVGUI_Module();
151   ~PVGUI_Module();
152
153   virtual void           initialize( CAM_Application* );
154   virtual void           windows( QMap<int, int>& ) const;
155
156   pqViewManager*         getMultiViewManager() const;
157
158   virtual bool           eventFilter( QObject*, QEvent* );
159
160   virtual QString engineIOR() const;
161
162   //! Compares the contents of the window with the given reference image, returns true if they "match" within some tolerance
163   bool                   compareView( const QString& ReferenceImage, double Threshold,
164                                       std::ostream& Output, const QString& TempDirectory );
165
166   void openFile(const char* theName);
167   void saveParaviewState(const char* theFileName);
168   void loadParaviewState(const char* theFileName);
169
170   QString printTrace();
171   void saveTrace(const char* theName);
172
173   pqServer* getActiveServer();
174
175   virtual void createPreferences();
176
177 public slots:
178   void onImportFromVisu(QString theEntry);
179
180 protected:
181   //virtual CAM_DataModel* createDataModel();
182
183 private:
184   //! Initialize ParaView if not yet done (once per session)
185   static bool            pvInit();  
186   //! Shutdown ParaView, should be called on application exit
187   static void            pvShutdown();   
188  
189   //! Create actions for ParaView GUI operations
190   void                   pvCreateActions();
191
192   //! Create menus for ParaView GUI operations duplicating menus in pqMainWindow ParaView class
193   void                   pvCreateMenus();
194
195   //! Create toolbars for ParaView GUI operations duplicating toolbars in pqMainWindow ParaView class
196   void                   pvCreateToolBars();
197
198   //! Create dock widgets for ParaView widgets
199   void                   setupDockWidgets();
200
201   //! Create dock widgets context menus
202   void                   setupDockWidgetsContextMenu();
203
204   //! Save states of dockable ParaView widgets
205   void                   saveDockWidgetsState();
206
207   //! Restore states of dockable ParaView widgets
208   void                   restoreDockWidgetsState();
209
210   //! Shows or hides ParaView view window
211   void                   showView( bool );    
212
213   //! Returns QMenu object for a given menu id
214   QMenu*                 getMenu( const int );
215
216   void                   deleteTemporaryFiles();
217
218 private slots:
219   void onUndoLabel( const QString& );
220   void onRedoLabel( const QString& );
221   
222   void onCameraUndoLabel( const QString& );
223   void onCameraRedoLabel( const QString& );
224
225   void onDeleteAll();
226
227   void onSelectionModeChanged( int mode );
228
229   void onShowCenterAxisChanged( bool );
230
231   void setTimeRanges( double, double );
232
233   void onPlaying( bool );
234   
235   void onAddCameraLink();
236   
237   void onHelpAbout();
238
239   void onParaViewHelp();
240
241   void showHelpForProxy( const QString& proxy );
242   void makeAssistant();
243   void assistantError( const QString& err );
244   
245   void onPreAccept();
246   void onPostAccept();
247   void endWaitCursor();
248
249   void connectToPlay();
250
251   void onOpenFile();
252
253   void activateTrace();
254
255 public slots:
256   virtual bool           activateModule( SUIT_Study* );
257   virtual bool           deactivateModule( SUIT_Study* );
258   virtual void           onApplicationClosed( SUIT_Application* );
259
260 private:
261   class pqImplementation;
262   pqImplementation*      Implementation;
263
264   int                    mySelectionControlsTb;
265   int                    mySourcesMenuId;
266   int                    myFiltersMenuId;
267
268   QList<QDockWidget*>    myDockWidgets;
269
270   QStringList            myTemporaryFiles;
271 };
272
273 #endif // PVGUI_Module_H