diff --git a/Hybrid/vtkAxisActor.cxx b/Hybrid/vtkAxisActor.cxx index 93982e09062fda5e0ddfc525a37e39877a00bad9..4879267b7f358a8795eca254c45b5c917e82b4cb 100644 --- a/Hybrid/vtkAxisActor.cxx +++ b/Hybrid/vtkAxisActor.cxx @@ -39,6 +39,8 @@ vtkStandardNewMacro(vtkAxisActor); vtkCxxSetObjectMacro(vtkAxisActor, Camera, vtkCamera); +vtkCxxSetObjectMacro(vtkAxisActor,LabelTextProperty,vtkTextProperty); +vtkCxxSetObjectMacro(vtkAxisActor,TitleTextProperty,vtkTextProperty); // **************************************************************** // Instantiate this object. @@ -109,6 +111,10 @@ vtkAxisActor::vtkAxisActor() this->TitleActor->SetEnableDistanceLOD(0); 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; @@ -266,6 +272,12 @@ vtkAxisActor::~vtkAxisActor() this->Title = NULL; } + if (this->TitleTextProperty) + { + this->TitleTextProperty->Delete(); + this->TitleTextProperty = NULL; + } + if (this->LabelMappers != NULL) { for (int i=0; i < this->NumberOfLabelsBuilt; i++) @@ -1068,6 +1080,9 @@ void vtkAxisActor::BuildTitle(bool force) 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); @@ -2263,16 +2278,18 @@ double vtkAxisActor::ComputeMaxLabelLength(const double vtkNotUsed(center)[3]) double length, maxLength = 0.; double bounds[6]; double xsize, ysize; + vtkProperty *newProp = this->NewLabelProperty(); for (int i = 0; i < this->NumberOfLabelsBuilt; i++) { this->LabelActors[i]->SetCamera(this->Camera); - this->LabelActors[i]->SetProperty(this->GetProperty()); + this->LabelActors[i]->SetProperty(newProp); this->LabelActors[i]->GetMapper()->GetBounds(bounds); xsize = bounds[1] - bounds[0]; ysize = bounds[3] - bounds[2]; length = sqrt(xsize*xsize + ysize*ysize); maxLength = (length > maxLength ? length : maxLength); } + newProp->Delete(); return maxLength; } @@ -2309,7 +2326,9 @@ double vtkAxisActor::ComputeTitleLength(const double vtkNotUsed(center)[3]) this->TitleVector->SetText(this->Title); this->TitleActor->SetCamera(this->Camera); - this->TitleActor->SetProperty(this->GetProperty()); + vtkProperty * newProp = this->NewTitleProperty(); + this->TitleActor->SetProperty(newProp); + newProp->Delete(); this->TitleActor->GetMapper()->GetBounds(bounds); xsize = bounds[1] - bounds[0]; ysize = bounds[3] - bounds[2]; @@ -2360,32 +2379,12 @@ void vtkAxisActor::SetTitle(const char *t) this->Modified(); } -// **************************************************************************** -void vtkAxisActor::SetTitleTextProperty(vtkTextProperty *prop) -{ - if(this->TitleTextProperty != NULL) - this->TitleTextProperty->Delete(); - if(prop != NULL) - prop->Register(NULL); - this->TitleTextProperty = prop; - this->Modified(); -} - -// **************************************************************************** -void vtkAxisActor::SetLabelTextProperty(vtkTextProperty *prop) -{ - if(this->LabelTextProperty != NULL) - this->LabelTextProperty->Delete(); - if(prop != NULL) - prop->Register(NULL); - this->LabelTextProperty = prop; - this->Modified(); -} - // **************************************************************************** void vtkAxisActor::SetAxisLinesProperty(vtkProperty *prop) { this->AxisLinesActor->SetProperty(prop); + this->LabelTextProperty->SetColor(this->AxisLinesActor->GetProperty()->GetColor()); + this->TitleTextProperty->SetColor(this->AxisLinesActor->GetProperty()->GetColor()); this->Modified(); } @@ -2434,6 +2433,29 @@ vtkProperty* vtkAxisActor::GetGridpolysProperty() return this->GridpolysActor->GetProperty(); } +// **************************************************************************** +vtkProperty* vtkAxisActor::NewTitleProperty() +{ + vtkProperty *newProp = vtkProperty::New(); + newProp->DeepCopy(this->GetProperty()); + newProp->SetColor(this->TitleTextProperty->GetColor()); + // We pass the opacity in the line offset. + newProp->SetOpacity(this->TitleTextProperty->GetLineOffset()); + return newProp; +} + +// **************************************************************************** +vtkProperty* vtkAxisActor::NewLabelProperty() +{ + vtkProperty *newProp = vtkProperty::New(); + newProp->DeepCopy(this->GetProperty()); + newProp->SetColor(this->LabelTextProperty->GetColor()); + // We pass the opacity in the line offset. + newProp->SetOpacity(this->LabelTextProperty->GetLineOffset()); + return newProp; +} + + // **************************************************************************** double vtkAxisActor::GetDeltaMajor(int axis){ if(axis>=0 && axis<=2) diff --git a/Hybrid/vtkAxisActor.h b/Hybrid/vtkAxisActor.h index f2b2d29be0ed6d9d366055b0f561c1b1581d25ec..c59d2f0d5f4ed50a62af25413b16743a451db3cf 100644 --- a/Hybrid/vtkAxisActor.h +++ b/Hybrid/vtkAxisActor.h @@ -190,19 +190,15 @@ public: vtkBooleanMacro(TitleVisibility, int); // Description: - // Get axis title text property. - void SetTitleTextProperty(vtkTextProperty *); - //BTX - vtkGetMacro(TitleTextProperty, vtkTextProperty *); - //ETX + // Set/Get the axis title text property. + virtual void SetTitleTextProperty(vtkTextProperty *p); + vtkGetObjectMacro(TitleTextProperty,vtkTextProperty); // Description: - // Get axis labels text property. - void SetLabelTextProperty(vtkTextProperty *); - //BTX - vtkGetMacro(LabelTextProperty, vtkTextProperty *); - //ETX - + // Set/Get the axis labels text property. + virtual void SetLabelTextProperty(vtkTextProperty *p); + vtkGetObjectMacro(LabelTextProperty,vtkTextProperty); + // Description: // Get/Set axis actor property (axis and its ticks) void SetAxisLinesProperty(vtkProperty *); @@ -440,6 +436,9 @@ private: bool BuildTickPointsForZType(double p1[3], double p2[3], bool); bool TickVisibilityChanged(void); + vtkProperty *NewTitleProperty(); + vtkProperty2D *NewTitleProperty2D(); + vtkProperty *NewLabelProperty(); bool BoundsDisplayCoordinateChanged(vtkViewport *viewport); @@ -481,8 +480,8 @@ private: vtkVectorText **LabelVectors; vtkPolyDataMapper **LabelMappers; vtkAxisFollower **LabelActors; - vtkTextProperty *LabelTextProperty; vtkTextActor **LabelActors2D; + vtkTextProperty *LabelTextProperty; vtkPolyData *AxisLines; vtkPolyDataMapper *AxisLinesMapper;