From: ouv Date: Wed, 20 Dec 2006 14:48:53 +0000 (+0000) Subject: Persistance X-Git-Tag: WP1_2_3_25-12-2006_persistent_for_cache~10 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=4110dc5202bc2e072ed373984d1ac4e9984345d7;p=modules%2Fvisu.git Persistance --- diff --git a/src/VISU_I/VISU_ColoredPrs3dCache_i.cc b/src/VISU_I/VISU_ColoredPrs3dCache_i.cc index 3447140e..da9bf7a8 100644 --- a/src/VISU_I/VISU_ColoredPrs3dCache_i.cc +++ b/src/VISU_I/VISU_ColoredPrs3dCache_i.cc @@ -42,9 +42,9 @@ #include #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 = "<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(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); +} diff --git a/src/VISU_I/VISU_ColoredPrs3dCache_i.hh b/src/VISU_I/VISU_ColoredPrs3dCache_i.hh index 8f5e8a85..9e9ee833 100644 --- a/src/VISU_I/VISU_ColoredPrs3dCache_i.hh +++ b/src/VISU_I/VISU_ColoredPrs3dCache_i.hh @@ -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; }; diff --git a/src/VISU_I/VISU_ColoredPrs3dHolder_i.cc b/src/VISU_I/VISU_ColoredPrs3dHolder_i.cc index 0dfe8781..740b84e2 100644 --- a/src/VISU_I/VISU_ColoredPrs3dHolder_i.cc +++ b/src/VISU_I/VISU_ColoredPrs3dHolder_i.cc @@ -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::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::GetServant(aHolder).in() ); + + return aHolderImpl->Restore(theSObject,theMap,thePrefix); + */ + return NULL; +} diff --git a/src/VISU_I/VISU_ColoredPrs3dHolder_i.hh b/src/VISU_I/VISU_ColoredPrs3dHolder_i.hh index 78dbb6e7..a47a46b4 100644 --- a/src/VISU_I/VISU_ColoredPrs3dHolder_i.hh +++ b/src/VISU_I/VISU_ColoredPrs3dHolder_i.hh @@ -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; }; } diff --git a/src/VISU_I/VISU_Gen_i.cc b/src/VISU_I/VISU_Gen_i.cc index be084e93..05e2ab64 100644 --- a/src/VISU_I/VISU_Gen_i.cc +++ b/src/VISU_I/VISU_Gen_i.cc @@ -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)); + Storable::Registry(ColoredPrs3dHolder_i::myComment.c_str(),&(ColoredPrs3dHolder_i::Restore)); + Storable::Registry(ColoredPrs3dCache_i::myComment.c_str(),&(ColoredPrs3dCache_i::Restore)); }