Salome HOME
Merge branch 'agr/edf12447-catalyst'
[modules/paravis.git] / src / PVGUI / PVGUI_Module.h
1 // PARAVIS : ParaView wrapper SALOME module
2 //
3 // Copyright (C) 2010-2016  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, Adrien BRUNETON
23 //
24
25
26 #ifndef PVGUI_Module_H
27 #define PVGUI_Module_H
28
29 #include <LightApp_Module.h>
30
31 class QMenu;
32 class QTimer;
33 class vtkEventQtSlotConnect;
34 class pqServer;
35 class pqPythonScriptEditor;
36 class pqPVApplicationCore;
37 class PVViewer_GUIElements;
38 class PVServer_ServiceWrapper;
39 class SUIT_ViewWindow;
40
41 class PVGUI_Module: public LightApp_Module
42 {
43   Q_OBJECT
44
45   //! Menu actions
46   enum {
47     //-----------
48     // Menu "File"
49     OpenFileId,
50     //-
51     LoadStateId,
52     SaveStateId,
53     //-
54     SaveDataId,
55     SaveScreenshotId,
56     ExportId,
57     //-
58     SaveAnimationId,
59     SaveGeometryId,
60     //-
61     ConnectId,
62     DisconnectId,
63     //-----------
64     // Menu "Edit"
65     UndoId,
66     RedoId,
67     //-
68     CameraUndoId,
69     CameraRedoId,
70     //-
71     FindDataId,
72     ChangeInputId,
73     IgnoreTimeId,
74     DeleteId,
75     DeleteAllId,
76     //-
77     SettingsId,             // not used
78     ViewSettingsId,         // not used
79     //-----------
80     // Menu "View"
81     FullScreenId,           // not used
82     //-----------
83     // Menu "Animation"
84     FirstFrameId,           // not used
85     PreviousFrameId,        // not used
86     PlayId,                 // not used
87     NextFrameId,            // not used
88     LastFrameId,            // not used
89     LoopId,                 // not used
90     //-----------
91     // Menu "Tools"
92     CreateCustomFilterId,
93     ManageCustomFiltersId,
94     CreateLookmarkId,       // not used
95     ManageLinksId,
96     AddCameraLinkId,
97     ManagePluginsExtensionsId,
98     DumpWidgetNamesId,      //  not used
99     RecordTestId,
100     RecordTestScreenshotId, // not used
101     PlayTestId,
102     MaxWindowSizeId,
103     CustomWindowSizeId,
104     TimerLogId,
105     OutputWindowId,
106     PythonShellId,
107     ShowTraceId,
108     RestartTraceId,
109     //-----------
110     // Menu "Help"
111     AboutParaViewId,
112     ParaViewHelpId,
113     EnableTooltipsId,       // not used
114   };
115
116 public:
117   PVGUI_Module();
118   ~PVGUI_Module();
119
120   virtual void initialize( CAM_Application* );
121   virtual void windows( QMap<int, int>& ) const;
122
123   void openFile( const char* );                   // not used inside PARAVIS
124   void executeScript( const char* );              // not used inside PARAVIS
125
126   void saveParaviewState( const QString& );
127   void loadParaviewState( const QString& );
128   void clearParaviewState();
129
130   QString getTraceString();
131   void startTrace();
132   void stopTrace();
133   void saveTrace( const char* );
134
135   pqServer* getActiveServer();
136
137   virtual void createPreferences();
138
139   inline static PVServer_ServiceWrapper* GetEngine();
140   inline static pqPVApplicationCore* GetPVApplication(); // not used inside PARAVIS
141
142   virtual CAM_DataModel* createDataModel();
143
144 private:
145   //! Create actions for ParaView GUI operations
146   void pvCreateActions();
147
148   //! Create menus for ParaView GUI operations duplicating menus in pqMainWindow ParaView class
149   void pvCreateMenus();
150
151   //! Create toolbars for ParaView GUI operations duplicating toolbars in pqMainWindow ParaView class
152   void pvCreateToolBars();
153
154   //! Create dock widgets for ParaView widgets
155   void setupDockWidgets();
156
157   //! Save states of dockable ParaView widgets
158   void saveDockWidgetsState( bool = true );
159
160   //! Restore states of dockable ParaView widgets
161   void restoreDockWidgetsState();
162
163   //! Shows or hides ParaView view window
164   void showView( bool );
165
166   //! Get list of embedded macros files
167   QStringList getEmbeddedMacrosList();
168
169   //! update macros state
170   void updateMacros();
171
172   //! store visibility of the common dockable windows (OB, PyConsole, ... etc.)
173   void storeCommonWindowsState();
174
175   //! restore visibility of the common dockable windows (OB, PyConsole, ... etc.)
176   void restoreCommonWindowsState();
177
178 private slots:
179   void showHelpForProxy( const QString&, const QString& );
180
181   void onPreAccept();    // not used inside PARAVIS
182   void onPostAccept();   // not used inside PARAVIS
183   void endWaitCursor();  // not used inside PARAVIS
184
185   void onDataRepresentationUpdated();
186
187   void onStartProgress();
188   void onEndProgress();
189   void onShowTrace();
190   void onRestartTrace();
191   void onStopTrace();
192
193 public slots:
194   virtual bool           activateModule( SUIT_Study* );
195   virtual bool           deactivateModule( SUIT_Study* );
196   virtual void           onApplicationClosed( SUIT_Application* );
197   virtual void           studyClosed( SUIT_Study* );
198
199 protected slots:
200   virtual void           onInitTimer();
201   virtual void           onViewManagerAdded( SUIT_ViewManager* );
202   virtual void           onViewManagerRemoved( SUIT_ViewManager* );
203   virtual void           onPVViewCreated( SUIT_ViewWindow* );
204   virtual void           onPVViewDelete( SUIT_ViewWindow* );
205
206 private:
207   int                    mySourcesMenuId;
208   int                    myFiltersMenuId;
209 #ifdef PVCATALYST_ENABLED
210   int                    myCatalystMenuId;
211 #endif
212   int                    myMacrosMenuId;
213   int                    myRecentMenuId;
214
215   typedef QMap<QWidget*, bool> WgMap;
216   WgMap                  myDockWidgets;
217   WgMap                  myToolbars;
218   WgMap                  myToolbarBreaks;
219   QList<QMenu*>          myMenus;
220
221   typedef QMap<int, bool> DockWindowMap;
222   DockWindowMap           myCommonMap;
223 #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
224   QtMsgHandler            myOldMsgHandler;
225 #else
226   QtMessageHandler        myOldMsgHandler;
227 #endif
228   vtkEventQtSlotConnect*  VTKConnect;
229
230   pqPythonScriptEditor*   myTraceWindow;
231
232   //! Single shot timer used to connect to the PVServer, and start the trace.
233   QTimer*                 myInitTimer;
234
235   PVViewer_GUIElements*   myGuiElements;
236 };
237
238 #endif // PVGUI_Module_H