From: mpa Date: Fri, 23 May 2014 08:09:19 +0000 (+0400) Subject: Correction of GUI part X-Git-Tag: V7_5_0a1~50^2~40 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=a782d52dec860bd9d13f65ccfdad6def082bb92c;p=modules%2Fgeom.git Correction of GUI part --- diff --git a/src/DependencyTree/CMakeLists.txt b/src/DependencyTree/CMakeLists.txt index 9a1fb4398..30d86cbad 100644 --- a/src/DependencyTree/CMakeLists.txt +++ b/src/DependencyTree/CMakeLists.txt @@ -32,7 +32,8 @@ INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_BINARY_DIR} ${PROJECT_SOURCE_DIR}/src/GEOMGUI ${PROJECT_SOURCE_DIR}/src/GEOMBase - ${PROJECT_SOURCE_DIR}/src/GEOM + ${PROJECT_SOURCE_DIR}/src/GEOM + ${PROJECT_SOURCE_DIR}/src/GEOMUtils ${PROJECT_BINARY_DIR}/idl @@ -64,6 +65,7 @@ SET(_link_LIBRARIES ${GUI_GraphicsView} ${GUI_SalomeObject} GEOMUtils + ${KERNEL_SalomeDS} ) # --- headers --- diff --git a/src/DependencyTree/DependencyTree_Arrow.h b/src/DependencyTree/DependencyTree_Arrow.h index abf227540..1518c72ea 100644 --- a/src/DependencyTree/DependencyTree_Arrow.h +++ b/src/DependencyTree/DependencyTree_Arrow.h @@ -26,6 +26,7 @@ class DependencyTree_Object; class DependencyTree_Arrow : public QGraphicsLineItem { + public: DependencyTree_Arrow( DependencyTree_Object* startItem, DependencyTree_Object* endItem, diff --git a/src/DependencyTree/DependencyTree_Object.cxx b/src/DependencyTree/DependencyTree_Object.cxx index ab0c2c1fa..0f85a0405 100644 --- a/src/DependencyTree/DependencyTree_Object.cxx +++ b/src/DependencyTree/DependencyTree_Object.cxx @@ -19,9 +19,15 @@ #include "DependencyTree_Object.h" +// GEOM includes +#include +#include + // GUI includes #include #include +#include +#include // Qt includes #include @@ -29,7 +35,7 @@ const int itemH = 20; const int itemW = 90; -DependencyTree_Object::DependencyTree_Object( const QString& theEntry, QGraphicsItem* theParent ) +DependencyTree_Object::DependencyTree_Object( const std::string& theEntry, QGraphicsItem* theParent ) :GraphicsView_Object( theParent ), myIsMainObject( false ), myIsLongName( false ) @@ -135,7 +141,7 @@ void DependencyTree_Object::unselect() // function : getEntry() // purpose : get entry of current item //================================================================================= -QString DependencyTree_Object::getEntry() const +std::string DependencyTree_Object::getEntry() const { return myEntry; } @@ -146,9 +152,18 @@ QString DependencyTree_Object::getEntry() const //================================================================================= void DependencyTree_Object::updateName() { - QString name = myEntry; + SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() ); + if ( !app ) return; + SalomeApp_Study* study = dynamic_cast(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 = myEntry.c_str(); - setName( myEntry ); + setName( name ); myTextItem->setText( name ); double textWidth = myTextItem->sceneBoundingRect().width(); diff --git a/src/DependencyTree/DependencyTree_Object.h b/src/DependencyTree/DependencyTree_Object.h index 4f4eaf147..da04b6901 100644 --- a/src/DependencyTree/DependencyTree_Object.h +++ b/src/DependencyTree/DependencyTree_Object.h @@ -28,7 +28,8 @@ class DependencyTree_Object: public GraphicsView_Object { public: - DependencyTree_Object( const QString&, QGraphicsItem* = 0 ); + + DependencyTree_Object( const std::string&, QGraphicsItem* = 0 ); ~DependencyTree_Object(); virtual void compute() {}; @@ -39,7 +40,7 @@ public: virtual bool select( double, double, const QRectF& ); virtual void unselect(); - QString getEntry() const; + std::string getEntry() const; void updateName(); @@ -60,7 +61,7 @@ private: QGraphicsPolygonItem* myPolygonItem; QGraphicsSimpleTextItem* myTextItem; - QString myEntry; + std::string myEntry; bool myIsMainObject; bool myIsLongName; diff --git a/src/DependencyTree/DependencyTree_View.cxx b/src/DependencyTree/DependencyTree_View.cxx index 82efb1ef2..198a50bc6 100644 --- a/src/DependencyTree/DependencyTree_View.cxx +++ b/src/DependencyTree/DependencyTree_View.cxx @@ -17,52 +17,30 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -#include -#include -#include - - #include "DependencyTree_View.h" #include "DependencyTree_Object.h" #include "DependencyTree_Arrow.h" - -#include -#include -#include - -#include -#include - -#include - -#include -#include -#include -#include -#include -#include - -#include +#include +#include +#include // GUI includes #include #include - -#include - #include #include +#include #include #include -#include -#include -#include -#include "GEOMUtils.hxx" - +// Qt includes +#include +#include +#include +#include int iter = 0; DependencyTree_View::DependencyTree_View( QWidget* theParent ) @@ -77,16 +55,11 @@ myIsUpdate( true ) if ( !app ) return; SalomeApp_Study* study = dynamic_cast(app->activeStudy()); - - _PTR(Study) aStudy = study->studyDS(); - if ( !aStudy ) - return; - - SALOMEDS::Study_var aStudyDS = GeometryGUI::ClientStudyToStudy(aStudy); + SALOMEDS::Study_var myStudy = GeometryGUI::ClientStudyToStudy( study->studyDS()); LightApp_SelectionMgr* aSelMgr = app->selectionMgr(); if ( !aSelMgr ) return; - + SALOME_ListIO aSelList; aSelMgr->selectedObjects(aSelList); @@ -96,57 +69,26 @@ myIsUpdate( true ) for ( SALOME_ListIteratorOfListIO It( aSelList ); It.More(); It.Next() ) { Handle( SALOME_InteractiveObject ) io = It.Value(); -// if ( io->IsKind(STANDARD_TYPE(GEOM_InteractiveObject))) { -// Handle(GEOM_InteractiveObject) objectGEOM = Handle(GEOM_InteractiveObject)::DownCast( io ); -// const char* ior = objectGEOM->getIOR(); -// objectGEOM.getEntry(); -// objectGEOM.getName(); -// std::cout << "\n\n\n !!!!! IOR = " << ior << std::endl; -// } GEOM::GEOM_Object_var myObject = GEOM::GEOM_Object::_nil(); myObject = GEOMBase::ConvertIOinGEOMObject( io ); - //QString ior = GEOMBase::GetIORFromObject(myObject); QString ior = myObject->GetEntry(); ObjectIORs[aaa] = ior.toLatin1().constData(); aaa++; std::cout << "\n\n IOR = " << ior.toStdString() << std::endl; -// if ( !CORBA::is_nil( myObject ) ) -// myGrp->LineEdit1->setText( GEOMBase::GetName( myObject ) ); } -// -// SALOME_ListIO selected; -// aSelMgr->selectedObjects( selected ); -// if ( selected.IsEmpty() ) return; -// -// GEOM::string_array ObjectIORs; -// ObjectIORs.lenght( selected.Extent()) -// for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) { -// Handle( SALOME_InteractiveObject ) io = It.Value(); -// const char* entry = io->getEntry(); -// ObjectIORs.push_back( entry ); -// //CORBA::String_var IOR = app->orb()->object_to_string( io ); -// //if ( strcmp(IOR.in(), "") != 0 ) -// //{ -//// QString objIOR = GEOMBase::GetIORFromObject( io ); -// //char* GetStringFromIOR(GEOM::GEOM_Object_ptr theObject) -// -// } - // get dependencies tree as a stream SALOMEDS::TMPFile_var SeqFile = - GeometryGUI::GetGeomGen()->GetDependencyTree( aStudyDS, ObjectIORs ); - // convert stream into string - char* treeStr; - treeStr = (char*) &SeqFile[0]; + GeometryGUI::GetGeomGen()->GetDependencyTree( myStudy, ObjectIORs ); + char* buf; + buf = (char*) &SeqFile[0]; - std::cout << "\n TREE = " << treeStr << std::endl; + std::cout << "\n\n\n\n\n TREE = " << buf << std::endl; + + GEOMUtils::ConvertStringToTree( buf, myTreeModel ); - // parse string to deal with 'TreeModel' object - GEOMUtils::TreeModel tree; - GEOMUtils::ConvertStringToTree( treeStr, tree ); } DependencyTree_View::~DependencyTree_View() @@ -156,74 +98,133 @@ DependencyTree_View::~DependencyTree_View() void DependencyTree_View::drawArrows() { - QMap >::iterator i; + GEOMUtils::TreeModel::const_iterator i; for (i = myTreeModel.begin(); i != myTreeModel.end(); i++ ) { - DependencyTree_Object* Main_object = myTreeMap[i.key()]; - LevelInfo Levelup = i.value().first.at(0); + DependencyTree_Object* Main_object = myTreeMap[i->first]; + GEOMUtils::LevelInfo Levelup = i->second.first.at(0); if( myDisplayAscendants ->isChecked() ) { - QMap::iterator node; + GEOMUtils::LevelInfo::const_iterator node; for (node = Levelup.begin(); node != Levelup.end(); node++ ) { - DependencyTree_Object* object = myTreeMap[node.key()]; - addArrow(Main_object, object); + DependencyTree_Object* object = myTreeMap[node->first]; + DependencyTree_Arrow* arrow = Arrows[std::pair(Main_object, object)]; + if( arrow && !isItemAdded( arrow) ) + addItem( arrow ); } } if( myDisplayAscendants ->isChecked() ) - drawWardArrows( i.value().first ); + drawWardArrows( i->second.first ); if( myDisplayDescendants->isChecked() ) - drawWardArrows( i.value().second ); + drawWardArrows( i->second.second ); } } -void DependencyTree_View::drawWardArrows( LevelsList theWard ) +void DependencyTree_View::drawWardArrows( GEOMUtils::LevelsList theWard ) { for(int j = 0; j < theWard.size(); j++ ) { if( j >= myLevelsNumber ) break; - LevelInfo Level = theWard.at(j); - QMap::iterator node; + GEOMUtils::LevelInfo Level = theWard.at(j); + GEOMUtils::LevelInfo::const_iterator node; for (node = Level.begin(); node != Level.end(); node++ ) { - DependencyTree_Object* object = myTreeMap[node.key()]; - QList Links = node.value(); + DependencyTree_Object* object = myTreeMap[node->first]; + GEOMUtils::NodeLinks Links = node->second; for( int link = 0; link < Links.size(); link++ ) { DependencyTree_Object* LinkObject = myTreeMap[Links[link]]; if( isItemAdded( object ) && isItemAdded( LinkObject ) ) { - addArrow(object, LinkObject); - } + DependencyTree_Arrow* arrow = Arrows[std::pair(object, LinkObject)]; + if( arrow && !isItemAdded( arrow) ) + addItem( arrow ); + } } } } } - -void DependencyTree_View::parseData( QString& theData ) +void DependencyTree_View::parseTree() { - int cursor = 0; - while( theData.indexOf('-',cursor) != -1 ) //find next selected object - { - int objectIndex = theData.indexOf( '-', cursor ); - QString objectEntry = theData.mid( cursor, objectIndex - cursor ); - addNode( objectEntry ); - std::cout<<"\n\nMainObject = " << objectEntry.toStdString() <first; + addNode( objectEntry ); + parseTreeWard( i->second.first ); + if( i->second.first.size() > myMaxUpwardLevelsNumber ) + myMaxUpwardLevelsNumber = i->second.first.size(); + parseTreeWard( i->second.second ); + if( i->second.second.size() > myMaxDownwardLevelsNumber ) + myMaxDownwardLevelsNumber = i->second.second.size(); + } + + for (i = myTreeModel.begin(); i != myTreeModel.end(); i++ ) { + DependencyTree_Object* Main_object = myTreeMap[i->first]; + GEOMUtils::LevelInfo Levelup = i->second.first.at(0); + GEOMUtils::LevelInfo::const_iterator node; + for (node = Levelup.begin(); node != Levelup.end(); node++ ) { + DependencyTree_Object* object = myTreeMap[node->first]; + addArrow( Main_object, object ); + } + parseTreeWardArrow( i->second.first ); + parseTreeWardArrow( i->second.second ); + } - int upwardIndexBegin = theData.indexOf("{",cursor) + 1; - int upwardIndexFinish = theData.indexOf("}",upwardIndexBegin); - std::cout<<" Upward:" << std::endl; - LevelsList upwardList = parseWard( theData, cursor ); - if( upwardList.size() > myMaxUpwardLevelsNumber ) - myMaxUpwardLevelsNumber = upwardList.size(); - std::cout<<" Downward:" << std::endl; - LevelsList downwardList = parseWard( theData, cursor ); - if( downwardList.size() > myMaxDownwardLevelsNumber ) - myMaxDownwardLevelsNumber = downwardList.size(); - myTreeModel[objectEntry] = QPair( upwardList, downwardList ); - } } +void DependencyTree_View::parseTreeWard(const GEOMUtils::LevelsList theWard) +{ + int levelsNumber = theWard.size(); + for( int level = 0; level < levelsNumber; level++ ) { + GEOMUtils::LevelInfo levelInfo = theWard[ level ]; + GEOMUtils::LevelInfo::const_iterator node; + for (node = levelInfo.begin(); node != levelInfo.end(); node++ ) { + addNode( node->first ); + } + } +} +void DependencyTree_View::parseTreeWardArrow(const GEOMUtils::LevelsList theWard) +{ + for(int j = 0; j < theWard.size(); j++ ) { + GEOMUtils::LevelInfo Level = theWard.at(j); + GEOMUtils::LevelInfo::const_iterator node; + for (node = Level.begin(); node != Level.end(); node++ ) { + DependencyTree_Object* object = myTreeMap[node->first]; + std::vector Links = node->second; + for( int link = 0; link < Links.size(); link++ ) { + DependencyTree_Object* LinkObject = myTreeMap[Links[link]]; + if( object && LinkObject ) + addArrow( object, LinkObject ); + } + } + } +} +//void DependencyTree_View::parseData( QString& theData ) +//{ +// int cursor = 0; +// +// while( theData.indexOf('-',cursor) != -1 ) //find next selected object +// { +// int objectIndex = theData.indexOf( '-', cursor ); +// QString objectEntry = theData.mid( cursor, objectIndex - cursor ); +// //addNode( objectEntry ); +// std::cout<<"\n\nMainObject = " << objectEntry.toStdString() < myMaxUpwardLevelsNumber ) +// myMaxUpwardLevelsNumber = upwardList.size(); +// std::cout<<" Downward:" << std::endl; +// LevelsList downwardList = parseWard( theData, cursor ); +// if( downwardList.size() > myMaxDownwardLevelsNumber ) +// myMaxDownwardLevelsNumber = downwardList.size(); +// +// myTreeModel[objectEntry] = QPair( upwardList, downwardList ); +// } +//} -void DependencyTree_View::addNode( const QString& theEntry ) +void DependencyTree_View::addNode( const std::string& theEntry ) { if( !myTreeMap[theEntry] ) myTreeMap[theEntry] = new DependencyTree_Object( theEntry ); @@ -233,9 +234,10 @@ void DependencyTree_View::addArrow( DependencyTree_Object *startItem, Dependency { bool isFind = false; - std::cout << " " << startItem->getEntry().toStdString() << " " << endItem->getEntry().toStdString() << std::endl; - for( int i = 0; i < Arrows.size(); i++ ) { - DependencyTree_Arrow* arrow = Arrows.at(i); + std::cout << " " << startItem->getEntry() << " " << endItem->getEntry() << std::endl; + std::map, DependencyTree_Arrow* >::const_iterator i; + for (i = Arrows.begin(); i != Arrows.end(); i++ ) { + DependencyTree_Arrow* arrow = i->second; if( arrow->getStartItem() == startItem && arrow->getEndItem() == endItem ) { isFind = true; std::cout<<" theSame " << std::endl; @@ -249,126 +251,121 @@ void DependencyTree_View::addArrow( DependencyTree_Object *startItem, Dependency if( !isFind ) { DependencyTree_Arrow *arrow = new DependencyTree_Arrow(startItem, endItem); - Arrows.append( arrow ); - addItem(arrow); + //Arrows.append( arrow ); + //addItem(arrow); + Arrows[std::pair( startItem, endItem )] = arrow; std::cout<<" addArrow " << std::endl; } } -DependencyTree_View::LevelsList DependencyTree_View::parseWard( const QString& theData, int& theCursor ) -{ - int indexStart = theData.indexOf( "{", theCursor ) + 1; - int indexEnd = theData.indexOf( "}", indexStart ); - - QString ward = theData.mid( indexStart, indexEnd - indexStart ); - QStringList levelsListStr = ward.split( ';' ); - LevelsList levelsListData; - for( int level = 0; level < levelsListStr.size(); level++ ) { - std::cout<<" Level" << level + 1 << ":" << std::endl; - QStringList namesListStr = levelsListStr[level].split( ',' ); - LevelInfo levelInfoData; - for( int node = 0; node < namesListStr.size(); node++ ) { - QStringList linksListStr = namesListStr[node].split( '_' ); - QString nodeItem = linksListStr[0]; - if( !nodeItem.isEmpty() ) { - addNode( nodeItem ); - NodeLinks linksListData; - std::cout<<" " << nodeItem.toStdString() << " - "; - for( int link = 1; link < linksListStr.size(); link++ ) { - QString linkItem = linksListStr[link]; - addNode( linkItem ); - linksListData.append( linkItem ); - std::cout << linkItem.toStdString() << ", "; - }// Links - levelInfoData[nodeItem] = linksListData; - std::cout << std::endl; - } - }// Level's objects - levelsListData.append(levelInfoData); - }// Levels - - theCursor = indexEnd + 1; - - return levelsListData; -} +//DependencyTree_View::LevelsList DependencyTree_View::parseWard( const QString& theData, int& theCursor ) +//{ +// int indexStart = theData.indexOf( "{", theCursor ) + 1; +// int indexEnd = theData.indexOf( "}", indexStart ); +// +// QString ward = theData.mid( indexStart, indexEnd - indexStart ); +// QStringList levelsListStr = ward.split( ';' ); +// LevelsList levelsListData; +// for( int level = 0; level < levelsListStr.size(); level++ ) { +// std::cout<<" Level" << level + 1 << ":" << std::endl; +// QStringList namesListStr = levelsListStr[level].split( ',' ); +// LevelInfo levelInfoData; +// for( int node = 0; node < namesListStr.size(); node++ ) { +// QStringList linksListStr = namesListStr[node].split( '_' ); +// QString nodeItem = linksListStr[0]; +// if( !nodeItem.isEmpty() ) { +// //addNode( nodeItem ); +// NodeLinks linksListData; +// std::cout<<" " << nodeItem.toStdString() << " - "; +// for( int link = 1; link < linksListStr.size(); link++ ) { +// QString linkItem = linksListStr[link]; +// //addNode( linkItem ); +// linksListData.append( linkItem ); +// std::cout << linkItem.toStdString() << ", "; +// }// Links +// levelInfoData[nodeItem] = linksListData; +// std::cout << std::endl; +// } +// }// Level's objects +// levelsListData.append(levelInfoData); +// }// Levels +// +// theCursor = indexEnd + 1; +// +// return levelsListData; +//} void DependencyTree_View::drawTree() { - int horDistance, verDistance; - myCurrentLevel = 0; - std::cout<<"\n\n\n\n MY TREE MODEL SIZE = " << myTreeModel.size() << std::endl; - std::cout<<"\n\n\n\n MY TREE MAP SIZE = " << myTreeMap.size() << std::endl; - for( int j = 0; j < myTreeModel.keys().size(); j++ ) - std::cout<< " STRING = " << myTreeModel.keys().at(j).toStdString() << std::endl; - QMap >::iterator i; - for (i = myTreeModel.begin(); i != myTreeModel.end(); i++ ) { - myCurrentLevel = 0; - QString objectEntry = i.key(); - std::cout<< " NAME = " << objectEntry.toStdString() << std::endl; - DependencyTree_Object* objectItem = myTreeMap[ objectEntry ]; - objectItem->setEnabled(true); - if( objectItem->isEnabled() ) - std::cout<<"OK!!! "<< std::endl; - horDistance = 100 + int( objectItem->boundingRect().width() ); - verDistance = 3 * int( objectItem->boundingRect().height() ); - if( isItemAdded( objectItem ) ) { - myCurrentLevel = myLevelMap[ objectEntry ]; - } - else { - addItem( objectItem ); - std::cout<<"\nLevel = " << myCurrentLevel << " Object = " << objectEntry.toStdString() << std::endl; - myLevelMap[ objectEntry ] = myCurrentLevel; - myLevelsObject[ myCurrentLevel ].append( objectEntry ); - } - objectItem->setIsMainObject( true ); - - int levelposition = myCurrentLevel; - if( myDisplayAscendants ->isChecked() ){ - drawWard( i.value().first, -1 ); - myCurrentLevel = levelposition; - } - if( myDisplayDescendants->isChecked() ) - drawWard( i.value().second, 1 ); - - //centerOn( objectItem ); - } - - QMap< int, QList >::iterator j; + int horDistance, verDistance; + myCurrentLevel = 0; + GEOMUtils::TreeModel::const_iterator i; + for (i = myTreeModel.begin(); i != myTreeModel.end(); i++ ) { + myCurrentLevel = 0; + std::string objectEntry = i->first; + DependencyTree_Object* objectItem = myTreeMap[ objectEntry ]; + horDistance = 100 + int( objectItem->boundingRect().width() ); + verDistance = 3 * int( objectItem->boundingRect().height() ); + if( isItemAdded( objectItem ) ) { + myCurrentLevel = myLevelMap[ objectEntry ]; + } + else { + addItem( objectItem ); + myLevelMap[ objectEntry ] = myCurrentLevel; + myLevelsObject[ myCurrentLevel ].push_back( objectEntry ); + } + objectItem->setIsMainObject( true ); + + int levelposition = myCurrentLevel; + if( myDisplayAscendants ->isChecked() ){ + drawWard( i->second.first, -1 ); + myCurrentLevel = levelposition; + } + if( myDisplayDescendants->isChecked() ) + drawWard( i->second.second, 1 ); + } + + std::map< int, std::vector >::const_iterator j; for (j = myLevelsObject.begin(); j != myLevelsObject.end(); j++ ) { - int step = -horDistance*( j.value().size() - 1 )/2; - std::cout<<"\n\n LEVEL = " << j.key() << std::endl; - for( int object = 0; object < j.value().size(); object++ ) { + int step = -horDistance*( j->second.size() - 1 )/2; + std::cout<<"\n\n LEVEL = " << j->first << std::endl; + for( int object = 0; object < j->second.size(); object++ ) { if( myIsCompute ) { - std::cout << j.value().at( object ).toStdString() << ", "; - DependencyTree_Object* anObject = myTreeMap[ j.value().at( object ) ]; - anObject->setPos( step, verDistance*j.key() ); + std::cout << j->second.at( object ) << ", "; + DependencyTree_Object* anObject = myTreeMap[ j->second.at( object ) ]; + anObject->setPos( step, verDistance*j->first ); step += horDistance; //sleep(1); } } } + centerOn( scene()->sceneRect().center() ); } -void DependencyTree_View::drawWard( const DependencyTree_View::LevelsList theWard, const int theLevelStep ) +void DependencyTree_View::drawWard( const GEOMUtils::LevelsList theWard, const int theLevelStep ) { + std::cout << "\n\n myLevelsNumber2 = " << myLevelsNumber << std::endl; int levelsNumber = theWard.size(); + std::cout << "\n\n levelsNumber = " << levelsNumber << std::endl; for( int level = 0; level < levelsNumber; level++ ) { if( level >= myLevelsNumber ) return; myCurrentLevel += theLevelStep; - LevelInfo levelInfo = theWard.at( level ); - QMap::iterator node; + GEOMUtils::LevelInfo levelInfo = theWard.at( level ); + GEOMUtils::LevelInfo::const_iterator node; for (node = levelInfo.begin(); node != levelInfo.end(); node++ ) { - DependencyTree_Object* object = myTreeMap[ node.key() ]; + DependencyTree_Object* object = myTreeMap[ node->first ]; if( !isItemAdded( object ) ) { + std::cout<< "\n\n\n addItem = " << object->getEntry() << std::endl; addItem( object ); - myLevelMap[ node.key() ] = myCurrentLevel; - myLevelsObject[ myCurrentLevel ].append( node.key() ); + myLevelMap[ node->first ] = myCurrentLevel; + myLevelsObject[ myCurrentLevel ].push_back( node->first ); } } } + } void DependencyTree_View::onUpdateTree() @@ -377,22 +374,20 @@ void DependencyTree_View::onUpdateTree() myLevelsObject.clear(); - QMap::iterator i; + std::map::const_iterator i; for (i = myTreeMap.begin(); i != myTreeMap.end(); i++ ) { - DependencyTree_Object* object = myTreeMap[ i.key() ]; + DependencyTree_Object* object = myTreeMap[ i->first ]; if( isItemAdded( object ) && object ) removeItem( object ); } - - std::cout<<"\n\n\n\n ARROWS = " << Arrows.size() << std::endl; - - for(int j = 0; j, DependencyTree_Arrow* >::const_iterator j; + for (j = Arrows.begin(); j != Arrows.end(); j++ ) { + DependencyTree_Arrow* object = Arrows[ j->first ]; + if( isItemAdded( object ) && object ) + removeItem( object ); + } drawTree(); drawArrows(); @@ -413,13 +408,26 @@ int DependencyTree_View::checkMaxLevelsNumber() void DependencyTree_View::init( GraphicsView_ViewFrame* theViewFrame ) { SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); - QString Data = "MainObject1-upward{up11_up21_up22,up12_up23,up13_up24;up21_up11,up22_up21_up12,up23_up23,up24}" + + std::string Data = "MainObject1-upward{up11_up21_up22,up12_up23,up13_up24;up21_up11,up22_up21_up12,up23_up23,up24}" "downward{down11_MainObject1,down12_MainObject1;down21_down11,down22_down12,down23_down12,down24_down24_down11,down25_down12;down31_down11_down23,down32_down25}" "down23-upward{down12_MainObject1;MainObject1_up11_up12_up13;up11_up21_up22,up12_up23,up13_up24;up21,up22_up21_up12,up23,up24}" "downward{down31_down11_down23}" - "MainObject2-upward{up21,newup11_newup31,newup12_newup21;newup21_newup31LongName;newup31LongName}downward{newdown11_MainObject2,newdown12_MainObject2,newdown13_MainObject2;newdown21_newdown13,down21;newdown31_newdown11}"; + "MainObject2-upward{up21,newup11_newup31,newup12_newup21;newup21_newup31LongName;newup31LongName}downward{newdown11_MainObject2,newdown12_MainObject2,newdown13_MainObject2;newdown21_newdown13,down21;newdown31_newdown11}" + "MainObject3-upward{moUP1_moUP4,moUP2_moUP3;moUP4,moUP3_down23}downward{moDOWN1_MainObject3}"; + + + //GEOMUtils::ConvertStringToTree( Data, myTreeModel ); - parseData( Data ); + + +// GEOMUtils::TreeModel::const_iterator i; +// for ( i = aTreeModel.begin(); i != aTreeModel.end(); i++ ) { +// std::string objectEntry = i->first; +// std::cout << "\n\n Main object = " << objectEntry << std::endl; +// } +// parseData( Data ); + parseTree(); myNodesMovable = new QCheckBox( tr( "MOVE_NODES" ) ); @@ -436,6 +444,7 @@ void DependencyTree_View::init( GraphicsView_ViewFrame* theViewFrame ) ShowChildrenAction->setDefaultWidget( myDisplayDescendants ); myLevelsNumber = checkMaxLevelsNumber(); + std::cout << "\n\n myLevelsNumber1 = " << myLevelsNumber << std::endl; myHierarchyDepth = new QSpinBox(); myHierarchyDepth->setRange( 0, checkMaxLevelsNumber() ); myHierarchyDepth->setValue( 0 ); @@ -497,10 +506,11 @@ void DependencyTree_View::init( GraphicsView_ViewFrame* theViewFrame ) void DependencyTree_View::onMoveNodes( bool theIsMoveNodes ) { - QMap::iterator i; + std::map::const_iterator i; for (i = myTreeMap.begin(); i != myTreeMap.end(); i++ ) { - DependencyTree_Object* object = myTreeMap[ i.key() ]; - object->setMovable( theIsMoveNodes ); + DependencyTree_Object* object = myTreeMap[ i->first ]; + if( object ) + object->setMovable( theIsMoveNodes ); } } @@ -527,22 +537,21 @@ void DependencyTree_View::updateView() myLevelsObject.clear(); - QMap::iterator i; + std::map::const_iterator i; for (i = myTreeMap.begin(); i != myTreeMap.end(); i++ ) { - DependencyTree_Object* object = myTreeMap[ i.key() ]; + DependencyTree_Object* object = myTreeMap[ i->first ]; if( isItemAdded( object ) && object ) removeItem( object ); } - std::cout<<"\n\n\n\n ARROWS = " << Arrows.size() << std::endl; - - for(int j = 0; j, DependencyTree_Arrow* >::const_iterator j; + for (j = Arrows.begin(); j != Arrows.end(); j++ ) { + DependencyTree_Arrow* object = Arrows[ j->first ]; + if( isItemAdded( object ) && object ) + removeItem( object ); + } @@ -638,51 +647,54 @@ void DependencyTree_View::setPrefBackgroundColor( const QColor& theColor ) void DependencyTree_View::setNodeColor( const QColor& theColor ) { - QMap::iterator i; + std::map::const_iterator i; for (i = myTreeMap.begin(); i != myTreeMap.end(); i++ ) { - DependencyTree_Object* object = myTreeMap[ i.key() ]; + DependencyTree_Object* object = myTreeMap[ i->first ]; object->setColor( theColor ); } } void DependencyTree_View::setMainNodeColor( const QColor& theColor ) { - QMap::iterator i; + std::map::const_iterator i; for (i = myTreeMap.begin(); i != myTreeMap.end(); i++ ) { - DependencyTree_Object* object = myTreeMap[ i.key() ]; + DependencyTree_Object* object = myTreeMap[ i->first ]; object->setMainObjectColor( theColor ); } } void DependencyTree_View::setSelectNodeColor( const QColor& theColor ) { - QMap::iterator i; + std::map::const_iterator i; for (i = myTreeMap.begin(); i != myTreeMap.end(); i++ ) { - DependencyTree_Object* object = myTreeMap[ i.key() ]; + DependencyTree_Object* object = myTreeMap[ i->first ]; object->setSelectColor( theColor ); } } void DependencyTree_View::setArrowColor( const QColor& theColor ) { - for( int i = 0; i < Arrows.size(); i++ ) { - DependencyTree_Arrow* arrow = Arrows[i]; + std::map, DependencyTree_Arrow* >::const_iterator j; + for (j = Arrows.begin(); j != Arrows.end(); j++ ) { + DependencyTree_Arrow* arrow = Arrows[ j->first ]; arrow->setColor( theColor ); } } void DependencyTree_View::setHighlightArrowColor( const QColor& theColor ) { - for( int i = 0; i < Arrows.size(); i++ ) { - DependencyTree_Arrow* arrow = Arrows[i]; + std::map, DependencyTree_Arrow* >::const_iterator j; + for (j = Arrows.begin(); j != Arrows.end(); j++ ) { + DependencyTree_Arrow* arrow = Arrows[ j->first ]; arrow->setHighlightColor( theColor ); } } void DependencyTree_View::setSelectArrowColor( const QColor& theColor ) { - for( int i = 0; i < Arrows.size(); i++ ) { - DependencyTree_Arrow* arrow = Arrows[i]; + std::map, DependencyTree_Arrow* >::const_iterator j; + for (j = Arrows.begin(); j != Arrows.end(); j++ ) { + DependencyTree_Arrow* arrow = Arrows[ j->first ]; arrow->setSelectColor( theColor ); } } diff --git a/src/DependencyTree/DependencyTree_View.h b/src/DependencyTree/DependencyTree_View.h index 02d0e322e..059770757 100644 --- a/src/DependencyTree/DependencyTree_View.h +++ b/src/DependencyTree/DependencyTree_View.h @@ -23,32 +23,28 @@ #include #include -#include -#include -#include -#include -#include +#include + #include +#include #include #include #include #include -#include - -#include "DependencyTree_Arrow.h" class DependencyTree_Object; +class DependencyTree_Arrow; class DependencyTree_View; - class DependencyTree_ComputeDlg_QThread : public QThread { Q_OBJECT public: - DependencyTree_ComputeDlg_QThread(DependencyTree_View*); - bool result(); - void cancel(); + + DependencyTree_ComputeDlg_QThread( DependencyTree_View* ); + bool result(); + void cancel(); DependencyTree_View* getView() { return myView; }; @@ -61,11 +57,11 @@ private: class DependencyTree_View: public GraphicsView_ViewPort { - Q_OBJECT -public: + Q_OBJECT +public: - DependencyTree_View( QWidget* theParent=0 ); + DependencyTree_View( QWidget* = 0 ); ~DependencyTree_View(); void setHierarchyType( const int ); @@ -78,18 +74,18 @@ public: void setHighlightArrowColor( const QColor& ); void setSelectArrowColor( const QColor& ); - typedef QList NodeLinks; - typedef QMap LevelInfo; - typedef QList LevelsList; - typedef QMap > TreeModel; +// typedef QList NodeLinks; +// typedef QMap LevelInfo; +// typedef QList LevelsList; +// typedef QMap > TreeModel; - TreeModel myTreeModel; - QMap myTreeMap; - QList Arrows; + GEOMUtils::TreeModel myTreeModel; + std::map myTreeMap; + std::map,DependencyTree_Arrow*> Arrows; - QMap myLevelMap; + std::map myLevelMap; - QMap< int, QList > myLevelsObject; + std::map< int, std::vector > myLevelsObject; int myCurrentLevel; void init( GraphicsView_ViewFrame* ); @@ -112,15 +108,20 @@ private slots: void onCancel(); private: - void parseData( QString& data ); - void addNode( const QString& entry ); +// void parseData( QString& data ); + + 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 ); - DependencyTree_View::LevelsList parseWard( const QString& data, int& cursor ); +// GEOMUtils::LevelsList parseWard( const QString& data, int& cursor ); void drawTree(); - void drawWard( DependencyTree_View::LevelsList ward, const int levelStep ); + void drawWard( GEOMUtils::LevelsList ward, const int levelStep ); void drawArrows(); - void drawWardArrows( LevelsList ); + void drawWardArrows( GEOMUtils::LevelsList ); int checkMaxLevelsNumber(); int myLevelsNumber; @@ -132,7 +133,7 @@ private: QCheckBox* myDisplayAscendants; QCheckBox* myDisplayDescendants; - QString myData; + std::string myData; bool myIsUpdate; @@ -145,34 +146,8 @@ private: QWidgetAction* cancelAction; QWidgetAction* progressAction; -}; + //SALOMEDS::Study_var myStudy; - - -///*! -// * \brief Dialog to display Cancel button -// */ -// -//class DependencyTree_ComputeDlg_QThreadQDialog : public QDialog -//{ -// Q_OBJECT -// -//public: -// DependencyTree_ComputeDlg_QThreadQDialog(QWidget* parent, DependencyTree_View*); -// bool result(); -// -//protected: -// void timerEvent(QTimerEvent *timer); -// void closeEvent(QCloseEvent *event); -// -//private slots: -// void onCancel(); -// -//private: -// -// DependencyTree_ComputeDlg_QThread qthread; -// QPushButton * cancelButton; -// QProgressBar* progressBar; -//}; +}; #endif diff --git a/src/GEOMToolsGUI/CMakeLists.txt b/src/GEOMToolsGUI/CMakeLists.txt index 8d6a756de..7861b2f37 100755 --- a/src/GEOMToolsGUI/CMakeLists.txt +++ b/src/GEOMToolsGUI/CMakeLists.txt @@ -39,6 +39,7 @@ INCLUDE_DIRECTORIES( ${PROJECT_SOURCE_DIR}/src/GEOMBase ${PROJECT_SOURCE_DIR}/src/Material ${PROJECT_SOURCE_DIR}/src/DependencyTree + ${PROJECT_SOURCE_DIR}/src/GEOMUtils ${CMAKE_CURRENT_SOURCE_DIR} )