]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
Persistance
authorouv <ouv@opencascade.com>
Wed, 20 Dec 2006 14:48:53 +0000 (14:48 +0000)
committerouv <ouv@opencascade.com>
Wed, 20 Dec 2006 14:48:53 +0000 (14:48 +0000)
src/VISU_I/VISU_ColoredPrs3dCache_i.cc
src/VISU_I/VISU_ColoredPrs3dCache_i.hh
src/VISU_I/VISU_ColoredPrs3dHolder_i.cc
src/VISU_I/VISU_ColoredPrs3dHolder_i.hh
src/VISU_I/VISU_Gen_i.cc

index 3447140e2a82775609eb513e74d98946272edc34..da9bf7a897e0104e4e0e675929cb4fd52985ae4d 100644 (file)
@@ -42,9 +42,9 @@
 #include <vtkRenderWindow.h>
 
 #ifdef _DEBUG_
-static int MYDEBUG = 0;
+static int MYDEBUG = 1;
 #else
-static int MYDEBUG = 0;
+static int MYDEBUG = 1;
 #endif
 
 namespace
@@ -200,17 +200,22 @@ namespace
 
 //----------------------------------------------------------------------------
 VISU::ColoredPrs3dCache_i
-::ColoredPrs3dCache_i(SALOMEDS::Study_ptr theStudy):
+::ColoredPrs3dCache_i(SALOMEDS::Study_ptr theStudy,
+                     bool thePublishInStudy):
   RemovableObject_i()
 {
   if(MYDEBUG) MESSAGE("ColoredPrs3dCache_i::ColoredPrs3dCache_i - this = "<<this);
   SetStudyDocument(theStudy);
 
   SetName(GetFolderName(), false);
-  CORBA::String_var anIOR = GetID();
-  SALOMEDS::SComponent_var aSComponent = VISU::FindOrCreateVisuComponent(theStudy);
-  CORBA::String_var aFatherEntry = aSComponent->GetID();
-  CreateAttributes(GetStudyDocument(), aFatherEntry.in(), "", anIOR.in(), GetName(), "", "", true);
+
+  if( thePublishInStudy )
+  {
+    CORBA::String_var anIOR = GetID();
+    SALOMEDS::SComponent_var aSComponent = VISU::FindOrCreateVisuComponent(theStudy);
+    CORBA::String_var aFatherEntry = aSComponent->GetID();
+    CreateAttributes(GetStudyDocument(), aFatherEntry.in(), "", anIOR.in(), GetName(), "", "", true);
+  }
 
   SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
 
@@ -299,13 +304,18 @@ VISU::ColoredPrs3dCache_i*
 VISU::ColoredPrs3dCache_i
 ::GetInstance_i(SALOMEDS::Study_ptr theStudy)
 {
+  cout << "VISU::ColoredPrs3dCache_i::GetInstance_i " << theStudy << endl;
   std::string aFolderName = VISU::ColoredPrs3dCache_i::GetFolderName();
   SALOMEDS::SObject_var aSObject = theStudy->FindObject(aFolderName.c_str());
   if(!CORBA::is_nil(aSObject)){
+    cout << 111 << endl;
     CORBA::Object_var anObject = aSObject->GetObject();
     VISU::ColoredPrs3dCache_var aCache = VISU::ColoredPrs3dCache::_narrow(anObject);
     if(!CORBA::is_nil(aCache))
+    {
+      cout << 222 << endl;
       return dynamic_cast<VISU::ColoredPrs3dCache_i*>(GetServant(aCache).in());
+    }
   }
   
   return new VISU::ColoredPrs3dCache_i(theStudy);
@@ -402,18 +412,6 @@ VISU::ColoredPrs3dCache_i
   return "3D Cache System"; 
 }
 
-void
-VISU::ColoredPrs3dCache_i
-::ToStream(std::ostringstream&) 
-{}
-
-VISU::Storable* 
-VISU::ColoredPrs3dCache_i
-::Restore(const Storable::TRestoringMap& theMap)
-{
-  return this;
-}
-
 //----------------------------------------------------------------------------
 VISU::ColoredPrs3d_i*
 VISU::ColoredPrs3dCache_i
@@ -565,7 +563,6 @@ VISU::ColoredPrs3dCache_i
            aPrs3d->SetActiveState(true);
            //aLastVisitedPrs3d->RemoveActors();
          }
-         //aViewWindow->Repaint();
          aViewWindow->getRenderWindow()->Render();
          return true;
        }
@@ -658,3 +655,36 @@ VISU::ColoredPrs3dCache_i
     myHolderMap.erase(anIter);
 }
 
+//----------------------------------------------------------------------------
+void
+VISU::ColoredPrs3dCache_i
+::ToStream(std::ostringstream& theStr) 
+{
+  Storable::DataToStream( theStr, "myMemoryMode", GetMemoryMode() );
+  Storable::DataToStream( theStr, "myLimitedMemory", GetLimitedMemory() );
+}
+
+//---------------------------------------------------------------
+VISU::Storable*
+VISU::ColoredPrs3dCache_i
+::Restore(SALOMEDS::SObject_ptr theSObject,
+         const Storable::TRestoringMap& theMap,
+         const string& thePrefix)
+{
+  SetMemoryMode( (VISU::ColoredPrs3dCache::MemoryMode)VISU::Storable::FindValue( theMap, "myMemoryMode" ).toInt() );
+  SetLimitedMemory( VISU::Storable::FindValue( theMap, "myLimitedMemory" ).toInt() );
+
+  return this;
+}
+
+//---------------------------------------------------------------
+VISU::Storable*
+VISU::ColoredPrs3dCache_i
+::Restore(SALOMEDS::SObject_ptr theSObject,
+         const string& thePrefix,
+         const Storable::TRestoringMap& theMap)
+{
+  SALOMEDS::Study_var aStudy = theSObject->GetStudy();
+  VISU::ColoredPrs3dCache_i* aCache = new VISU::ColoredPrs3dCache_i(aStudy, false);
+  return aCache->Restore(theSObject,theMap,thePrefix);
+}
index 8f5e8a851e34f19a500365015230688d640e26c6..9e9ee833b0d249c2e8b234b24f333b683f486d90 100644 (file)
@@ -57,7 +57,8 @@ namespace VISU
     //----------------------------------------------------------------------------
     //! A constructor to create an instance of the class
     explicit
-    ColoredPrs3dCache_i(SALOMEDS::Study_ptr theStudy);
+    ColoredPrs3dCache_i(SALOMEDS::Study_ptr theStudy,
+                       bool thePublishInStudy = true);
 
     virtual
     ~ColoredPrs3dCache_i();
@@ -117,9 +118,17 @@ namespace VISU
     void
     ToStream(std::ostringstream&);
 
-    virtual 
-    Storable* 
-    Restore(const Storable::TRestoringMap& theMap);
+    virtual
+    Storable*
+    Restore(SALOMEDS::SObject_ptr theSObject,
+           const Storable::TRestoringMap& theMap,
+           const std::string& thePrefix);
+
+    static
+    Storable*
+    Restore(SALOMEDS::SObject_ptr theSObject,
+           const std::string& thePrefix,
+           const Storable::TRestoringMap& theMap);
 
     //----------------------------------------------------------------------------
     //! Finds or creates instance of the ColoredPrs3dCache in the given SALOMEDS::Study
@@ -162,6 +171,10 @@ namespace VISU
     //! Unregister the holder instance from cache
     void
     RemoveHolder(VISU::ColoredPrs3dHolder_i* theHolder);
+
+  public:
+    static const std::string myComment;
+
   protected:
     //----------------------------------------------------------------------------
     virtual int
@@ -190,8 +203,6 @@ namespace VISU
     VISU::ColoredPrs3dCache::MemoryMode myMemoryMode;
 
     TColoredPrs3dHolderMap myHolderMap; 
-
-    static const std::string myComment;
   };
 
 
index 0dfe87817238a46ec99c29b86ad04c32a7b4cb48..740b84e243b8ffb070b39725eddb9f038fc17f10 100644 (file)
@@ -28,6 +28,7 @@
 
 #include "VISU_ColoredPrs3dCache_i.hh"
 #include "VISU_ColoredPrs3d_i.hh"
+#include "VISU_Gen_i.hh"
 
 using namespace VISU;
 using namespace std;
@@ -180,14 +181,84 @@ VISU::ColoredPrs3dHolder_i
 //----------------------------------------------------------------------------
 void
 VISU::ColoredPrs3dHolder_i
-::ToStream(std::ostringstream&) 
-{}
+::ToStream(std::ostringstream& theStr) 
+{
+  Storable::DataToStream( theStr, "myType", GetPrsType() );
+  GetPrs3dDevice()->ToStream(theStr);
+}
 
-//----------------------------------------------------------------------------
-VISU::Storable* 
+//---------------------------------------------------------------
+VISU::Storable*
 VISU::ColoredPrs3dHolder_i
-::Restore(const Storable::TRestoringMap& theMap)
+::Restore(SALOMEDS::SObject_ptr theSObject,
+         const Storable::TRestoringMap& theMap,
+         const string& thePrefix)
 {
-  return this;
+  VISU::ColoredPrs3d_i* aDevice = GetPrs3dDevice();
+  return aDevice->Restore(theMap);
 }
 
