Salome HOME
689a21a67d5bef2e55c510766022354ae807dd0b
[modules/geom.git] / src / GEOMGUI / GEOMGUI_TextTreeWdg.h
1 // Copyright (C) 2015  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
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.
7 //
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.
12 //
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
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #ifndef GEOMGUI_TEXTTREEWDG_H
21 #define GEOMGUI_TEXTTREEWDG_H
22
23 #include "GEOM_GEOMGUI.hxx"
24 #include "GEOM_Displayer.h"
25
26 #include <QTreeWidget>
27 #include <QHash>
28
29 #include <SALOMEDSClient.hxx>
30
31 class QLabel;
32 class QLineEdit;
33 class QString;
34 class QTreeWidgetItem;
35 class SalomeApp_Application;
36 class SalomeApp_Study;
37
38 /*!
39  * \brief Tree view contains Dimension and Annotation text items:
40  *  - text visibility in OCC viewer
41  *  - text object name
42  */
43 class GEOMGUI_EXPORT GEOMGUI_TextTreeWdg : public QTreeWidget
44 {
45   Q_OBJECT
46
47  public:
48   GEOMGUI_TextTreeWdg( SalomeApp_Application* app );
49   ~GEOMGUI_TextTreeWdg();
50
51   int getWinID() { return myWindowID; }
52
53   void                          removeBranch( const QString& theEntry, 
54                                               bool force = true );
55   int                           idFromItem( QTreeWidgetItem* theItem );
56   QString                       entryFromItem( QTreeWidgetItem* theShapeItem );
57   QTreeWidgetItem*              itemFromEntry( QString theEntry );
58   void                          setShapeDimensionsVisibility( QString theEntry, bool theVisibility );
59   void                          setDimensionVisibility( QString theEntry, QTreeWidgetItem* theDimItem, bool theVisibility );
60
61 protected:
62   void                          createActions();
63   void                          redisplay( QString theEntry );
64
65  public slots:
66   void                          updateTree();
67   void                          updateBranch( const QString& theEntry );
68
69 private slots:
70   void                          onItemClicked(QTreeWidgetItem*, int );
71   void                          updateVisibilityColumn( QString theEntry, Qtx::VisibilityState theState );
72   void                          setVisibility( bool visibility );
73   void                          showContextMenu( const QPoint& pos );
74
75  private:
76
77   int                           myWindowID;
78
79   QIcon                         myVisibleIcon;
80   QIcon                         myInvisibleIcon;
81   QHash<QString, QTreeWidgetItem*> myObjects;
82   SalomeApp_Study*              myStudy;
83   QTreeWidgetItem*              myDimensionsItem;
84   GEOM_Displayer                myDisplayer;
85
86   QMap<int, QAction*>           myActions;   //!< menu actions list
87
88 };
89 #endif