VTKCubeAxesActor:ComputeTickSize ; does not always honor changes when custom range is set. (Fix included)
This issue was created automatically from an original Mantis Issue. Further discussion may take place here.
Issue found with a patched*(footnote) version Paraview 3.14.1 so I don't know which version of vtk I should file this under.
PROBLEM: When SetXRange is used to set a custom range, the tick and labels may not updated.
Cause: In vtkCubeAxesActor::ComputeTickSize(double bounds[6]) { (identical code for Y and Z axes omitted)
bool xRangeChanged = this->LastXRange[0] != bounds[0] || ...
if (!(xRangeChanged || yRangeChanged || ...)) { // no need to re-compute ticksize. return false; <<<<< **** RETURNS EARLY HERE WHEN IT SHOULD NOT. **** }
So... why is LastXRange's value incorrect? Later in the same function, we have the following logic.
this->LastXRange[0] = (this->XAxisRange[0] == VTK_DOUBLE_MAX ? bounds[0] : this->XAxisRange[0]);
->The fix is to check for changes in both the range AND the bounds.
The attached cxx file includes a new field "LastBound" to catch these kinds of modifications that need to force an update to the tick marks. The main changes are in ComputeTickSize and are highlighted below -
vtkCubeAxesActor::ComputeTickSize(double bounds[6]) { ...
double xrange[2], yrange[2], zrange[2];
xrange[0] = (this->XAxisRange[0] == VTK_DOUBLE_MAX ? bounds[0] : this->XAxisRange[0]); ... bool xRangeChanged = this->LastXRange[0] != xrange[0] || ...
Also do explicit bounds check - bool boundsChanged = this->LastBounds[0] != bounds[0] || ... this->LastBounds[5] != bounds[5];
// A new boundsChange check - if (!(xRangeChanged || yRangeChanged || zRangeChanged || boundsChanged) &&
And at the end of the function, we cache the range AND bounds we used- this->LastXRange[0] = xrange[0]; this->LastXRange[1] = xrange[1]; this->LastYRange[0] = yrange[0]; this->LastYRange[1] = yrange[1]; this->LastZRange[0] = zrange[0]; this->LastZRange[1] = zrange[1]; for( int i =0; i < 6; i++) { this->LastBounds[0] = bounds[0]; }
Footnote: This will not affect the official Paraview until http://vtk.org/Bug/view.php?id=13093 is included.