+//---------------------------------------------------------------
+VISU::Storable*
+VISU::ColoredPrs3dHolder_i
+::Restore(SALOMEDS::SObject_ptr theSObject,
+         const string& thePrefix,
+         const Storable::TRestoringMap& theMap)
+{
+  /*
+  Storable::TRestoringMap aMap = theMap;
+
+  std::string aResultEntry = VISU::Storable::FindValue(theMap,"myResultEntry");
+  cout << aResultEntry.c_str() << endl;
+
+  SALOMEDS::SObject_var aFather = theSObject->GetFather();
+  SALOMEDS::SObject_var aGrandFather = aFather->GetFather();
+  cout << aGrandFather->GetName() << endl;
+
+  VISU::Result_var aResult;
+  SALOMEDS::Study_var aStudy = theSObject->GetStudy();
+  SALOMEDS::SObject_var aSObject = aStudy->FindObjectID();
+
+  SALOMEDS::ChildIterator_var anIter = aStudy->NewChildIterator(aGrandFather);
+  for (anIter->InitEx(true); anIter->More(); anIter->Next())
+  {
+    SALOMEDS::SObject_var gotBranch = anIter->Value();
+    CORBA::Object_var anObj = SObjectToObject(gotBranch);
+    if(CORBA::is_nil(anObj))
+      continue;
+
+    aResult = VISU::Result::_narrow(anObj);
+    if(!CORBA::is_nil(aResult))
+      break;
+  }
+
+  if(CORBA::is_nil(aResult))
+    return NULL;
+
+  VISU::ColoredPrs3dHolder::BasicInput anInput;
+  anInput.myResult = aResult;
+  anInput.myMeshName = VISU::Storable::FindValue(theMap,"myMeshName").latin1();
+  anInput.myEntity = (VISU::Entity)VISU::Storable::FindValue(theMap,"myEntity").toInt();
+  anInput.myFieldName = VISU::Storable::FindValue(theMap,"myFieldName").latin1();
+  anInput.myTimeStampNumber = VISU::Storable::FindValue(theMap,"myIteration").toInt();
+
+  VISU_Gen_i* aVisuGen = VISU::Base_i::GetVisuGenImpl();
+  VISU::ColoredPrs3dCache_i* aCache =
+    dynamic_cast<VISU::ColoredPrs3dCache_i*>( VISU::GetServant(aVisuGen->GetColoredPrs3dCache(aStudy)).in() );
+
+  bool isFind = false;
+  QString aType = Storable::FindValue( theMap, "myType", &isFind );
+  if( !isFind )
+    return NULL;
+
+  VISU::VISUType aVISUType = (VISU::VISUType)( aType.toInt() );
+
+  VISU::ColoredPrs3dHolder_var aHolder = aCache->CreateHolder( aVISUType, anInput );
+
+  VISU::ColoredPrs3dHolder_i* aHolderImpl =
+    dynamic_cast<VISU::ColoredPrs3dHolder_i*>( VISU::GetServant(aHolder).in() );
+
+  return aHolderImpl->Restore(theSObject,theMap,thePrefix);
+  */
+  return NULL;
+}
index 78dbb6e759e4f1fb88f98bc41ecd6005b7c8412e..a47a46b4e88c4f57e0ea15ca3ec346e681551a2b 100644 (file)
@@ -118,14 +118,25 @@ namespace VISU
     void
     ToStream(std::ostringstream&);
 
-    virtual 
-    Storable* 
-    Restore(const Storable::TRestoringMap& theMap);
+    virtual
+    Storable*
+    Restore(SALOMEDS::SObject_ptr theSObject,
+           const Storable::TRestoringMap& theMap,
+           const std::string& thePrefix);
+
+    static
+    Storable*
+    Restore(SALOMEDS::SObject_ptr theSObject,
+           const std::string& thePrefix,
+           const Storable::TRestoringMap& theMap);
 
     virtual
     QString 
     GenerateName();
 
+  public:
+    static const std::string myComment;
+
     //----------------------------------------------------------------------------
   private:
     void
@@ -133,7 +144,6 @@ namespace VISU
                   const std::string& theComment);
 
     VISU::ColoredPrs3dCache_i& myCache;
-    static const std::string myComment;
     static int myNbHolders;
   };
 }
index be084e93d1a1c2f6e41b06c11e0f3e875ab52d6b..05e2ab64878acaec12a38aae7b65644123e48409 100644 (file)
@@ -207,6 +207,8 @@ namespace VISU
     Storable::Registry(Curve_i::myComment.c_str(),&(Curve_i::Restore));
     Storable::Registry(Container_i::myComment.c_str(),&(Container_i::Restore));
     Storable::Registry(ScalarMapOnDeformedShape_i::myComment.c_str(),&(Restore<ScalarMapOnDeformedShape_i>));
+    Storable::Registry(ColoredPrs3dHolder_i::myComment.c_str(),&(ColoredPrs3dHolder_i::Restore));
+    Storable::Registry(ColoredPrs3dCache_i::myComment.c_str(),&(ColoredPrs3dCache_i::Restore));
   }