From: jfa Date: Mon, 25 Jul 2005 05:26:53 +0000 (+0000) Subject: IPAL9553: Zero time values in animation (Mandrake only) X-Git-Tag: T2_2_5a~4 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=4d486ff8a657893d2c0972b15b2d1ec64cd97130;p=modules%2Fvisu.git IPAL9553: Zero time values in animation (Mandrake only) --- diff --git a/src/VISU_I/VISU_TimeAnimation.cxx b/src/VISU_I/VISU_TimeAnimation.cxx index 2f16e023..23e22671 100644 --- a/src/VISU_I/VISU_TimeAnimation.cxx +++ b/src/VISU_I/VISU_TimeAnimation.cxx @@ -99,12 +99,12 @@ void VISU_TimeAnimation::clearData(FieldData& theData) { theData.myActors.clear(); } if (!theData.myPrs.empty()) { - for (int i = 0, iEnd = theData.myPrs.size(); i < iEnd; i++) + for (int i = 0, iEnd = theData.myPrs.size(); i < iEnd; i++) if (theData.myPrs[i] != 0) { theData.myPrs[i]->_remove_ref(); } theData.myPrs.clear(); - } + } theData.myNbFrames = 0; myView->update(); } @@ -117,7 +117,7 @@ void VISU_TimeAnimation::generatePresentations(CORBA::Long theFieldNum) { // Delete previous presentations clearData(aData); - VISU::Result_i* pResult = createPresent(aData.myField); + VISU::Result_i* pResult = createPresent(aData.myField); VISU::Storable::TRestoringMap aMap = getMapOfValue(aData.myField); aData.myNbFrames = aData.myNbTimes; //VISU::Storable::FindValue(aMap,"myNbTimeStamps").toLong(); @@ -145,77 +145,80 @@ void VISU_TimeAnimation::generatePresentations(CORBA::Long theFieldNum) { } VISU::Storable::TRestoringMap aTimeMap = getMapOfValue(aTimeStamp); - QString aMeshName = VISU::Storable::FindValue(aTimeMap,"myMeshName"); - VISU::Entity anEntity = (VISU::Entity) VISU::Storable::FindValue(aTimeMap,"myEntityId").toInt(); - QString aFieldName = VISU::Storable::FindValue(aTimeMap,"myFieldName"); - int aTimeStampId = VISU::Storable::FindValue(aTimeMap,"myTimeStampId").toInt(); - + QString aMeshName = VISU::Storable::FindValue(aTimeMap,"myMeshName"); + VISU::Entity anEntity = (VISU::Entity) VISU::Storable::FindValue(aTimeMap,"myEntityId").toInt(); + QString aFieldName = VISU::Storable::FindValue(aTimeMap,"myFieldName"); + int aTimeStampId = VISU::Storable::FindValue(aTimeMap,"myTimeStampId").toInt(); + switch (aData.myPrsType) { case VISU::TSCALARMAP: // ScalarMap { VISU::ScalarMap_i* aPresent = new VISU::ScalarMap_i(pResult, false); - aPresent->Create(aMeshName.latin1(), anEntity, + aPresent->Create(aMeshName.latin1(), anEntity, aFieldName.latin1(), aTimeStampId); //VISU::ScalarMap_var aTmp = aPresent->_this(); //aPresent->_remove_ref(); aData.myPrs[i] = aPresent; } break; - + case VISU::TISOSURFACE: // Iso Surfaces { VISU::IsoSurfaces_i* aPresent = new VISU::IsoSurfaces_i(pResult, false); - aPresent->Create(aMeshName.latin1(), anEntity, + aPresent->Create(aMeshName.latin1(), anEntity, aFieldName.latin1(), aTimeStampId); //VISU::IsoSurfaces_var aTmp = aPresent->_this(); //aPresent->_remove_ref(); aData.myPrs[i] = aPresent; } break; - + case VISU::TCUTPLANES: // Cut Planes { VISU::CutPlanes_i* aPresent = new VISU::CutPlanes_i(pResult, false); - aPresent->Create(aMeshName.latin1(), anEntity, + aPresent->Create(aMeshName.latin1(), anEntity, aFieldName.latin1(), aTimeStampId); //VISU::CutPlanes_var aTmp = aPresent->_this(); //aPresent->_remove_ref(); aData.myPrs[i] = aPresent; } break; - + case VISU::TDEFORMEDSHAPE: // Deformed Shape { VISU::DeformedShape_i* aPresent = new VISU::DeformedShape_i(pResult, false); - aPresent->Create(aMeshName.latin1(), anEntity, + aPresent->Create(aMeshName.latin1(), anEntity, aFieldName.latin1(), aTimeStampId); //VISU::DeformedShape_var aTmp = aPresent->_this(); //aPresent->_remove_ref(); aData.myPrs[i] = aPresent; } break; - + case VISU::TVECTORS: // Vectors { VISU::Vectors_i* aPresent = new VISU::Vectors_i(pResult, false); - aPresent->Create(aMeshName.latin1(), anEntity, + aPresent->Create(aMeshName.latin1(), anEntity, aFieldName.latin1(), aTimeStampId); //VISU::Vectors_var aTmp = aPresent->_this(); //aPresent->_remove_ref(); aData.myPrs[i] = aPresent; } break; - + case VISU::TSTREAMLINES: // Stream Lines { VISU::StreamLines_i* aPresent = new VISU::StreamLines_i(pResult, false); - aPresent->Create(aMeshName.latin1(), anEntity, + aPresent->Create(aMeshName.latin1(), anEntity, aFieldName.latin1(), aTimeStampId); //VISU::StreamLines_var aTmp = aPresent->_this(); //aPresent->_remove_ref(); aData.myPrs[i] = aPresent; } break; + default: + MESSAGE("Not implemented for this presentation type: " << aData.myPrsType); + return; } if (aData.myPrs[i]->GetMin() < aMin) aMin = aData.myPrs[i]->GetMin(); if (aData.myPrs[i]->GetMax() > aMax) aMax = aData.myPrs[i]->GetMax(); @@ -224,7 +227,7 @@ void VISU_TimeAnimation::generatePresentations(CORBA::Long theFieldNum) { aData.myNbFrames = i; QString aFixRange = QAD_CONFIG->getSetting("Visu:SBImposeRange"); if (aFixRange.compare("true") != 0) { - for (i = 0; i < aData.myNbFrames; i++) + for (i = 0; i < aData.myNbFrames; i++) aData.myPrs[i]->SetRange(aMin, aMax); if(aData.myPrsType == VISU::TISOSURFACE) for (i = 0; i < aData.myNbFrames; i++) @@ -237,7 +240,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; } @@ -275,7 +278,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(); @@ -287,7 +290,7 @@ void VISU_TimeAnimation::clearView() { aData.myActors[i]->RemoveFromRender(aRen); aData.myActors[i]->Delete(); } - } + } aData.myActors.clear(); } } @@ -313,15 +316,15 @@ void VISU_TimeAnimation::nextFrame() { stopAnimation(); if (myFrame < (myFieldsLst[0].myNbFrames-1)) { int i; - for (i = 0; i < getNbFields(); i++) + for (i = 0; i < getNbFields(); i++) if (myFieldsLst[i].myActors[myFrame] != 0) myFieldsLst[i].myActors[myFrame]->VisibilityOff(); myFrame++; - for (i = 0; i < getNbFields(); i++) + for (i = 0; i < getNbFields(); i++) if (myFieldsLst[i].myActors[myFrame] != 0) myFieldsLst[i].myActors[myFrame]->VisibilityOn(); - + emit frameChanged(myFrame, myFieldsLst[0].myTiming[myFrame]); myView->Repaint(); } @@ -332,15 +335,15 @@ void VISU_TimeAnimation::prevFrame() { stopAnimation(); if (myFrame > 0) { int i; - for (i = 0; i < getNbFields(); i++) + for (i = 0; i < getNbFields(); i++) if (myFieldsLst[i].myActors[myFrame] != 0) myFieldsLst[i].myActors[myFrame]->VisibilityOff(); myFrame--; - for (i = 0; i < getNbFields(); i++) + for (i = 0; i < getNbFields(); i++) if (myFieldsLst[i].myActors[myFrame] != 0) - myFieldsLst[i].myActors[myFrame]->VisibilityOn(); - + myFieldsLst[i].myActors[myFrame]->VisibilityOn(); + emit frameChanged(myFrame, myFieldsLst[0].myTiming[myFrame]); myView->Repaint(); } @@ -350,15 +353,15 @@ void VISU_TimeAnimation::prevFrame() { void VISU_TimeAnimation::firstFrame() { stopAnimation(); int i; - for (i = 0; i < getNbFields(); i++) + for (i = 0; i < getNbFields(); i++) if(!myFieldsLst[i].myActors.empty()) if (myFieldsLst[i].myActors[myFrame] != 0) myFieldsLst[i].myActors[myFrame]->VisibilityOff(); myFrame = 0; - for (i = 0; i < getNbFields(); i++) + for (i = 0; i < getNbFields(); i++) if(!myFieldsLst[i].myActors.empty()) if (myFieldsLst[i].myActors[myFrame] != 0) - myFieldsLst[i].myActors[myFrame]->VisibilityOn(); + myFieldsLst[i].myActors[myFrame]->VisibilityOn(); if(!myFieldsLst[0].myTiming.empty()){ emit frameChanged(myFrame, myFieldsLst[0].myTiming[myFrame]); myView->Repaint(); @@ -369,12 +372,12 @@ void VISU_TimeAnimation::firstFrame() { void VISU_TimeAnimation::lastFrame() { stopAnimation(); int i; - for (i = 0; i < getNbFields(); i++) + for (i = 0; i < getNbFields(); i++) if (myFieldsLst[i].myActors[myFrame] != 0) myFieldsLst[i].myActors[myFrame]->VisibilityOff(); myFrame = myFieldsLst[0].myNbFrames-1; - for (i = 0; i < getNbFields(); i++) + for (i = 0; i < getNbFields(); i++) if (myFieldsLst[i].myActors[myFrame] != 0) myFieldsLst[i].myActors[myFrame]->VisibilityOn(); @@ -386,24 +389,24 @@ void VISU_TimeAnimation::lastFrame() { //************************************************************************ // For Batchmode using void VISU_TimeAnimation::gotoFrame(CORBA::Long theFrame) { - if ((theFrame < 0) || (theFrame > (getNbFrames()-1))) + if ((theFrame < 0) || (theFrame > (getNbFrames()-1))) return; stopAnimation(); qApp->lock(); qApp->syncX(); int i; - for (i = 0; i < getNbFields(); i++) + for (i = 0; i < getNbFields(); i++) if (myFieldsLst[i].myActors[myFrame] != 0) myFieldsLst[i].myActors[myFrame]->VisibilityOff(); myFrame = theFrame; - for (i = 0; i < getNbFields(); i++) + for (i = 0; i < getNbFields(); i++) if (myFieldsLst[i].myActors[myFrame] != 0) myFieldsLst[i].myActors[myFrame]->VisibilityOn(); emit frameChanged(myFrame, myFieldsLst[0].myTiming[myFrame]); myView->Repaint(); - qApp->flushX(); + qApp->flushX(); qApp->processEvents(3); qApp->unlock(); } @@ -420,7 +423,7 @@ VISU::ScalarMap_ptr VISU_TimeAnimation::getPresentation(CORBA::Long theField, CO //************************************************************************ -CORBA::Long VISU_TimeAnimation::getNbFrames() { +CORBA::Long VISU_TimeAnimation::getNbFrames() { return (getNbFields() > 0)? myFieldsLst[0].myNbFrames : 0; } @@ -428,23 +431,23 @@ CORBA::Long VISU_TimeAnimation::getNbFrames() { //************************************************************************ 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; - qApp->lock(); + 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]); for (int i = 0; i < getNbFields(); i++) { FieldData& aData = myFieldsLst[i]; if (myFrame > 0) { - if (aData.myActors[myFrame-1] != 0) + if (aData.myActors[myFrame-1] != 0) aData.myActors[myFrame-1]->VisibilityOff(); - } else { + } else { if (aData.myActors[aData.myNbFrames-1] != 0) aData.myActors[aData.myNbFrames-1]->VisibilityOff(); } @@ -453,6 +456,8 @@ void VISU_TimeAnimation::run() { } } myView->Repaint(false); + + int delay = 100; if (isDumping) { QPixmap px = QPixmap::grabWindow(myView->getViewWidget()->winId()); QString aFile(myDumpPath); @@ -463,33 +468,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; + break; case 1: if (myFieldsLst[0].myNbFrames > 2) - k = (myFieldsLst[0].myTiming[myFrame+1] - myFieldsLst[0].myTiming[myFrame])/aOneVal; - else - k = 1; - break; + 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++; @@ -517,7 +518,6 @@ VISU::Result_i* VISU_TimeAnimation::createPresent(SALOMEDS::SObject_var theField return dynamic_cast(VISU::GetServant(anObject).in()); } - //************************************************************************ VISU::Storable::TRestoringMap VISU_TimeAnimation::getMapOfValue(SALOMEDS::SObject_var theSObject) { VISU::Storable::TRestoringMap aMap; @@ -538,15 +538,19 @@ double VISU_TimeAnimation::getTimeValue(SALOMEDS::SObject_var theTimeStamp) { SALOMEDS::GenericAttribute_var anAttr; if(theTimeStamp->FindAttribute(anAttr, "AttributeName")) { SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr); - QString aNameString(aName->Value()); - return aNameString.toDouble(); + QString aNameString (aName->Value()); + int time_len = aNameString.find(','); + if (time_len > -1) + return aNameString.left(time_len).toDouble(); + else + return aNameString.toDouble(); } return -1.0; } - + //************************************************************************ -void VISU_TimeAnimation::setSpeed(CORBA::Long theSpeed) { - mySpeed = (theSpeed<1)? 1 : theSpeed; +void VISU_TimeAnimation::setSpeed(CORBA::Long theSpeed) { + mySpeed = (theSpeed<1)? 1 : theSpeed; } @@ -555,164 +559,164 @@ VISU_TimeAnimation_i::VISU_TimeAnimation_i(SALOMEDS::Study_ptr theStudy, VISU::V myAnim = new VISU_TimeAnimation(theStudy,theView3D); } - -VISU_TimeAnimation_i::~VISU_TimeAnimation_i(){ +VISU_TimeAnimation_i::~VISU_TimeAnimation_i() +{ delete myAnim; } - -void VISU_TimeAnimation_i::addField(SALOMEDS::SObject_ptr theField){ +void VISU_TimeAnimation_i::addField(SALOMEDS::SObject_ptr theField) +{ myAnim->addField(theField); } - -CORBA::Boolean VISU_TimeAnimation_i::generateFrames(){ - return ProcessEvent(new TMemFunEvent(myAnim,&VISU_TimeAnimation::generateFrames)); +CORBA::Boolean VISU_TimeAnimation_i::generateFrames() +{ + return ProcessEvent(new TMemFunEvent + (myAnim,&VISU_TimeAnimation::generateFrames)); } - -void VISU_TimeAnimation_i::generatePresentations(CORBA::Long theFieldNum){ +void VISU_TimeAnimation_i::generatePresentations(CORBA::Long theFieldNum) +{ myAnim->generatePresentations(theFieldNum); } - -void VISU_TimeAnimation_i::clearView(){ +void VISU_TimeAnimation_i::clearView() +{ ProcessVoidEvent(new TVoidMemFunEvent(myAnim,&VISU_TimeAnimation::clearView)); } - -void VISU_TimeAnimation_i::stopAnimation(){ +void VISU_TimeAnimation_i::stopAnimation() +{ ProcessVoidEvent(new TVoidMemFunEvent(myAnim,&VISU_TimeAnimation::stopAnimation)); } - -void VISU_TimeAnimation_i::startAnimation(){ +void VISU_TimeAnimation_i::startAnimation() +{ ProcessVoidEvent(new TVoidMemFunEvent(myAnim,&VISU_TimeAnimation::startAnimation)); } - -void VISU_TimeAnimation_i::nextFrame(){ +void VISU_TimeAnimation_i::nextFrame() +{ ProcessVoidEvent(new TVoidMemFunEvent(myAnim,&VISU_TimeAnimation::nextFrame)); } - -void VISU_TimeAnimation_i::prevFrame(){ +void VISU_TimeAnimation_i::prevFrame() +{ ProcessVoidEvent(new TVoidMemFunEvent(myAnim,&VISU_TimeAnimation::prevFrame)); } - -void VISU_TimeAnimation_i::firstFrame(){ +void VISU_TimeAnimation_i::firstFrame() +{ ProcessVoidEvent(new TVoidMemFunEvent(myAnim,&VISU_TimeAnimation::firstFrame)); } - -void VISU_TimeAnimation_i::lastFrame(){ +void VISU_TimeAnimation_i::lastFrame() +{ ProcessVoidEvent(new TVoidMemFunEvent(myAnim,&VISU_TimeAnimation::lastFrame)); } - -void VISU_TimeAnimation_i::gotoFrame(CORBA::Long theFrame){ - ProcessVoidEvent(new TVoidMemFun1ArgEvent(myAnim,&VISU_TimeAnimation::gotoFrame,theFrame)); +void VISU_TimeAnimation_i::gotoFrame(CORBA::Long theFrame) +{ + ProcessVoidEvent(new TVoidMemFun1ArgEvent + (myAnim,&VISU_TimeAnimation::gotoFrame,theFrame)); } - -CORBA::Long VISU_TimeAnimation_i::getNbFields(){ +CORBA::Long VISU_TimeAnimation_i::getNbFields() +{ return myAnim->getNbFields(); } - -CORBA::Long VISU_TimeAnimation_i::getNbFrames(){ +CORBA::Long VISU_TimeAnimation_i::getNbFrames() +{ return myAnim->getNbFrames(); } - -CORBA::Boolean VISU_TimeAnimation_i::isRunning(){ +CORBA::Boolean VISU_TimeAnimation_i::isRunning() +{ return myAnim->isRunning(); } - -CORBA::Long VISU_TimeAnimation_i::getCurrentFrame(){ +CORBA::Long VISU_TimeAnimation_i::getCurrentFrame() +{ return myAnim->getCurrentFrame(); } - -VISU::ScalarMap_ptr VISU_TimeAnimation_i::getPresentation(CORBA::Long theField, CORBA::Long theFrame){ +VISU::ScalarMap_ptr VISU_TimeAnimation_i::getPresentation(CORBA::Long theField, CORBA::Long theFrame) +{ return myAnim->getPresentation(theField,theFrame); } - -void VISU_TimeAnimation_i::setPresentationType(CORBA::Long theFieldNum, VISU::VISUType theType){ +void VISU_TimeAnimation_i::setPresentationType(CORBA::Long theFieldNum, VISU::VISUType theType) +{ myAnim->setPresentationType(theFieldNum,theType); } - -VISU::VISUType VISU_TimeAnimation_i::getPresentationType(CORBA::Long theFieldNum){ +VISU::VISUType VISU_TimeAnimation_i::getPresentationType(CORBA::Long theFieldNum) +{ return myAnim->getPresentationType(theFieldNum); } - -void VISU_TimeAnimation_i::setSpeed(CORBA::Long theSpeed){ +void VISU_TimeAnimation_i::setSpeed(CORBA::Long theSpeed) +{ myAnim->setSpeed(theSpeed); } - -CORBA::Long VISU_TimeAnimation_i::getSpeed(){ +CORBA::Long VISU_TimeAnimation_i::getSpeed() +{ return myAnim->getSpeed(); } - -CORBA::Boolean VISU_TimeAnimation_i::isProportional(){ +CORBA::Boolean VISU_TimeAnimation_i::isProportional() +{ return myAnim->isProportional(); } - -void VISU_TimeAnimation_i::setAnimationRange(CORBA::Double theMin, CORBA::Double theMax){ +void VISU_TimeAnimation_i::setAnimationRange(CORBA::Double theMin, CORBA::Double theMax) +{ myAnim->setAnimationRange(theMin,theMax); } - -CORBA::Double VISU_TimeAnimation_i::getMinRange(){ +CORBA::Double VISU_TimeAnimation_i::getMinRange() +{ return myAnim->getMinRange(); } - -CORBA::Double VISU_TimeAnimation_i::getMaxRange(){ +CORBA::Double VISU_TimeAnimation_i::getMaxRange() +{ return myAnim->getMaxRange(); } - -CORBA::Boolean VISU_TimeAnimation_i::isRangeDefined(){ +CORBA::Boolean VISU_TimeAnimation_i::isRangeDefined() +{ return myAnim->isRangeDefined(); } - -void VISU_TimeAnimation_i::dumpTo(const char* thePath){ +void VISU_TimeAnimation_i::dumpTo(const char* thePath) +{ myAnim->dumpTo(thePath); } - -CORBA::Boolean VISU_TimeAnimation_i::isCycling(){ +CORBA::Boolean VISU_TimeAnimation_i::isCycling() +{ return myAnim->isCycling(); } - -CORBA::Double VISU_TimeAnimation_i::getMinTime(){ +CORBA::Double VISU_TimeAnimation_i::getMinTime() +{ return myAnim->getMinTime(); } - -CORBA::Double VISU_TimeAnimation_i::getMaxTime(){ +CORBA::Double VISU_TimeAnimation_i::getMaxTime() +{ return myAnim->getMaxTime(); } - -void VISU_TimeAnimation_i::setProportional(CORBA::Boolean theProp){ +void VISU_TimeAnimation_i::setProportional(CORBA::Boolean theProp) +{ myAnim->setProportional(theProp); } - -void VISU_TimeAnimation_i::setCycling(CORBA::Boolean theCycle){ +void VISU_TimeAnimation_i::setCycling(CORBA::Boolean theCycle) +{ myAnim->setCycling(theCycle); } - -