]> SALOME platform Git repositories - modules/geom.git/blob - src/DependencyTree/DependencyTree_View.h
Salome HOME
Merge remote branch 'origin/akl/22379'
[modules/geom.git] / src / DependencyTree / DependencyTree_View.h
1 // Copyright (C) 2014  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 DEPENDENCYTREE_VIEW_H
21 #define DEPENDENCYTREE_VIEW_H
22
23 // GEOM includes
24 #include <GEOMUtils.hxx>
25 #include <GeometryGUI.h>
26
27 // GUI includes
28 #include <GraphicsView_ViewPort.h>
29 #include <GraphicsView_ViewFrame.h>
30
31 #include <SalomeApp_Application.h>
32
33 // QT includes
34 #include <QPushButton>
35 #include <QSpinBox>
36 #include <QCheckBox>
37
38 class DependencyTree_Object;
39 class DependencyTree_Arrow;
40 class DependencyTree_View;
41
42 typedef std::map<std::string,DependencyTree_Object*> EntryObjectMap;
43 typedef std::map<std::pair<DependencyTree_Object*,DependencyTree_Object*>,DependencyTree_Arrow*> ArrowsInfo;
44
45 class DependencyTree_View: public GraphicsView_ViewPort
46 {
47   Q_OBJECT
48
49 public:
50
51   DependencyTree_View( QWidget* = 0 );
52   ~DependencyTree_View();
53
54   void                    init( GraphicsView_ViewFrame* );
55   void                    updateModel( bool = true, bool = true );
56
57   void                    mouseMoveEvent(QMouseEvent* event);
58   void                    wheelEvent( QWheelEvent* event );
59
60   QString                 getViewName() const;
61   int                     getStudyId() const;
62
63   DependencyTree_Object*  getObjectByEntry( const std::string& );
64
65 public slots:
66
67   void                    onRebuildModel();
68
69 private slots:
70
71   void                    onUpdateModel();
72   void                    onMoveNodes( bool );
73   void                    onHierarchyType();
74   void                    onPreferenceChanged( const QString&, const QString& );
75   void                    onRenameObject( const QString& theEntry );
76
77 private:
78
79   void                    parseTree();
80   void                    parseTreeWard( const GEOMUtils::LevelsList& );
81   void                    parseTreeWardArrow( const GEOMUtils::LevelsList& );
82
83   void                    addNode( const std::string& );
84   void                    addArrow( DependencyTree_Object*, DependencyTree_Object* );
85
86   void                    drawTree();
87   void                    drawWard( const GEOMUtils::LevelsList&, std::map< std::string, int >&,
88                                     std::map< int, std::vector< std::string > >&, int, const int );
89   void                    drawWardArrows( const GEOMUtils::LevelsList& );
90
91   void                    updateView();
92   void                    clearView( bool );
93
94   int                     checkMaxLevelsNumber();
95
96   void                    getNewTreeModel( bool = true, bool = true );
97
98   void                    setHierarchyType( const int );
99   void                    setNodesMovable( const bool );
100   void                    setPrefBackgroundColor( const QColor& );
101   void                    setNodeColor( const QColor& );
102   void                    setMainNodeColor( const QColor& );
103   void                    setUnpublishNodeColor( const QColor& );
104   void                    setSelectNodeColor( const QColor& );
105   void                    setArrowColor( const QColor& );
106   void                    setHighlightArrowColor( const QColor& );
107   void                    setSelectArrowColor( const QColor& );
108
109   GEOMUtils::TreeModel    myTreeModel;
110
111   EntryObjectMap          myTreeMap;
112   ArrowsInfo              myArrows;
113
114   int                     myLevelsNumber;
115   int                     myMaxDownwardLevelsNumber;
116   int                     myMaxUpwardLevelsNumber;
117
118   QCheckBox*              myNodesMovable;
119   QSpinBox*               myHierarchyDepth;
120   QCheckBox*              myDisplayAscendants;
121   QCheckBox*              myDisplayDescendants;
122   QPushButton*            updateButton;
123
124   SALOMEDS::Study_var     myStudy;
125   LightApp_SelectionMgr*  mySelectionMgr;
126   GEOM::string_array_var  myMainEntries;
127
128   bool                    myIsUpdate;
129
130 };
131
132 #endif