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>
26 #include <GEOMUtils.hxx>
28 #include <QWidgetAction>
29 #include <QPushButton>
32 #include <QProgressBar>
35 class DependencyTree_Object;
36 class DependencyTree_Arrow;
37 class DependencyTree_View;
39 class DependencyTree_ComputeDlg_QThread : public QThread
45 DependencyTree_ComputeDlg_QThread( DependencyTree_View* );
49 DependencyTree_View* getView() { return myView; };
55 DependencyTree_View* myView;
58 class DependencyTree_View: public GraphicsView_ViewPort
64 DependencyTree_View( QWidget* = 0 );
65 ~DependencyTree_View();
67 void setHierarchyType( const int );
68 void setNodesMovable( const bool );
69 void setPrefBackgroundColor( const QColor& );
70 void setNodeColor( const QColor& );
71 void setMainNodeColor( const QColor& );
72 void setSelectNodeColor( const QColor& );
73 void setArrowColor( const QColor& );
74 void setHighlightArrowColor( const QColor& );
75 void setSelectArrowColor( const QColor& );
77 virtual int select( const QRectF&, bool );
79 // typedef QList<QString> NodeLinks;
80 // typedef QMap<QString, NodeLinks> LevelInfo;
81 // typedef QList<LevelInfo> LevelsList;
82 // typedef QMap<QString,QPair<LevelsList,LevelsList> > TreeModel;
84 GEOMUtils::TreeModel myTreeModel;
85 std::map<std::string,DependencyTree_Object*> myTreeMap;
86 std::map<std::pair<DependencyTree_Object*,DependencyTree_Object*>,DependencyTree_Arrow*> Arrows;
88 std::map<std::string,int> myLevelMap;
90 std::map< int, std::vector<std::string> > myLevelsObject;
93 void init( GraphicsView_ViewFrame* );
97 void setIsCompute( bool theIsCompute );
98 bool getIsCompute() { return myIsCompute; };
102 void onMoveNodes( bool );
103 void onHierarchyType();
106 void timerEvent(QTimerEvent *timer);
107 void closeEvent(QCloseEvent *event);
113 // void parseData( QString& data );
116 void parseTreeWard(const GEOMUtils::LevelsList);
117 void parseTreeWardArrow(const GEOMUtils::LevelsList);
119 void addNode( const std::string& entry );
120 void addArrow( DependencyTree_Object *startItem, DependencyTree_Object *endItem );
121 void findArrow( DependencyTree_Object *startItem, DependencyTree_Object *endItem );
122 // GEOMUtils::LevelsList parseWard( const QString& data, int& cursor );
124 void drawWard( GEOMUtils::LevelsList ward, const int levelStep );
126 void drawWardArrows( GEOMUtils::LevelsList );
128 int checkMaxLevelsNumber();
130 int myMaxDownwardLevelsNumber;
131 int myMaxUpwardLevelsNumber;
133 QCheckBox* myNodesMovable;
134 QSpinBox* myHierarchyDepth;
135 QCheckBox* myDisplayAscendants;
136 QCheckBox* myDisplayDescendants;
144 GraphicsView_ViewFrame* myViewFrame;
147 DependencyTree_ComputeDlg_QThread* qthread;
148 QPushButton * cancelButton;
149 QProgressBar* progressBar;
150 QWidgetAction* cancelAction;
151 QWidgetAction* progressAction;
153 //SALOMEDS::Study_var myStudy;