1 // Copyright (C) 2014-2015 EDF-R&D
2 // This library is free software; you can redistribute it and/or
3 // modify it under the terms of the GNU Lesser General Public
4 // License as published by the Free Software Foundation; either
5 // version 2.1 of the License, or (at your option) any later version.
7 // This library is distributed in the hope that it will be useful,
8 // but WITHOUT ANY WARRANTY; without even the implied warranty of
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10 // Lesser General Public License for more details.
12 // You should have received a copy of the GNU Lesser General Public
13 // License along with this library; if not, write to the Free Software
14 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #ifndef HYDROGUI_MODULE_H
20 #define HYDROGUI_MODULE_H
22 #include <HYDROData_Entity.h>
25 #pragma warning ( disable: 4251 )
28 #include <LightApp_Module.h>
29 #include <LightApp_Application.h>
34 #pragma warning ( default: 4251 )
37 class QGraphicsSceneMouseEvent;
38 class GraphicsView_Viewer;
39 class OCCViewer_Viewer;
42 class SUIT_ViewWindow;
43 class SUIT_ViewManager;
45 class HYDROData_StricklerTable;
47 class HYDROGUI_DataModel;
48 class HYDROGUI_Displayer;
49 class HYDROGUI_OCCDisplayer;
50 class HYDROGUI_VTKPrsDisplayer;
51 class HYDROGUI_AbstractDisplayer;
53 class HYDROGUI_VTKPrs;
54 class HYDROGUI_Operation;
55 class HYDROGUI_Overview;
57 /**\class HYDROGUI_Module
58 *\brief The class representing the HYDROGUI module
60 class HYDROGUI_Module : public LightApp_Module
64 enum CustomEvent { NewViewEvent = QEvent::User + 100 };
65 enum CustomWindows { OverviewWindow = LightApp_Application::WT_User + 100 };
81 CT_PointingHandCursor,
99 //VMR_PreviewZone, // totally unused, to delete
100 VMR_PreviewCaseZones // actually unused, to review
102 typedef QPair< SUIT_ViewManager*, ViewManagerRole > ViewManagerInfo;
104 typedef QMap < int, ViewManagerInfo > ViewManagerMap;
105 typedef QMapIterator< int, ViewManagerInfo > ViewManagerMapIterator;
112 ObjectState() : Visibility( false ), Transparency( 1.0 ), ZValue( 0.0 ) {}
114 typedef QMap< QString, ObjectState > Entry2ObjectStateMap;
115 typedef QMap< int, Entry2ObjectStateMap > ViewId2Entry2ObjectStateMap;
117 typedef QList<HYDROGUI_Shape*> ListOfShapes;
118 typedef QMap<int,ListOfShapes> ViewId2ListOfShapes;
120 typedef QList<HYDROGUI_VTKPrs*> ListOfVTKPrs;
121 typedef QMap<int,ListOfVTKPrs> ViewId2ListOfVTKPrs;
123 typedef QMap<int, Handle(HYDROData_StricklerTable)> ViewId2StricklerTable;
127 virtual ~HYDROGUI_Module();
129 int getStudyId() const;
131 virtual void initialize( CAM_Application* );
132 virtual void windows( QMap<int, int>& ) const;
133 virtual void viewManagers( QStringList& ) const;
135 virtual void contextMenuPopup( const QString&, QMenu*, QString& );
136 virtual void createPreferences();
138 virtual void update( const int );
139 virtual void updateCommandsStatus();
141 virtual void selectionChanged();
143 SUIT_ViewManager* getViewManager( const int theId ) const;
144 HYDROGUI_DataModel* getDataModel() const;
145 HYDROGUI_Displayer* getDisplayer() const;
146 HYDROGUI_OCCDisplayer* getOCCDisplayer() const;
147 HYDROGUI_VTKPrsDisplayer* getVTKDisplayer() const;
149 GraphicsView_Viewer* getViewer( const int theId ) const;
150 OCCViewer_Viewer* getOCCViewer( const int theId ) const;
151 SVTK_Viewer* getVTKViewer( const int theId ) const;
153 int getViewManagerId( SUIT_ViewManager* theViewManager );
154 ViewManagerRole getViewManagerRole( SUIT_ViewManager* theViewManager );
155 void setViewManagerRole( SUIT_ViewManager* theViewManager,
156 const ViewManagerRole theRole );
158 bool isObjectVisible( const int theViewId,
159 const Handle(HYDROData_Entity)& theObject ) const;
160 void setObjectVisible( const int theViewId,
161 const Handle(HYDROData_Entity)& theObject,
162 const bool theState );
164 virtual void preferencesChanged( const QString&, const QString& );
166 void resetViewState();
169 * Set IsToUpdate flag for all presentations of the given object to recompute them during
170 * the next viewer(s) updating.
171 * @param theObject the data model object
172 * @param theState the flag to set for object's presentations, it's true by default.
174 void setIsToUpdate( const Handle(HYDROData_Entity)& theObject,
175 const bool theState = true );
176 QList<HYDROGUI_Shape*> getObjectShapes( const int theViewId,
177 ObjectKind theKind ) const;
178 HYDROGUI_Shape* getObjectShape( const int theViewId,
179 const Handle(HYDROData_Entity)& theObject ) const;
180 void setObjectShape( const int theViewId,
181 const Handle(HYDROData_Entity)& theObject,
182 HYDROGUI_Shape* theShape );
183 void removeViewShapes( const int theViewId );
184 void removeObjectShape( const int theViewId,
185 const Handle(HYDROData_Entity)& theObject );
187 HYDROGUI_VTKPrs* getObjectVTKPrs( const int theViewId,
188 const Handle(HYDROData_Entity)& theObject ) const;
189 void setObjectVTKPrs( const int theViewId,
190 const Handle(HYDROData_Entity)& theObject,
191 HYDROGUI_VTKPrs* theShape );
192 void removeViewVTKPrs( const int theViewId );
193 void removeObjectVTKPrs( const int theViewId,
194 const Handle(HYDROData_Entity)& theObject );
196 void removeObjectVTKPrs( const int theViewId,
197 const QString& theEntry );
200 * Update global imposed range of Z values for the given VTK viewer id
202 void updateVTKZRange( const int theViewId, double theRange[] );
205 * Returns true if the object with the given entry can be renamed.
206 * @param theEntry the object entry
208 virtual bool renameAllowed( const QString& theEntry ) const;
210 * Returns true if the object with the given entry is renamed.
211 * @param theEntry the object entry
212 * @param theName the new name
214 virtual bool renameObject( const QString& theEntry, const QString& theName );
216 QStack<HYDROGUI_Operation*>& getActiveOperations();
217 HYDROGUI_Operation* activeOperation();
220 * Returns the cursor defined for edition operations in module preferences.
221 * \return specific cursor
223 QCursor getPrefEditCursor() const;
228 * Returns Strickler table used for Land Cover scalar map coloring in the given view.
229 * @param theViewId the view id
230 * @return the Strickler table used for scalar map coloring of Land Covers in the given view;
231 null - if scalar map coloring is off for the view
233 Handle(HYDROData_StricklerTable) getLandCoverColoringTable( const int theViewId ) const;
236 * Set Strickler table to be used for Land Cover scalar map coloring in the given view.
237 * @param theViewId the view id
238 * @param theTable the Strickler table
240 void setLandCoverColoringTable( const int theViewId,
241 const Handle(HYDROData_StricklerTable)& theTable );
243 * Set Land Cover scalar map coloring mode off for the given view.
244 * @param theViewId the view id
246 void setLandCoversScalarMapModeOff( const int theViewId );
249 * Check if Land Cover scalar map coloring mode is on in the given view.
250 * @param theViewId the view id
251 * @return true if the mode is on, false if the mode is off
253 bool isLandCoversScalarMapModeOn( const int theViewId ) const;
256 * Set object as removed.
257 * @param theObject the removed object
259 void setObjectRemoved( const Handle(HYDROData_Entity)& theObject );
261 void enableLCMActions();
263 bool arrowsVisible() const;
264 void setArrowsVisible( bool );
267 CAM_DataModel* createDataModel();
268 void setAutoZoomToAllViewManagers(bool bAutoZoom);
269 void setAutoZoom(SUIT_ViewManager* aVMgr, bool bAutoZoom);
271 virtual bool activateModule( SUIT_Study* );
272 virtual bool deactivateModule( SUIT_Study* );
273 virtual void onObjectClicked( SUIT_DataObject*, int );
276 virtual LightApp_Operation* createOperation( const int ) const;
277 virtual bool reusableOperation( const int id );
279 virtual void customEvent( QEvent* );
280 virtual bool eventFilter( QObject*, QEvent* );
285 void onBathymetrySelection();
286 void onBathymetryText();
289 bool onUndo( int theNumActions );
290 bool onRedo( int theNumActions );
292 virtual void onViewManagerAdded( SUIT_ViewManager* );
293 virtual void onViewManagerRemoved( SUIT_ViewManager* );
294 virtual void onViewCreated( SUIT_ViewWindow* );
296 void onViewActivated( SUIT_ViewManager* );
298 void onViewPortMouseEvent( QGraphicsSceneMouseEvent* );
300 void onMouseMove( SUIT_ViewWindow*, QMouseEvent* );
303 void updateViewer( HYDROGUI_AbstractDisplayer* theDisplayer,
304 const bool theIsInit = false,
305 const bool theIsForced = false,
306 const bool theDoFitAll = false );
308 void createSelector( SUIT_ViewManager* viewMgr );
310 bool setUpdateEnabled( const bool theState );
311 bool isUpdateEnabled() const;
313 QStringList storeSelection() const;
314 void restoreSelection( const QStringList& theEntryList );
317 void createActions();
320 void createToolbars();
322 void createUndoRedoActions();
323 void updateUndoRedoControls();
326 QAction* createAction( const int theId, const QString& theSuffix,
327 const QString& theImg = QString::null,
328 const int theKey = 0, const bool isToggle = false,
329 const QString& theSlot = QString::null );
332 HYDROGUI_Displayer* myDisplayer;
333 HYDROGUI_OCCDisplayer* myOCCDisplayer;
334 HYDROGUI_VTKPrsDisplayer* myVTKDisplayer;
336 ViewManagerMap myViewManagerMap;
337 ViewId2Entry2ObjectStateMap myObjectStateMap;
339 QStack<HYDROGUI_Operation*> myActiveOperationMap;
341 ViewId2ListOfShapes myShapesMap;
342 ViewId2ListOfVTKPrs myVTKPrsMap;
343 bool myIsUpdateEnabled;
345 QStringList myGeomObjectsToImport; ///< entries of GEOM objects to be imported
347 ViewId2StricklerTable myLandCoverColoringMap;
349 HYDROGUI_Overview* myOverview;