]> SALOME platform Git repositories - modules/geom.git/blob - src/DependencyTree/DependencyTree_View.h
Salome HOME
- add possibility to rebuild dependency tree by selecting objects
[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 #include <GraphicsView_ViewPort.h>
24 #include <GraphicsView_ViewFrame.h>
25 #include <GraphicsView_Scene.h>
26
27 #include <SalomeApp_Application.h>
28
29 #include <SALOME_ListIO.hxx>
30
31 #include <GEOMUtils.hxx>
32
33 #include <QWidgetAction>
34 #include <QPushButton>
35 #include <QSpinBox>
36 #include <QCheckBox>
37 #include <QProgressBar>
38 #include <QThread>
39 #include <QMutex>
40
41 class DependencyTree_Object;
42 class DependencyTree_Arrow;
43 class DependencyTree_View;
44
45 class DependencyTree_ComputeDlg_QThread : public QThread
46 {
47   Q_OBJECT
48
49 public:
50
51   DependencyTree_ComputeDlg_QThread( DependencyTree_View* );
52   void sleepDraw();
53   void cancel();
54
55   DependencyTree_View*   getView() { return myView; };
56
57 protected:
58   void run();
59
60 private:
61   DependencyTree_View* myView;
62 };
63
64 typedef std::map<std::string,DependencyTree_Object*> EntryObjectMap;
65 typedef std::map<std::pair<DependencyTree_Object*,DependencyTree_Object*>,DependencyTree_Arrow*> ArrowsInfo;
66
67 class DependencyTree_View: public GraphicsView_ViewPort
68 {
69   Q_OBJECT
70
71 public:
72
73   DependencyTree_View( QWidget* = 0 );
74   ~DependencyTree_View();
75
76   void init( GraphicsView_ViewFrame* );
77   void updateModel( bool = true );
78   void drawTree();
79
80   virtual int select( const QRectF&, bool );
81   virtual void customEvent ( QEvent* );
82   void mouseMoveEvent(QMouseEvent *event);
83
84   void setHierarchyType( const int );
85   void setNodesMovable( const bool );
86   void setPrefBackgroundColor( const QColor& );
87   void setNodeColor( const QColor& );
88   void setMainNodeColor( const QColor& );
89   void setSelectNodeColor( const QColor& );
90   void setArrowColor( const QColor& );
91   void setHighlightArrowColor( const QColor& );
92   void setSelectArrowColor( const QColor& );
93
94   void setIsCompute( bool );
95   bool getIsCompute();
96
97
98   QMutex myMutex;
99
100 public slots:
101   void onUpdateModel( bool = true );
102
103 protected:
104   void closeEvent( QCloseEvent* );
105
106 private slots:
107   void updateView();
108   void onMoveNodes( bool );
109   void onHierarchyType();
110   void onCancel();
111
112 signals:
113
114 private:
115
116   void addNode( const std::string& );
117   void addArrow( DependencyTree_Object*, DependencyTree_Object* );
118   void addNewItem( QGraphicsItem* );
119
120   void parseTree();
121   void parseTreeWard(const GEOMUtils::LevelsList);
122   void parseTreeWardArrow(const GEOMUtils::LevelsList);
123
124   void drawWard( const GEOMUtils::LevelsList&, std::map< std::string, int >&,
125                  std::map< int, std::vector< std::string > >&, int, const int );
126   void drawWardArrows( GEOMUtils::LevelsList );
127
128   void getNewTreeModel( bool = true );
129   void clearView( bool );
130
131   int checkMaxLevelsNumber();
132   void calcTotalCost();
133   double getComputeProgress();
134
135   void changeWidgetState( bool );
136
137   GEOMUtils::TreeModel myTreeModel;
138
139   EntryObjectMap myTreeMap;
140   ArrowsInfo myArrows;
141
142   int myLevelsNumber;
143   int myMaxDownwardLevelsNumber;
144   int myMaxUpwardLevelsNumber;
145
146   QCheckBox* myNodesMovable;
147   QSpinBox* myHierarchyDepth;
148   QCheckBox* myDisplayAscendants;
149   QCheckBox* myDisplayDescendants;
150   QWidgetAction*  cancelAction;
151   QWidgetAction*  progressAction;
152   QPushButton* updateButton;
153
154   int myTimer;
155
156   bool myIsUpdate;
157
158   bool myIsCompute;
159
160   int myTotalCost;
161   int myComputedCost;
162
163   DependencyTree_ComputeDlg_QThread* qthread;
164
165   SALOME_ListIO myMainObjects;
166
167   SALOMEDS::Study_var myStudy;
168   LightApp_SelectionMgr* mySelectionMgr;
169
170
171 };
172
173 #endif