Commit e565c937 authored by Utkarsh Ayachit's avatar Utkarsh Ayachit

Fixes time value rounding issue.

pqAnimationTimeWidget added spport for using a different display time
precision (#15767). That, however, causing the time to loose precision
between the two instances of pqAnimationTimeWidget we have in the
ParaView UI. Fixed that by keeping track of the full precision value in
pqAnimationTimeWidget. #17966 should make this obsolete, but until
then...
parent 987a52a5
......@@ -99,12 +99,12 @@ pqAnimationTimeWidget::pqAnimationTimeWidget(QWidget* parentObject)
this->setEnabled(false);
Ui::AnimationTimeWidget& ui = this->Internals->Ui;
this->connect(ui.timeValue, SIGNAL(textChangedAndEditingFinished()), SIGNAL(timeValueChanged()));
this->connect(ui.timeValue, SIGNAL(textChangedAndEditingFinished()), SLOT(timeLineEditChanged()));
this->connect(ui.radioButtonValue, SIGNAL(toggled(bool)), SIGNAL(playModeChanged()));
this->connect(
ui.radioButtonValue, SIGNAL(toggled(bool)), SLOT(updateTimestepCountLabelVisibility()));
this->connect(
ui.timestepValue, SIGNAL(valueChangedAndEditingFinished()), SLOT(timestepValueChanged()));
ui.timestepValue, SIGNAL(valueChangedAndEditingFinished()), SLOT(timeSpinBoxChanged()));
}
//-----------------------------------------------------------------------------
......@@ -166,6 +166,7 @@ vtkSMProxy* pqAnimationTimeWidget::timeKeeper() const
void pqAnimationTimeWidget::setTimeValue(double time)
{
Ui::AnimationTimeWidget& ui = this->Internals->Ui;
ui.timeValue->setProperty("PQ_DOUBLE_VALUE", QVariant(time));
ui.timeValue->setTextAndResetCursor(QString::number(time, 'g', this->Internals->Precision));
bool prev = ui.timestepValue->blockSignals(true);
int index = vtkSMTimeKeeperProxy::GetLowerBoundTimeStepIndex(this->timeKeeper(), time);
......@@ -177,7 +178,17 @@ void pqAnimationTimeWidget::setTimeValue(double time)
double pqAnimationTimeWidget::timeValue() const
{
Ui::AnimationTimeWidget& ui = this->Internals->Ui;
return ui.timeValue->text().toDouble();
auto doubleValue = ui.timeValue->property("PQ_DOUBLE_VALUE");
return doubleValue.isValid() ? doubleValue.toDouble() : ui.timeValue->text().toDouble();
}
//-----------------------------------------------------------------------------
void pqAnimationTimeWidget::timeLineEditChanged()
{
auto& ui = this->Internals->Ui;
const auto currentValue = ui.timeValue->text().toDouble();
ui.timeValue->setProperty("PQ_DOUBLE_VALUE", QVariant(currentValue));
emit this->timeValueChanged();
}
//-----------------------------------------------------------------------------
......@@ -249,7 +260,7 @@ void pqAnimationTimeWidget::updateTimestepCountLabelVisibility()
}
//-----------------------------------------------------------------------------
void pqAnimationTimeWidget::timestepValueChanged()
void pqAnimationTimeWidget::timeSpinBoxChanged()
{
Ui::AnimationTimeWidget& ui = this->Internals->Ui;
int index = ui.timestepValue->value();
......
......@@ -130,7 +130,14 @@ private slots:
* to change the current timestep. We will update the current time and
* result in triggering timeValueChanged() if time indeed changed.
*/
void timestepValueChanged();
void timeSpinBoxChanged();
/**
* called when user changes the time value in the line edit.
* we update the internal "full precision" time value and fire
* `timeValueChanged`.
*/
void timeLineEditChanged();
private:
Q_DISABLE_COPY(pqAnimationTimeWidget)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment