]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
Force saving of presentations parameters during saving of animation
authorjfa <jfa@opencascade.com>
Wed, 14 Sep 2005 06:35:35 +0000 (06:35 +0000)
committerjfa <jfa@opencascade.com>
Wed, 14 Sep 2005 06:35:35 +0000 (06:35 +0000)
src/VISU_I/VISU_TimeAnimation.cxx

index de93129cd35c7114697bc64174ae8bc4715074cf..46ec8a89683a25930196529be6e25aedc0c72163 100644 (file)
@@ -664,19 +664,18 @@ SALOMEDS::SObject_ptr VISU_TimeAnimation::publishInStudy()
 
   for (int i = 0; i < getNbFields(); i++) {
     FieldData& aData = myFieldsLst[i];
+
     _PTR(SObject) newObj = aStudyBuilder->NewObject(aAnimSObject);
     aStudyBuilder->Addreference(newObj, aData.myField);
+
     if (aData.myPrs.empty()) {
       generatePresentations(i);
-      //VISU::CreateAttributes(myStudy, newObj->GetID().c_str(),"","",
-      //                       GetPresentationComment(aData.myPrsType).c_str(),"","",true);
-    }// else {
-      ostringstream strOut;
-      aData.myPrs[0]->ToStream(strOut);
-      string aPrsComment = strOut.str();
-      VISU::CreateAttributes(myStudy, newObj->GetID().c_str(),"","",
-                             aData.myPrs[0]->GetComment(),"",aPrsComment.c_str(),true);
-    //}
+    }
+    ostringstream strOut;
+    aData.myPrs[0]->ToStream(strOut);
+    string aPrsComment = strOut.str();
+    VISU::CreateAttributes(myStudy, newObj->GetID().c_str(),"","",
+                           aData.myPrs[0]->GetComment(),"",aPrsComment.c_str(),true);
   }
   aStudyBuilder->CommitCommand();
 
@@ -686,7 +685,7 @@ SALOMEDS::SObject_ptr VISU_TimeAnimation::publishInStudy()
 //************************************************************************
 void VISU_TimeAnimation::saveAnimation()
 {
-  if (myStudy->GetProperties()->IsLocked())  return;
+  if (myStudy->GetProperties()->IsLocked()) return;
   if (myAnimEntry.isEmpty()) return;
 
   _PTR(SObject) aAnimSObject = myStudy->FindObjectID(myAnimEntry.latin1());
@@ -707,26 +706,25 @@ void VISU_TimeAnimation::saveAnimation()
   aCmnt->SetValue(aComment.latin1());
 
   _PTR(ChildIterator) anIter = myStudy->NewChildIterator(aAnimSObject);
-  int i;
-  for (i = 0, anIter->Init(); anIter->More(); anIter->Next(), i++) {
+  int i = 0, nbf = getNbFields();
+  for (anIter->Init(); anIter->More(); anIter->Next(), i++) {
+    if (i >= nbf) break; // it must not be
     FieldData& aData = myFieldsLst[i];
 
+    // Get presentation name and comment
+    if (aData.myPrs.empty()) {
+      generatePresentations(i);
+    }
+    ostringstream strOut;
+    aData.myPrs[0]->ToStream(strOut);
+    string aPrsComment = strOut.str();
+    string aPrsNameTxt = aData.myPrs[0]->GetComment();
+
+    // Save in study
     _PTR(SObject) aRefObj = anIter->Value();
     _PTR(ChildIterator) anPrsIter = myStudy->NewChildIterator(aRefObj);
     anPrsIter->Init();
 
-    string aPrsComment, aPrsNameTxt;
-    if (aData.myPrs.empty()) {
-      aPrsComment = "";
-      aPrsNameTxt = GetPresentationComment(aData.myPrsType);
-    } else {
-      ostringstream strOut;
-      aData.myPrs[0]->ToStream(strOut);
-      aPrsComment = strOut.str();
-
-      aPrsNameTxt = aData.myPrs[0]->GetComment();
-    }
-
     if (anPrsIter->More()) {
       _PTR(SObject) aPrsObj = anPrsIter->Value();
       anAttr = aStudyBuilder->FindOrCreateAttribute(aPrsObj, "AttributeComment");