X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FGEOMGUI%2FGEOMGUI_TextTreeWdg.h;h=b54ef208abb9b304cbf75fae90f26dd76c77be76;hb=f9cf20ad5b28991bc130f571c79bd530d3d1ffdf;hp=4f6677c88047b0fefdf6ab3057a620fd52b23123;hpb=ec168c32f86cab8199030ec4e8e2b1cbd5e42670;p=modules%2Fgeom.git diff --git a/src/GEOMGUI/GEOMGUI_TextTreeWdg.h b/src/GEOMGUI/GEOMGUI_TextTreeWdg.h index 4f6677c88..b54ef208a 100644 --- a/src/GEOMGUI/GEOMGUI_TextTreeWdg.h +++ b/src/GEOMGUI/GEOMGUI_TextTreeWdg.h @@ -1,4 +1,4 @@ -// Copyright (C) 2015-2016 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2015-2021 CEA/DEN, EDF R&D, OPEN CASCADE // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -23,8 +23,11 @@ #include "GEOM_GEOMGUI.hxx" #include "GEOM_Displayer.h" -#include #include +#include +#include +#include +#include #include @@ -44,46 +47,97 @@ class GEOMGUI_EXPORT GEOMGUI_TextTreeWdg : public QTreeWidget { Q_OBJECT - public: +public: + enum BranchType { DimensionShape, AnnotationShape }; + +public: GEOMGUI_TextTreeWdg( SalomeApp_Application* app ); ~GEOMGUI_TextTreeWdg(); int getWinID() { return myWindowID; } - void removeBranch( const QString& theEntry, - bool force = true ); + void removeBranch( const BranchType& theBranchType, const QString& theEntry, + bool force = true ); int idFromItem( QTreeWidgetItem* theItem ); - QString entryFromItem( QTreeWidgetItem* theShapeItem ); - QTreeWidgetItem* itemFromEntry( QString theEntry ); - void setShapeDimensionsVisibility( QString theEntry, bool theVisibility ); - void setDimensionVisibility( QString theEntry, QTreeWidgetItem* theDimItem, bool theVisibility ); + QString entryFromItem( QTreeWidgetItem* theShapeItem ) const; + QTreeWidgetItem* itemFromEntry( const BranchType& theBranchType, QString theEntry ); + void setAllShapeItemsVisibility( const BranchType& theBranchType, + const QString& theEntry, + const bool theVisibility ); + void setShapeItemVisibility( const BranchType& theBranchType, + const QString& theEntry, + QTreeWidgetItem* theWidgetItem, + const bool theVisibility ); + void updateVisibility(); + + void getSelected( QMap >& theAnnotations ); + void setSelected( const QMap >& theAnnotations ); + + QList getAllEntries( const BranchType& theBranchType ); + + QString getSingleSelectedObject(); protected: void createActions(); void redisplay( QString theEntry ); - public slots: +public slots: void updateTree(); - void updateBranch( const QString& theEntry ); + void updateBranches( const QString& theEntry ); + void updateDimensionBranch( const QString& theEntry ); + void updateAnnotationBranch( const QString& theEntry ); + void updateObjectName( const QString& theEntry ); private slots: + void onUpdateVisibilityColumn( QString theEntry, Qtx::VisibilityState theState ); void onItemClicked(QTreeWidgetItem*, int ); - void updateVisibilityColumn( QString theEntry, Qtx::VisibilityState theState ); - void setVisibility( bool visibility ); + void setVisibility( QTreeWidgetItem* theItem, bool visibility ); void showContextMenu( const QPoint& pos ); - private: - - int myWindowID; - - QIcon myVisibleIcon; - QIcon myInvisibleIcon; - QHash myObjects; - SalomeApp_Study* myStudy; - QTreeWidgetItem* myDimensionsItem; - GEOM_Displayer myDisplayer; - - QMap myActions; //!< menu actions list - +public: + + /*! + * \brief Common interface for working with shape dimension and annotation properties + * of object in a unified way irrespectively of the implementation. + */ + class VisualProperty + { + public: + virtual int GetNumber() = 0; + virtual QString GetName( const int theIndex ) = 0; + virtual bool GetIsVisible( const int theIndex ) = 0; + virtual void SetIsVisible( const int theIndex, const bool theIsVisible ) = 0; + virtual void Save() = 0; + }; + +private: + bool setShapeItemVisibility( QSharedPointer& theProps, + QTreeWidgetItem* theWidgetItem, + const bool theVisibility ); + QSharedPointer getVisualProperty( const BranchType& theBranchType, + SalomeApp_Study* theStudy, + const std::string& theEntry ); + void fillBranch( const BranchType& theBranchType, + const QString& theEntry ); + void updateVisibilityColumn( const BranchType& theBranchType, + QString theEntry, + Qtx::VisibilityState theState ); + QTreeWidgetItem* getPropertyRootItem( const BranchType& theBranchType ); + QHash& getObjects( const BranchType& theBranchType ); + BranchType branchTypeFromItem( QTreeWidgetItem* theItem ); + +private: + + int myWindowID; + QIcon myVisibleIcon; + QIcon myInvisibleIcon; + QHash myDimensionObjects; + QHash myAnnotationObjects; + SalomeApp_Study* myStudy; + QTreeWidgetItem* myDimensionsItem; + QTreeWidgetItem* myAnnotationsItem; + GEOM_Displayer myDisplayer; + QMap myActions; //!< menu actions list }; + #endif