geom/src/DependencyTree/DependencyTree_View.h

164 lines
4.0 KiB
C
Raw Normal View History

2014-05-21 19:42:20 +06:00
// Copyright (C) 2014 CEA/DEN, EDF R&D, OPEN CASCADE
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#ifndef DEPENDENCYTREE_VIEW_H
#define DEPENDENCYTREE_VIEW_H
#include <GraphicsView_ViewPort.h>
#include <GraphicsView_ViewFrame.h>
#include <GraphicsView_Scene.h>
#include <SalomeApp_Application.h>
2014-05-21 19:42:20 +06:00
2014-05-23 14:09:19 +06:00
#include <GEOMUtils.hxx>
2014-05-21 19:42:20 +06:00
#include <QWidgetAction>
2014-05-23 14:09:19 +06:00
#include <QPushButton>
2014-05-21 19:42:20 +06:00
#include <QSpinBox>
#include <QCheckBox>
#include <QProgressBar>
#include <QThread>
class DependencyTree_Object;
2014-05-23 14:09:19 +06:00
class DependencyTree_Arrow;
2014-05-21 19:42:20 +06:00
class DependencyTree_View;
class DependencyTree_ComputeDlg_QThread : public QThread
{
Q_OBJECT
public:
2014-05-23 14:09:19 +06:00
DependencyTree_ComputeDlg_QThread( DependencyTree_View* );
void sleepDraw();
2014-05-23 14:09:19 +06:00
void cancel();
2014-05-21 19:42:20 +06:00
DependencyTree_View* getView() { return myView; };
protected:
void run();
private:
DependencyTree_View* myView;
};
typedef std::map<std::string,DependencyTree_Object*> EntryObjectMap;
typedef std::map<std::pair<DependencyTree_Object*,DependencyTree_Object*>,DependencyTree_Arrow*> ArrowsInfo;
2014-05-21 19:42:20 +06:00
class DependencyTree_View: public GraphicsView_ViewPort
{
2014-05-23 14:09:19 +06:00
Q_OBJECT
2014-05-21 19:42:20 +06:00
2014-05-23 14:09:19 +06:00
public:
2014-05-21 19:42:20 +06:00
2014-05-23 14:09:19 +06:00
DependencyTree_View( QWidget* = 0 );
2014-05-21 19:42:20 +06:00
~DependencyTree_View();
void init( GraphicsView_ViewFrame* );
void updateModel();
void drawTree();
virtual int select( const QRectF&, bool );
virtual void customEvent ( QEvent* );
void addItem( QGraphicsItem* );
void mouseMoveEvent(QMouseEvent *event);
2014-05-21 19:42:20 +06:00
void setHierarchyType( const int );
void setNodesMovable( const bool );
void setPrefBackgroundColor( const QColor& );
void setNodeColor( const QColor& );
void setMainNodeColor( const QColor& );
void setSelectNodeColor( const QColor& );
void setArrowColor( const QColor& );
void setHighlightArrowColor( const QColor& );
void setSelectArrowColor( const QColor& );
void setIsCompute( bool );
bool getIsCompute();
2014-05-23 17:43:01 +06:00
protected:
// void timerEvent( QTimerEvent* );
void closeEvent( QCloseEvent* );
2014-05-21 19:42:20 +06:00
private slots:
void updateView();
void onMoveNodes( bool );
void onHierarchyType();
void onCancel();
signals:
2014-05-21 19:42:20 +06:00
private:
void addNode( const std::string& );
void addArrow( DependencyTree_Object*, DependencyTree_Object* );
2014-05-23 14:09:19 +06:00
void parseTree();
void parseTreeWard(const GEOMUtils::LevelsList);
void parseTreeWardArrow(const GEOMUtils::LevelsList);
void drawWard( const GEOMUtils::LevelsList&, std::map< std::string, int >&,
std::map< int, std::vector< std::string > >&, int, const int );
2014-05-23 14:09:19 +06:00
void drawWardArrows( GEOMUtils::LevelsList );
2014-05-21 19:42:20 +06:00
void getNewTreeModel();
void clearView( bool );
2014-05-21 19:42:20 +06:00
int checkMaxLevelsNumber();
void calcTotalCost();
double getComputeProgress();
void changeWidgetState( bool );
GEOMUtils::TreeModel myTreeModel;
EntryObjectMap myTreeMap;
ArrowsInfo myArrows;
2014-05-21 19:42:20 +06:00
int myLevelsNumber;
int myMaxDownwardLevelsNumber;
int myMaxUpwardLevelsNumber;
QCheckBox* myNodesMovable;
QSpinBox* myHierarchyDepth;
QCheckBox* myDisplayAscendants;
QCheckBox* myDisplayDescendants;
QWidgetAction* cancelAction;
QWidgetAction* progressAction;
QPushButton* updateButton;
2014-05-21 19:42:20 +06:00
int myTimer;
2014-05-21 19:42:20 +06:00
bool myIsUpdate;
bool myIsCompute;
int myTotalCost;
int myComputedCost;
2014-05-21 19:42:20 +06:00
DependencyTree_ComputeDlg_QThread* qthread;
SALOMEDS::Study_var myStudy;
LightApp_SelectionMgr* mySelectionMgr;
2014-05-21 19:42:20 +06:00
2014-05-23 14:09:19 +06:00
};
2014-05-21 19:42:20 +06:00
#endif