]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
Apply debug on UpdateObjBrowser functionality
authorapo <apo@opencascade.com>
Mon, 12 Dec 2005 12:55:32 +0000 (12:55 +0000)
committerapo <apo@opencascade.com>
Mon, 12 Dec 2005 12:55:32 +0000 (12:55 +0000)
src/VISUGUI/VisuGUI_Tools.cxx

index affe004b73b772588a7ee9b3943a3f8f640efbc9..280c8ca0057f0492181b43d0d3a9bed632d5e4b1 100644 (file)
@@ -109,28 +109,56 @@ namespace VISU
     return false;
   }
 
+  LightApp_DataObject*
+  FindDataObject(SUIT_DataObject* theDataObject,
+                const QString& theEntry,
+                int theLevel)
+  {
+    int aLevel = theDataObject->level() + 2;
+    QString aSourceEntry = theEntry.section(':',0,aLevel);
+    DataObjectList aList;
+    theDataObject->children(aList);
+    DataObjectListIterator aDataObjectIter(aList);
+    while(SUIT_DataObject* aDataObject = aDataObjectIter.current()){
+      if(LightApp_DataObject* aChildDataObject = dynamic_cast<LightApp_DataObject*>(aDataObject)){
+       QString anEntry = aChildDataObject->entry();
+       QString aCurrentEntry = anEntry.section(':',0,aLevel);
+       if(aSourceEntry == aCurrentEntry){
+         if(theLevel == aLevel){
+           return aChildDataObject;
+         }else{
+           return FindDataObject(aChildDataObject,theEntry,theLevel);
+         }
+       }
+      }
+      ++aDataObjectIter;
+    }
+    return NULL;
+  }
+
+  LightApp_DataObject*
+  FindDataObject(CAM_Module* theModule,
+                _PTR(SObject) theSObject)
+  {
+    CAM_DataModel* aDataModel = theModule->dataModel();
+    CAM_DataObject* aRootDataObject = aDataModel->root();
+    if(_PTR(SComponent) aComponent = theSObject)
+      return dynamic_cast<LightApp_DataObject*>(aRootDataObject);
+
+    int aLevel = theSObject->Depth();
+    std::string anEntry = theSObject->GetID();
+    return FindDataObject(aRootDataObject,anEntry.c_str(),aLevel);
+  }
+
   void
   UpdateObjBrowser(SalomeApp_Module* theModule,
                   bool theIsUpdateDataModel,
                   _PTR(SObject) theSObject)
   {
     LightApp_DataObject* aDataObject = NULL;
-    if(theSObject){
-      std::string anEntry = theSObject->GetID();
-      SalomeApp_Application* anApp = theModule->getApp();
-      OB_Browser* aBrowser = anApp->objectBrowser();
-      DataObjectList aList = aBrowser->getSelected();
-      DataObjectListIterator anIter(aList);
-      while(SUIT_DataObject* anObject = anIter.current()){
-       aDataObject = dynamic_cast<LightApp_DataObject*>(anObject);
-       if(aDataObject){
-         if(anEntry == aDataObject->entry().latin1()){
-           break;
-         }
-       }
-       ++anIter;
-      }
-    }
+    if(theSObject)
+      aDataObject = FindDataObject(theModule,theSObject);
+
     theModule->updateObjBrowser(theIsUpdateDataModel,aDataObject);
     theModule->getApp()->updateActions();
   }
@@ -1165,6 +1193,12 @@ namespace VISU
             }
           }
           PlotContainer( theModule, pContainer, VISU::eDisplay );
+
+         QString anEntry = pContainer->GetEntry();
+         _PTR(Study) aStudy = theTableSO->GetStudy();
+         _PTR(SObject) aContainerSO = aStudy->FindObjectID(anEntry.latin1());
+         _PTR(SObject) aParentSO = aContainerSO->GetFather();
+         UpdateObjBrowser(theModule,true,aParentSO);
         }
       }
     }