]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
To provide additional fix for Bug GVIEW10573
authorapo <apo@opencascade.com>
Thu, 24 Nov 2005 07:07:09 +0000 (07:07 +0000)
committerapo <apo@opencascade.com>
Thu, 24 Nov 2005 07:07:09 +0000 (07:07 +0000)
 time to load sandia file too long

To define new methods to control the Result calculations

src/VISU_I/VISU_Gen_i.cc
src/VISU_I/VISU_Gen_i.hh
src/VISU_I/VISU_Result_i.cc
src/VISU_I/VISU_Result_i.hh

index 58c7a2ddd623b7f1776ea1a66dcd8303190ba996..886878486e18b87e353679adcb976de582258cec 100644 (file)
@@ -499,6 +499,23 @@ namespace VISU{
     }
   }
 
+  Result_ptr VISU_Gen_i::CreateResult(const char* theFileName){
+    if(myStudyDocument->GetProperties()->IsLocked())
+      return Result::_nil();
+    Mutex mt(myMutex);
+    aFileInfo.setFile(theFileName);
+    Result_i* pResult = new Result_i(myStudyDocument,
+                                    Result_i::eFile,
+                                    Result_i::eImportFile,
+                                    false);
+    if(pResult->Create(theFileName) != NULL)
+      return pResult->_this();
+    else{
+      pResult->_remove_ref();
+      return VISU::Result::_nil();
+    }
+  }
+
   Result_ptr VISU_Gen_i::CopyAndImportFile(const char* theFileName){
     if(myStudyDocument->GetProperties()->IsLocked())
       return Result::_nil();
index a387b2e5186ba9292f35130ce3da052169edde2c..4ad14670fc04f9b9afe1344848805c50f41e976d 100644 (file)
@@ -44,6 +44,7 @@ namespace VISU{
 
     //Create Result
     virtual Result_ptr ImportFile(const char* theFileName);
+    virtual Result_ptr CreateResult(const char* theFileName);
     virtual Result_ptr CopyAndImportFile(const char* theFileName);
     virtual Result_ptr ImportMed(SALOMEDS::SObject_ptr theMedSObject);
     virtual Result_ptr ImportMedField(SALOME_MED::FIELD_ptr theField);
index fa1aece5a41352d4bcd28518da13cd6d973d8dfb..97bc365c797eaae6c6a5e52ffd4ea543782626a5 100644 (file)
@@ -72,30 +72,30 @@ static int MYTIMEDEBUG = 0;
 #endif
 
 
-//---------------------------------------------------------------
-VISU::Result_var 
-VISU::FindResult (SALOMEDS::SObject_ptr theSObject)
+namespace VISU
 {
-  SALOMEDS::SComponent_var aSComponent = theSObject->GetFatherComponent();
-  SALOMEDS::SObject_var aFather = theSObject->GetFather();
-  CORBA::String_var aComponentID (aSComponent->GetID());
-  CORBA::String_var aFatherID    (aFather->GetID());
-  VISU::Result_var aResult;
-  while (strcmp(aComponentID, aFatherID) != 0) {
-    CORBA::Object_var anObject = VISU::SObjectToObject(aFather);
-    if (!CORBA::is_nil(anObject)) {
-      aResult = VISU::Result::_narrow(anObject);
-      if (!aResult->_is_nil()) return aResult;
+  //---------------------------------------------------------------
+  Result_var 
+  FindResult (SALOMEDS::SObject_ptr theSObject)
+  {
+    SALOMEDS::SComponent_var aSComponent = theSObject->GetFatherComponent();
+    SALOMEDS::SObject_var aFather = theSObject->GetFather();
+    CORBA::String_var aComponentID (aSComponent->GetID());
+    CORBA::String_var aFatherID    (aFather->GetID());
+    Result_var aResult;
+    while (strcmp(aComponentID, aFatherID) != 0) {
+      CORBA::Object_var anObject = SObjectToObject(aFather);
+      if (!CORBA::is_nil(anObject)) {
+       aResult = Result::_narrow(anObject);
+       if (!aResult->_is_nil()) return aResult;
+      }
+      aFather = aFather->GetFather();
+      aFatherID = aFather->GetID();
     }
-    aFather = aFather->GetFather();
-    aFatherID = aFather->GetID();
+    return aResult;
   }
-  return aResult;
-}
 
 
-namespace VISU
-{
   //---------------------------------------------------------------
   typedef boost::recursive_mutex TMutex;
   typedef TMutex::scoped_lock TLock;
@@ -148,7 +148,7 @@ namespace VISU
       aMap[theName] = 0;
       tmp = theName;
     } else {
-      tmp = VISU::GenerateName(theName,++aMap[theName]);
+      tmp = GenerateName(theName,++aMap[theName]);
     }
     if(MYDEBUG) MESSAGE("GenerateName - "<<tmp<<" from - "<<theName<<"; " <<aMap[theName]);
     return tmp;
@@ -256,9 +256,9 @@ namespace VISU
   //---------------------------------------------------------------
   struct TResultManager
   {
-    VISU::Result_i* myResult;
+    Result_i* myResult;
 
-    TResultManager(VISU::Result_i* theResult):
+    TResultManager(Result_i* theResult):
       myResult(theResult)
     {
       myResult->Register();
@@ -331,11 +331,110 @@ namespace VISU
 
   //---------------------------------------------------------------
   void
-  BuildGroups(VISU::Result_i* theResult,
+  BuildEntities(Result_i* theResult,
+               VISU_Convertor* theInput,
+               CORBA::Boolean* theIsDone,
+               std::string theResultEntry,
+               _PTR(Study) theStudy)
+  {
+    if(*theIsDone)
+      return;
+
+    TTimerLog aTimerLog(MYTIMEDEBUG,"Result_i::BuildEntities");
+    TResultManager aResultManager(theResult);
+    TTransactionManager aTransactionManager(theStudy);
+
+    {
+      TTimerLog aTimerLog(MYTIMEDEBUG,"theInput->BuildEntities");
+      theInput->BuildEntities();
+    }
+
+    QString aComment;
+    const TMeshMap& aMeshMap = theInput->GetMeshMap();
+    TMeshMap::const_iterator aMeshMapIter = aMeshMap.begin();
+    for(; aMeshMapIter != aMeshMap.end(); aMeshMapIter++){
+      const string& aMeshName = aMeshMapIter->first;
+      const PMesh& aMesh = aMeshMapIter->second;
+      const TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
+      if(aMeshOnEntityMap.empty()) 
+       continue;
+    
+      aComment.sprintf("myComment=MESH;myName=%s;myDim=%d",
+                      aMeshName.c_str(),
+                      aMesh->myDim);
+      aMesh->myEntry = 
+       CreateAttributes(theStudy,
+                        theResultEntry,
+                        "",
+                        aMeshName,
+                        "",
+                        aComment.latin1(),
+                        true);
+    
+      aComment.sprintf("myComment=FAMILIES;myMeshName=%s",
+                      aMeshName.c_str());
+      string aSubMeshesEntry = 
+       CreateAttributes(theStudy,
+                        aMesh->myEntry,
+                        "",
+                        "Families",
+                        "",
+                        aComment.latin1(),
+                        true);
+      //Import entities
+      TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter = aMeshOnEntityMap.begin();
+      for(; aMeshOnEntityMapIter != aMeshOnEntityMap.end(); aMeshOnEntityMapIter++){
+       const TEntity& anEntity = aMeshOnEntityMapIter->first;
+       const PMeshOnEntity& aMeshOnEntity = aMeshOnEntityMapIter->second;
+       
+       string anEntityName;
+       switch(anEntity){
+       case NODE_ENTITY: 
+         anEntityName = "onNodes"; 
+         break;
+       case EDGE_ENTITY: 
+         anEntityName = "onEdges"; 
+         break;
+       case FACE_ENTITY: 
+         anEntityName = "onFaces"; 
+         break;
+       case CELL_ENTITY: 
+         anEntityName = "onCells"; 
+         break;
+       default:
+       continue;
+       }
+       
+       aComment.sprintf("myComment=ENTITY;myType=%d;myMeshName=%s;myId=%d",
+                        VISU::TENTITY,
+                        aMeshName.c_str(),
+                        anEntity);
+       
+       aMeshOnEntity->myEntry = 
+         CreateAttributes(theStudy, 
+                          aSubMeshesEntry, 
+                          "", 
+                          anEntityName.c_str(), 
+                          "", 
+                          aComment.latin1(), 
+                          true);
+      }
+    }
+    
+    ProcessVoidEvent(new TUpdateObjBrowser(theStudy->StudyId(),theIsDone));
+  }
+
+  //---------------------------------------------------------------
+  void
+  BuildGroups(Result_i* theResult,
              VISU_Convertor* theInput,
              CORBA::Boolean* theIsDone,
+             CORBA::Boolean theIsBuild,
              _PTR(Study) theStudy)
   {
+    if(!theIsBuild || *theIsDone)
+      return;
+
     TTimerLog aTimerLog(MYTIMEDEBUG,"Result_i::BuildGroups");
     TResultManager aResultManager(theResult);
     TTransactionManager aTransactionManager(theStudy);
@@ -426,11 +525,15 @@ namespace VISU
 
   //---------------------------------------------------------------
   void
-  BuildFields(VISU::Result_i* theResult,
+  BuildFields(Result_i* theResult,
              VISU_Convertor* theInput,
              CORBA::Boolean* theIsDone,
+             CORBA::Boolean theIsBuild,
              _PTR(Study) theStudy)
   {
+    if(!theIsBuild || *theIsDone)
+      return;
+
     TTimerLog aTimerLog(MYTIMEDEBUG,"Result_i::BuildFields");
     TResultManager aResultManager(theResult);
     TTransactionManager aTransactionManager(theStudy);
@@ -480,7 +583,7 @@ namespace VISU
          const TValField& aValField = aField->myValField;
          QString aFieldNameWithUnit = GenerateFieldName(aFieldName,aField->myUnitNames[0]);
          aComment.sprintf("myComment=FIELD;myType=%d;myMeshName=%s;myEntityId=%d;myName=%s;myNbTimeStamps=%d;myNumComponent=%d",
-                          VISU::TFIELD,
+                          TFIELD,
                           aMeshName.c_str(),
                           anEntity,
                           aFieldName.c_str(),
@@ -502,7 +605,7 @@ namespace VISU
            int aTimeStamp = aValFieldIter->first;
            const PValForTime& aValForTime = aValFieldIter->second;
            aComment.sprintf("myComment=TIMESTAMP;myType=%d;myMeshName=%s;myEntityId=%d;myFieldName=%s;myTimeStampId=%d;myNumComponent=%d",
-                            VISU::TTIMESTAMP,
+                            TTIMESTAMP,
                             aMeshName.c_str(),
                             anEntity,
                             aFieldName.c_str(),
@@ -528,10 +631,14 @@ namespace VISU
 
   //---------------------------------------------------------------
   void
-  BuildMinMax(VISU::Result_i* theResult,
+  BuildMinMax(Result_i* theResult,
              VISU_Convertor* theInput,
-             CORBA::Boolean* theIsDone)
+             CORBA::Boolean* theIsDone,
+             CORBA::Boolean theIsBuild)
   {
+    if(!theIsBuild || *theIsDone)
+      return;
+
     TTimerLog aTimerLog(MYTIMEDEBUG,"Result_i::BuildMinMax");
     TResultManager aResultManager(theResult);
     
@@ -542,26 +649,97 @@ namespace VISU
 
   //---------------------------------------------------------------
   void
-  BuildDataTree(VISU::Result_i* theResult,
-               VISU_Convertor* theInput,
-               CORBA::Boolean* theIsFieldsDone,
-               CORBA::Boolean* theIsMinMaxDone,
-               CORBA::Boolean* theIsGroupsDone,
-               _PTR(Study) theStudy)
+  BuildFieldDataTree(Result_i* theResult,
+                    VISU_Convertor* theInput,
+                    CORBA::Boolean* theIsFieldsDone,
+                    CORBA::Boolean theIsBuildFields,
+                    CORBA::Boolean* theIsMinMaxDone,
+                    CORBA::Boolean theIsBuildMinMax,
+                    _PTR(Study) theStudy)
   {
     BuildFields(theResult,
                theInput,
                theIsFieldsDone,
+               theIsBuildFields,
                theStudy);
 
     BuildMinMax(theResult,
                theInput,
-               theIsMinMaxDone);
+               theIsMinMaxDone,
+               theIsBuildMinMax);
+  }
+  
 
-    BuildGroups(theResult,
-               theInput,
-               theIsGroupsDone,
-               theStudy);
+  //---------------------------------------------------------------
+  struct TBuildArgs
+  {
+    Result_i* myResult;
+    VISU_Convertor* myInput;
+    CORBA::Boolean* myIsEntitiesDone;
+    std::string myResultEntry;
+    CORBA::Boolean* myIsFieldsDone;
+    CORBA::Boolean myIsBuildFields;
+    CORBA::Boolean* myIsMinMaxDone;
+    CORBA::Boolean myIsBuildMinMax;
+    CORBA::Boolean* myIsGroupsDone;
+    CORBA::Boolean myIsBuildGroups;
+    _PTR(Study) myStudy;
+
+    TBuildArgs(Result_i* theResult,
+              VISU_Convertor* theInput,
+              CORBA::Boolean* theIsEntitiesDone,
+              std::string theResultEntry,
+              CORBA::Boolean* theIsFieldsDone,
+              CORBA::Boolean theIsBuildFields,
+              CORBA::Boolean* theIsMinMaxDone,
+              CORBA::Boolean theIsBuildMinMax,
+              CORBA::Boolean* theIsGroupsDone,
+              CORBA::Boolean theIsBuildGroups,
+              _PTR(Study) theStudy):
+      myResult(theResult),
+      myInput(theInput),
+      myIsEntitiesDone(theIsEntitiesDone),
+      myResultEntry(theResultEntry),
+      myIsFieldsDone(theIsFieldsDone),
+      myIsBuildFields(theIsBuildFields),
+      myIsMinMaxDone(theIsMinMaxDone),
+      myIsBuildMinMax(theIsBuildMinMax),
+      myIsGroupsDone(theIsGroupsDone),
+      myIsBuildGroups(theIsBuildGroups),
+      myStudy(theStudy)
+    {}
+      
+  };
+
+  //---------------------------------------------------------------
+  void
+  BuildDataTree(TBuildArgs theBuildArgs)
+  {
+    BuildEntities(theBuildArgs.myResult,
+                 theBuildArgs.myInput,
+                 theBuildArgs.myIsEntitiesDone,
+                 theBuildArgs.myResultEntry,
+                 theBuildArgs.myStudy);
+
+    {
+      boost::thread aThread(boost::bind(&BuildFieldDataTree,
+                                       theBuildArgs.myResult,
+                                       theBuildArgs.myInput,
+                                       theBuildArgs.myIsFieldsDone,
+                                       theBuildArgs.myIsBuildFields,
+                                       theBuildArgs.myIsMinMaxDone,
+                                       theBuildArgs.myIsBuildMinMax,
+                                       theBuildArgs.myStudy));
+    }
+
+    {
+      boost::thread aThread(boost::bind(&BuildGroups,
+                                       theBuildArgs.myResult,
+                                       theBuildArgs.myInput,
+                                       theBuildArgs.myIsGroupsDone,
+                                       theBuildArgs.myIsBuildGroups,
+                                       theBuildArgs.myStudy));
+    }
   }
   
 }
@@ -575,15 +753,21 @@ const char* VISU::Result_i::GetComment() const { return myComment.c_str();}
 VISU::Result_i
 ::Result_i (SALOMEDS::Study_ptr theStudy,
            const ESourceId& theSourceId,
-           const ECreationId& theCreationId):
+           const ECreationId& theCreationId,
+           CORBA::Boolean theIsBuildImmediately):
   myStudyDocument(SALOMEDS::Study::_duplicate(theStudy)),
   myCreationId(theCreationId),
   mySourceId(theSourceId),
+  myIsBuildImmediately(theIsBuildImmediately),
   myInput(NULL),
-  myIsFieldsDone(0),
-  myIsGroupsDone(0),
-  myIsMinMaxDone(0),
-  myIsDone(0)
+  myIsEntitiesDone(false),
+  myIsFieldsDone(false),
+  myIsGroupsDone(false),
+  myIsMinMaxDone(false),
+  myIsBuildFields(true),
+  myIsBuildGroups(true),
+  myIsBuildMinMax(true),
+  myIsAllDone(false)
 {
   myStudy = ProcessEvent(new TGetStudy(myStudyDocument->StudyId()));
 }
@@ -624,9 +808,11 @@ CORBA::Boolean
 VISU::Result_i
 ::BuildAll()
 {
-  if(MYDEBUG) MESSAGE("Result_i::Build - myIsDone = "<<myIsDone);
-  if(myIsDone) return 1;
-  if(!IsPossible()) return 0;
+  if(MYDEBUG) MESSAGE("Result_i::Build - myIsAllDone = "<<myIsAllDone);
+  if(myIsAllDone) 
+    return 1;
+  if(!IsPossible()) 
+    return 0;
   try{
     const VISU::TMeshMap& aMeshMap = myInput->GetMeshMap();
     VISU::TMeshMap::const_iterator aMeshMapIter = aMeshMap.begin();
@@ -694,30 +880,48 @@ VISU::Result_i
        }
       }
     }
-    myIsDone = 1;
+    myIsAllDone = 1;
   }catch(std::exception& exc){
     INFOS("Follow exception was occured :\n"<<exc.what());
   }catch(...){
     INFOS("Unknown exception was occured!!!");
   }
-  return myIsDone;
+  return myIsAllDone;
 }
 
 
 //---------------------------------------------------------------
-void
+CORBA::Boolean
 VISU::Result_i
-::BuildEntities(SALOMEDS::SObject_ptr theSObject)
+::Build(CORBA::Boolean theIsBuildAll,
+       CORBA::Boolean theIsAtOnce)
 {
-  TTimerLog aTimerLog(MYTIMEDEBUG,"Result_i::BuildEntities");
-  TResultManager aResultManager(this);
-  TTransactionManager aTransactionManager(myStudy);
+  if(theIsBuildAll)
+    theIsAtOnce = true;
 
-  QString aComment;
+  if(Build(SALOMEDS::SObject::_nil(),theIsAtOnce)){
+    if(theIsBuildAll)
+      return BuildAll();
+    return true;
+  }
+
+  return false;
+}
+
+
+//---------------------------------------------------------------
+VISU::Storable*
+VISU::Result_i
+::Build(SALOMEDS::SObject_ptr theSObject,
+       CORBA::Boolean theIsAtOnce)
+{
+  if(IsDone())
+    return this;
 
   mySComponent = FindOrCreateVisuComponent(myStudyDocument);
   CORBA::String_var aSComponentEntry = mySComponent->GetID();
   CORBA::String_var anIOR(GetID());
+  QString aComment;
   aComment.sprintf("myComment=%s;myType=%d;myFileName=%s;myInitFileName=%s",
                   GetComment(),
                   VISU::TRESULT,
@@ -737,104 +941,46 @@ VISU::Result_i
     CreateReference(myStudyDocument,aResultEntry,aString.in());
   }
 
-  myInput->BuildEntities();
-  const TMeshMap& aMeshMap = myInput->GetMeshMap();
-  TMeshMap::const_iterator aMeshMapIter = aMeshMap.begin();
-  for(; aMeshMapIter != aMeshMap.end(); aMeshMapIter++){
-    const string& aMeshName = aMeshMapIter->first;
-    const PMesh& aMesh = aMeshMapIter->second;
-    const TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
-    if(aMeshOnEntityMap.empty()) 
-      continue;
+  if(theIsAtOnce){
+    BuildEntities(this,
+                 myInput,
+                 &myIsEntitiesDone,
+                 aResultEntry,
+                 myStudy);
     
-    aComment.sprintf("myComment=MESH;myName=%s;myDim=%d",
-                    aMeshName.c_str(),
-                    aMesh->myDim);
-    aMesh->myEntry = 
-      CreateAttributes(myStudy,
-                      aResultEntry,
-                      "",
-                      aMeshName,
-                      "",
-                      aComment.latin1(),
-                      true);
+    BuildFields(this,
+               myInput,
+               &myIsFieldsDone,
+               myIsBuildFields,
+               myStudy);
     
-    aComment.sprintf("myComment=FAMILIES;myMeshName=%s",
-                    aMeshName.c_str());
-    string aSubMeshesEntry = 
-      CreateAttributes(myStudy,
-                      aMesh->myEntry,
-                      "",
-                      "Families",
-                      "",
-                      aComment.latin1(),
-                      true);
-    //Import entities
-    TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter = aMeshOnEntityMap.begin();
-    for(; aMeshOnEntityMapIter != aMeshOnEntityMap.end(); aMeshOnEntityMapIter++){
-      const TEntity& anEntity = aMeshOnEntityMapIter->first;
-      const PMeshOnEntity& aMeshOnEntity = aMeshOnEntityMapIter->second;
-      
-      string anEntityName;
-      switch(anEntity){
-      case NODE_ENTITY: 
-       anEntityName = "onNodes"; 
-       break;
-      case EDGE_ENTITY: 
-       anEntityName = "onEdges"; 
-       break;
-      case FACE_ENTITY: 
-       anEntityName = "onFaces"; 
-       break;
-      case CELL_ENTITY: 
-       anEntityName = "onCells"; 
-       break;
-      default:
-       continue;
-      }
-      
-      aComment.sprintf("myComment=ENTITY;myType=%d;myMeshName=%s;myId=%d",
-                      VISU::TENTITY,
-                      aMeshName.c_str(),
-                      anEntity);
-      
-      aMeshOnEntity->myEntry = 
-       CreateAttributes(myStudy, 
-                        aSubMeshesEntry, 
-                        "", 
-                        anEntityName.c_str(), 
-                        "", 
-                        aComment.latin1(), 
-                        true);
-    }
-  }
-  
-  CORBA::Boolean anIsEntitiesDone;
-  ProcessVoidEvent(new TUpdateObjBrowser(myStudy->StudyId(),&anIsEntitiesDone));
-}
-
-
-//---------------------------------------------------------------
-VISU::Storable*
-VISU::Result_i
-::Build(SALOMEDS::SObject_ptr theSObject)
-{
-  bool isBuildAll = VISU::GetResourceMgr()->booleanValue("VISU", "full_med_loading", false);
-  if(isBuildAll) 
-    return BuildAll(theSObject);
-  else{
-    BuildEntities(theSObject);
-
-    // To start build of the fields, groups and perfrom min/max calculation
+    BuildMinMax(this,
+               myInput,
+               &myIsMinMaxDone,
+               myIsBuildMinMax);
+    
+    BuildGroups(this,
+               myInput,
+               &myIsGroupsDone,
+               myIsBuildGroups,
+               myStudy);
+  }else{
+    TBuildArgs aBuildArgs(this,
+                         myInput,
+                         &myIsEntitiesDone,
+                         aResultEntry,
+                         &myIsFieldsDone,
+                         myIsBuildFields,
+                         &myIsMinMaxDone,
+                         myIsBuildMinMax,
+                         &myIsGroupsDone,
+                         myIsBuildGroups,
+                         myStudy);
     boost::thread aThread(boost::bind(&BuildDataTree,
-                                     this,
-                                     myInput,
-                                     &myIsFieldsDone,
-                                     &myIsMinMaxDone,
-                                     &myIsGroupsDone,
-                                     myStudy));
-    return this;
+                                     aBuildArgs));
   }
+
+  return this;
 }
 
 
@@ -845,22 +991,7 @@ VISU::Result_i
 {
   if(MYDEBUG) MESSAGE("Result_i::Build");
   try{
-    BuildEntities(theSObject);
-
-    BuildFields(this,
-               myInput,
-               &myIsFieldsDone,
-               myStudy);
-
-    BuildMinMax(this,
-               myInput,
-               &myIsMinMaxDone);
-
-    BuildGroups(this,
-               myInput,
-               &myIsGroupsDone,
-               myStudy);
-
+    Build(theSObject);
     BuildAll();
   }catch(std::exception& exc){
     INFOS("Follow exception was occured :\n"<<exc.what());
@@ -895,9 +1026,11 @@ Create(const char* theFileName)
       myFileInfo.setFile(QString(aTmpDir.c_str()) + myFileInfo.fileName());
     }
     myInput = CreateConvertor(myFileInfo.absFilePath().latin1());
-    if(!myInput)
-      throw std::runtime_error("Create - Cannot create a Convertor for this file!!!");
-    return Build();
+    if(myInput){
+      if(myIsBuildImmediately)
+       Build(SALOMEDS::SObject::_nil(),false); //apo
+      return this;
+    }
   }catch(std::exception& exc){
     INFOS("Follow exception was occured :\n"<<exc.what());
   }catch(...){
@@ -918,14 +1051,15 @@ Create(SALOMEDS::SObject_ptr theMedSObject)
     if(myInput == NULL)
       return NULL;
 
+    myInput->Build();
+
     string aCompDataType = GetComponentDataType(theMedSObject);
     myFileInfo.setFile(aCompDataType.c_str());
     myInitFileName = aCompDataType;
 
     myName = ::GenerateName("aResult").latin1();
 
-    VISU::Storable* aStorable = Build(theMedSObject);
-    return aStorable;
+    return Build(theMedSObject);
   }catch(std::exception& exc){
     INFOS("Follow exception was occured :\n"<<exc.what());
   }catch(...){
@@ -946,6 +1080,8 @@ Create(SALOME_MED::FIELD_ptr theField)
     if(myInput == NULL)
       return NULL;
 
+    myInput->Build();
+
     string aCompDataType = "MED";
     myFileInfo.setFile(aCompDataType.c_str());
     myInitFileName = aCompDataType;
@@ -955,8 +1091,7 @@ Create(SALOME_MED::FIELD_ptr theField)
     CORBA::String_var anIOR = myStudyDocument->ConvertObjectToIOR(theField);
     SALOMEDS::SObject_var aFieldSObject = myStudyDocument->FindObjectIOR(anIOR);
 
-    VISU::Storable* aStorable = Build(aFieldSObject);
-    return aStorable;
+    return Build(aFieldSObject);
   }catch(std::exception& exc){
     INFOS("Follow exception was occured :\n"<<exc.what());
   }catch(...){
@@ -996,9 +1131,10 @@ 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)
+      if (strcmp(aDataType, "MED") == 0){
        myInput = CreateMEDConvertor(aTargetRefSObj);
-      else
+       myInput->Build();
+      }else
        throw std::runtime_error("GetInput - There is no convertor for the aDataType !!!");
     } else {
       myFileInfo.setFile(thePrefix.c_str());
@@ -1053,6 +1189,7 @@ Restore(SALOMEDS::SObject_ptr theSObject,
       }
       if(MYDEBUG) MESSAGE("VISU::Result_i::Restore - mySourceId = " << mySourceId);
       myInput = CreateConvertor(myFileInfo.filePath().latin1());
+      myInput->Build();
       QString aComment;
       aComment.sprintf("myComment=%s;myType=%d;myFileName=%s;myInitFileName=%s",
                       GetComment(), VISU::TRESULT, myFileInfo.filePath().latin1(),
@@ -1084,6 +1221,43 @@ VISU::Result_i
 }
 
 //---------------------------------------------------------------
+CORBA::Boolean 
+VISU::Result_i
+::IsDone() 
+{
+  return 
+    myIsEntitiesDone && 
+    (myIsBuildFields && myIsFieldsDone) &&
+    (myIsBuildMinMax && myIsMinMaxDone) &&
+    (myIsBuildGroups && myIsGroupsDone);
+}
+
+CORBA::Boolean 
+VISU::Result_i
+::IsEntitiesDone() 
+{
+  return myIsEntitiesDone;
+}
+
+void
+VISU::Result_i
+::SetBuildFields(CORBA::Boolean theIsBuildFields, 
+                CORBA::Boolean theIsCalculateMinMax)
+{
+  myIsBuildFields = theIsBuildFields;
+  if(theIsBuildFields)
+    myIsBuildMinMax = theIsCalculateMinMax;
+  else
+    myIsBuildMinMax = false;
+}
+
+void
+VISU::Result_i
+::SetBuildGroups(CORBA::Boolean theIsBuildGroups)
+{
+  myIsBuildGroups = theIsBuildGroups;
+}
+
 CORBA::Boolean 
 VISU::Result_i
 ::IsFieldsDone() 
@@ -1144,7 +1318,6 @@ string
 VISU::Result_i
 ::GetRefFatherEntry() 
 {
-  //return QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->entry();
   return "";
 }
 
index d414ff0b53151285d29f431edc46d934f34cdfce..e56cc0f6b60c6f569f14486ace2e7fdd29ede5d8 100644 (file)
@@ -50,7 +50,8 @@ namespace VISU{
 
     Result_i(SALOMEDS::Study_ptr theStudy,
             const ESourceId& theSourceId,
-            const ECreationId& theCreationId);
+            const ECreationId& theCreationId,
+            CORBA::Boolean theIsBuildImmediately = true);
 
     virtual ~Result_i();
     virtual void RemoveFromStudy();
@@ -58,8 +59,19 @@ namespace VISU{
     virtual VISU::VISUType GetType() { return VISU::TRESULT;}
     virtual CORBA::Boolean BuildAll();
 
+    virtual CORBA::Boolean Build(CORBA::Boolean theIsBuildAll,
+                                CORBA::Boolean theIsAtOnce);
+    virtual CORBA::Boolean IsDone();
+
+    virtual CORBA::Boolean IsEntitiesDone();
+
+    virtual void SetBuildFields(CORBA::Boolean theIsBuildFields, 
+                               CORBA::Boolean theIsCalculateMinMax);
     virtual CORBA::Boolean IsFieldsDone();
+
+    virtual void SetBuildGroups(CORBA::Boolean theIsBuildGroups);
     virtual CORBA::Boolean IsGroupsDone();
+
     virtual CORBA::Boolean IsMinMaxDone();
 
     typedef VISU_Convertor TInput;
@@ -69,19 +81,28 @@ namespace VISU{
     ECreationId myCreationId;
 
     TInput *myInput;
-    CORBA::Boolean myIsDone;
     std::string myName, myInitFileName;
     QFileInfo myFileInfo;
 
   protected:
-    virtual Storable* Build(SALOMEDS::SObject_ptr theSObject = SALOMEDS::SObject::_nil()) ;
+    virtual Storable* Build(SALOMEDS::SObject_ptr theSObject,
+                           CORBA::Boolean theIsAtOnce = true) ;
     virtual Storable* BuildAll(SALOMEDS::SObject_ptr theSObject) ;
 
-    void BuildEntities(SALOMEDS::SObject_ptr theSObject);
+    _PTR(Study) myStudy;
+    CORBA::Boolean myIsBuildImmediately;
+
+    CORBA::Boolean myIsEntitiesDone;
     CORBA::Boolean myIsFieldsDone;
     CORBA::Boolean myIsGroupsDone;
     CORBA::Boolean myIsMinMaxDone;
 
+    CORBA::Boolean myIsBuildFields;
+    CORBA::Boolean myIsBuildGroups;
+    CORBA::Boolean myIsBuildMinMax;
+
+    CORBA::Boolean myIsAllDone;
+
   public:
     virtual int IsPossible();
 
@@ -108,7 +129,6 @@ namespace VISU{
     const ECreationId& GetCreationId() const { return myCreationId;}
 
   private:
-    _PTR(Study) myStudy;
     SALOMEDS::SObject_var mySObject;
     SALOMEDS::Study_var myStudyDocument;
     SALOMEDS::SComponent_var mySComponent;