From 1f2fc1511d31eed36e572c7cc401cd696959772e Mon Sep 17 00:00:00 2001 From: jfa Date: Mon, 18 Jul 2005 11:46:37 +0000 Subject: [PATCH] IPAL8935: Incorrect publishing of animation --- src/VISUGUI/VisuGUI_TimeAnimation.cxx | 2 +- src/VISU_I/VISU_TimeAnimation.cxx | 89 +++++++++++++++++++++------ 2 files changed, 70 insertions(+), 21 deletions(-) diff --git a/src/VISUGUI/VisuGUI_TimeAnimation.cxx b/src/VISUGUI/VisuGUI_TimeAnimation.cxx index 9418696f..b2d43a52 100644 --- a/src/VISUGUI/VisuGUI_TimeAnimation.cxx +++ b/src/VISUGUI/VisuGUI_TimeAnimation.cxx @@ -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(); diff --git a/src/VISU_I/VISU_TimeAnimation.cxx b/src/VISU_I/VISU_TimeAnimation.cxx index 9b19847e..b9f713c2 100644 --- a/src/VISU_I/VISU_TimeAnimation.cxx +++ b/src/VISU_I/VISU_TimeAnimation.cxx @@ -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]); -- 2.39.2