X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSUPERVGUI%2FSUPERVGUI_BrowseNodeDlg.cxx;h=5969c3923b921e34d07ed94b90a48f5ceaa9bc18;hb=HEAD;hp=a50fe23ce2ccaa3568f0d2040d6df841eb5005a4;hpb=0523de189224d3c253468f9f7f994d39a4fc01fc;p=modules%2Fsuperv.git diff --git a/src/SUPERVGUI/SUPERVGUI_BrowseNodeDlg.cxx b/src/SUPERVGUI/SUPERVGUI_BrowseNodeDlg.cxx index a50fe23..5969c39 100644 --- a/src/SUPERVGUI/SUPERVGUI_BrowseNodeDlg.cxx +++ b/src/SUPERVGUI/SUPERVGUI_BrowseNodeDlg.cxx @@ -302,7 +302,88 @@ void SUPERVGUI_BrowseNodeDlg::onFieldActivated() myActiveField = (aField->isEditable())? aField : 0; } +namespace { + + QString getIORfromIO (const Handle(SALOME_InteractiveObject)& theIO, + SUPERVGUI * theModule) + { + QString ior (""); + if (!theIO->hasEntry()) return ior; + + SalomeApp_Study* anAppStudy = dynamic_cast(theModule->getActiveStudy()); + _PTR(SObject) aSObj (anAppStudy->studyDS()->FindObjectID(theIO->getEntry())); + + _PTR(GenericAttribute) anAttr; + if (aSObj->FindAttribute(anAttr, "AttributeIOR")) { + _PTR(AttributeIOR) anIOR (anAttr); + ior = anIOR->Value().c_str(); + return ior; + } + // old code, it is useless, because GetObject()> here will be NULL + // (because it is retrieved from by stored IOR) + /* + SALOMEDS_Study* aSStudy = dynamic_cast( aSObj->GetStudy().get() ); + SALOMEDS_SObject* aSSObj = dynamic_cast( aSObj.get() ); + if ( aSStudy && aSSObj ) + ior = aSStudy->ConvertObjectToIOR( aSSObj->GetObject() ).c_str(); + //*/ + + // new code + + // default value: null IOR (IOR:01000000010000000000...) + SalomeApp_Application* anApp = theModule->getApp(); + CORBA::Object_var aNullObj; + ior = anApp->orb()->object_to_string(aNullObj); + + // try to load a component data from an opened (presumably) study + _PTR(SComponent) aSComp = aSObj->GetFatherComponent(); + std::string aCompIOR; + if (!aSComp->ComponentIOR(aCompIOR)) { + std::string aCompDataType = aSComp->ComponentDataType(); + + // obtain a driver by a component data type + // like it is done in SALOMEDS_DriverFactory_i::GetDriverByType + SALOMEDS::Driver_var anEngine = SALOMEDS::Driver::_nil(); + SALOME_LifeCycleCORBA * LCC = anApp->lcc(); + try { + CORBA::Object_var + anEngineObj = LCC->FindOrLoad_Component("FactoryServer", aCompDataType.c_str()); + if (CORBA::is_nil(anEngineObj)) + anEngineObj = LCC->FindOrLoad_Component("FactoryServerPy", aCompDataType.c_str()); + + if (!CORBA::is_nil(anEngineObj)) + anEngine = SALOMEDS::Driver::_narrow(anEngineObj); + } + catch (...) { + } + + if (!CORBA::is_nil(anEngine)) { + // try to load + _PTR(StudyBuilder) aStudyBuilder = aSObj->GetStudy()->NewBuilder(); + bool isOk = true; + try { + CORBA::String_var aDriverIOR = anApp->orb()->object_to_string(anEngine); + aStudyBuilder->LoadWith(aSComp, aDriverIOR.in()); + } + catch (...) { + isOk = false; + } + + if (isOk) { + // now try to obtain the IOR once again (after successfull component data loading) + if (aSObj->FindAttribute( anAttr, "AttributeIOR" )) { + _PTR(AttributeIOR) anIOR ( anAttr ); + ior = anIOR->Value().c_str(); + } + } + } // if (!CORBA::is_nil(anEngine)) + } // if (!aSComp->ComponentIOR(aCompIOR)) + + return ior; + } + +} // no name namespace /** * Slot, called when selection is changed @@ -310,7 +391,7 @@ void SUPERVGUI_BrowseNodeDlg::onFieldActivated() void SUPERVGUI_BrowseNodeDlg::onSelectionChanged() { if ( myActiveField ) { - + SALOME_ListIO aList; aList.Clear(); @@ -320,28 +401,13 @@ void SUPERVGUI_BrowseNodeDlg::onSelectionChanged() return; } - (( SalomeApp_Application* )(aSupMod->getActiveStudy()->application())) - ->selectionMgr()->selectedObjects( aList ); - - if( aList.Extent() == 1 ) { + SalomeApp_Application* anApp = aSupMod->getApp(); + anApp->selectionMgr()->selectedObjects( aList ); + + if ( aList.Extent() == 1 ) { Handle( SALOME_InteractiveObject ) anIO = aList.First(); if ( anIO->hasEntry() ) { - _PTR(SObject) aObj ( dynamic_cast( aSupMod->getActiveStudy() )-> - studyDS()->FindObjectID( anIO->getEntry() ) ); - - _PTR(GenericAttribute) anAttr; - QString ior(""); - - if (aObj->FindAttribute( anAttr, "AttributeIOR" ) ) { - _PTR(AttributeIOR) anIOR ( anAttr ); - ior = anIOR->Value().c_str(); - } - else { - SALOMEDS_Study* aSStudy = dynamic_cast( aObj->GetStudy().get() ); - SALOMEDS_SObject* aSSObj = dynamic_cast( aObj.get() ); - if ( aSStudy && aSSObj ) - ior = aSStudy->ConvertObjectToIOR( aSSObj->GetObject() ).c_str(); - } + QString ior = ::getIORfromIO(anIO, aSupMod); myActiveField->setData( ior ); } } @@ -476,35 +542,20 @@ void SUPERVGUI_GetValueDlg::onSelectionChanged() { SALOME_ListIO aList; aList.Clear(); - + SUPERVGUI* aSupMod = SUPERVGUI::Supervision(); if ( !aSupMod ) { MESSAGE("NULL Supervision module!"); return; } - - (( SalomeApp_Application* )(aSupMod->getActiveStudy()->application())) - ->selectionMgr()->selectedObjects( aList ); - - if( aList.Extent() == 1 ) { + + SalomeApp_Application* anApp = aSupMod->getApp(); + anApp->selectionMgr()->selectedObjects( aList ); + + if ( aList.Extent() == 1 ) { Handle( SALOME_InteractiveObject ) anIO = aList.First(); if ( anIO->hasEntry() ) { - _PTR(SObject) aObj ( dynamic_cast( aSupMod->getActiveStudy() )-> - studyDS()->FindObjectID( anIO->getEntry() ) ); - - _PTR(GenericAttribute) anAttr; - QString ior(""); - - if (aObj->FindAttribute( anAttr, "AttributeIOR" ) ) { - _PTR(AttributeIOR) anIOR ( anAttr ); - ior = anIOR->Value().c_str(); - } - else { - SALOMEDS_Study* aSStudy = dynamic_cast( aObj->GetStudy().get() ); - SALOMEDS_SObject* aSSObj = dynamic_cast( aObj.get() ); - if ( aSStudy && aSSObj ) - ior = aSStudy->ConvertObjectToIOR( aSSObj->GetObject() ).c_str(); - } + QString ior = ::getIORfromIO(anIO, aSupMod); myField->setData( ior ); } }