1 // Copyright (C) 2014 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 DEPENDENCYTREE_VIEW_H
21 #define DEPENDENCYTREE_VIEW_H
24 #include <GEOMUtils.hxx>
25 #include <GeometryGUI.h>
28 #include <GraphicsView_ViewPort.h>
29 #include <GraphicsView_ViewFrame.h>
31 #include <SalomeApp_Application.h>
34 #include <QWidgetAction>
35 #include <QPushButton>
41 class DependencyTree_Object;
42 class DependencyTree_Arrow;
43 class DependencyTree_View;
45 class DependencyTree_QThread : public QThread
51 DependencyTree_QThread( DependencyTree_View* );
55 DependencyTree_View* getView() { return myView; };
61 DependencyTree_View* myView;
64 typedef std::map<std::string,DependencyTree_Object*> EntryObjectMap;
65 typedef std::map<std::pair<DependencyTree_Object*,DependencyTree_Object*>,DependencyTree_Arrow*> ArrowsInfo;
67 class DependencyTree_View: public GraphicsView_ViewPort
73 DependencyTree_View( QWidget* = 0 );
74 ~DependencyTree_View();
76 void init( GraphicsView_ViewFrame* );
77 void updateModel( bool = true, bool = true );
80 QString getViewName() const;
82 virtual void customEvent ( QEvent* );
83 void mouseMoveEvent(QMouseEvent *event);
85 DependencyTree_Object* getObjectByEntry( QString );
87 void setHierarchyType( const int );
88 void setNodesMovable( const bool );
89 void setPrefBackgroundColor( const QColor& );
90 void setNodeColor( const QColor& );
91 void setMainNodeColor( const QColor& );
92 void setSelectNodeColor( const QColor& );
93 void setArrowColor( const QColor& );
94 void setHighlightArrowColor( const QColor& );
95 void setSelectArrowColor( const QColor& );
97 void setIsCompute( bool );
100 bool updateObjectName( const std::string &theEntry );
105 void onUpdateModel();
106 void onRebuildModel();
109 void closeEvent( QCloseEvent* );
113 void onMoveNodes( bool );
114 void onHierarchyType();
121 void addNode( const std::string& );
122 void addArrow( DependencyTree_Object*, DependencyTree_Object* );
123 void addNewItem( QGraphicsItem* );
126 void parseTreeWard(const GEOMUtils::LevelsList);
127 void parseTreeWardArrow(const GEOMUtils::LevelsList);
129 void drawWard( const GEOMUtils::LevelsList&, std::map< std::string, int >&,
130 std::map< int, std::vector< std::string > >&, int, const int );
131 void drawWardArrows( GEOMUtils::LevelsList );
133 void getNewTreeModel( bool = true, bool = true );
134 void clearView( bool );
136 int checkMaxLevelsNumber();
137 void calcTotalCost();
138 double getComputeProgress();
140 void changeWidgetState( bool );
142 GEOMUtils::TreeModel myTreeModel;
144 EntryObjectMap myTreeMap;
148 int myMaxDownwardLevelsNumber;
149 int myMaxUpwardLevelsNumber;
151 QCheckBox* myNodesMovable;
152 QSpinBox* myHierarchyDepth;
153 QCheckBox* myDisplayAscendants;
154 QCheckBox* myDisplayDescendants;
155 QWidgetAction* cancelAction;
156 QWidgetAction* progressAction;
157 QPushButton* updateButton;
168 DependencyTree_QThread* qthread;
170 GEOM::string_array_var myMainEntries;
172 SALOMEDS::Study_var myStudy;
173 LightApp_SelectionMgr* mySelectionMgr;