Commit df07f68f authored by Utkarsh Ayachit's avatar Utkarsh Ayachit

BUG #15320: Fix time precision descrepancies.

The reported bug happened because of loss of double precision when
converting from double to string and then back to double. As a result,
the  methods to find the index for a particular time value ended up
being off by 1 between the multiple instances of pqAnimationTimeWidget.
This fixes that by using maximum precision of 17 for timesteps. Also
updated the xmls to ensure that state files save the same precision for
timesteps.
parent 755c4ca3
......@@ -190,7 +190,7 @@
default_values="none"
name="AnimationTime"
number_of_elements="1"
precision="16">
precision="17">
<Documentation>Set the current animation time.</Documentation>
</DoubleVectorProperty>
<DoubleVectorProperty command="SetStartTime"
......@@ -198,7 +198,7 @@
label="Start Time"
name="StartTime"
number_of_elements="1"
precision="16">
precision="17">
<Documentation>Set the start time for the animation
scene.</Documentation>
</DoubleVectorProperty>
......@@ -207,7 +207,7 @@
label="End Time"
name="EndTime"
number_of_elements="1"
precision="16">
precision="17">
<Documentation>Set the end time for the animation
scene.</Documentation>
</DoubleVectorProperty>
......
......@@ -149,8 +149,10 @@ double vtkSMTimeKeeperProxy::GetLowerBoundTimeStep(double value)
this->GetProperty("TimestepValues"));
if (dvp && dvp->GetNumberOfElements() > 0)
{
// we shirk the range so that if value > the last timestep, this simply
// returns the last timestep's time.
return *(std::lower_bound(dvp->GetElements(),
dvp->GetElements() + dvp->GetNumberOfElements() - 1, // note: this is "last"
dvp->GetElements() + dvp->GetNumberOfElements() - 1,
value));
}
return value;
......@@ -164,8 +166,10 @@ int vtkSMTimeKeeperProxy::GetLowerBoundTimeStepIndex(double value)
this->GetProperty("TimestepValues"));
if (dvp && dvp->GetNumberOfElements() > 0)
{
// we shirk the range so that if value > the last timestep, this simply
// returns the last timestep's index.
const double* first = dvp->GetElements();
const double* last = dvp->GetElements() + dvp->GetNumberOfElements() - 1; // note: this is "last"
const double* last = dvp->GetElements() + dvp->GetNumberOfElements() - 1;
const double* iter = std::lower_bound(first, last, value);
return static_cast<int>(iter - first);
}
......
......@@ -2096,7 +2096,7 @@
default_values="0"
name="Time"
number_of_elements="1"
precision="16"
precision="17"
state_ignored="1">
<!-- state-ignored simply makes this property not be saved in the UndoRedo state -->
<DoubleRangeDomain name="range" />
......@@ -2112,7 +2112,7 @@
information_only="1"
name="TimeRange"
number_of_elements="2"
precision="16"
precision="17"
state_ignored="1">
<!-- state-ignored simply makes this property not be saved in the UndoRedo state -->
<Documentation>This is the time range. It's possible that there are no
......
......@@ -170,10 +170,10 @@ vtkSMProxy* pqAnimationTimeWidget::timeKeeper() const
void pqAnimationTimeWidget::setTimeValue(double time)
{
Ui::AnimationTimeWidget &ui = this->Internals->Ui;
ui.timeValue->setTextAndResetCursor(QString::number(time));
ui.timeValue->setTextAndResetCursor(QString::number(time, 'g', 17));
bool prev = ui.timestepValue->blockSignals(true);
ui.timestepValue->setValue(
vtkSMTimeKeeperProxy::GetLowerBoundTimeStepIndex(this->timeKeeper(), time));
int index = vtkSMTimeKeeperProxy::GetLowerBoundTimeStepIndex(this->timeKeeper(), time);
ui.timestepValue->setValue(index);
ui.timestepValue->blockSignals(prev);
}
......
......@@ -241,8 +241,10 @@ void pqProxyInformationWidget::updateInformation()
{
QTreeWidgetItem * item = new QTreeWidgetItem(this->Ui->timeValues);
item->setData(0, Qt::DisplayRole, i);
item->setData(1, Qt::DisplayRole, tsv->GetElement(i));
item->setData(1, Qt::ToolTipRole, tsv->GetElement(i));
item->setData(1, Qt::DisplayRole,
QString::number(tsv->GetElement(i), 'g', 17));
item->setData(1, Qt::ToolTipRole,
QString::number(tsv->GetElement(i), 'g', 17));
item->setFlags( item->flags() | Qt::ItemIsEditable);
}
}
......
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