1 // Copyright (C) 2015-2021 CEA/DEN, EDF R&D, OPEN CASCADE
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #ifndef GEOMGUI_TEXTTREEWDG_H
21 #define GEOMGUI_TEXTTREEWDG_H
23 #include "GEOM_GEOMGUI.hxx"
24 #include "GEOM_Displayer.h"
29 #include <QSharedPointer>
30 #include <QTreeWidget>
32 #include <SALOMEDSClient.hxx>
37 class QTreeWidgetItem;
38 class SalomeApp_Application;
39 class SalomeApp_Study;
42 * \brief Tree view contains Dimension and Annotation text items:
43 * - text visibility in OCC viewer
46 class GEOMGUI_EXPORT GEOMGUI_TextTreeWdg : public QTreeWidget
51 enum BranchType { DimensionShape, AnnotationShape };
54 GEOMGUI_TextTreeWdg( SalomeApp_Application* app );
55 ~GEOMGUI_TextTreeWdg();
57 int getWinID() { return myWindowID; }
59 void removeBranch( const BranchType& theBranchType, const QString& theEntry,
61 int idFromItem( QTreeWidgetItem* theItem );
62 QString entryFromItem( QTreeWidgetItem* theShapeItem ) const;
63 QTreeWidgetItem* itemFromEntry( const BranchType& theBranchType, QString theEntry );
64 void setAllShapeItemsVisibility( const BranchType& theBranchType,
65 const QString& theEntry,
66 const bool theVisibility );
67 void setShapeItemVisibility( const BranchType& theBranchType,
68 const QString& theEntry,
69 QTreeWidgetItem* theWidgetItem,
70 const bool theVisibility );
71 void updateVisibility();
73 void getSelected( QMap<QString, QList<int> >& theAnnotations );
74 void setSelected( const QMap<QString, QList<int> >& theAnnotations );
76 QList<QString> getAllEntries( const BranchType& theBranchType );
78 QString getSingleSelectedObject();
82 void redisplay( QString theEntry );
86 void updateBranches( const QString& theEntry );
87 void updateDimensionBranch( const QString& theEntry );
88 void updateAnnotationBranch( const QString& theEntry );
89 void updateObjectName( const QString& theEntry );
92 void onUpdateVisibilityColumn( QString theEntry, Qtx::VisibilityState theState );
93 void onItemClicked(QTreeWidgetItem*, int );
94 void setVisibility( QTreeWidgetItem* theItem, bool visibility );
95 void showContextMenu( const QPoint& pos );
100 * \brief Common interface for working with shape dimension and annotation properties
101 * of object in a unified way irrespectively of the implementation.
106 virtual int GetNumber() = 0;
107 virtual QString GetName( const int theIndex ) = 0;
108 virtual bool GetIsVisible( const int theIndex ) = 0;
109 virtual void SetIsVisible( const int theIndex, const bool theIsVisible ) = 0;
110 virtual void Save() = 0;
114 bool setShapeItemVisibility( QSharedPointer<VisualProperty>& theProps,
115 QTreeWidgetItem* theWidgetItem,
116 const bool theVisibility );
117 QSharedPointer<VisualProperty> getVisualProperty( const BranchType& theBranchType,
118 SalomeApp_Study* theStudy,
119 const std::string& theEntry );
120 void fillBranch( const BranchType& theBranchType,
121 const QString& theEntry );
122 void updateVisibilityColumn( const BranchType& theBranchType,
124 Qtx::VisibilityState theState );
125 QTreeWidgetItem* getPropertyRootItem( const BranchType& theBranchType );
126 QHash<QString, QTreeWidgetItem*>& getObjects( const BranchType& theBranchType );
127 BranchType branchTypeFromItem( QTreeWidgetItem* theItem );
133 QIcon myInvisibleIcon;
134 QHash<QString, QTreeWidgetItem*> myDimensionObjects;
135 QHash<QString, QTreeWidgetItem*> myAnnotationObjects;
136 SalomeApp_Study* myStudy;
137 QTreeWidgetItem* myDimensionsItem;
138 QTreeWidgetItem* myAnnotationsItem;
139 GEOM_Displayer myDisplayer;
140 QMap<int, QAction*> myActions; //!< menu actions list