mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2025-02-03 19:10:34 +05:00
- add new method for view
- edit the work of thread
This commit is contained in:
parent
ff4c9a2717
commit
2bda43c6b2
@ -72,8 +72,8 @@ SET(_link_LIBRARIES
|
||||
|
||||
SET(DependencyTree_HEADERS
|
||||
DependencyTree.h
|
||||
DependencyTree_Object.h
|
||||
DependencyTree_Arrow.h
|
||||
DependencyTree_Object.h
|
||||
)
|
||||
|
||||
# header files / to be processed by moc
|
||||
|
@ -73,7 +73,11 @@ DependencyTree::DependencyTree()
|
||||
svm->setTitle("DEPENDENCY_TREE");
|
||||
}
|
||||
else {
|
||||
svm->getActiveView()->setFocus();
|
||||
if( DependencyTree_ViewModel* viewModel = dynamic_cast<DependencyTree_ViewModel*>( svm->getViewModel() ) )
|
||||
if( DependencyTree_View* view = dynamic_cast<DependencyTree_View*>( viewModel->getActiveViewPort() ) ) {
|
||||
svm->getActiveView()->setFocus();
|
||||
view->updateModel();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -48,6 +48,7 @@ myEndItem( theEndItem )
|
||||
myStartItem = theStartItem;
|
||||
myEndItem = theEndItem;
|
||||
|
||||
myLine = QLineF( myStartItem->pos(), myEndItem->pos() );
|
||||
myArrowHead = createArrowHead( myStartItem->pos(), myEndItem->pos() );
|
||||
myReverseArrowHead = createArrowHead( myEndItem->pos(), myStartItem->pos() );
|
||||
|
||||
@ -79,8 +80,8 @@ QRectF DependencyTree_Arrow::boundingRect() const
|
||||
}
|
||||
else {
|
||||
extra = ( pen().width() + 20 ) / 2.0;
|
||||
boundingRect = QRectF( line().p1(), QSizeF( line().p2().x() - line().p1().x(),
|
||||
line().p2().y() - line().p1().y() ) );
|
||||
boundingRect = QRectF( myLine.p1(), QSizeF( myLine.p2().x() - myLine.p1().x(),
|
||||
myLine.p2().y() - myLine.p1().y() ) );
|
||||
}
|
||||
return boundingRect.normalized().adjusted( -extra, -extra, extra, extra );
|
||||
}
|
||||
@ -209,7 +210,7 @@ void DependencyTree_Arrow::paint( QPainter* painter, const QStyleOptionGraphicsI
|
||||
myArrowHead = createArrowHead( myStartItem->pos(), myEndItem->pos() );
|
||||
myReverseArrowHead = createArrowHead( myEndItem->pos(), myStartItem->pos() );
|
||||
|
||||
painter->drawLine( line() );
|
||||
painter->drawLine( myLine );
|
||||
painter->drawPolygon( myArrowHead );
|
||||
if( myIsBiLink )
|
||||
painter->drawPolygon( myReverseArrowHead );
|
||||
@ -238,21 +239,21 @@ QPolygonF DependencyTree_Arrow::createArrowHead( QPointF theStartPoint, QPointF
|
||||
break;
|
||||
p1 = p2;
|
||||
}
|
||||
setLine( QLineF( intersectPoint, theStartPoint ) );
|
||||
myLine = QLineF( intersectPoint, theStartPoint );
|
||||
}
|
||||
else
|
||||
setLine( QLineF( theEndPoint, theStartPoint ) );
|
||||
myLine = QLineF( theEndPoint, theStartPoint );
|
||||
|
||||
double angle = acos(line().dx() / line().length());
|
||||
if( line().dy() >= 0 )
|
||||
double angle = acos(myLine.dx() / myLine.length());
|
||||
if( myLine.dy() >= 0 )
|
||||
angle = ( M_PI * 2 ) - angle;
|
||||
|
||||
QPointF arrowP1 = line().p1() + QPointF( sin( angle + M_PI / 3 ) * arrowSize,
|
||||
QPointF arrowP1 = myLine.p1() + QPointF( sin( angle + M_PI / 3 ) * arrowSize,
|
||||
cos( angle + M_PI / 3 ) * arrowSize );
|
||||
QPointF arrowP2 = line().p1() + QPointF( sin( angle + M_PI - M_PI / 3 ) * arrowSize,
|
||||
QPointF arrowP2 = myLine.p1() + QPointF( sin( angle + M_PI - M_PI / 3 ) * arrowSize,
|
||||
cos( angle + M_PI - M_PI / 3 ) * arrowSize );
|
||||
|
||||
QPolygonF anArrowHead;
|
||||
anArrowHead << line().p1() << arrowP1 << arrowP2;
|
||||
anArrowHead << myLine.p1() << arrowP1 << arrowP2;
|
||||
return anArrowHead;
|
||||
}
|
||||
|
@ -67,6 +67,8 @@ private:
|
||||
|
||||
QRectF mySelfDependencyArrow;
|
||||
|
||||
QLineF myLine;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -37,8 +37,7 @@ const int itemW = 90;
|
||||
|
||||
DependencyTree_Object::DependencyTree_Object( const std::string& theEntry, QGraphicsItem* theParent )
|
||||
:GraphicsView_Object( theParent ),
|
||||
myIsMainObject( false ),
|
||||
myIsLongName( false )
|
||||
myIsMainObject( false )
|
||||
{
|
||||
SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
|
||||
|
||||
@ -61,6 +60,13 @@ myIsLongName( false )
|
||||
myTextItem->setFont( textFont );
|
||||
|
||||
myEntry = theEntry;
|
||||
|
||||
SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
|
||||
if ( !app ) return;
|
||||
SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>(app->activeStudy());
|
||||
int studyId = GeometryGUI::ClientStudyToStudy( study->studyDS())->StudyId();
|
||||
myGeomObject = GeometryGUI::GetGeomGen()->GetObject( studyId, myEntry.c_str() );
|
||||
|
||||
updateName();
|
||||
|
||||
addToGroup( myPolygonItem );
|
||||
@ -85,8 +91,7 @@ bool DependencyTree_Object::highlight( double theX, double theY )
|
||||
myPolygonItem->setBrush( color );
|
||||
myPolygonItem->setPen( getPen( color ) );
|
||||
|
||||
if( myIsLongName )
|
||||
myPolygonItem->setToolTip( getName() );
|
||||
myPolygonItem->setToolTip( getName() );
|
||||
}
|
||||
return GraphicsView_Object::highlight( theX, theY );
|
||||
}
|
||||
@ -146,29 +151,31 @@ std::string DependencyTree_Object::getEntry() const
|
||||
return myEntry;
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : getGeomObject()
|
||||
// purpose : get geometry object of current item
|
||||
//=================================================================================
|
||||
GEOM::GEOM_BaseObject_var DependencyTree_Object::getGeomObject() const
|
||||
{
|
||||
return myGeomObject;
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : updateName()
|
||||
// purpose : update name of current item using its entry
|
||||
//=================================================================================
|
||||
void DependencyTree_Object::updateName()
|
||||
{
|
||||
SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
|
||||
SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
|
||||
if ( !app ) return;
|
||||
SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>(app->activeStudy());
|
||||
SALOMEDS::Study_var aStudyDS = GeometryGUI::ClientStudyToStudy( study->studyDS());
|
||||
int StudyId = aStudyDS->StudyId();
|
||||
GEOM::_objref_GEOM_BaseObject* object = GeometryGUI::GetGeomGen()->GetObject( StudyId, myEntry.c_str() );
|
||||
|
||||
QString name = object->GetName();
|
||||
QString StudyEntry = object->GetStudyEntry();
|
||||
std::cout << "\n\n\n StudyEntry = " << StudyEntry.toStdString() << " " << StudyEntry.isEmpty() << std::endl;
|
||||
QString name = myGeomObject->GetName();
|
||||
QString studyEntry = myGeomObject->GetStudyEntry();
|
||||
|
||||
|
||||
if( StudyEntry.isEmpty() ) {
|
||||
if( studyEntry.isEmpty() ) {
|
||||
if( name.isEmpty() )
|
||||
name = "unpublished";
|
||||
myColor = resMgr->colorValue( "Geometry", "dependency_tree_background_color", QColor( 255, 255, 255 ) );
|
||||
myColor = QColor( 255, 255, 255 );
|
||||
myPolygonItem->setBrush( myColor );
|
||||
myPolygonItem->setPen( getPen( myColor ) );
|
||||
}
|
||||
|
||||
setName( name );
|
||||
@ -181,7 +188,6 @@ void DependencyTree_Object::updateName()
|
||||
double polygonHeight = myPolygonItem->sceneBoundingRect().height();
|
||||
|
||||
if( ( textWidth - 4 ) > polygonWidth ) {
|
||||
myIsLongName = true;
|
||||
int numberSymbol = int( polygonWidth * name.length() / textWidth );
|
||||
QString newName = name.left( numberSymbol - 3 ) + "...";
|
||||
myTextItem->setText( newName );
|
||||
|
@ -22,6 +22,10 @@
|
||||
|
||||
#include <GraphicsView_Object.h>
|
||||
|
||||
// GEOM includes
|
||||
#include <GeometryGUI.h>
|
||||
#include <GEOM_BaseObject.hxx>
|
||||
|
||||
#include <QPen>
|
||||
|
||||
class DependencyTree_Object: public GraphicsView_Object
|
||||
@ -32,39 +36,41 @@ public:
|
||||
DependencyTree_Object( const std::string&, QGraphicsItem* = 0 );
|
||||
~DependencyTree_Object();
|
||||
|
||||
virtual void compute() {};
|
||||
virtual void compute() {};
|
||||
|
||||
virtual bool highlight( double, double );
|
||||
virtual void unhighlight();
|
||||
virtual bool highlight( double, double );
|
||||
virtual void unhighlight();
|
||||
|
||||
virtual bool select( double, double, const QRectF& );
|
||||
virtual void unselect();
|
||||
virtual bool select( double, double, const QRectF& );
|
||||
virtual void unselect();
|
||||
|
||||
std::string getEntry() const;
|
||||
std::string getEntry() const;
|
||||
|
||||
void updateName();
|
||||
GEOM::GEOM_BaseObject_var getGeomObject() const;
|
||||
|
||||
void setColor(const QColor& );
|
||||
void setSelectColor(const QColor& );
|
||||
void setMainObjectColor(const QColor& );
|
||||
void updateName();
|
||||
|
||||
void setIsMainObject( bool );
|
||||
void setColor(const QColor& );
|
||||
void setSelectColor(const QColor& );
|
||||
void setMainObjectColor(const QColor& );
|
||||
|
||||
void setIsMainObject( bool );
|
||||
|
||||
private:
|
||||
|
||||
QPen getPen( const QColor& );
|
||||
QPen getPen( const QColor& );
|
||||
|
||||
QColor myColor;
|
||||
QColor mySelectColor;
|
||||
QColor myMainObjectColor;
|
||||
QColor myColor;
|
||||
QColor mySelectColor;
|
||||
QColor myMainObjectColor;
|
||||
|
||||
QGraphicsPolygonItem* myPolygonItem;
|
||||
QGraphicsSimpleTextItem* myTextItem;
|
||||
QGraphicsPolygonItem* myPolygonItem;
|
||||
QGraphicsSimpleTextItem* myTextItem;
|
||||
|
||||
std::string myEntry;
|
||||
GEOM::GEOM_BaseObject_var myGeomObject;
|
||||
std::string myEntry;
|
||||
|
||||
bool myIsMainObject;
|
||||
bool myIsLongName;
|
||||
bool myIsMainObject;
|
||||
|
||||
};
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -22,6 +22,9 @@
|
||||
|
||||
#include <GraphicsView_ViewPort.h>
|
||||
#include <GraphicsView_ViewFrame.h>
|
||||
#include <GraphicsView_Scene.h>
|
||||
|
||||
#include <SalomeApp_Application.h>
|
||||
|
||||
#include <GEOMUtils.hxx>
|
||||
|
||||
@ -55,6 +58,9 @@ private:
|
||||
DependencyTree_View* myView;
|
||||
};
|
||||
|
||||
typedef std::map<std::string,DependencyTree_Object*> EntryObjectMap;
|
||||
typedef std::map<std::pair<DependencyTree_Object*,DependencyTree_Object*>,DependencyTree_Arrow*> ArrowsInfo;
|
||||
|
||||
class DependencyTree_View: public GraphicsView_ViewPort
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -64,6 +70,13 @@ public:
|
||||
DependencyTree_View( QWidget* = 0 );
|
||||
~DependencyTree_View();
|
||||
|
||||
void init( GraphicsView_ViewFrame* );
|
||||
void updateModel();
|
||||
void drawTree();
|
||||
|
||||
virtual int select( const QRectF&, bool );
|
||||
void mouseMoveEvent(QMouseEvent *event);
|
||||
|
||||
void setHierarchyType( const int );
|
||||
void setNodesMovable( const bool );
|
||||
void setPrefBackgroundColor( const QColor& );
|
||||
@ -74,58 +87,48 @@ public:
|
||||
void setHighlightArrowColor( const QColor& );
|
||||
void setSelectArrowColor( const QColor& );
|
||||
|
||||
virtual int select( const QRectF&, bool );
|
||||
void setIsCompute( bool );
|
||||
bool getIsCompute();
|
||||
|
||||
// typedef QList<QString> NodeLinks;
|
||||
// typedef QMap<QString, NodeLinks> LevelInfo;
|
||||
// typedef QList<LevelInfo> LevelsList;
|
||||
// typedef QMap<QString,QPair<LevelsList,LevelsList> > TreeModel;
|
||||
protected:
|
||||
void timerEvent( QTimerEvent* );
|
||||
void closeEvent( QCloseEvent* );
|
||||
|
||||
GEOMUtils::TreeModel myTreeModel;
|
||||
std::map<std::string,DependencyTree_Object*> myTreeMap;
|
||||
std::map<std::pair<DependencyTree_Object*,DependencyTree_Object*>,DependencyTree_Arrow*> Arrows;
|
||||
|
||||
std::map<std::string,int> myLevelMap;
|
||||
|
||||
std::map< int, std::vector<std::string> > myLevelsObject;
|
||||
int myCurrentLevel;
|
||||
|
||||
void init( GraphicsView_ViewFrame* );
|
||||
|
||||
void onRedrawTree();
|
||||
|
||||
void setIsCompute( bool theIsCompute );
|
||||
bool getIsCompute() { return myIsCompute; };
|
||||
private slots:
|
||||
void onUpdateTree();
|
||||
void updateView();
|
||||
void onMoveNodes( bool );
|
||||
void onHierarchyType();
|
||||
|
||||
protected:
|
||||
void timerEvent(QTimerEvent *timer);
|
||||
void closeEvent(QCloseEvent *event);
|
||||
|
||||
private slots:
|
||||
void onCancel();
|
||||
|
||||
signals:
|
||||
|
||||
private:
|
||||
// void parseData( QString& data );
|
||||
|
||||
void addNode( const std::string& );
|
||||
void addArrow( DependencyTree_Object*, DependencyTree_Object* );
|
||||
|
||||
void parseTree();
|
||||
void parseTreeWard(const GEOMUtils::LevelsList);
|
||||
void parseTreeWardArrow(const GEOMUtils::LevelsList);
|
||||
|
||||
void addNode( const std::string& entry );
|
||||
void addArrow( DependencyTree_Object *startItem, DependencyTree_Object *endItem );
|
||||
void findArrow( DependencyTree_Object *startItem, DependencyTree_Object *endItem );
|
||||
// GEOMUtils::LevelsList parseWard( const QString& data, int& cursor );
|
||||
void drawTree();
|
||||
void drawWard( GEOMUtils::LevelsList ward, const int levelStep );
|
||||
void drawArrows();
|
||||
void drawWard( const GEOMUtils::LevelsList&, std::map< std::string, int >&,
|
||||
std::map< int, std::vector< std::string > >&, int, const int );
|
||||
void drawWardArrows( GEOMUtils::LevelsList );
|
||||
|
||||
void getNewTreeModel();
|
||||
void clearView( bool );
|
||||
|
||||
int checkMaxLevelsNumber();
|
||||
void calcTotalCost();
|
||||
double getComputeProgress();
|
||||
|
||||
void changeWidgetState( bool );
|
||||
|
||||
GEOMUtils::TreeModel myTreeModel;
|
||||
|
||||
EntryObjectMap myTreeMap;
|
||||
ArrowsInfo myArrows;
|
||||
|
||||
int myLevelsNumber;
|
||||
int myMaxDownwardLevelsNumber;
|
||||
int myMaxUpwardLevelsNumber;
|
||||
@ -134,23 +137,23 @@ private:
|
||||
QSpinBox* myHierarchyDepth;
|
||||
QCheckBox* myDisplayAscendants;
|
||||
QCheckBox* myDisplayDescendants;
|
||||
|
||||
std::string myData;
|
||||
QWidgetAction* cancelAction;
|
||||
QWidgetAction* progressAction;
|
||||
|
||||
int myTimer;
|
||||
|
||||
bool myIsUpdate;
|
||||
|
||||
GraphicsView_ViewFrame* myViewFrame;
|
||||
|
||||
bool myIsCompute;
|
||||
DependencyTree_ComputeDlg_QThread* qthread;
|
||||
QPushButton * cancelButton;
|
||||
QProgressBar* progressBar;
|
||||
QWidgetAction* cancelAction;
|
||||
QWidgetAction* progressAction;
|
||||
|
||||
//SALOMEDS::Study_var myStudy;
|
||||
int myTotalCost;
|
||||
int myComputedCost;
|
||||
|
||||
DependencyTree_ComputeDlg_QThread* qthread;
|
||||
|
||||
|
||||
SALOMEDS::Study_var myStudy;
|
||||
LightApp_SelectionMgr* mySelectionMgr;
|
||||
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user