//************************************************************************
VISU_TimeAnimation::VISU_TimeAnimation(SALOMEDS::Study_ptr theStudy, VISU::View3D_ptr theView3D) {
- myStudy = theStudy;
+ // myStudy = theStudy;
+ myStudy = SALOMEDS::Study::_duplicate(theStudy);
myIsActive = false;
myFrame = 0;
mySpeed = 1;
myLastError = "";
myCycling = false;
- myAnimSObject = SALOMEDS::SObject::_nil();
+ myAnimEntry = "";
+ //myAnimSObject = SALOMEDS::SObject::_nil();
}
SALOMEDS::SObject_ptr VISU_TimeAnimation::publishInStudy()
{
if (myStudy->GetProperties()->IsLocked())
- return myAnimSObject;
+ return SALOMEDS::SObject::_nil();
- if (!myAnimSObject->_is_nil()) {
- myAnimSObject = SALOMEDS::SObject::_nil();
- }
SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder();
aStudyBuilder->NewCommand(); // There is a transaction
SALOMEDS::SComponent_var aSComponent = VISU::FindOrCreateVisuComponent(myStudy);
aComment.sprintf("myComment=ANIMATION;myType=%d;myMinVal=%g;myMaxVal=%g",VISU::TANIMATION,myMinVal,myMaxVal);
string anEntry = VISU::CreateAttributes(myStudy,aSComponentEntry.in(),"","", GenerateName(),"",aComment,true);
- myAnimSObject = myStudy->FindObjectID(anEntry.c_str());
+ myAnimEntry = anEntry.c_str();
+ SALOMEDS::SObject_var aAnimSObject = myStudy->FindObjectID(anEntry.c_str());
for (int i = 0; i < getNbFields(); i++) {
FieldData& aData = myFieldsLst[i];
- SALOMEDS::SObject_var newObj = aStudyBuilder->NewObject(myAnimSObject);
+ SALOMEDS::SObject_var newObj = aStudyBuilder->NewObject(aAnimSObject);
aStudyBuilder->Addreference(newObj, aData.myField);
if (!aData.myPrs.empty()) {
ostringstream strOut;
}
}
aStudyBuilder->CommitCommand();
- return myAnimSObject;
+ return aAnimSObject._retn();
}
//************************************************************************
void VISU_TimeAnimation::saveAnimation()
{
- if (myStudy->GetProperties()->IsLocked()) return ;
- if (myAnimSObject->_is_nil()) return;
+ if (myStudy->GetProperties()->IsLocked()) return;
+ // if (myAnimSObject->_is_nil()) return;
+ if (myAnimEntry.isEmpty()) return;
+
+ SALOMEDS::SObject_var aAnimSObject = myStudy->FindObjectID(myAnimEntry);
+ if (aAnimSObject->_is_nil()) return;
SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder();
aStudyBuilder->NewCommand(); // There is a transaction
aComment.sprintf("myComment=ANIMATION;myType=%d;myMinVal=%g;myMaxVal=%g",VISU::TANIMATION,myMinVal,myMaxVal);
SALOMEDS::GenericAttribute_var anAttr;
- anAttr = aStudyBuilder->FindOrCreateAttribute(myAnimSObject, "AttributeComment");
+ anAttr = aStudyBuilder->FindOrCreateAttribute(aAnimSObject, "AttributeComment");
SALOMEDS::AttributeComment_var aCmnt = SALOMEDS::AttributeComment::_narrow(anAttr);
aCmnt->SetValue(aComment);
- SALOMEDS::ChildIterator_var anIter = myStudy->NewChildIterator(myAnimSObject);
+ SALOMEDS::ChildIterator_var anIter = myStudy->NewChildIterator(aAnimSObject);
int i;
for (i = 0, anIter->Init(); anIter->More(); anIter->Next(), i++) {
SALOMEDS::SObject_var aRefObj = anIter->Value();
SALOMEDS::AttributeName_var aPrsName = SALOMEDS::AttributeName::_narrow(anAttr);
aPrsName->SetValue(aData.myPrs[0]->GetComment());
}
+ aStudyBuilder->CommitCommand();
}
//************************************************************************
void VISU_TimeAnimation::restoreFromStudy(SALOMEDS::SObject_ptr theField)
{
- myAnimSObject = SALOMEDS::SObject::_duplicate(theField);
+ SALOMEDS::SObject_var aAnimSObject = SALOMEDS::SObject::_duplicate(theField);
VISU::Storable::TRestoringMap aMap;
SALOMEDS::GenericAttribute_var anAttr;
- if (!myAnimSObject->FindAttribute(anAttr, "AttributeComment")) return;
+ if (!aAnimSObject->FindAttribute(anAttr, "AttributeComment")) return;
SALOMEDS::AttributeComment_var aComment = SALOMEDS::AttributeComment::_narrow(anAttr);
string aComm = aComment->Value();
myMinVal = VISU::Storable::FindValue(aMap,"myMinVal",&isExist).toDouble();
myMaxVal = VISU::Storable::FindValue(aMap,"myMaxVal",&isExist).toDouble();
- SALOMEDS::ChildIterator_var anIter = myStudy->NewChildIterator(myAnimSObject);
+ SALOMEDS::ChildIterator_var anIter = myStudy->NewChildIterator(aAnimSObject);
for (anIter->Init(); anIter->More(); anIter->Next()) {
SALOMEDS::SObject_var aRefObj = anIter->Value();
SALOMEDS::SObject_var aFieldObj;
addField(aFieldObj);
FieldData& aData = getFieldData(getNbFields()-1);
+ // Get Presentation object
SALOMEDS::ChildIterator_var anPrsIter = myStudy->NewChildIterator(aRefObj);
anPrsIter->Init();
if (!anPrsIter->More()) continue;
aData.myPrs[i]->SameAs(aData.myPrs[0]);
}
}
-
+ CORBA::String_var aEntry = aAnimSObject->GetID();
+ string aStr(aEntry);
+ myAnimEntry = aStr.c_str();
}