mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2025-02-04 00:40: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
|
SET(DependencyTree_HEADERS
|
||||||
DependencyTree.h
|
DependencyTree.h
|
||||||
DependencyTree_Object.h
|
|
||||||
DependencyTree_Arrow.h
|
DependencyTree_Arrow.h
|
||||||
|
DependencyTree_Object.h
|
||||||
)
|
)
|
||||||
|
|
||||||
# header files / to be processed by moc
|
# header files / to be processed by moc
|
||||||
|
@ -73,7 +73,11 @@ DependencyTree::DependencyTree()
|
|||||||
svm->setTitle("DEPENDENCY_TREE");
|
svm->setTitle("DEPENDENCY_TREE");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
if( DependencyTree_ViewModel* viewModel = dynamic_cast<DependencyTree_ViewModel*>( svm->getViewModel() ) )
|
||||||
|
if( DependencyTree_View* view = dynamic_cast<DependencyTree_View*>( viewModel->getActiveViewPort() ) ) {
|
||||||
svm->getActiveView()->setFocus();
|
svm->getActiveView()->setFocus();
|
||||||
|
view->updateModel();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -48,6 +48,7 @@ myEndItem( theEndItem )
|
|||||||
myStartItem = theStartItem;
|
myStartItem = theStartItem;
|
||||||
myEndItem = theEndItem;
|
myEndItem = theEndItem;
|
||||||
|
|
||||||
|
myLine = QLineF( myStartItem->pos(), myEndItem->pos() );
|
||||||
myArrowHead = createArrowHead( myStartItem->pos(), myEndItem->pos() );
|
myArrowHead = createArrowHead( myStartItem->pos(), myEndItem->pos() );
|
||||||
myReverseArrowHead = createArrowHead( myEndItem->pos(), myStartItem->pos() );
|
myReverseArrowHead = createArrowHead( myEndItem->pos(), myStartItem->pos() );
|
||||||
|
|
||||||
@ -79,8 +80,8 @@ QRectF DependencyTree_Arrow::boundingRect() const
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
extra = ( pen().width() + 20 ) / 2.0;
|
extra = ( pen().width() + 20 ) / 2.0;
|
||||||
boundingRect = QRectF( line().p1(), QSizeF( line().p2().x() - line().p1().x(),
|
boundingRect = QRectF( myLine.p1(), QSizeF( myLine.p2().x() - myLine.p1().x(),
|
||||||
line().p2().y() - line().p1().y() ) );
|
myLine.p2().y() - myLine.p1().y() ) );
|
||||||
}
|
}
|
||||||
return boundingRect.normalized().adjusted( -extra, -extra, extra, extra );
|
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() );
|
myArrowHead = createArrowHead( myStartItem->pos(), myEndItem->pos() );
|
||||||
myReverseArrowHead = createArrowHead( myEndItem->pos(), myStartItem->pos() );
|
myReverseArrowHead = createArrowHead( myEndItem->pos(), myStartItem->pos() );
|
||||||
|
|
||||||
painter->drawLine( line() );
|
painter->drawLine( myLine );
|
||||||
painter->drawPolygon( myArrowHead );
|
painter->drawPolygon( myArrowHead );
|
||||||
if( myIsBiLink )
|
if( myIsBiLink )
|
||||||
painter->drawPolygon( myReverseArrowHead );
|
painter->drawPolygon( myReverseArrowHead );
|
||||||
@ -238,21 +239,21 @@ QPolygonF DependencyTree_Arrow::createArrowHead( QPointF theStartPoint, QPointF
|
|||||||
break;
|
break;
|
||||||
p1 = p2;
|
p1 = p2;
|
||||||
}
|
}
|
||||||
setLine( QLineF( intersectPoint, theStartPoint ) );
|
myLine = QLineF( intersectPoint, theStartPoint );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
setLine( QLineF( theEndPoint, theStartPoint ) );
|
myLine = QLineF( theEndPoint, theStartPoint );
|
||||||
|
|
||||||
double angle = acos(line().dx() / line().length());
|
double angle = acos(myLine.dx() / myLine.length());
|
||||||
if( line().dy() >= 0 )
|
if( myLine.dy() >= 0 )
|
||||||
angle = ( M_PI * 2 ) - angle;
|
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 );
|
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 );
|
cos( angle + M_PI - M_PI / 3 ) * arrowSize );
|
||||||
|
|
||||||
QPolygonF anArrowHead;
|
QPolygonF anArrowHead;
|
||||||
anArrowHead << line().p1() << arrowP1 << arrowP2;
|
anArrowHead << myLine.p1() << arrowP1 << arrowP2;
|
||||||
return anArrowHead;
|
return anArrowHead;
|
||||||
}
|
}
|
||||||
|
@ -67,6 +67,8 @@ private:
|
|||||||
|
|
||||||
QRectF mySelfDependencyArrow;
|
QRectF mySelfDependencyArrow;
|
||||||
|
|
||||||
|
QLineF myLine;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -37,8 +37,7 @@ const int itemW = 90;
|
|||||||
|
|
||||||
DependencyTree_Object::DependencyTree_Object( const std::string& theEntry, QGraphicsItem* theParent )
|
DependencyTree_Object::DependencyTree_Object( const std::string& theEntry, QGraphicsItem* theParent )
|
||||||
:GraphicsView_Object( theParent ),
|
:GraphicsView_Object( theParent ),
|
||||||
myIsMainObject( false ),
|
myIsMainObject( false )
|
||||||
myIsLongName( false )
|
|
||||||
{
|
{
|
||||||
SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
|
SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
|
||||||
|
|
||||||
@ -61,6 +60,13 @@ myIsLongName( false )
|
|||||||
myTextItem->setFont( textFont );
|
myTextItem->setFont( textFont );
|
||||||
|
|
||||||
myEntry = theEntry;
|
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();
|
updateName();
|
||||||
|
|
||||||
addToGroup( myPolygonItem );
|
addToGroup( myPolygonItem );
|
||||||
@ -85,7 +91,6 @@ bool DependencyTree_Object::highlight( double theX, double theY )
|
|||||||
myPolygonItem->setBrush( color );
|
myPolygonItem->setBrush( color );
|
||||||
myPolygonItem->setPen( getPen( color ) );
|
myPolygonItem->setPen( getPen( color ) );
|
||||||
|
|
||||||
if( myIsLongName )
|
|
||||||
myPolygonItem->setToolTip( getName() );
|
myPolygonItem->setToolTip( getName() );
|
||||||
}
|
}
|
||||||
return GraphicsView_Object::highlight( theX, theY );
|
return GraphicsView_Object::highlight( theX, theY );
|
||||||
@ -146,29 +151,31 @@ std::string DependencyTree_Object::getEntry() const
|
|||||||
return myEntry;
|
return myEntry;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//=================================================================================
|
||||||
|
// function : getGeomObject()
|
||||||
|
// purpose : get geometry object of current item
|
||||||
|
//=================================================================================
|
||||||
|
GEOM::GEOM_BaseObject_var DependencyTree_Object::getGeomObject() const
|
||||||
|
{
|
||||||
|
return myGeomObject;
|
||||||
|
}
|
||||||
|
|
||||||
//=================================================================================
|
//=================================================================================
|
||||||
// function : updateName()
|
// function : updateName()
|
||||||
// purpose : update name of current item using its entry
|
// purpose : update name of current item using its entry
|
||||||
//=================================================================================
|
//=================================================================================
|
||||||
void DependencyTree_Object::updateName()
|
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 name = myGeomObject->GetName();
|
||||||
QString StudyEntry = object->GetStudyEntry();
|
QString studyEntry = myGeomObject->GetStudyEntry();
|
||||||
std::cout << "\n\n\n StudyEntry = " << StudyEntry.toStdString() << " " << StudyEntry.isEmpty() << std::endl;
|
|
||||||
|
|
||||||
|
if( studyEntry.isEmpty() ) {
|
||||||
if( StudyEntry.isEmpty() ) {
|
|
||||||
if( name.isEmpty() )
|
if( name.isEmpty() )
|
||||||
name = "unpublished";
|
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 );
|
setName( name );
|
||||||
@ -181,7 +188,6 @@ void DependencyTree_Object::updateName()
|
|||||||
double polygonHeight = myPolygonItem->sceneBoundingRect().height();
|
double polygonHeight = myPolygonItem->sceneBoundingRect().height();
|
||||||
|
|
||||||
if( ( textWidth - 4 ) > polygonWidth ) {
|
if( ( textWidth - 4 ) > polygonWidth ) {
|
||||||
myIsLongName = true;
|
|
||||||
int numberSymbol = int( polygonWidth * name.length() / textWidth );
|
int numberSymbol = int( polygonWidth * name.length() / textWidth );
|
||||||
QString newName = name.left( numberSymbol - 3 ) + "...";
|
QString newName = name.left( numberSymbol - 3 ) + "...";
|
||||||
myTextItem->setText( newName );
|
myTextItem->setText( newName );
|
||||||
|
@ -22,6 +22,10 @@
|
|||||||
|
|
||||||
#include <GraphicsView_Object.h>
|
#include <GraphicsView_Object.h>
|
||||||
|
|
||||||
|
// GEOM includes
|
||||||
|
#include <GeometryGUI.h>
|
||||||
|
#include <GEOM_BaseObject.hxx>
|
||||||
|
|
||||||
#include <QPen>
|
#include <QPen>
|
||||||
|
|
||||||
class DependencyTree_Object: public GraphicsView_Object
|
class DependencyTree_Object: public GraphicsView_Object
|
||||||
@ -42,6 +46,8 @@ public:
|
|||||||
|
|
||||||
std::string getEntry() const;
|
std::string getEntry() const;
|
||||||
|
|
||||||
|
GEOM::GEOM_BaseObject_var getGeomObject() const;
|
||||||
|
|
||||||
void updateName();
|
void updateName();
|
||||||
|
|
||||||
void setColor(const QColor& );
|
void setColor(const QColor& );
|
||||||
@ -61,10 +67,10 @@ private:
|
|||||||
QGraphicsPolygonItem* myPolygonItem;
|
QGraphicsPolygonItem* myPolygonItem;
|
||||||
QGraphicsSimpleTextItem* myTextItem;
|
QGraphicsSimpleTextItem* myTextItem;
|
||||||
|
|
||||||
|
GEOM::GEOM_BaseObject_var myGeomObject;
|
||||||
std::string myEntry;
|
std::string myEntry;
|
||||||
|
|
||||||
bool myIsMainObject;
|
bool myIsMainObject;
|
||||||
bool myIsLongName;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -22,6 +22,9 @@
|
|||||||
|
|
||||||
#include <GraphicsView_ViewPort.h>
|
#include <GraphicsView_ViewPort.h>
|
||||||
#include <GraphicsView_ViewFrame.h>
|
#include <GraphicsView_ViewFrame.h>
|
||||||
|
#include <GraphicsView_Scene.h>
|
||||||
|
|
||||||
|
#include <SalomeApp_Application.h>
|
||||||
|
|
||||||
#include <GEOMUtils.hxx>
|
#include <GEOMUtils.hxx>
|
||||||
|
|
||||||
@ -55,6 +58,9 @@ private:
|
|||||||
DependencyTree_View* myView;
|
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
|
class DependencyTree_View: public GraphicsView_ViewPort
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -64,6 +70,13 @@ public:
|
|||||||
DependencyTree_View( QWidget* = 0 );
|
DependencyTree_View( QWidget* = 0 );
|
||||||
~DependencyTree_View();
|
~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 setHierarchyType( const int );
|
||||||
void setNodesMovable( const bool );
|
void setNodesMovable( const bool );
|
||||||
void setPrefBackgroundColor( const QColor& );
|
void setPrefBackgroundColor( const QColor& );
|
||||||
@ -74,58 +87,48 @@ public:
|
|||||||
void setHighlightArrowColor( const QColor& );
|
void setHighlightArrowColor( const QColor& );
|
||||||
void setSelectArrowColor( const QColor& );
|
void setSelectArrowColor( const QColor& );
|
||||||
|
|
||||||
virtual int select( const QRectF&, bool );
|
void setIsCompute( bool );
|
||||||
|
bool getIsCompute();
|
||||||
|
|
||||||
// typedef QList<QString> NodeLinks;
|
protected:
|
||||||
// typedef QMap<QString, NodeLinks> LevelInfo;
|
void timerEvent( QTimerEvent* );
|
||||||
// typedef QList<LevelInfo> LevelsList;
|
void closeEvent( QCloseEvent* );
|
||||||
// typedef QMap<QString,QPair<LevelsList,LevelsList> > TreeModel;
|
|
||||||
|
|
||||||
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:
|
private slots:
|
||||||
void onUpdateTree();
|
|
||||||
void updateView();
|
void updateView();
|
||||||
void onMoveNodes( bool );
|
void onMoveNodes( bool );
|
||||||
void onHierarchyType();
|
void onHierarchyType();
|
||||||
|
|
||||||
protected:
|
|
||||||
void timerEvent(QTimerEvent *timer);
|
|
||||||
void closeEvent(QCloseEvent *event);
|
|
||||||
|
|
||||||
private slots:
|
|
||||||
void onCancel();
|
void onCancel();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// void parseData( QString& data );
|
|
||||||
|
void addNode( const std::string& );
|
||||||
|
void addArrow( DependencyTree_Object*, DependencyTree_Object* );
|
||||||
|
|
||||||
void parseTree();
|
void parseTree();
|
||||||
void parseTreeWard(const GEOMUtils::LevelsList);
|
void parseTreeWard(const GEOMUtils::LevelsList);
|
||||||
void parseTreeWardArrow(const GEOMUtils::LevelsList);
|
void parseTreeWardArrow(const GEOMUtils::LevelsList);
|
||||||
|
|
||||||
void addNode( const std::string& entry );
|
void drawWard( const GEOMUtils::LevelsList&, std::map< std::string, int >&,
|
||||||
void addArrow( DependencyTree_Object *startItem, DependencyTree_Object *endItem );
|
std::map< int, std::vector< std::string > >&, int, const int );
|
||||||
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 drawWardArrows( GEOMUtils::LevelsList );
|
void drawWardArrows( GEOMUtils::LevelsList );
|
||||||
|
|
||||||
|
void getNewTreeModel();
|
||||||
|
void clearView( bool );
|
||||||
|
|
||||||
int checkMaxLevelsNumber();
|
int checkMaxLevelsNumber();
|
||||||
|
void calcTotalCost();
|
||||||
|
double getComputeProgress();
|
||||||
|
|
||||||
|
void changeWidgetState( bool );
|
||||||
|
|
||||||
|
GEOMUtils::TreeModel myTreeModel;
|
||||||
|
|
||||||
|
EntryObjectMap myTreeMap;
|
||||||
|
ArrowsInfo myArrows;
|
||||||
|
|
||||||
int myLevelsNumber;
|
int myLevelsNumber;
|
||||||
int myMaxDownwardLevelsNumber;
|
int myMaxDownwardLevelsNumber;
|
||||||
int myMaxUpwardLevelsNumber;
|
int myMaxUpwardLevelsNumber;
|
||||||
@ -134,23 +137,23 @@ private:
|
|||||||
QSpinBox* myHierarchyDepth;
|
QSpinBox* myHierarchyDepth;
|
||||||
QCheckBox* myDisplayAscendants;
|
QCheckBox* myDisplayAscendants;
|
||||||
QCheckBox* myDisplayDescendants;
|
QCheckBox* myDisplayDescendants;
|
||||||
|
QWidgetAction* cancelAction;
|
||||||
std::string myData;
|
QWidgetAction* progressAction;
|
||||||
|
|
||||||
int myTimer;
|
int myTimer;
|
||||||
|
|
||||||
bool myIsUpdate;
|
bool myIsUpdate;
|
||||||
|
|
||||||
GraphicsView_ViewFrame* myViewFrame;
|
|
||||||
|
|
||||||
bool myIsCompute;
|
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