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& );
167 * Set IsToUpdate flag for all presentations of the given object to recompute them during
168 * the next viewer(s) updating.
169 * @param theObject the data model object
170 * @param theState the flag to set for object's presentations, it's true by default.
172 void setIsToUpdate( const Handle(HYDROData_Entity)& theObject,
173 const bool theState = true );
174 QList<HYDROGUI_Shape*> getObjectShapes( const int theViewId,
175 ObjectKind theKind ) const;
176 HYDROGUI_Shape* getObjectShape( const int theViewId,
177 const Handle(HYDROData_Entity)& theObject ) const;
178 void setObjectShape( const int theViewId,
179 const Handle(HYDROData_Entity)& theObject,
180 HYDROGUI_Shape* theShape );
181 void removeViewShapes( const int theViewId );
182 void removeObjectShape( const int theViewId,
183 const Handle(HYDROData_Entity)& theObject );
185 HYDROGUI_VTKPrs* getObjectVTKPrs( const int theViewId,
186 const Handle(HYDROData_Entity)& theObject ) const;
187 void setObjectVTKPrs( const int theViewId,
188 const Handle(HYDROData_Entity)& theObject,
189 HYDROGUI_VTKPrs* theShape );
190 void removeViewVTKPrs( const int theViewId );
191 void removeObjectVTKPrs( const int theViewId,
192 const Handle(HYDROData_Entity)& theObject );
194 void removeObjectVTKPrs( const int theViewId,
195 const QString& theEntry );
198 * Update global imposed range of Z values for the given VTK viewer id
200 void updateVTKZRange( const int theViewId, double theRange[] );
203 * Returns true if the object with the given entry can be renamed.
204 * @param theEntry the object entry
206 virtual bool renameAllowed( const QString& theEntry ) const;
208 * Returns true if the object with the given entry is renamed.
209 * @param theEntry the object entry
210 * @param theName the new name
212 virtual bool renameObject( const QString& theEntry, const QString& theName );
214 QStack<HYDROGUI_Operation*>& getActiveOperations();
215 HYDROGUI_Operation* activeOperation();
218 * Returns the cursor defined for edition operations in module preferences.
219 * \return specific cursor
221 QCursor getPrefEditCursor() const;
226 * Returns Strickler table used for Land Cover scalar map coloring in the given view.
227 * @param theViewId the view id
228 * @return the Strickler table used for scalar map coloring of Land Covers in the given view;
229 null - if scalar map coloring is off for the view
231 Handle(HYDROData_StricklerTable) getLandCoverColoringTable( const int theViewId ) const;
234 * Set Strickler table to be used for Land Cover scalar map coloring in the given view.
235 * @param theViewId the view id
236 * @param theTable the Strickler table
238 void setLandCoverColoringTable( const int theViewId,
239 const Handle(HYDROData_StricklerTable)& theTable );
241 * Set Land Cover scalar map coloring mode off for the given view.
242 * @param theViewId the view id
244 void setLandCoversScalarMapModeOff( const int theViewId );
247 * Check if Land Cover scalar map coloring mode is on in the given view.
248 * @param theViewId the view id
249 * @return true if the mode is on, false if the mode is off
251 bool isLandCoversScalarMapModeOn( const int theViewId ) const;
254 * Set object as removed.
255 * @param theObject the removed object
257 void setObjectRemoved( const Handle(HYDROData_Entity)& theObject );
259 void enableLCMActions();
261 bool arrowsVisible() const;
262 void setArrowsVisible( bool );
265 CAM_DataModel* createDataModel();
266 void setAutoZoomToAllViewManagers(bool bAutoZoom);
267 void setAutoZoom(SUIT_ViewManager* aVMgr, bool bAutoZoom);
269 virtual bool activateModule( SUIT_Study* );
270 virtual bool deactivateModule( SUIT_Study* );
271 virtual void onObjectClicked( SUIT_DataObject*, int );
274 virtual LightApp_Operation* createOperation( const int ) const;
275 virtual bool reusableOperation( const int id );
277 virtual void customEvent( QEvent* );
278 virtual bool eventFilter( QObject*, QEvent* );
283 void onBathymetrySelection();
284 void onBathymetryText();
287 bool onUndo( int theNumActions );
288 bool onRedo( int theNumActions );
290 virtual void onViewManagerAdded( SUIT_ViewManager* );
291 virtual void onViewManagerRemoved( SUIT_ViewManager* );
292 virtual void onViewCreated( SUIT_ViewWindow* );
294 void onViewActivated( SUIT_ViewManager* );
296 void onViewPortMouseEvent( QGraphicsSceneMouseEvent* );
298 void onMouseMove( SUIT_ViewWindow*, QMouseEvent* );
301 void updateViewer( HYDROGUI_AbstractDisplayer* theDisplayer,
302 const bool theIsInit = false,
303 const bool theIsForced = false,
304 const bool theDoFitAll = false );
306 void createSelector( SUIT_ViewManager* viewMgr );
308 bool setUpdateEnabled( const bool theState );
309 bool isUpdateEnabled() const;
311 QStringList storeSelection() const;
312 void restoreSelection( const QStringList& theEntryList );
315 void createActions();
318 void createToolbars();
320 void createUndoRedoActions();
321 void updateUndoRedoControls();
324 QAction* createAction( const int theId, const QString& theSuffix,
325 const QString& theImg = QString::null,
326 const int theKey = 0, const bool isToggle = false,
327 const QString& theSlot = QString::null );
330 HYDROGUI_Displayer* myDisplayer;
331 HYDROGUI_OCCDisplayer* myOCCDisplayer;
332 HYDROGUI_VTKPrsDisplayer* myVTKDisplayer;
334 ViewManagerMap myViewManagerMap;
335 ViewId2Entry2ObjectStateMap myObjectStateMap;
337 QStack<HYDROGUI_Operation*> myActiveOperationMap;
339 ViewId2ListOfShapes myShapesMap;
340 ViewId2ListOfVTKPrs myVTKPrsMap;
341 bool myIsUpdateEnabled;
343 QStringList myGeomObjectsToImport; ///< entries of GEOM objects to be imported
345 ViewId2StricklerTable myLandCoverColoringMap;
347 HYDROGUI_Overview* myOverview;