]> SALOME platform Git repositories - modules/geom.git/commitdiff
Salome HOME
Add object selection in Dependency Tree
authormpa <mpa@opencascade.com>
Fri, 23 May 2014 13:04:32 +0000 (17:04 +0400)
committermpa <mpa@opencascade.com>
Fri, 23 May 2014 13:04:32 +0000 (17:04 +0400)
src/DependencyTree/DependencyTree_View.cxx
src/DependencyTree/DependencyTree_View.h

index 9a3a50774e1fb4263e703b83da7125ebc68e9e74..4785f4101d768ade431f0706f715d5309eab3c9f 100644 (file)
@@ -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<DependencyTree_View*>(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<SalomeApp_Study*>(app->activeStudy());
-//    SALOMEDS::Study_var aStudyDS = GeometryGUI::ClientStudyToStudy( study->studyDS());
-//    int StudyId = aStudyDS->StudyId();
-//    for( initSelected(); moreSelected(); nextSelected() )
-//      if( DependencyTree_Object* aDepObject = dynamic_cast<DependencyTree_Object*>( 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<SalomeApp_Study*>(app->activeStudy());
+    SALOMEDS::Study_var aStudyDS = GeometryGUI::ClientStudyToStudy( study->studyDS());
+    int StudyId = aStudyDS->StudyId();
+    for( initSelected(); moreSelected(); nextSelected() )
+      if( DependencyTree_Object* aDepObject = dynamic_cast<DependencyTree_Object*>( 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 );
 }
 
 //================================================================================
index 97d5811b5171c4434c4da1d11e7325e2ec5f1617..19c5d0b23a1fef91082979012471135d595378db 100644 (file)
@@ -137,6 +137,8 @@ private:
 
   std::string myData;
 
+  int myTimer;
+
   bool myIsUpdate;
 
   GraphicsView_ViewFrame* myViewFrame;