#include <vtkRenderWindow.h>
#ifdef _DEBUG_
-static int MYDEBUG = 0;
+static int MYDEBUG = 1;
#else
-static int MYDEBUG = 0;
+static int MYDEBUG = 1;
#endif
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();
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);
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
aPrs3d->SetActiveState(true);
//aLastVisitedPrs3d->RemoveActors();
}
- //aViewWindow->Repaint();
aViewWindow->getRenderWindow()->Render();
return true;
}
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);
+}
//----------------------------------------------------------------------------
//! 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();
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
//! Unregister the holder instance from cache
void
RemoveHolder(VISU::ColoredPrs3dHolder_i* theHolder);
+
+ public:
+ static const std::string myComment;
+
protected:
//----------------------------------------------------------------------------
virtual int
VISU::ColoredPrs3dCache::MemoryMode myMemoryMode;
TColoredPrs3dHolderMap myHolderMap;
-
- static const std::string myComment;
};
#include "VISU_ColoredPrs3dCache_i.hh"
#include "VISU_ColoredPrs3d_i.hh"
+#include "VISU_Gen_i.hh"
using namespace VISU;
using namespace std;
//----------------------------------------------------------------------------
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;
+}
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
const std::string& theComment);
VISU::ColoredPrs3dCache_i& myCache;
- static const std::string myComment;
static int myNbHolders;
};
}
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));
}