]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
IPAL8935: Incorrect publishing of animation
authorjfa <jfa@opencascade.com>
Mon, 18 Jul 2005 11:46:37 +0000 (11:46 +0000)
committerjfa <jfa@opencascade.com>
Mon, 18 Jul 2005 11:46:37 +0000 (11:46 +0000)
src/VISUGUI/VisuGUI_TimeAnimation.cxx
src/VISU_I/VISU_TimeAnimation.cxx

index 9418696fe3eca54b0d2c0f4fc109021d675dda68..b2d43a52cbb8f899207ab0e9c0b78a5423f4bb7c 100644 (file)
@@ -61,7 +61,7 @@
 
 ArrangeDlg::ArrangeDlg(QWidget* theParent, VISU_TimeAnimation* theAnimator)
   : QDialog(theParent, "ArrangeDlg", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu),
-    myAnimator(theAnimator), myViewWindow(0)
+    myAnimator(theAnimator), myViewWindow(theAnimator->getViewer())
 {
   myCurrent = 0;
   init();
index 9b19847e56bf9774e749005049c597e70f02216b..b9f713c22dbe8b2782fc54493699c60cd139372e 100644 (file)
@@ -607,6 +607,36 @@ QString VISU_TimeAnimation::GenerateName()
   return VISU::GenerateName("Animation", myNBAnimations++);
 }
 
+//************************************************************************
+std::string GetPresentationComment (VISU::VISUType thePrsType)
+{
+  std::string aPrsCmt;
+  switch (thePrsType) {
+  case VISU::TSCALARMAP:
+    aPrsCmt = VISU::ScalarMap_i::myComment;
+    break;
+  case VISU::TISOSURFACE:
+    aPrsCmt = VISU::IsoSurfaces_i::myComment;
+    break;
+  case VISU::TCUTPLANES:
+    aPrsCmt = VISU::CutPlanes_i::myComment;
+    break;
+  case VISU::TDEFORMEDSHAPE:
+    aPrsCmt = VISU::DeformedShape_i::myComment;
+    break;
+  case VISU::TVECTORS:
+    aPrsCmt = VISU::Vectors_i::myComment;
+    break;
+  case VISU::TSTREAMLINES:
+    aPrsCmt = VISU::StreamLines_i::myComment;
+    break;
+  default:
+    aPrsCmt = "Unknown presentation";
+    break;
+  }
+  return aPrsCmt;
+}
+
 //************************************************************************
 SALOMEDS::SObject_ptr VISU_TimeAnimation::publishInStudy()
 {
@@ -631,7 +661,10 @@ SALOMEDS::SObject_ptr VISU_TimeAnimation::publishInStudy()
     FieldData& aData = myFieldsLst[i];
     _PTR(SObject) newObj = aStudyBuilder->NewObject(aAnimSObject);
     aStudyBuilder->Addreference(newObj, aData.myField);
-    if (!aData.myPrs.empty()) {
+    if (aData.myPrs.empty()) {
+      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();
@@ -670,24 +703,38 @@ void VISU_TimeAnimation::saveAnimation()
   _PTR(ChildIterator) anIter = myStudy->NewChildIterator(aAnimSObject);
   int i;
   for (i = 0, anIter->Init(); anIter->More(); anIter->Next(), i++) {
+    FieldData& aData = myFieldsLst[i];
+
     _PTR(SObject) aRefObj = anIter->Value();
     _PTR(ChildIterator) anPrsIter = myStudy->NewChildIterator(aRefObj);
     anPrsIter->Init();
-    if (!anPrsIter->More()) continue;
-    FieldData& aData = myFieldsLst[i];
-    if (aData.myPrs.empty()) continue;
 
-    _PTR(SObject) aPrsObj = anPrsIter->Value();
-    ostringstream strOut;
-    aData.myPrs[0]->ToStream(strOut);
-    string aPrsComment = strOut.str();
-    anAttr = aStudyBuilder->FindOrCreateAttribute(aPrsObj, "AttributeComment");
-    aCmnt = _PTR(AttributeComment)(anAttr);
-    aCmnt->SetValue(aPrsComment.c_str());
-
-    anAttr = aStudyBuilder->FindOrCreateAttribute(aPrsObj, "AttributeName");
-    _PTR(AttributeName) aPrsName (anAttr);
-    aPrsName->SetValue(aData.myPrs[0]->GetComment());
+    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");
+      aCmnt = _PTR(AttributeComment)(anAttr);
+      aCmnt->SetValue(aPrsComment.c_str());
+
+      anAttr = aStudyBuilder->FindOrCreateAttribute(aPrsObj, "AttributeName");
+      _PTR(AttributeName) aPrsName (anAttr);
+      aPrsName->SetValue(aPrsNameTxt);
+
+    } else {
+      VISU::CreateAttributes(myStudy, aRefObj->GetID().c_str(),"","",
+                             aPrsNameTxt.c_str(),"",aPrsComment.c_str(),true);
+    }
   }
   aStudyBuilder->CommitCommand();
 }
@@ -750,14 +797,16 @@ void VISU_TimeAnimation::restoreFromStudy(_PTR(SObject) theField)
       continue;
     generatePresentations(getNbFields()-1);
 
-    if (!aPrsObj->FindAttribute(anAttr, "AttributeComment")) return;
+    if (!aPrsObj->FindAttribute(anAttr, "AttributeComment")) continue;
     _PTR(AttributeComment) aPrsComment (anAttr);
     string aPrsComm = aPrsComment->Value();
-    QString strPrsIn(aPrsComm.c_str());
-    VISU::Storable::TRestoringMap aPrsMap;
-    VISU::Storable::StrToMap(strPrsIn,aPrsMap);
+    if (aPrsComm.length() > 0) {
+      QString strPrsIn (aPrsComm.c_str());
+      VISU::Storable::TRestoringMap aPrsMap;
+      VISU::Storable::StrToMap(strPrsIn,aPrsMap);
 
-    aData.myPrs[0]->Restore(aPrsMap);
+      aData.myPrs[0]->Restore(aPrsMap);
+    }
     aData.myPrs[0]->GetOffset(aData.myOffset);
     for (int i = 1; i < aData.myNbFrames; i++) {
       aData.myPrs[i]->SameAs(aData.myPrs[0]);