Commit a58d6410 authored by Philippe Pébay's avatar Philippe Pébay
Browse files

Corrected placement of ticks on polar axis; and other problems

Change-Id: Ied2d3dd4d20b97c67fa6435174417cf416ea1359
parent 6bd6de06
......@@ -80,9 +80,11 @@ int TestPolarAxes( int argc, char * argv [] )
vtkNew<vtkPolarAxesActor> polaxes;
polaxes->SetBounds( normals->GetOutput()->GetBounds() );
polaxes->SetPole( -3., 0., 2. );
polaxes->SetPole( 0., 1., 3. );
polaxes->SetAutoScaleRadius( false );
polaxes->SetMaximumRadius( 6. );
polaxes->SetMaximumRadius( 3. );
polaxes->SetMaximumAngle( 180. );
polaxes->SetNumberOfRadialAxes( 7 );
polaxes->SetCamera( renderer->GetActiveCamera() );
polaxes->SetRadialLabelFormat( "%6.1f" );
polaxes->GetRadialAxesProperty()->SetColor( .0, .0, .9 );
......
......@@ -435,7 +435,6 @@ void vtkPolarAxesActor::BuildAxes( vtkViewport *viewport )
// Prepare axes for rendering with user-definable options
double dAlpha = this->MaximumAngle / ( this->NumberOfRadialAxes - 1. );
this->BuildPolarAxisTicks( bounds[0], bounds[1] );
// this->BuildLabels( this->RadialAxes );
// this->UpdateLabels( this->RadialAxes );
......@@ -465,6 +464,8 @@ void vtkPolarAxesActor::BuildAxes( vtkViewport *viewport )
axis->SetTitle( thetaStream.str().c_str() );
}
this->BuildPolarAxisTicks( o[0] );
if ( this->ForceRadialLabelReset )
{
// Must recompute the scale
......@@ -575,23 +576,10 @@ inline double vtkPolarAxesActor::FSign( double value, double sign )
}
// *******************************************************************
void vtkPolarAxesActor::BuildPolarAxisTicks( double boundsMin,
double boundsMax )
void vtkPolarAxesActor::BuildPolarAxisTicks( double origin )
{
vtkAxisActor* axis = this->RadialAxes[0];
double sortedRange[2], range;
double fxt, fnt, frac;
double div, major;
double majorStart;
int numTicks;
double *inRange = axis->GetRange();
sortedRange[0] = inRange[0] < inRange[1] ? inRange[0] : inRange[1];
sortedRange[1] = inRange[0] > inRange[1] ? inRange[0] : inRange[1];
range = sortedRange[1] - sortedRange[0];
// Find the integral points.
double range = this->MaximumRadius;
double pow10 = log10( range );
// Build in numerical tolerance
......@@ -607,15 +595,15 @@ void vtkPolarAxesActor::BuildPolarAxisTicks( double boundsMin,
pow10 = pow10 - 1.;
}
fxt = pow( 10., this->FFix( pow10 ) );
double fxt = pow( 10., this->FFix( pow10 ) );
// Find the number of integral points in the interval.
fnt = range/fxt;
double fnt = range / fxt;
fnt = this->FFix( fnt );
frac = fnt;
numTicks = frac <= 0.5 ? static_cast<int>( this->FFix( fnt ) ) : static_cast<int>( this->FFix( fnt ) + 1 );
double frac = fnt;
int numTicks = frac <= 0.5 ? static_cast<int>( this->FFix( fnt ) ) : static_cast<int>( this->FFix( fnt ) + 1 );
div = 1.;
double div = 1.;
if ( numTicks < 5 )
{
div = 2.;
......@@ -627,7 +615,7 @@ void vtkPolarAxesActor::BuildPolarAxisTicks( double boundsMin,
// If there aren't enough major tick points in this decade, use the next
// decade.
major = fxt;
double major = fxt;
if ( div != 1.)
{
major /= div;
......@@ -635,6 +623,13 @@ void vtkPolarAxesActor::BuildPolarAxisTicks( double boundsMin,
// Figure out the first major tick locations, relative to the
// start of the axis.
double sortedRange[2];
vtkAxisActor* axis = this->RadialAxes[0];
double *inRange = axis->GetRange();
sortedRange[0] = inRange[0] < inRange[1] ? inRange[0] : inRange[1];
sortedRange[1] = inRange[0] > inRange[1] ? inRange[0] : inRange[1];
double majorStart;
if ( sortedRange[0] <= 0.)
{
majorStart = major * ( this->FFix( sortedRange[0]*( 1./major ) ) + 0. );
......@@ -648,9 +643,7 @@ void vtkPolarAxesActor::BuildPolarAxisTicks( double boundsMin,
axis->SetDeltaRangeMajor( major );
double t = ( majorStart - sortedRange[0] ) / range;
majorStart = t * boundsMax + ( 1. - t ) * boundsMin;
const double scale = ( boundsMax - boundsMin ) / range;
major *= scale;
majorStart = t * range + origin;
// Set major start and deltas
axis->SetMajorStart( VTK_AXIS_TYPE_X, majorStart );
......
......@@ -32,7 +32,7 @@ All rights reserve
#ifndef __vtkPolarAxesActor_h
#define __vtkPolarAxesActor_h
#define VTK_DEFAULT_NUMBER_OF_RADIAL_AXES 5
#define VTK_DEFAULT_NUMBER_OF_RADIAL_AXES 100
#define VTK_DEFAULT_MAXIMUM_POLAR_ANGLE 90.0
#include "vtkActor.h"
......@@ -203,8 +203,7 @@ protected:
// Description:
// Prepare ticks on polar axis
void BuildPolarAxisTicks( double rangeMin,
double rangeMax );
void BuildPolarAxisTicks( double );
int LabelExponent(double min, double max );
......
Supports Markdown
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