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
23 #include <GraphicsView_ViewPort.h>
24 #include <GraphicsView_ViewFrame.h>
25 #include <GraphicsView_Scene.h>
27 #include <SalomeApp_Application.h>
29 #include <SALOME_ListIO.hxx>
31 #include <GEOMUtils.hxx>
33 #include <QWidgetAction>
34 #include <QPushButton>
37 #include <QProgressBar>
41 class DependencyTree_Object;
42 class DependencyTree_Arrow;
43 class DependencyTree_View;
45 class DependencyTree_ComputeDlg_QThread : public QThread
51 DependencyTree_ComputeDlg_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 );
80 virtual int select( const QRectF&, bool );
81 virtual void customEvent ( QEvent* );
82 void mouseMoveEvent(QMouseEvent *event);
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& );
94 void setIsCompute( bool );
97 bool updateObjectName( const std::string &theEntry );
102 void onUpdateModel( bool = true );
105 void closeEvent( QCloseEvent* );
109 void onMoveNodes( bool );
110 void onHierarchyType();
117 void addNode( const std::string& );
118 void addArrow( DependencyTree_Object*, DependencyTree_Object* );
119 void addNewItem( QGraphicsItem* );
122 void parseTreeWard(const GEOMUtils::LevelsList);
123 void parseTreeWardArrow(const GEOMUtils::LevelsList);
125 void drawWard( const GEOMUtils::LevelsList&, std::map< std::string, int >&,
126 std::map< int, std::vector< std::string > >&, int, const int );
127 void drawWardArrows( GEOMUtils::LevelsList );
129 void getNewTreeModel( bool = true );
130 void clearView( bool );
132 int checkMaxLevelsNumber();
133 void calcTotalCost();
134 double getComputeProgress();
136 void changeWidgetState( bool );
138 GEOMUtils::TreeModel myTreeModel;
140 EntryObjectMap myTreeMap;
144 int myMaxDownwardLevelsNumber;
145 int myMaxUpwardLevelsNumber;
147 QCheckBox* myNodesMovable;
148 QSpinBox* myHierarchyDepth;
149 QCheckBox* myDisplayAscendants;
150 QCheckBox* myDisplayDescendants;
151 QWidgetAction* cancelAction;
152 QWidgetAction* progressAction;
153 QPushButton* updateButton;
164 DependencyTree_ComputeDlg_QThread* qthread;
166 SALOME_ListIO myMainObjects;
168 SALOMEDS::Study_var myStudy;
169 LightApp_SelectionMgr* mySelectionMgr;