From 328ea5246ced56e456cb8297b0ff1cd0465e6a4a Mon Sep 17 00:00:00 2001 From: mpa Date: Fri, 23 May 2014 17:04:32 +0400 Subject: [PATCH] Add object selection in Dependency Tree --- src/DependencyTree/DependencyTree_View.cxx | 70 +++++++++++----------- src/DependencyTree/DependencyTree_View.h | 2 + 2 files changed, 37 insertions(+), 35 deletions(-) diff --git a/src/DependencyTree/DependencyTree_View.cxx b/src/DependencyTree/DependencyTree_View.cxx index 9a3a50774..4785f4101 100644 --- a/src/DependencyTree/DependencyTree_View.cxx +++ b/src/DependencyTree/DependencyTree_View.cxx @@ -89,6 +89,7 @@ myIsUpdate( true ) GEOMUtils::ConvertStringToTree( buf, myTreeModel ); + aSelMgr->clearSelected(); } DependencyTree_View::~DependencyTree_View() @@ -345,6 +346,7 @@ void DependencyTree_View::drawTree() } } centerOn( scene()->sceneRect().center() ); + fitAll( true ); } @@ -362,7 +364,6 @@ void DependencyTree_View::drawWard( const GEOMUtils::LevelsList theWard, const i for (node = levelInfo.begin(); node != levelInfo.end(); node++ ) { DependencyTree_Object* object = myTreeMap[ node->first ]; if( !isItemAdded( object ) ) { - std::cout<< "\n\n\n addItem = " << object->getEntry() << std::endl; addItem( object ); myLevelMap[ node->first ] = myCurrentLevel; myLevelsObject[ myCurrentLevel ].push_back( node->first ); @@ -506,6 +507,7 @@ void DependencyTree_View::init( GraphicsView_ViewFrame* theViewFrame ) setNodesMovable( resMgr->booleanValue( "Geometry", "dependency_tree_move_nodes", true ) ); setHierarchyType( resMgr->integerValue( "Geometry", "dependency_tree_hierarchy_type", 0 ) ); + } void DependencyTree_View::onMoveNodes( bool theIsMoveNodes ) @@ -564,7 +566,11 @@ void DependencyTree_View::updateView() qthread = new DependencyTree_ComputeDlg_QThread(this);// = DependencyTree_ComputeDlg_QThread(this);// const_cast(this) ); cancelAction->setVisible( true ); progressAction->setVisible(true); - startTimer(100); // millisecs + myNodesMovable->setEnabled(false); + myHierarchyDepth->setEnabled( false); + myDisplayAscendants->setEnabled( false ); + myDisplayDescendants->setEnabled( false ); + myTimer = startTimer(100); // millisecs qthread->start(); } @@ -578,6 +584,10 @@ void DependencyTree_View::onCancel() qthread->cancel(); cancelButton->setText( tr("CANCELING")); cancelButton->setEnabled(false); + killTimer( myTimer ); + qthread->killTimer( myTimer ); + qthread->deleteLater(); + } void DependencyTree_View::timerEvent(QTimerEvent *event) @@ -592,6 +602,10 @@ void DependencyTree_View::timerEvent(QTimerEvent *event) progressAction->setVisible(false); cancelButton->setText( tr("CANCEL")); cancelButton->setEnabled(true); + myNodesMovable->setEnabled( true ); + myHierarchyDepth->setEnabled( true ); + myDisplayAscendants->setEnabled( true ); + myDisplayDescendants->setEnabled( true ); } event->accept(); @@ -707,39 +721,25 @@ int DependencyTree_View::select( const QRectF& theRect, bool theIsAppend ) { GraphicsView_ViewPort::select( theRect, theIsAppend ); -// SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() ); -// -// LightApp_SelectionMgr* aSelMgr = app->selectionMgr(); -// -// // get selection -// SALOME_ListIO listIO; -// -// SalomeApp_Study* study = dynamic_cast(app->activeStudy()); -// SALOMEDS::Study_var aStudyDS = GeometryGUI::ClientStudyToStudy( study->studyDS()); -// int StudyId = aStudyDS->StudyId(); -// for( initSelected(); moreSelected(); nextSelected() ) -// if( DependencyTree_Object* aDepObject = dynamic_cast( selectedObject() ) ) { -// -// _PTR(SObject) SO ( aStudyDS->FindObjectID( aDepObject->getEntry().c_str() ) ); -// if ( SO ) { //;&& QString(SO->GetID().c_str()) == QString(SO->GetFatherComponent()->GetID().c_str()) ) { -// _PTR(SComponent) SC ( SO->GetFatherComponent() ); -// // if component is selected -// _PTR(ChildIterator) anIter ( aStudyDS->NewChildIterator( SO ) ); -// anIter->InitEx( true ); -// while( anIter->More() ) { -// _PTR(SObject) valSO ( anIter->Value() ); -// _PTR(SObject) refSO; -// if ( !valSO->ReferencedObject( refSO ) ) { -// listIO.Append( new SALOME_InteractiveObject(valSO->GetID().c_str(), -// SC->ComponentDataType().c_str(), -// valSO->GetName().c_str()) ); -// } -// anIter->Next(); -// } -// break; -// } -// } -// aSelMgr->setSelectedObjects( listIO, true ); + SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() ); + + LightApp_SelectionMgr* aSelMgr = app->selectionMgr(); + + // get selection + SALOME_ListIO listIO; +aSelMgr->clearSelected(); + SalomeApp_Study* study = dynamic_cast(app->activeStudy()); + SALOMEDS::Study_var aStudyDS = GeometryGUI::ClientStudyToStudy( study->studyDS()); + int StudyId = aStudyDS->StudyId(); + for( initSelected(); moreSelected(); nextSelected() ) + if( DependencyTree_Object* aDepObject = dynamic_cast( selectedObject() ) ) { + GEOM::_objref_GEOM_BaseObject* object = GeometryGUI::GetGeomGen()->GetObject( StudyId, aDepObject->getEntry().c_str() ); + CORBA::String_var aChildEntry = object->GetStudyEntry(); + Handle(SALOME_InteractiveObject) tmpIO = + new SALOME_InteractiveObject( aChildEntry.in(), "GEOM", "TEMP_IO"); + listIO.Append(tmpIO); + } + aSelMgr->setSelectedObjects( listIO, true ); } //================================================================================ diff --git a/src/DependencyTree/DependencyTree_View.h b/src/DependencyTree/DependencyTree_View.h index 97d5811b5..19c5d0b23 100644 --- a/src/DependencyTree/DependencyTree_View.h +++ b/src/DependencyTree/DependencyTree_View.h @@ -137,6 +137,8 @@ private: std::string myData; + int myTimer; + bool myIsUpdate; GraphicsView_ViewFrame* myViewFrame; -- 2.39.2