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>
33 #pragma warning ( default: 4251 )
36 class QGraphicsSceneMouseEvent;
37 class GraphicsView_Viewer;
38 class OCCViewer_Viewer;
41 class SUIT_ViewWindow;
42 class SUIT_ViewManager;
44 class Handle(HYDROData_StricklerTable);
46 class HYDROGUI_DataModel;
47 class HYDROGUI_Displayer;
48 class HYDROGUI_OCCDisplayer;
49 class HYDROGUI_VTKPrsDisplayer;
50 class HYDROGUI_AbstractDisplayer;
52 class HYDROGUI_VTKPrs;
53 class HYDROGUI_Operation;
55 /**\class HYDROGUI_Module
56 *\brief The class representing the HYDROGUI module
58 class HYDROGUI_Module : public LightApp_Module
62 enum CustomEvent { NewViewEvent = QEvent::User + 100 };
78 CT_PointingHandCursor,
96 //VMR_PreviewZone, // totally unused, to delete
97 VMR_PreviewCaseZones // actually unused, to review
99 typedef QPair< SUIT_ViewManager*, ViewManagerRole > ViewManagerInfo;
101 typedef QMap < int, ViewManagerInfo > ViewManagerMap;
102 typedef QMapIterator< int, ViewManagerInfo > ViewManagerMapIterator;
109 ObjectState() : Visibility( false ), Transparency( 1.0 ), ZValue( 0.0 ) {}
111 typedef QMap< QString, ObjectState > Entry2ObjectStateMap;
112 typedef QMap< int, Entry2ObjectStateMap > ViewId2Entry2ObjectStateMap;
114 typedef QList<HYDROGUI_Shape*> ListOfShapes;
115 typedef QMap<int,ListOfShapes> ViewId2ListOfShapes;
117 typedef QList<HYDROGUI_VTKPrs*> ListOfVTKPrs;
118 typedef QMap<int,ListOfVTKPrs> ViewId2ListOfVTKPrs;
120 typedef QMap<int, Handle(HYDROData_StricklerTable)> ViewId2StricklerTable;
124 virtual ~HYDROGUI_Module();
126 int getStudyId() const;
128 virtual void initialize( CAM_Application* );
129 virtual void windows( QMap<int, int>& ) const;
130 virtual void viewManagers( QStringList& ) const;
132 virtual void contextMenuPopup( const QString&, QMenu*, QString& );
133 virtual void createPreferences();
135 virtual void update( const int );
136 virtual void updateCommandsStatus();
138 virtual void selectionChanged();
140 SUIT_ViewManager* getViewManager( const int theId ) const;
141 HYDROGUI_DataModel* getDataModel() const;
142 HYDROGUI_Displayer* getDisplayer() const;
143 HYDROGUI_OCCDisplayer* getOCCDisplayer() const;
144 HYDROGUI_VTKPrsDisplayer* getVTKDisplayer() const;
146 GraphicsView_Viewer* getViewer( const int theId ) const;
147 OCCViewer_Viewer* getOCCViewer( const int theId ) const;
148 SVTK_Viewer* getVTKViewer( const int theId ) const;
150 int getViewManagerId( SUIT_ViewManager* theViewManager );
151 ViewManagerRole getViewManagerRole( SUIT_ViewManager* theViewManager );
152 void setViewManagerRole( SUIT_ViewManager* theViewManager,
153 const ViewManagerRole theRole );
155 bool isObjectVisible( const int theViewId,
156 const Handle(HYDROData_Entity)& theObject ) const;
157 void setObjectVisible( const int theViewId,
158 const Handle(HYDROData_Entity)& theObject,
159 const bool theState );
161 * Set IsToUpdate flag for all presentations of the given object to recompute them during
162 * the next viewer(s) updating.
163 * @param theObject the data model object
164 * @param theState the flag to set for object's presentations, it's true by default.
166 void setIsToUpdate( const Handle(HYDROData_Entity)& theObject,
167 const bool theState = true );
168 QList<HYDROGUI_Shape*> getObjectShapes( const int theViewId,
169 ObjectKind theKind ) const;
170 HYDROGUI_Shape* getObjectShape( const int theViewId,
171 const Handle(HYDROData_Entity)& theObject ) const;
172 void setObjectShape( const int theViewId,
173 const Handle(HYDROData_Entity)& theObject,
174 HYDROGUI_Shape* theShape );
175 void removeViewShapes( const int theViewId );
176 void removeObjectShape( const int theViewId,
177 const Handle(HYDROData_Entity)& theObject );
179 HYDROGUI_VTKPrs* getObjectVTKPrs( const int theViewId,
180 const Handle(HYDROData_Entity)& theObject ) const;
181 void setObjectVTKPrs( const int theViewId,
182 const Handle(HYDROData_Entity)& theObject,
183 HYDROGUI_VTKPrs* theShape );
184 void removeViewVTKPrs( const int theViewId );
185 void removeObjectVTKPrs( const int theViewId,
186 const Handle(HYDROData_Entity)& theObject );
188 void removeObjectVTKPrs( const int theViewId,
189 const QString& theEntry );
192 * Update global imposed range of Z values for the given VTK viewer id
194 void updateVTKZRange( const int theViewId, double theRange[] );
197 * Returns true if the object with the given entry can be renamed.
198 * @param theEntry the object entry
200 virtual bool renameAllowed( const QString& theEntry ) const;
202 * Returns true if the object with the given entry is renamed.
203 * @param theEntry the object entry
204 * @param theName the new name
206 virtual bool renameObject( const QString& theEntry, const QString& theName );
208 QStack<HYDROGUI_Operation*>& getActiveOperations();
209 HYDROGUI_Operation* activeOperation();
212 * Returns the cursor defined for edition operations in module preferences.
213 * \return specific cursor
215 QCursor getPrefEditCursor() const;
218 * Returns Strickler table used for Land Cover scalar map coloring in the given view.
219 * @param theViewId the view id
220 * @return the Strickler table used for scalar map coloring of Land Covers in the given view;
221 null - if scalar map coloring is off for the view
223 Handle(HYDROData_StricklerTable) getLandCoverColoringTable( const int theViewId ) const;
226 * Set Strickler table to be used for Land Cover scalar map coloring in the given view.
227 * @param theViewId the view id
228 * @param theTable the Strickler table
230 void setLandCoverColoringTable( const int theViewId,
231 const Handle(HYDROData_StricklerTable)& theTable );
233 * Set Land Cover scalar map coloring mode off for the given view.
234 * @param theViewId the view id
236 void setLandCoversScalarMapModeOff( const int theViewId );
239 * Check if Land Cover scalar map coloring mode is on in the given view.
240 * @param theViewId the view id
241 * @return true if the mode is on, false if the mode is off
243 bool isLandCoversScalarMapModeOn( const int theViewId ) const;
246 * Set object as removed.
247 * @param theObject the removed object
249 void setObjectRemoved( const Handle(HYDROData_Entity)& theObject );
252 CAM_DataModel* createDataModel();
255 virtual bool activateModule( SUIT_Study* );
256 virtual bool deactivateModule( SUIT_Study* );
257 virtual void onObjectClicked( SUIT_DataObject*, int );
260 virtual LightApp_Operation* createOperation( const int ) const;
261 virtual bool reusableOperation( const int id );
263 virtual void customEvent( QEvent* );
264 virtual bool eventFilter( QObject*, QEvent* );
271 bool onUndo( int theNumActions );
272 bool onRedo( int theNumActions );
274 virtual void onViewManagerAdded( SUIT_ViewManager* );
275 virtual void onViewManagerRemoved( SUIT_ViewManager* );
276 virtual void onViewCreated( SUIT_ViewWindow* );
278 void onViewPortMouseEvent( QGraphicsSceneMouseEvent* );
280 void onMouseMove( SUIT_ViewWindow*, QMouseEvent* );
283 void updateViewer( HYDROGUI_AbstractDisplayer* theDisplayer,
284 const bool theIsInit = false,
285 const bool theIsForced = false,
286 const bool theDoFitAll = false );
288 void createSelector( SUIT_ViewManager* viewMgr );
290 bool setUpdateEnabled( const bool theState );
291 bool isUpdateEnabled() const;
293 QStringList storeSelection() const;
294 void restoreSelection( const QStringList& theEntryList );
297 void createActions();
300 void createToolbars();
302 void createUndoRedoActions();
303 void updateUndoRedoControls();
306 QAction* createAction( const int theId, const QString& theSuffix,
307 const QString& theImg = QString::null,
308 const int theKey = 0, const bool isToggle = false,
309 const QString& theSlot = QString::null );
312 HYDROGUI_Displayer* myDisplayer;
313 HYDROGUI_OCCDisplayer* myOCCDisplayer;
314 HYDROGUI_VTKPrsDisplayer* myVTKDisplayer;
316 ViewManagerMap myViewManagerMap;
317 ViewId2Entry2ObjectStateMap myObjectStateMap;
319 QStack<HYDROGUI_Operation*> myActiveOperationMap;
321 ViewId2ListOfShapes myShapesMap;
322 ViewId2ListOfVTKPrs myVTKPrsMap;
323 bool myIsUpdateEnabled;
325 QStringList myGeomObjectsToImport; ///< entries of GEOM objects to be imported
327 ViewId2StricklerTable myLandCoverColoringMap;