X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHYDROGUI%2FHYDROGUI_Module.h;h=1b3523f17cb2c2c82add42cd6cc831ed856e5ba6;hb=39a306b77b32044c89bf6cef4445d5bfdea43149;hp=b930a167a397437b46b3ab45eb259b416f221d75;hpb=d6aeef5b61d85b44493cd5d93ed9870cc513e68f;p=modules%2Fhydro.git diff --git a/src/HYDROGUI/HYDROGUI_Module.h b/src/HYDROGUI/HYDROGUI_Module.h index b930a167..1b3523f1 100644 --- a/src/HYDROGUI/HYDROGUI_Module.h +++ b/src/HYDROGUI/HYDROGUI_Module.h @@ -1,12 +1,8 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// +// Copyright (C) 2014-2015 EDF-R&D // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either -// version 2.1 of the License. +// version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -23,13 +19,38 @@ #ifndef HYDROGUI_MODULE_H #define HYDROGUI_MODULE_H -#include "HYDROGUI.h" +#include + +#ifdef WIN32 + #pragma warning ( disable: 4251 ) +#endif #include +#include +#include + +#ifdef WIN32 + #pragma warning ( default: 4251 ) +#endif + +class QGraphicsSceneMouseEvent; +class GraphicsView_Viewer; +class OCCViewer_Viewer; +class SVTK_Viewer; class SUIT_ViewWindow; +class SUIT_ViewManager; + +class Handle(HYDROData_StricklerTable); class HYDROGUI_DataModel; +class HYDROGUI_Displayer; +class HYDROGUI_OCCDisplayer; +class HYDROGUI_VTKPrsDisplayer; +class HYDROGUI_AbstractDisplayer; +class HYDROGUI_Shape; +class HYDROGUI_VTKPrs; +class HYDROGUI_Operation; /**\class HYDROGUI_Module *\brief The class representing the HYDROGUI module @@ -38,46 +59,277 @@ class HYDROGUI_Module : public LightApp_Module { Q_OBJECT + enum CustomEvent { NewViewEvent = QEvent::User + 100 }; + + enum CursorType + { + CT_ArrowCursor = 0, + CT_UpArrowCursor, + CT_CrossCursor, + CT_WaitCursor, + CT_IBeamCursor, + CT_SizeVerCursor, + CT_SizeHorCursor, + CT_SizeBDiagCursor, + CT_SizeFDiagCursor, + CT_SizeAllCursor, + CT_SplitVCursor, + CT_SplitHCursor, + CT_PointingHandCursor, + CT_ForbiddenCursor, + CT_WhatsThisCursor, + CT_BusyCursor, + CT_OpenHandCursor, + CT_ClosedHandCursor, + CT_User + }; + +public: + + enum ViewManagerRole + { + VMR_Unknown = 0, + VMR_General, + VMR_TransformImage, + VMR_ReferenceImage, + VMR_ObserveImage, + //VMR_PreviewZone, // totally unused, to delete + VMR_PreviewCaseZones // actually unused, to review + }; + typedef QPair< SUIT_ViewManager*, ViewManagerRole > ViewManagerInfo; + + typedef QMap < int, ViewManagerInfo > ViewManagerMap; + typedef QMapIterator< int, ViewManagerInfo > ViewManagerMapIterator; + + struct ObjectState + { + bool Visibility; + double Transparency; + double ZValue; + ObjectState() : Visibility( false ), Transparency( 1.0 ), ZValue( 0.0 ) {} + }; + typedef QMap< QString, ObjectState > Entry2ObjectStateMap; + typedef QMap< int, Entry2ObjectStateMap > ViewId2Entry2ObjectStateMap; + + typedef QList ListOfShapes; + typedef QMap ViewId2ListOfShapes; + + typedef QList ListOfVTKPrs; + typedef QMap ViewId2ListOfVTKPrs; + + typedef QMap ViewId2StricklerTable; + public: HYDROGUI_Module(); virtual ~HYDROGUI_Module(); + int getStudyId() const; + + virtual void initialize( CAM_Application* ); + virtual void windows( QMap& ) const; + virtual void viewManagers( QStringList& ) const; + + virtual void contextMenuPopup( const QString&, QMenu*, QString& ); + virtual void createPreferences(); + + virtual void update( const int ); + virtual void updateCommandsStatus(); + + virtual void selectionChanged(); + + SUIT_ViewManager* getViewManager( const int theId ) const; + HYDROGUI_DataModel* getDataModel() const; + HYDROGUI_Displayer* getDisplayer() const; + HYDROGUI_OCCDisplayer* getOCCDisplayer() const; + HYDROGUI_VTKPrsDisplayer* getVTKDisplayer() const; + + GraphicsView_Viewer* getViewer( const int theId ) const; + OCCViewer_Viewer* getOCCViewer( const int theId ) const; + SVTK_Viewer* getVTKViewer( const int theId ) const; + + int getViewManagerId( SUIT_ViewManager* theViewManager ); + ViewManagerRole getViewManagerRole( SUIT_ViewManager* theViewManager ); + void setViewManagerRole( SUIT_ViewManager* theViewManager, + const ViewManagerRole theRole ); + + bool isObjectVisible( const int theViewId, + const Handle(HYDROData_Entity)& theObject ) const; + void setObjectVisible( const int theViewId, + const Handle(HYDROData_Entity)& theObject, + const bool theState ); + + virtual void preferencesChanged( const QString&, const QString& ); + + /** + * Set IsToUpdate flag for all presentations of the given object to recompute them during + * the next viewer(s) updating. + * @param theObject the data model object + * @param theState the flag to set for object's presentations, it's true by default. + */ + void setIsToUpdate( const Handle(HYDROData_Entity)& theObject, + const bool theState = true ); + QList getObjectShapes( const int theViewId, + ObjectKind theKind ) const; + HYDROGUI_Shape* getObjectShape( const int theViewId, + const Handle(HYDROData_Entity)& theObject ) const; + void setObjectShape( const int theViewId, + const Handle(HYDROData_Entity)& theObject, + HYDROGUI_Shape* theShape ); + void removeViewShapes( const int theViewId ); + void removeObjectShape( const int theViewId, + const Handle(HYDROData_Entity)& theObject ); + + HYDROGUI_VTKPrs* getObjectVTKPrs( const int theViewId, + const Handle(HYDROData_Entity)& theObject ) const; + void setObjectVTKPrs( const int theViewId, + const Handle(HYDROData_Entity)& theObject, + HYDROGUI_VTKPrs* theShape ); + void removeViewVTKPrs( const int theViewId ); + void removeObjectVTKPrs( const int theViewId, + const Handle(HYDROData_Entity)& theObject ); + + void removeObjectVTKPrs( const int theViewId, + const QString& theEntry ); + + /** + * Update global imposed range of Z values for the given VTK viewer id + */ + void updateVTKZRange( const int theViewId, double theRange[] ); + + /** + * Returns true if the object with the given entry can be renamed. + * @param theEntry the object entry + */ + virtual bool renameAllowed( const QString& theEntry ) const; + /** + * Returns true if the object with the given entry is renamed. + * @param theEntry the object entry + * @param theName the new name + */ + virtual bool renameObject( const QString& theEntry, const QString& theName ); + + QStack& getActiveOperations(); + HYDROGUI_Operation* activeOperation(); + + /** + * Returns the cursor defined for edition operations in module preferences. + * \return specific cursor + */ + QCursor getPrefEditCursor() const; + + void clearCache(); + + /** + * Returns Strickler table used for Land Cover scalar map coloring in the given view. + * @param theViewId the view id + * @return the Strickler table used for scalar map coloring of Land Covers in the given view; + null - if scalar map coloring is off for the view + */ + Handle(HYDROData_StricklerTable) getLandCoverColoringTable( const int theViewId ) const; + /** - * Returns the module study identifier + * Set Strickler table to be used for Land Cover scalar map coloring in the given view. + * @param theViewId the view id + * @param theTable the Strickler table */ - int getStudyId() const; + void setLandCoverColoringTable( const int theViewId, + const Handle(HYDROData_StricklerTable)& theTable ); + /** + * Set Land Cover scalar map coloring mode off for the given view. + * @param theViewId the view id + */ + void setLandCoversScalarMapModeOff( const int theViewId ); - virtual void initialize( CAM_Application* ); - virtual void windows( QMap& ) const; - virtual void viewManagers( QStringList& ) const; + /** + * Check if Land Cover scalar map coloring mode is on in the given view. + * @param theViewId the view id + * @return true if the mode is on, false if the mode is off + */ + bool isLandCoversScalarMapModeOn( const int theViewId ) const; - HYDROGUI_DataModel* getModel() const; + /** + * Set object as removed. + * @param theObject the removed object + */ + void setObjectRemoved( const Handle(HYDROData_Entity)& theObject ); protected: - CAM_DataModel* createDataModel(); + CAM_DataModel* createDataModel(); public slots: - virtual bool activateModule( SUIT_Study* ); + virtual bool activateModule( SUIT_Study* ); + virtual bool deactivateModule( SUIT_Study* ); + virtual void onObjectClicked( SUIT_DataObject*, int ); protected: - virtual LightApp_Operation* createOperation( const int ) const; + virtual LightApp_Operation* createOperation( const int ) const; + virtual bool reusableOperation( const int id ); + + virtual void customEvent( QEvent* ); + virtual bool eventFilter( QObject*, QEvent* ); protected slots: - void onOperation(); - virtual void onViewManagerAdded( SUIT_ViewManager* ); - virtual void onViewWindowAdded( SUIT_ViewWindow* ); + void onOperation(); + void onDelete(); + + + bool onUndo( int theNumActions ); + bool onRedo( int theNumActions ); + + virtual void onViewManagerAdded( SUIT_ViewManager* ); + virtual void onViewManagerRemoved( SUIT_ViewManager* ); + virtual void onViewCreated( SUIT_ViewWindow* ); + + void onViewPortMouseEvent( QGraphicsSceneMouseEvent* ); + + void onMouseMove( SUIT_ViewWindow*, QMouseEvent* ); + +private: + void updateViewer( HYDROGUI_AbstractDisplayer* theDisplayer, + const bool theIsInit = false, + const bool theIsForced = false, + const bool theDoFitAll = false ); + + void createSelector( SUIT_ViewManager* viewMgr ); + + bool setUpdateEnabled( const bool theState ); + bool isUpdateEnabled() const; + + QStringList storeSelection() const; + void restoreSelection( const QStringList& theEntryList ); private: - void CreateActions(); - void CreateMenus(); - void CreatePopups(); - void CreateToolbars(); + void createActions(); + void createMenus(); + void createPopups(); + void createToolbars(); + + void createUndoRedoActions(); + void updateUndoRedoControls(); private: - QAction* CreateAction( const int theId, const QString& theSuffix, - const QString& theImg = QString::null, - const int theKey = 0, const bool isToggle = false, - const QString& theSlot = QString::null ); + QAction* createAction( const int theId, const QString& theSuffix, + const QString& theImg = QString::null, + const int theKey = 0, const bool isToggle = false, + const QString& theSlot = QString::null ); + +private: + HYDROGUI_Displayer* myDisplayer; + HYDROGUI_OCCDisplayer* myOCCDisplayer; + HYDROGUI_VTKPrsDisplayer* myVTKDisplayer; + + ViewManagerMap myViewManagerMap; + ViewId2Entry2ObjectStateMap myObjectStateMap; + + QStack myActiveOperationMap; + + ViewId2ListOfShapes myShapesMap; + ViewId2ListOfVTKPrs myVTKPrsMap; + bool myIsUpdateEnabled; + + QStringList myGeomObjectsToImport; ///< entries of GEOM objects to be imported + + ViewId2StricklerTable myLandCoverColoringMap; }; #endif