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()
{
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();
_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();
}
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]);