From: mkr Date: Tue, 28 Nov 2006 11:41:23 +0000 (+0000) Subject: Some corrections concerning PAL11537: X-Git-Tag: mergefrom_ScalarMap_ON_GROUP_3_2_0_30Nov06~3 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=e80764c816911040bdbd170c31d00b0327345287;p=modules%2Fvisu.git Some corrections concerning PAL11537: 1)second click on "Play" button of the "Succcessive animation" dlg after animation finishing convert "Play" button in "Pause"; 2)wrong behaviour of the play-slider. --- diff --git a/src/VISU_I/VISU_TimeAnimation.cxx b/src/VISU_I/VISU_TimeAnimation.cxx index d3f51335..71055430 100644 --- a/src/VISU_I/VISU_TimeAnimation.cxx +++ b/src/VISU_I/VISU_TimeAnimation.cxx @@ -167,7 +167,7 @@ bool VISU_TimeAnimation::addField (_PTR(SObject) theField) if ( !myFieldsLst.isEmpty() && myFieldsLst.first().myNbTimes != aNewData.myNbTimes ) return false; if ( myFieldsLst.isEmpty() ) - myFieldsAbsFrames.push_back(aNewData.myNbTimes); + myFieldsAbsFrames.push_back(aNewData.myNbTimes); } else { // succcessive animation mode if ( aNewData.myNbTimes < 1 ) @@ -350,8 +350,15 @@ namespace double getMinFieldsValue( QValueList& theFieldsLst ) { // for succcessive animation mode only - double aRes = theFieldsLst[0].myPrs[0]->GetMin(); - for (int i = 1; i < theFieldsLst.count(); i++) { + double aRes; + for (int i = 0; i < theFieldsLst.count(); i++) { + if ( theFieldsLst[i].myPrs[0] ) { + aRes = theFieldsLst[i].myPrs[0]->GetMin(); + break; + } + } + + for (int i = 1; i < theFieldsLst.count() && theFieldsLst[i].myPrs[0]; i++) { if ( aRes > theFieldsLst[i].myPrs[0]->GetMin() ) aRes = theFieldsLst[i].myPrs[0]->GetMin(); } @@ -361,8 +368,15 @@ double getMinFieldsValue( QValueList& theFieldsLst ) double getMaxFieldsValue( QValueList& theFieldsLst ) { // for succcessive animation mode only - double aRes = theFieldsLst[0].myPrs[0]->GetMax(); - for (int i = 1; i < theFieldsLst.count(); i++) { + double aRes; + for (int i = 0; i < theFieldsLst.count(); i++) { + if ( theFieldsLst[i].myPrs[0] ) { + aRes = theFieldsLst[i].myPrs[0]->GetMax(); + break; + } + } + + for (int i = 1; i < theFieldsLst.count() && theFieldsLst[i].myPrs[0]; i++) { if ( aRes < theFieldsLst[i].myPrs[0]->GetMax() ) aRes = theFieldsLst[i].myPrs[0]->GetMax(); } @@ -574,6 +588,7 @@ void VISU_TimeAnimation::clearView() //------------------------------------------------------------------------ void VISU_TimeAnimation::_visibilityOff(int num_field, int num_frame) { + if ( num_field < 0 || num_frame < 0 ) return; FieldData& aData = myFieldsLst[num_field]; VISU_Actor* aActor = aData.myActors[num_frame]; if (! myCleaningMemoryAtEachFrame) { @@ -940,7 +955,7 @@ CORBA::Long VISU_TimeAnimation::getNbFrames() { if ( myAnimationMode == 0 ) // parallel animation mode return (getNbFields() > 0)? myFieldsLst[0].myNbFrames : 0; else //succcessive animation mode - return (getNbFields() > 0) ? myFieldsAbsFrames[myFieldsAbsFrames.size()-1] : 0; + return (getNbFields() > 0 && !myFieldsAbsFrames.empty()) ? myFieldsAbsFrames[myFieldsAbsFrames.size()-1] : 0; } //------------------------------------------------------------------------ @@ -1079,8 +1094,12 @@ void VISU_TimeAnimation::parallelAnimation( bool& theIsDumping, QValueList& //------------------------------------------------------------------------ void VISU_TimeAnimation::succcessiveAnimation( bool& theIsDumping, QValueList& theIndexList ) { - if ( myFrame >= getNbFrames() - 1 ) + if ( myFrame >= getNbFrames() - 1 ) + { + myIsActive = false; + ProcessVoidEvent(new TVoidMemFunEvent(this,&VISU_TimeAnimation::_emitStopped)); return; + } double k = 1; double aOneVal = 1; @@ -1094,6 +1113,7 @@ void VISU_TimeAnimation::succcessiveAnimation( bool& theIsDumping, QValueList(this, &VISU_TimeAnimation::_emitFrameChanged, @@ -1463,18 +1483,19 @@ 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); + if ( aData.myPrs[0] ) { + _PTR(SObject) newObj = aStudyBuilder->NewObject(aAnimSObject); + aStudyBuilder->Addreference(newObj, aData.myField); + + if (aData.myPrs.empty()) { + generatePresentations(i); + } + 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(); @@ -1572,7 +1593,10 @@ void VISU_TimeAnimation::restoreFromStudy(_PTR(SObject) theField) _PTR(SObject) aRefObj = anIter->Value(); _PTR(SObject) aFieldObj; if (!aRefObj->ReferencedObject(aFieldObj) ) continue; + addField(aFieldObj); + if ( isRangeDefined() ) myFieldsAbsFrames.pop_back(); + FieldData& aData = getFieldData(getNbFields()-1); // Get Presentation object