From e06bb61801c6805358c0dd1f3fcc908365d8b717 Mon Sep 17 00:00:00 2001 From: vsv Date: Tue, 18 Mar 2008 14:01:58 +0000 Subject: [PATCH] Correction of bug 19202 --- src/VISUGUI/VisuGUI_TimeAnimation.cxx | 83 +++++++++++++++++++-------- src/VISUGUI/VisuGUI_TimeAnimation.h | 16 ++++-- 2 files changed, 70 insertions(+), 29 deletions(-) diff --git a/src/VISUGUI/VisuGUI_TimeAnimation.cxx b/src/VISUGUI/VisuGUI_TimeAnimation.cxx index d6c94084..c0856da8 100644 --- a/src/VISUGUI/VisuGUI_TimeAnimation.cxx +++ b/src/VISUGUI/VisuGUI_TimeAnimation.cxx @@ -90,6 +90,7 @@ #include #define MAXVAL 1e10 +#define VALPRECISION 8 ArrangeDlg::ArrangeDlg(QWidget* theParent, VISU_TimeAnimation* theAnimator) : QDialog(theParent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint), @@ -526,7 +527,7 @@ SetupDlg::SetupDlg (QWidget* theParent, double aMaxTime = myAnimator->getMaxTime(); double aMinTime = myAnimator->getMinTime(); - double aStep; + double aStep = 1; if ( myAnimator->getAnimationMode() == VISU::Animation::PARALLEL ) aStep = (aMaxTime - aMinTime) / (myAnimator->getFieldData(0).myNbTimes - 1); else { // successive animation mode @@ -537,26 +538,38 @@ SetupDlg::SetupDlg (QWidget* theParent, QLabel* aMinLbl = new QLabel("From", myUseRangeBox); aRangeLayout->addWidget(aMinLbl); - myMinVal = new QtxDoubleSpinBox( aMinTime, aMaxTime, aStep, myUseRangeBox ); + //myMinVal = new QtxDoubleSpinBox( aMinTime, aMaxTime, aStep, myUseRangeBox ); + myMinVal = new QLineEdit(myUseRangeBox); + myMinVal->setValidator(new QDoubleValidator(aMinTime, aMaxTime, VALPRECISION, myMinVal)); if (myUseRangeBox->isChecked()) - myMinVal->setValue( myAnimator->getMinRange() ); + myMinVal->setText( QString::number(myAnimator->getMinRange()) ); else - myMinVal->setValue( aMinTime ); - - connect(myMinVal, SIGNAL( valueChanged(double)), - this, SLOT( onMinValue(double) )); + myMinVal->setText( QString::number(aMinTime) ); + + // connect(myMinVal, SIGNAL( valueChanged(double)), + // this, SLOT( onMinValue(double) )); + connect(myMinVal, SIGNAL( editingFinished()), + this, SLOT( onMinValue() )); + connect(myMinVal, SIGNAL( textChanged(const QString&)), + this, SLOT( onMinValueEdit(const QString&) )); aRangeLayout->addWidget(myMinVal); QLabel* aMaxLbl = new QLabel("To", myUseRangeBox); aRangeLayout->addWidget(aMaxLbl); - myMaxVal = new QtxDoubleSpinBox( aMinTime, aMaxTime, aStep, myUseRangeBox ); + //myMaxVal = new QtxDoubleSpinBox( aMinTime, aMaxTime, aStep, myUseRangeBox ); + myMaxVal = new QLineEdit(myUseRangeBox); + myMaxVal->setValidator(new QDoubleValidator(aMinTime, aMaxTime, VALPRECISION, myMaxVal)); if (myUseRangeBox->isChecked()) - myMaxVal->setValue( myAnimator->getMaxRange() ); - else - myMaxVal->setValue( aMaxTime ); - - connect(myMaxVal, SIGNAL( valueChanged(double)), - this, SLOT( onMaxValue(double) )); + myMaxVal->setText( QString::number(myAnimator->getMaxRange()) ); + else { + myMaxVal->setText( QString::number(aMaxTime) ); + } + // connect(myMaxVal, SIGNAL( valueChanged(double)), + // this, SLOT( onMaxValue(double) )); + connect(myMaxVal, SIGNAL( editingFinished() ), + this, SLOT( onMaxValue() )); + connect(myMaxVal, SIGNAL( textChanged(const QString&)), + this, SLOT( onMaxValueEdit(const QString&) )); aRangeLayout->addWidget(myMaxVal); connect(myUseRangeBox, SIGNAL( toggled(bool)), @@ -1041,36 +1054,58 @@ void SetupDlg::onRangeCheck (bool theCheck) if (!theCheck) myAnimator->setAnimationRange(0, 0); else - myAnimator->setAnimationRange(myMinVal->value(), myMaxVal->value()); + myAnimator->setAnimationRange(myMinVal->text().toDouble(), myMaxVal->text().toDouble()); setIsRegenerate( true ); } //------------------------------------------------------------------------ -void SetupDlg::onMinValue (double theVal) +void SetupDlg::onMinValue () { - if (theVal > myAnimator->getMaxRange()) { - myMinVal->setValue( myAnimator->getMinTime() ); + double aVal = myMinVal->text().toDouble(); + if (aVal > myAnimator->getMaxRange()) { + myMinVal->setText( QString::number(myAnimator->getMinTime()) ); myMinVal->setFocus(); return; } - myAnimator->setAnimationRange(theVal, myAnimator->getMaxRange()); + myAnimator->setAnimationRange(aVal, myAnimator->getMaxRange()); setIsRegenerate( true ); } //------------------------------------------------------------------------ -void SetupDlg::onMaxValue (double theVal) +void SetupDlg::onMaxValue () { - if (theVal < myAnimator->getMinRange()) { - myMaxVal->setValue( myAnimator->getMaxTime() ); + double aVal = myMaxVal->text().toDouble(); + if (aVal < myAnimator->getMinRange()) { + myMaxVal->setText( QString::number(myAnimator->getMaxTime()) ); myMaxVal->setFocus(); return; - } - myAnimator->setAnimationRange(myAnimator->getMinRange(), theVal); + } + myAnimator->setAnimationRange(myAnimator->getMinRange(), aVal); setIsRegenerate( true ); } +//------------------------------------------------------------------------ +void SetupDlg::onMinValueEdit (const QString& theVal) +{ + double aVal = theVal.toDouble(); + if ((aVal > myAnimator->getMaxRange()) || (aVal < myAnimator->getMinRange())){ + myMinVal->setText( QString::number(myAnimator->getMinTime()) ); + myMinVal->setFocus(); + return; + } +} + +//------------------------------------------------------------------------ +void SetupDlg::onMaxValueEdit (const QString& theVal) +{ + double aVal = theVal.toDouble(); + if ((aVal > myAnimator->getMaxRange()) || (aVal < myAnimator->getMinRange())) { + myMaxVal->setText( QString::number(myAnimator->getMaxTime()) ); + myMaxVal->setFocus(); + } +} //------------------------------------------------------------------------ void SetupDlg::onSequenceCheck( bool theCheck ) diff --git a/src/VISUGUI/VisuGUI_TimeAnimation.h b/src/VISUGUI/VisuGUI_TimeAnimation.h index 069ae5ab..80aeaf53 100644 --- a/src/VISUGUI/VisuGUI_TimeAnimation.h +++ b/src/VISUGUI/VisuGUI_TimeAnimation.h @@ -52,7 +52,7 @@ namespace VISU class SVTK_ViewWindow; -class QtxDoubleSpinBox; +//class QtxDoubleSpinBox; class QLabel; class QSlider; @@ -139,8 +139,12 @@ class SetupDlg: public QDialog { // void onScalarBarDlg(); void onPreferencesDlg(); void onRangeCheck(bool theCheck); - void onMinValue(double theVal); - void onMaxValue(double theVal); + // void onMinValue(double theVal); + // void onMaxValue(double theVal); + void onMinValue(); + void onMaxValue(); + void onMinValueEdit(const QString&); + void onMaxValueEdit(const QString&); void onSequenceCheck(bool theCheck); void onIndicesChanged(const QString& theIndices); void onValuesChanged(); @@ -160,8 +164,10 @@ class SetupDlg: public QDialog { QPushButton* myPropBtn; QPushButton* myArrangeBtn; QGroupBox* myUseRangeBox; - QtxDoubleSpinBox* myMinVal; - QtxDoubleSpinBox* myMaxVal; + // QtxDoubleSpinBox* myMinVal; + // QtxDoubleSpinBox* myMaxVal; + QLineEdit* myMinVal; + QLineEdit* myMaxVal; QGroupBox* myUseSequenceBox; QLineEdit* myIndices; -- 2.39.2