]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
Fix bug 11596: Incorrect filling of range of time stamps in 'Setup Animation' dlg...
authorjfa <jfa@opencascade.com>
Fri, 10 Mar 2006 11:14:15 +0000 (11:14 +0000)
committerjfa <jfa@opencascade.com>
Fri, 10 Mar 2006 11:14:15 +0000 (11:14 +0000)
src/VISUGUI/VisuGUI_TimeAnimation.cxx
src/VISU_I/VISU_TimeAnimation.cxx
src/VISU_I/VISU_TimeAnimation.h

index c56ed5d97f8be66d6c5afc84e0e71f7ea7da3e0d..0c531e791e706561863b5680e82012abbe99ed99 100644 (file)
@@ -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() ) );
 
index 718fd97fde01aa3923d9d5b08faca60811f49235..fa5befe56612e2e7a1d87990af36ba8a806ffc4e 100644 (file)
@@ -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<VISU::ScalarMap_i*>(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<VISU::IsoSurfaces_i*>(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<IsoSurfaces_i>(myStudy,
                                         aData,
                                         aResult,
                                         isRangeDefined(),
-                                        myMinVal,
-                                        myMaxVal,
-                                        myTimeMin,
-                                        myTimeMax);
+                                        myTimeMinVal,
+                                        myTimeMaxVal);
     break;
   case VISU::TCUTPLANES: // Cut Planes
     GeneratePresentations<CutPlanes_i>(myStudy,
                                       aData,
                                       aResult,
                                       isRangeDefined(),
-                                      myMinVal,
-                                      myMaxVal,
-                                      myTimeMin,
-                                      myTimeMax);
+                                      myTimeMinVal,
+                                      myTimeMaxVal);
     break;
   case VISU::TCUTLINES: // Cut Lines
     GeneratePresentations<CutLines_i>(myStudy,
                                      aData,
                                      aResult,
                                      isRangeDefined(),
-                                     myMinVal,
-                                     myMaxVal,
-                                     myTimeMin,
-                                     myTimeMax);
+                                     myTimeMinVal,
+                                     myTimeMaxVal);
     break;
   case VISU::TPLOT3D: // Plot3d
     GeneratePresentations<Plot3D_i>(myStudy,
                                    aData,
                                    aResult,
                                    isRangeDefined(),
-                                   myMinVal,
-                                   myMaxVal,
-                                   myTimeMin,
-                                   myTimeMax);
+                                   myTimeMinVal,
+                                   myTimeMaxVal);
     break;
   case VISU::TDEFORMEDSHAPE: // Deformed Shape
     GeneratePresentations<DeformedShape_i>(myStudy,
                                           aData,
                                           aResult,
                                           isRangeDefined(),
-                                          myMinVal,
-                                          myMaxVal,
-                                          myTimeMin,
-                                          myTimeMax);
+                                          myTimeMinVal,
+                                          myTimeMaxVal);
     break;
   case VISU::TVECTORS: // Vectors
     GeneratePresentations<Vectors_i>(myStudy,
                                     aData,
                                     aResult,
                                     isRangeDefined(),
-                                    myMinVal,
-                                    myMaxVal,
-                                    myTimeMin,
-                                    myTimeMax);
+                                    myTimeMinVal,
+                                    myTimeMaxVal);
     break;
   case VISU::TSTREAMLINES: // Stream Lines
     GeneratePresentations<StreamLines_i>(myStudy,
                                         aData,
                                         aResult,
                                         isRangeDefined(),
-                                        myMinVal,
-                                        myMaxVal,
-                                        myTimeMin,
-                                        myTimeMax);
+                                        myTimeMinVal,
+                                        myTimeMaxVal);
     break;
   case VISU::TGAUSSPOINTS: // Gauss Points
     GeneratePresentations<GaussPoints_i>(myStudy,
                                         aData,
                                         aResult,
                                         isRangeDefined(),
-                                        myMinVal,
-                                        myMaxVal,
-                                        myTimeMin,
-                                        myTimeMax);
+                                        myTimeMinVal,
+                                        myTimeMaxVal);
     break;
   case VISU::TSCALARMAPONDEFORMEDSHAPE: // Scalar map on deformed shape
     GeneratePresentations<ScalarMapOnDeformedShape_i>(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()) {
index 4c5ed652b450f1a4b1dde1c7a8736541e726ccc5..bb1925a80348bf7b1432a6fc46fe849038347d3f 100644 (file)
@@ -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;