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

Checkpoint

Change-Id: I47d194634b2c4422e07a6a7831fc7e3f5e9d8d06
parent d1b0ec67
......@@ -36,8 +36,7 @@
#include "vtkRenderWindowInteractor.h"
#include "vtkSmartPointer.h"
#include "vtkTestUtilities.h"
#include "vtkTextProperty.h"
//----------------------------------------------------------------------------
int TestCubeAxes3( int argc, char * argv [] )
......@@ -106,6 +105,7 @@ int TestCubeAxes3( int argc, char * argv [] )
axes2->SetScreenSize(15.0);
axes2->SetFlyModeToClosestTriad();
axes2->SetCornerOffset(0.0);
axes2->GetTitleTextProperty(0)->SetAmbient( 1 );
ren2->AddViewProp(axes2.GetPointer());
renWin->Render();
......
......@@ -31,8 +31,7 @@
#include "vtkRenderWindowInteractor.h"
#include "vtkSmartPointer.h"
#include "vtkTestUtilities.h"
#include "vtkTextProperty.h"
//----------------------------------------------------------------------------
int TestPolarAxes( int argc, char * argv [] )
......@@ -88,7 +87,9 @@ int TestPolarAxes( int argc, char * argv [] )
polaxes->SetCamera( renderer->GetActiveCamera() );
polaxes->SetRadialLabelFormat( "%6.1f" );
polaxes->GetRadialAxesProperty()->SetColor( .0, .0, .9 );
//polaxes->SetScreenSize( 12.0 );
polaxes->SetScreenSize( 12.0 );
polaxes->GetPolarAxisTitleTextProperty()->SetColor( 1., 0., 0. );
polaxes->GetPolarAxisLabelTextProperty()->SetColor( 1., 0., 0. );
vtkNew<vtkRenderWindow> renWin;
renWin->SetMultiSamples( 0 );
......
......@@ -76,18 +76,19 @@ vtkAxisActor::vtkAxisActor()
this->SaveTitlePosition = 0;
this->TitleConstantPosition[0] = this->TitleConstantPosition[1] = 0.0;
this->TitleTextProperty = vtkTextProperty::New();
this->TitleTextProperty->SetColor(1.,1.,1.);
this->TitleTextProperty->SetFontFamilyToArial();
this->TitleVector = vtkVectorText::New();
this->TitleMapper = vtkPolyDataMapper::New();
this->TitleMapper->SetInput(this->TitleVector->GetOutput());
this->TitleActor = vtkAxisFollower::New();
this->TitleActor->SetMapper(this->TitleMapper);
this->TitleActor->SetEnableDistanceLOD(0);
this->TitleActor->GetProperty()->SetColor(this->TitleTextProperty->GetColor());
this->TitleActor2D = vtkTextActor::New();
this->TitleTextProperty = vtkTextProperty::New();
this->TitleTextProperty->SetColor(1.,1.,1.);
this->TitleTextProperty->SetFontFamilyToArial();
// to avoid deleting/rebuilding create once up front
this->NumberOfLabelsBuilt = 0;
this->LabelVectors = NULL;
......@@ -96,7 +97,7 @@ vtkAxisActor::vtkAxisActor()
this->LabelActors2D = NULL;
this->LabelTextProperty = vtkTextProperty::New();
this->LabelTextProperty->SetColor(0.,0.,0.);
this->LabelTextProperty->SetColor(1.,1.,1.);
this->LabelTextProperty->SetFontFamilyToArial();
this->AxisLines = vtkPolyData::New();
......@@ -574,12 +575,6 @@ void vtkAxisActor::BuildAxis(vtkViewport *viewport, bool force)
vtkDebugMacro(<<"Rebuilding axis");
if (force || this->GetProperty()->GetMTime() > this->BuildTime.GetMTime())
{
this->AxisLinesActor->SetProperty(this->GetProperty());
this->TitleActor->SetProperty(this->GetProperty());
}
//
// Generate the axis and tick marks.
//
......@@ -637,7 +632,7 @@ vtkAxisActor::BuildLabels(vtkViewport *viewport, bool force)
for (int i = 0; i < this->NumberOfLabelsBuilt; i++)
{
this->LabelActors[i]->SetCamera(this->Camera);
this->LabelActors[i]->SetProperty(this->GetProperty());
this->LabelActors[i]->GetProperty()->SetColor(this->LabelTextProperty->GetColor());
if(!this->GetCalculateLabelOffset())
{
......@@ -889,10 +884,10 @@ void vtkAxisActor::BuildTitle(bool force)
labHeight = (labBounds[3] - labBounds[2])*scale[1];
maxHeight = (labHeight > maxHeight ? labHeight : maxHeight);
}
this->TitleVector->SetText(this->Title);
this->TitleActor->GetProperty()->SetColor(this->TitleTextProperty->GetColor());
this->TitleActor->GetProperty()->SetOpacity(1);
this->TitleActor->SetCamera(this->Camera);
this->TitleActor->SetPosition(p2[0], p2[1], p2[2]);
this->TitleActor->GetMapper()->GetBounds(titleBounds);
......@@ -1180,6 +1175,7 @@ void vtkAxisActor::SetLabels(vtkStringArray *labels)
this->LabelActors[i] = vtkAxisFollower::New();
this->LabelActors[i]->SetMapper(this->LabelMappers[i]);
this->LabelActors[i]->SetEnableDistanceLOD(0);
this->LabelActors[i]->GetProperty()->SetColor(this->LabelTextProperty->GetColor());
this->LabelActors2D[i] = vtkTextActor::New();
}
}
......@@ -1985,6 +1981,7 @@ double vtkAxisActor::ComputeMaxLabelLength(const double vtkNotUsed(center)[3])
this->LabelActors[i]->SetCamera(this->Camera);
this->LabelActors[i]->SetProperty(newProp);
this->LabelActors[i]->GetMapper()->GetBounds(bounds);
this->LabelActors[i]->GetProperty()->SetColor(this->LabelTextProperty->GetColor());
xsize = bounds[1] - bounds[0];
ysize = bounds[3] - bounds[2];
length = sqrt(xsize*xsize + ysize*ysize);
......@@ -2009,9 +2006,11 @@ double vtkAxisActor::ComputeTitleLength(const double vtkNotUsed(center)[3])
this->TitleActor->SetProperty(newProp);
newProp->Delete();
this->TitleActor->GetMapper()->GetBounds(bounds);
this->TitleActor->GetProperty()->SetColor(this->TitleTextProperty->GetColor());
xsize = bounds[1] - bounds[0];
ysize = bounds[3] - bounds[2];
length = sqrt(xsize*xsize + ysize*ysize);
return length;
}
......@@ -2062,8 +2061,8 @@ void vtkAxisActor::SetTitle(const char *t)
void vtkAxisActor::SetAxisLinesProperty(vtkProperty *prop)
{
this->AxisLinesActor->SetProperty(prop);
this->LabelTextProperty->SetColor(this->AxisLinesActor->GetProperty()->GetColor());
this->TitleTextProperty->SetColor(this->AxisLinesActor->GetProperty()->GetColor());
//this->LabelTextProperty->SetColor(this->AxisLinesActor->GetProperty()->GetColor());
//this->TitleTextProperty->SetColor(this->AxisLinesActor->GetProperty()->GetColor());
this->Modified();
}
......@@ -2119,7 +2118,7 @@ vtkProperty* vtkAxisActor::NewTitleProperty()
newProp->DeepCopy(this->GetProperty());
newProp->SetColor(this->TitleTextProperty->GetColor());
// We pass the opacity in the line offset.
newProp->SetOpacity(this->TitleTextProperty->GetLineOffset());
//newProp->SetOpacity(this->TitleTextProperty->GetLineOffset());
return newProp;
}
......@@ -2130,7 +2129,7 @@ vtkProperty* vtkAxisActor::NewLabelProperty()
newProp->DeepCopy(this->GetProperty());
newProp->SetColor(this->LabelTextProperty->GetColor());
// We pass the opacity in the line offset.
newProp->SetOpacity(this->LabelTextProperty->GetLineOffset());
//newProp->SetOpacity(this->LabelTextProperty->GetLineOffset());
return newProp;
}
......
......@@ -24,6 +24,7 @@
#include "vtkObjectFactory.h"
#include "vtkProperty.h"
#include "vtkStringArray.h"
#include "vtkTextProperty.h"
#include "vtkViewport.h"
......@@ -135,6 +136,17 @@ vtkCubeAxesActor::vtkCubeAxesActor() : vtkActor()
this->ZAxes[i]->GetTitleActor()->SetScreenOffset(this->TitleScreenOffset);
}
for (i = 0; i < 3; i++)
{
this->TitleTextProperty[i] = vtkTextProperty::New();
this->TitleTextProperty[i]->SetColor(1.,1.,1.);
this->TitleTextProperty[i]->SetFontFamilyToArial();
this->LabelTextProperty[i] = vtkTextProperty::New();
this->LabelTextProperty[i]->SetColor(1.,1.,1.);
this->LabelTextProperty[i]->SetFontFamilyToArial();
}
this->XTitle = new char[7];
sprintf(this->XTitle, "%s", "X-Axis");
this->XUnits = NULL;
......@@ -391,6 +403,21 @@ vtkCubeAxesActor::~vtkCubeAxesActor()
this->ZAxesGridpolysProperty->Delete();
}
for (int i = 0; i < 3; i++)
{
if(this->TitleTextProperty[i] != NULL)
{
this->TitleTextProperty[i]->Delete();
}
this->TitleTextProperty[i] = NULL;
if(this->LabelTextProperty[i] != NULL)
{
this->LabelTextProperty[i]->Delete();
}
this->LabelTextProperty[i] = NULL;
}
if (this->XLabelFormat)
{
delete [] this->XLabelFormat;
......@@ -1013,6 +1040,10 @@ void vtkCubeAxesActor::TransformBounds(vtkViewport *viewport,
// ***********************************************************************
bool vtkCubeAxesActor::ComputeTickSize(double bounds[6])
{
bool xPropsChanged = this->LabelTextProperty[0]->GetMTime() > this->BuildTime.GetMTime();
bool yPropsChanged = this->LabelTextProperty[1]->GetMTime() > this->BuildTime.GetMTime();
bool zPropsChanged = this->LabelTextProperty[2]->GetMTime() > this->BuildTime.GetMTime();
bool xRangeChanged = this->LastXRange[0] != bounds[0] ||
this->LastXRange[1] != bounds[1];
......@@ -1022,7 +1053,8 @@ bool vtkCubeAxesActor::ComputeTickSize(double bounds[6])
bool zRangeChanged = this->LastZRange[0] != bounds[4] ||
this->LastZRange[1] != bounds[5];
if (!(xRangeChanged || yRangeChanged || zRangeChanged))
if (!(xRangeChanged || yRangeChanged || zRangeChanged) &&
!(xPropsChanged || yPropsChanged || zPropsChanged))
{
// no need to re-compute ticksize.
return false;
......@@ -1655,6 +1687,8 @@ void vtkCubeAxesActor::SetNonDependentAttributes()
{
this->XAxes[i]->SetCamera(this->Camera);
this->XAxes[i]->SetProperty(prop);
this->XAxes[i]->SetTitleTextProperty(this->TitleTextProperty[0]);
this->XAxes[i]->SetLabelTextProperty(this->LabelTextProperty[0]);
this->XAxes[i]->SetAxisLinesProperty(this->XAxesLinesProperty);
this->XAxes[i]->SetGridlinesProperty(this->XAxesGridlinesProperty);
this->XAxes[i]->SetGridpolysProperty(this->XAxesGridpolysProperty);
......@@ -1671,6 +1705,8 @@ void vtkCubeAxesActor::SetNonDependentAttributes()
this->YAxes[i]->SetCamera(this->Camera);
this->YAxes[i]->SetProperty(prop);
this->YAxes[i]->SetTitleTextProperty(this->TitleTextProperty[1]);
this->YAxes[i]->SetLabelTextProperty(this->LabelTextProperty[1]);
this->YAxes[i]->SetAxisLinesProperty(this->YAxesLinesProperty);
this->YAxes[i]->SetGridlinesProperty(this->YAxesGridlinesProperty);
this->YAxes[i]->SetGridpolysProperty(this->YAxesGridpolysProperty);
......@@ -1687,6 +1723,8 @@ void vtkCubeAxesActor::SetNonDependentAttributes()
this->ZAxes[i]->SetCamera(this->Camera);
this->ZAxes[i]->SetProperty(prop);
this->ZAxes[i]->SetTitleTextProperty(this->TitleTextProperty[2]);
this->ZAxes[i]->SetLabelTextProperty(this->LabelTextProperty[2]);
this->ZAxes[i]->SetAxisLinesProperty(this->ZAxesLinesProperty);
this->ZAxes[i]->SetGridlinesProperty(this->ZAxesGridlinesProperty);
this->ZAxes[i]->SetGridpolysProperty(this->ZAxesGridpolysProperty);
......@@ -2361,6 +2399,24 @@ void vtkCubeAxesActor::SetLabelScaling(bool autoscale, int upowX, int upowY,
}
}
// ****************************************************************************
// Set the i-th title text property.
// ****************************************************************************
vtkTextProperty* vtkCubeAxesActor::GetTitleTextProperty(int axis)
{
return (axis >= 0 && axis < 3) ? this->TitleTextProperty[axis] : NULL;
}
// ****************************************************************************
// Get the i-th label text property.
// ****************************************************************************
vtkTextProperty* vtkCubeAxesActor::GetLabelTextProperty(int axis)
{
return (axis >= 0 && axis < 3) ? this->LabelTextProperty[axis] : NULL;
}
// ****************************************************************************
// Set axes and screen size of the labels.
// ****************************************************************************
......
......@@ -71,6 +71,7 @@ All rights reserve
class vtkAxisActor;
class vtkCamera;
class vtkTextProperty;
class VTK_HYBRID_EXPORT vtkCubeAxesActor : public vtkActor
{
......@@ -337,6 +338,14 @@ public:
void SetLabelScaling(bool, int, int, int);
// Description:
// Returns the text property for the title on an axis.
vtkTextProperty *GetTitleTextProperty(int);
// Description:
// Returns the text property for the labels on an axis.
vtkTextProperty *GetLabelTextProperty(int);
//! use textactor if val = 1 (2D) instead of follower (3D - val = 0) for title
void SetUse2DMode( int val );
//! return 1 if textactor is used
......@@ -499,6 +508,8 @@ private:
double YAxisRange[2];
double ZAxisRange[2];
vtkTextProperty* TitleTextProperty[3];
vtkTextProperty* LabelTextProperty[3];
double LabelScale;
double TitleScale;
......
......@@ -57,7 +57,8 @@ void vtkPolarAxesActor::PrintSelf( ostream& os, vtkIndent indent )
os << indent << "Maximum Radius" << this->MaximumRadius << endl;
os << indent << "Auto-Scale Radius" << this->AutoScaleRadius << endl;
os << indent << "Maximum Angle" << this->MaximumAngle << endl;
os << indent << "Radial Units (degrees): "
<< ( this->RadialUnits ? "On\n" : "Off\n" ) << endl;
if ( this->Camera )
{
......@@ -72,10 +73,10 @@ void vtkPolarAxesActor::PrintSelf( ostream& os, vtkIndent indent )
os << indent << "Rebuild Axes: "
<< ( this->RebuildAxes ? "On\n" : "Off\n" );
os << indent << "Polar Axis Title: " << this->PolarAxisTitle << "\n";
os << indent << "Radial Units (degrees): "
<< ( this->RadialUnits ? "On\n" : "Off\n" ) << endl;
os << indent << "Polar Axis Title: " << this->PolarAxisTitle << "\n";
os << indent << "PolarAxisLabelTextProperty: " << this->PolarAxisLabelTextProperty << endl;
os << indent << "PolarAxisTitleTextProperty: " << this->PolarAxisTitleTextProperty << endl;
os << indent << "Radial Axes Visibility: "
<< ( this->RadialAxesVisibility ? "On\n" : "Off\n" );
......@@ -132,6 +133,17 @@ vtkPolarAxesActor::vtkPolarAxesActor() : vtkActor()
// hence ( this->ScreenSize * 0.5 ).
this->LabelScreenOffset = 20.0 + this->ScreenSize * 0.5;
// Properties of the radial axes
this->RadialAxesProperty = vtkProperty::New();
// Text properties of polar axis title and labels, with default red color
this->PolarAxisTitleTextProperty = vtkTextProperty::New();
this->PolarAxisTitleTextProperty->SetColor( 1., 0. ,0. );
this->PolarAxisTitleTextProperty->SetFontFamilyToArial();
this->PolarAxisLabelTextProperty = vtkTextProperty::New();
this->PolarAxisLabelTextProperty->SetColor( 1., 0. ,0. );
this->PolarAxisLabelTextProperty->SetFontFamilyToArial();
// Create and set radial axes
this->RadialAxes = new vtkAxisActor*[this->NumberOfRadialAxes];
for ( int i = 0; i < this->NumberOfRadialAxes; ++ i )
......@@ -150,14 +162,12 @@ vtkPolarAxesActor::vtkPolarAxesActor() : vtkActor()
follower->SetAxis( axis );
if ( ! i )
{
// Rewrite default screen offset for polar axis only
// Replace default screen offset (for polar axis only)
follower->SetScreenOffset( this->LabelScreenOffset + this->ScreenSize * 0.5 );
follower->GetProperty()->SetColor( this->PolarAxisTitleTextProperty->GetColor() );
}
}
// Properties of the radial axes
this->RadialAxesProperty = vtkProperty::New();
this->ActualRadialLabel = 0;
// Default tick location, defined in vtkAxisActor
......@@ -212,12 +222,24 @@ vtkPolarAxesActor::~vtkPolarAxesActor()
this->RadialLabelFormat = NULL;
}
if (this->PolarAxisTitle)
if ( this->PolarAxisTitle )
{
delete [] this->PolarAxisTitle;
this->PolarAxisTitle = NULL;
}
if ( this->PolarAxisTitleTextProperty )
{
this->PolarAxisTitleTextProperty->Delete();
this->PolarAxisTitleTextProperty = NULL;
}
if ( this->PolarAxisLabelTextProperty )
{
this->PolarAxisLabelTextProperty->Delete();
this->PolarAxisLabelTextProperty = NULL;
}
if ( this->RadialAxes )
{
for ( int i = 0; i < this->NumberOfRadialAxes; ++ i )
......@@ -237,14 +259,26 @@ vtkPolarAxesActor::~vtkPolarAxesActor()
void vtkPolarAxesActor::ShallowCopy( vtkPolarAxesActor *actor )
{
this->Superclass::ShallowCopy( actor );
this->SetBounds( actor->GetBounds() );
this->SetPole( actor->GetPole() );
this->SetMaximumRadius( actor->GetMaximumRadius() );
this->SetAutoScaleRadius( actor->GetAutoScaleRadius() );
this->SetRadialUnits( actor->GetRadialUnits() );
this->SetRadialLabelFormat( actor->GetRadialLabelFormat() );
this->SetPolarAxisTitle( actor->GetPolarAxisTitle() );
this->SetMaximumAngle( actor->GetMaximumAngle() );
this->SetCamera( actor->GetCamera() );
this->SetPolarAxisTitle( actor->GetPolarAxisTitle() );
this->MustAdjustRadialValue = actor->MustAdjustRadialValue;
this->ForceRadialLabelReset = actor->ForceRadialLabelReset;
this->LabelScreenOffset = actor->LabelScreenOffset;
this->ScreenSize = actor->ScreenSize;
this->LabelScreenOffset = actor->LabelScreenOffset;
this->SetRadialLabelFormat( actor->GetRadialLabelFormat() );
this->SetPolarAxisTitleTextProperty( actor->GetPolarAxisTitleTextProperty() );
this->SetPolarAxisLabelTextProperty( actor->GetPolarAxisLabelTextProperty() );
}
// *************************************************************************
......@@ -282,6 +316,13 @@ int vtkPolarAxesActor::RenderOpaqueGeometry( vtkViewport *viewport )
}
}
cerr << endl;
this->GetProperty()->PrintSelf( cerr, vtkIndent(0));
cerr << endl;
this->RadialAxes[0]->GetTitleTextProperty()->PrintSelf( cerr, vtkIndent(0));
cerr << endl;
this->RadialAxes[0]->GetTitleActor()->GetProperty()->PrintSelf( cerr, vtkIndent(0));
cerr << endl;
return renderedSomething;
}
......@@ -491,10 +532,12 @@ void vtkPolarAxesActor::BuildAxes( vtkViewport *viewport )
}
else // if ( i )
{
// Special case of polar axis
axis->SetTitle( this->PolarAxisTitle );
axis->GetTitleTextProperty()->SetColor( this->PolarAxisTitleTextProperty->GetColor() );
}
}
// Build polar axis tick, with respect to specified x-origin
this->BuildPolarAxisTicks( o[0] );
......@@ -578,6 +621,8 @@ void vtkPolarAxesActor::SetNonDependentAttributes()
{
axis->SetLabelVisibility( this->PolarLabelVisibility );
axis->SetTickVisibility( this->PolarTickVisibility );
axis->SetTitleTextProperty( this->GetPolarAxisTitleTextProperty() );
axis->SetLabelTextProperty( this->GetPolarAxisLabelTextProperty() );
}
else
{
......
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