]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
Fix problems with usage in VISU of MED data from other modules (not only MED). These...
authorjfa <jfa@opencascade.com>
Thu, 22 Mar 2007 13:44:22 +0000 (13:44 +0000)
committerjfa <jfa@opencascade.com>
Thu, 22 Mar 2007 13:44:22 +0000 (13:44 +0000)
src/VISUGUI/VisuGUI.cxx
src/VISU_I/VISU_Gen_i.cc
src/VISU_I/VISU_Result_i.cc

index c967459c4ae60577422fe79ebf5b28a092d94419..bec2bebf37aaeba9829e1c36c81805c5769a11d3 100644 (file)
@@ -393,6 +393,44 @@ OnImportMedField()
     Handle(SALOME_InteractiveObject) anIO = It.Value();
     SALOMEDS::SObject_var aSObject = aStudy->FindObjectID(anIO->getEntry());
     if (!aSObject->_is_nil()) {
+
+      // try to load a component data from an opened (presumably) study
+      // The same in SUPERVISION: NPAL14522
+      {
+        SALOMEDS::SComponent_ptr aSComp = aSObject->GetFatherComponent();
+        //std::string aCompIOR;
+        CORBA::String_var aCompIOR;
+        if (!aSComp->ComponentIOR(aCompIOR)) { // not loaded
+          CORBA::String_var aCompDataType = aSComp->ComponentDataType();
+          //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 = getApp()->lcc();
+          try {
+            CORBA::Object_var
+              //anEngineObj = LCC->FindOrLoad_Component("FactoryServer", aCompDataType.c_str());
+              anEngineObj = LCC->FindOrLoad_Component("FactoryServer", aCompDataType);
+            if (CORBA::is_nil(anEngineObj))
+              //anEngineObj = LCC->FindOrLoad_Component("FactoryServerPy", aCompDataType.c_str());
+              anEngineObj = LCC->FindOrLoad_Component("FactoryServerPy", aCompDataType);
+
+            if (!CORBA::is_nil(anEngineObj))
+              anEngine = SALOMEDS::Driver::_narrow(anEngineObj);
+
+            if (!CORBA::is_nil(anEngine)) {
+              // try to load
+              SALOMEDS::StudyBuilder_ptr aStudyBuilder = aStudy->NewBuilder();
+              //aStudyBuilder->LoadWith(aSComp, aDriverIOR.in());
+              aStudyBuilder->LoadWith(aSComp, anEngine);
+            }
+          }
+          catch (...) {
+          }
+        }
+      }
+
       CORBA::Object_var anObject = VISU::SObjectToObject(aSObject);
       if (!CORBA::is_nil(anObject)) {
         SALOME_MED::MED_var aMED = SALOME_MED::MED::_narrow(anObject);
index 60a78ad0318a2a41f2712804868c847283d7c7bf..11f24415d303b70808a46848aff9c1752775cd78 100644 (file)
@@ -624,7 +624,13 @@ namespace VISU
          if(!CORBA::is_nil(aMedEngine))
            {
              SALOMEDS::StudyBuilder_var aStudyBuilder = myStudyDocument->NewBuilder();
-             aStudyBuilder->LoadWith( myStudyDocument->FindComponent( "MED" ), aMedEngine );
+             try {
+               aStudyBuilder->LoadWith( myStudyDocument->FindComponent( "MED" ), aMedEngine );
+             }
+             catch( const SALOME::SALOME_Exception& ) {
+               // Oops, something went wrong while loading
+               // See also SalomeApp_Study::openDataModel()
+             }
            }
        }
     } else {
index 0135f88f4dc35169b7ad21ad034307bb66ff1c13..4c53594b0bd910a7f3015ebf9e248d54c49d098a 100644 (file)
@@ -64,7 +64,7 @@ using namespace VISU;
 using namespace std;
 
 #ifdef _DEBUG_
-static int MYDEBUG = 0;
+static int MYDEBUG = 1;
 static int MYTIMEDEBUG = 0;
 #else
 static int MYDEBUG = 0;
@@ -1292,6 +1292,7 @@ Restore(SALOMEDS::SObject_ptr theSObject,
       SALOMEDS::StudyBuilder_var aStudyBuilder = myStudyDocument->NewBuilder();
       SALOMEDS::Driver_var aDriver = SALOMEDS::Driver::_narrow(aEngComp);
       aStudyBuilder->LoadWith(aCompRefSObj, aDriver);
+      /*
       if (strcmp(aDataType, "MED") == 0){
         // create field or MED converter
         CORBA::Object_var aMedObject = VISU::SObjectToObject(aTargetRefSObj);
@@ -1303,6 +1304,24 @@ Restore(SALOMEDS::SObject_ptr theSObject,
        myInput->Build();
       }else
        throw std::runtime_error("GetInput - There is no convertor for the aDataType !!!");
+      //*/
+
+      // create field or MED converter
+      CORBA::Object_var aMedObject = VISU::SObjectToObject(aTargetRefSObj);
+      SALOME_MED::FIELD_var aField = SALOME_MED::FIELD::_narrow(aMedObject);
+      if (!CORBA::is_nil(aField)) {
+        // create field converter
+       myInput = CreateMEDFieldConvertor(aField);
+       myInput->Build();
+      }
+      else if (strcmp(aDataType, "MED") == 0) {
+        // create MED converter
+       myInput = CreateMEDConvertor(aTargetRefSObj);
+       myInput->Build();
+      }
+      else {
+       throw std::runtime_error("GetInput - There is no convertor for the aDataType !!!");
+      }
     } else {
       myFileInfo.setFile(thePrefix.c_str());