From 0ae763a8ef7f625da49e9dcd2e4f7fbea42ce8d7 Mon Sep 17 00:00:00 2001 From: jfa Date: Thu, 21 Jul 2005 10:13:35 +0000 Subject: [PATCH] IPAL9484: Animation crashes if Proportional timing used --- src/VISU_I/VISU_TimeAnimation.cxx | 57 ++++++++++++++++--------------- 1 file changed, 30 insertions(+), 27 deletions(-) diff --git a/src/VISU_I/VISU_TimeAnimation.cxx b/src/VISU_I/VISU_TimeAnimation.cxx index b074f5f1..95f43444 100644 --- a/src/VISU_I/VISU_TimeAnimation.cxx +++ b/src/VISU_I/VISU_TimeAnimation.cxx @@ -298,7 +298,7 @@ void VISU_TimeAnimation::generatePresentations(CORBA::Long theFieldNum) { //************************************************************************ CORBA::Boolean VISU_TimeAnimation::generateFrames() { if (!myView) { - MESSAGE("Viewer is nod defined for animation"); + MESSAGE("Viewer is not defined for animation"); return false; } @@ -337,7 +337,7 @@ CORBA::Boolean VISU_TimeAnimation::generateFrames() { //************************************************************************ void VISU_TimeAnimation::clearView() { if (!myView) { - MESSAGE("Viewer is nod defined for animation"); + MESSAGE("Viewer is not defined for animation"); return; } vtkRenderer* aRen = myView->getRenderer(); @@ -487,16 +487,17 @@ CORBA::Long VISU_TimeAnimation::getNbFrames() { //************************************************************************ -void VISU_TimeAnimation::run() { +void VISU_TimeAnimation::run() +{ if (!myView) { - MESSAGE("Viewer is nod defined for animation"); + MESSAGE("Viewer is not defined for animation"); return; } - double k=1; - double aOneVal; - bool isDumping = !myDumpPath.isEmpty(); - aOneVal = (myFieldsLst[0].myNbFrames > 2) ? - myFieldsLst[0].myTiming[1] - myFieldsLst[0].myTiming[0] : 1; + double k = 1; + bool isDumping = !myDumpPath.isEmpty(); + double aOneVal = 1; + if (myFieldsLst[0].myNbFrames > 2) + aOneVal = myFieldsLst[0].myTiming[1] - myFieldsLst[0].myTiming[0]; qApp->lock(); while (myIsActive) { emit frameChanged(myFrame, myFieldsLst[0].myTiming[myFrame]); @@ -514,6 +515,8 @@ void VISU_TimeAnimation::run() { } } myView->Repaint(false); + + int delay = 100; if (isDumping) { QPixmap px = QPixmap::grabWindow(myView->winId()); QString aFile(myDumpPath); @@ -524,33 +527,29 @@ void VISU_TimeAnimation::run() { aFile += aName; aFile += ".jpeg"; px.save(aFile, "JPEG"); - } - if (!isDumping) { + } else { + k = 1; if (myProportional) { switch (myFrame) { case 0: - k=1; break; case 1: if (myFieldsLst[0].myNbFrames > 2) - k = (myFieldsLst[0].myTiming[myFrame+1] - myFieldsLst[0].myTiming[myFrame])/aOneVal; - else - k = 1; + k = (myFieldsLst[0].myTiming[myFrame+1] - + myFieldsLst[0].myTiming[myFrame]) / aOneVal; break; default: - k = (myFrame < (myFieldsLst[0].myNbFrames-1))? - (myFieldsLst[0].myTiming[myFrame+1] - myFieldsLst[0].myTiming[myFrame])/aOneVal : 1; + if (myFrame < (myFieldsLst[0].myNbFrames - 1)) + k = (myFieldsLst[0].myTiming[myFrame+1] - + myFieldsLst[0].myTiming[myFrame]) / aOneVal; } - } else - k = 1; - qApp->unlock(); - msleep((int)(1000.*k/mySpeed)); - qApp->lock(); - } else { - qApp->unlock(); - msleep(100); - qApp->lock(); + } + delay = (int)(1000. * k / mySpeed); } + qApp->unlock(); + msleep(delay); + qApp->lock(); + if (!myIsActive) break; myFrame++; @@ -602,7 +601,11 @@ double VISU_TimeAnimation::getTimeValue (_PTR(SObject) theTimeStamp) if (theTimeStamp->FindAttribute(anAttr, "AttributeName")) { _PTR(AttributeName) aName (anAttr); QString aNameString (aName->Value().c_str()); - return aNameString.toDouble(); + int time_len = aNameString.find(','); + if (time_len > -1) + return aNameString.left(time_len).toDouble(); + else + return aNameString.toDouble(); } return -1.0; } -- 2.39.2