From: jfa Date: Fri, 10 Mar 2006 11:14:15 +0000 (+0000) Subject: Fix bug 11596: Incorrect filling of range of time stamps in 'Setup Animation' dlg... X-Git-Tag: mergeto_trunk_13Mar06~2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=826a31145010aafc1912ff57a75c0a191a8838ee;p=modules%2Fvisu.git Fix bug 11596: Incorrect filling of range of time stamps in 'Setup Animation' dlg after data restoring. --- diff --git a/src/VISUGUI/VisuGUI_TimeAnimation.cxx b/src/VISUGUI/VisuGUI_TimeAnimation.cxx index c56ed5d9..0c531e79 100644 --- a/src/VISUGUI/VisuGUI_TimeAnimation.cxx +++ b/src/VISUGUI/VisuGUI_TimeAnimation.cxx @@ -78,8 +78,8 @@ ArrangeDlg::ArrangeDlg(QWidget* theParent, VISU_TimeAnimation* theAnimator) init(); QStringList aFieldNames; // Find names of fields - for (int i = 0; i < theAnimator->getNbFields(); i++) { - aFieldNames.append(VISU::getValue(theAnimator->getFieldData(i).myField, "myName")); + for (int i = 0; i < myAnimator->getNbFields(); i++) { + aFieldNames.append(VISU::getValue(myAnimator->getFieldData(i).myField, "myName")); Offset aOffs; aOffs.myOffset[0] = myAnimator->getFieldData(i).myOffset[0]; aOffs.myOffset[1] = myAnimator->getFieldData(i).myOffset[1]; @@ -459,6 +459,7 @@ SetupDlg::SetupDlg (QWidget* theParent, QVBoxLayout* aMainLayout = new QVBoxLayout(this, 7, 6); aMainLayout->setSpacing(5); + // Range of time stamps QFrame* aRangeGrp = new QFrame(this); QGridLayout* aRangeLayout = new QGridLayout( aRangeGrp ); aRangeLayout->setSpacing( 6 ); @@ -469,16 +470,19 @@ SetupDlg::SetupDlg (QWidget* theParent, aRangeLayout->addMultiCellWidget(myUseRangeChk, 0, 0, 0, 3); myUseRangeChk->setChecked(myAnimator->isRangeDefined()); + double aMaxTime = myAnimator->getMaxTime(); + double aMinTime = myAnimator->getMinTime(); + double aStep = (aMaxTime - aMinTime) / (myAnimator->getFieldData(0).myNbTimes - 1); + QLabel* aMinLbl = new QLabel("From", aRangeGrp); aMinLbl->setEnabled(myUseRangeChk->isChecked()); aRangeLayout->addWidget(aMinLbl, 1, 0); - double aStep = (myAnimator->getMaxTime() - myAnimator->getMinTime())/(theAnimator->getFieldData(0).myNbTimes - 1); - myMinVal = new QtxDblSpinBox( myAnimator->getMinTime(), myAnimator->getMaxTime(), aStep, aRangeGrp ); + myMinVal = new QtxDblSpinBox( aMinTime, aMaxTime, aStep, aRangeGrp ); myMinVal->setEnabled(myUseRangeChk->isChecked()); if (myUseRangeChk->isChecked()) myMinVal->setValue( myAnimator->getMinRange() ); else - myMinVal->setValue( myAnimator->getMinTime() ); + myMinVal->setValue( aMinTime ); connect(myMinVal, SIGNAL( valueChanged(double)), this, SLOT( onMinValue(double) )); @@ -487,12 +491,12 @@ SetupDlg::SetupDlg (QWidget* theParent, QLabel* aMaxLbl = new QLabel("To", aRangeGrp); aMaxLbl->setEnabled(myUseRangeChk->isChecked()); aRangeLayout->addWidget(aMaxLbl, 1, 2); - myMaxVal = new QtxDblSpinBox( myAnimator->getMinTime(), myAnimator->getMaxTime(), aStep, aRangeGrp ); + myMaxVal = new QtxDblSpinBox( aMinTime, aMaxTime, aStep, aRangeGrp ); myMaxVal->setEnabled(myUseRangeChk->isChecked()); if (myUseRangeChk->isChecked()) myMaxVal->setValue( myAnimator->getMaxRange() ); else - myMaxVal->setValue( myAnimator->getMaxTime() ); + myMaxVal->setValue( aMaxTime ); connect(myMaxVal, SIGNAL( valueChanged(double)), this, SLOT( onMaxValue(double) )); @@ -508,6 +512,7 @@ SetupDlg::SetupDlg (QWidget* theParent, aMainLayout->addWidget(aRangeGrp); + // Fields and Properties QHBox* aPropFrame = new QHBox(this); aPropFrame->setSpacing(5); @@ -515,8 +520,8 @@ SetupDlg::SetupDlg (QWidget* theParent, myFieldLst = new QListBox(aNamesBox); QStringList aFieldNames; // Find names of fields - for (int i = 0; i < theAnimator->getNbFields(); i++) { - _PTR(SObject) aSO = theAnimator->getFieldData(i).myField; + for (int i = 0; i < myAnimator->getNbFields(); i++) { + _PTR(SObject) aSO = myAnimator->getFieldData(i).myField; aFieldNames.append(VISU::getValue(aSO, "myName")); } myFieldLst->insertStringList(aFieldNames); @@ -539,7 +544,7 @@ SetupDlg::SetupDlg (QWidget* theParent, // this, SLOT( onScalarBarDlg() ) ); myPropBtn = new QPushButton("Properties...", aPropBox); - // myPropBtn->setEnabled(theAnimator->getFieldData(0).myPrsType != VISU::TSCALARMAP); + // myPropBtn->setEnabled(myAnimator->getFieldData(0).myPrsType != VISU::TSCALARMAP); connect( myPropBtn, SIGNAL( clicked() ), this, SLOT( onPreferencesDlg() ) ); diff --git a/src/VISU_I/VISU_TimeAnimation.cxx b/src/VISU_I/VISU_TimeAnimation.cxx index 718fd97f..fa5befe5 100644 --- a/src/VISU_I/VISU_TimeAnimation.cxx +++ b/src/VISU_I/VISU_TimeAnimation.cxx @@ -68,8 +68,8 @@ VISU_TimeAnimation::VISU_TimeAnimation (_PTR(Study) theStudy, connect( myView, SIGNAL( destroyed() ), this, SLOT( onViewDeleted() ) ); } - myMaxVal = 0; - myMinVal = 0; + myTimeMinVal = 0; + myTimeMaxVal = 0; myTimeMin = 0; myTimeMax = 0; myLastError = ""; @@ -162,13 +162,10 @@ namespace FieldData& theData, VISU::Result_i* theResult, bool theIsRangeDefined, - CORBA::Double& theMinVal, - CORBA::Double& theMaxVal, CORBA::Double theTimeMin, CORBA::Double theTimeMax) { - theMinVal = VTK_LARGE_FLOAT; - theMaxVal = -VTK_LARGE_FLOAT; + double aMin = VTK_LARGE_FLOAT, aMax = -VTK_LARGE_FLOAT; _PTR(ChildIterator) anIter = theStudy->NewChildIterator(theData.myField); anIter->Next(); // First is reference on support @@ -202,8 +199,8 @@ namespace aFieldName.latin1(), aTimeStampId); theData.myPrs[aFrameId++] = aPresent; - theMinVal = std::min(aPresent->GetMin(),theMinVal); - theMaxVal = std::max(aPresent->GetMax(),theMaxVal); + aMin = std::min(aPresent->GetMin(), aMin); + aMax = std::max(aPresent->GetMax(), aMax); } theData.myNbFrames = aFrameId; @@ -212,7 +209,7 @@ namespace if( aRangeType != 1 ){ for(long aFrameId = 0; aFrameId < theData.myNbFrames; aFrameId++) { if (VISU::ScalarMap_i* aPrs = dynamic_cast(theData.myPrs[aFrameId])){ - aPrs->SetRange(theMinVal, theMaxVal); + aPrs->SetRange(aMin, aMax); aPrs->SetOffset(theData.myOffset); } } @@ -220,7 +217,7 @@ namespace if (theData.myPrsType == VISU::TISOSURFACE) for (long aFrameId = 0; aFrameId < theData.myNbFrames; aFrameId++) if (VISU::IsoSurfaces_i* aPrs = dynamic_cast(theData.myPrs[aFrameId])) - aPrs->SetSubRange(theMinVal, theMaxVal); + aPrs->SetSubRange(aMin, aMax); } } } @@ -246,100 +243,80 @@ void VISU_TimeAnimation::generatePresentations(CORBA::Long theFieldNum) { aData, aResult, isRangeDefined(), - myMinVal, - myMaxVal, - myTimeMin, - myTimeMax); + myTimeMinVal, + myTimeMaxVal); break; case VISU::TISOSURFACE: // Iso Surfaces GeneratePresentations(myStudy, aData, aResult, isRangeDefined(), - myMinVal, - myMaxVal, - myTimeMin, - myTimeMax); + myTimeMinVal, + myTimeMaxVal); break; case VISU::TCUTPLANES: // Cut Planes GeneratePresentations(myStudy, aData, aResult, isRangeDefined(), - myMinVal, - myMaxVal, - myTimeMin, - myTimeMax); + myTimeMinVal, + myTimeMaxVal); break; case VISU::TCUTLINES: // Cut Lines GeneratePresentations(myStudy, aData, aResult, isRangeDefined(), - myMinVal, - myMaxVal, - myTimeMin, - myTimeMax); + myTimeMinVal, + myTimeMaxVal); break; case VISU::TPLOT3D: // Plot3d GeneratePresentations(myStudy, aData, aResult, isRangeDefined(), - myMinVal, - myMaxVal, - myTimeMin, - myTimeMax); + myTimeMinVal, + myTimeMaxVal); break; case VISU::TDEFORMEDSHAPE: // Deformed Shape GeneratePresentations(myStudy, aData, aResult, isRangeDefined(), - myMinVal, - myMaxVal, - myTimeMin, - myTimeMax); + myTimeMinVal, + myTimeMaxVal); break; case VISU::TVECTORS: // Vectors GeneratePresentations(myStudy, aData, aResult, isRangeDefined(), - myMinVal, - myMaxVal, - myTimeMin, - myTimeMax); + myTimeMinVal, + myTimeMaxVal); break; case VISU::TSTREAMLINES: // Stream Lines GeneratePresentations(myStudy, aData, aResult, isRangeDefined(), - myMinVal, - myMaxVal, - myTimeMin, - myTimeMax); + myTimeMinVal, + myTimeMaxVal); break; case VISU::TGAUSSPOINTS: // Gauss Points GeneratePresentations(myStudy, aData, aResult, isRangeDefined(), - myMinVal, - myMaxVal, - myTimeMin, - myTimeMax); + myTimeMinVal, + myTimeMaxVal); break; case VISU::TSCALARMAPONDEFORMEDSHAPE: // Scalar map on deformed shape GeneratePresentations(myStudy, aData, aResult, isRangeDefined(), - myMinVal, - myMaxVal, - myTimeMin, - myTimeMax); + myTimeMinVal, + myTimeMaxVal); break; default: MESSAGE("Not implemented for this presentation type: " << aData.myPrsType); @@ -769,8 +746,8 @@ SALOMEDS::SObject_ptr VISU_TimeAnimation::publishInStudy() std::string aSComponentEntry = aSComponent->GetID(); QString aComment; - aComment.sprintf("myComment=ANIMATION;myType=%d;myMinVal=%g;myMaxVal=%g", - VISU::TANIMATION,myMinVal,myMaxVal); + aComment.sprintf("myComment=ANIMATION;myType=%d;myTimeMinVal=%g;myTimeMaxVal=%g", + VISU::TANIMATION,myTimeMinVal,myTimeMaxVal); string anEntry = VISU::CreateAttributes(myStudy,aSComponentEntry.c_str(),"","", GenerateName(),"",aComment,true); @@ -812,8 +789,8 @@ void VISU_TimeAnimation::saveAnimation() std::string aSComponentEntry = aSComponent->GetID(); QString aComment; - aComment.sprintf("myComment=ANIMATION;myType=%d;myMinVal=%g;myMaxVal=%g", - VISU::TANIMATION,myMinVal,myMaxVal); + aComment.sprintf("myComment=ANIMATION;myType=%d;myTimeMinVal=%g;myTimeMaxVal=%g", + VISU::TANIMATION,myTimeMinVal,myTimeMaxVal); _PTR(GenericAttribute) anAttr; anAttr = aStudyBuilder->FindOrCreateAttribute(aAnimSObject, "AttributeComment"); @@ -879,8 +856,8 @@ void VISU_TimeAnimation::restoreFromStudy(_PTR(SObject) theField) VISU::Storable::StrToMap(strIn,aMap); bool isExist; - myMinVal = VISU::Storable::FindValue(aMap,"myMinVal",&isExist).toDouble(); - myMaxVal = VISU::Storable::FindValue(aMap,"myMaxVal",&isExist).toDouble(); + myTimeMinVal = VISU::Storable::FindValue(aMap,"myTimeMinVal",&isExist).toDouble(); + myTimeMaxVal = VISU::Storable::FindValue(aMap,"myTimeMaxVal",&isExist).toDouble(); _PTR(ChildIterator) anIter = myStudy->NewChildIterator(aAnimSObject); for (anIter->Init(); anIter->More(); anIter->Next()) { diff --git a/src/VISU_I/VISU_TimeAnimation.h b/src/VISU_I/VISU_TimeAnimation.h index 4c5ed652..bb1925a8 100644 --- a/src/VISU_I/VISU_TimeAnimation.h +++ b/src/VISU_I/VISU_TimeAnimation.h @@ -94,11 +94,11 @@ class VISU_TimeAnimation: public QObject, public QThread CORBA::Boolean isProportional() { return myProportional; } void setAnimationRange(CORBA::Double theMin, CORBA::Double theMax) - { myMaxVal = theMax; myMinVal = theMin; } + { myTimeMinVal = theMin; myTimeMaxVal = theMax; } - CORBA::Double getMinRange() { return myMinVal; } - CORBA::Double getMaxRange() { return myMaxVal; } - CORBA::Boolean isRangeDefined() { return !((myMaxVal==0) && (myMinVal == myMaxVal)); } + CORBA::Double getMinRange() { return myTimeMinVal; } + CORBA::Double getMaxRange() { return myTimeMaxVal; } + CORBA::Boolean isRangeDefined() { return !((myTimeMaxVal == 0) && (myTimeMinVal == myTimeMaxVal)); } void dumpTo(const char* thePath) { myDumpPath = thePath; } std::string setDumpFormat(const char* theFormat); @@ -133,7 +133,7 @@ class VISU_TimeAnimation: public QObject, public QThread private slots: void onViewDeleted(); - + private: QString myLastError; @@ -145,8 +145,8 @@ class VISU_TimeAnimation: public QObject, public QThread bool myCycling; _PTR(Study) myStudy; - double myMaxVal, myMinVal; - double myTimeMin, myTimeMax; + double myTimeMinVal, myTimeMaxVal; //!< Range of time stams, set by user + double myTimeMin , myTimeMax ; //!< Range of time stams, available for animation QString myDumpPath; QString myDumpFormat; SVTK_ViewWindow* myView;