From 265b77b65fe8bade1fc28517666ebe3cf9561278 Mon Sep 17 00:00:00 2001 From: apo Date: Mon, 12 Dec 2005 12:55:32 +0000 Subject: [PATCH] Apply debug on UpdateObjBrowser functionality --- src/VISUGUI/VisuGUI_Tools.cxx | 66 ++++++++++++++++++++++++++--------- 1 file changed, 50 insertions(+), 16 deletions(-) diff --git a/src/VISUGUI/VisuGUI_Tools.cxx b/src/VISUGUI/VisuGUI_Tools.cxx index affe004b..280c8ca0 100644 --- a/src/VISUGUI/VisuGUI_Tools.cxx +++ b/src/VISUGUI/VisuGUI_Tools.cxx @@ -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(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(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(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); } } } -- 2.39.2