Commit 65e6909b authored by Sebastien Barre's avatar Sebastien Barre
Browse files

ENH: prepare for VTK 4.2. Make the old text API obsolete, use vtkTextProperty instead, see FAQ 6.14

parent 1d2162ef
......@@ -75,16 +75,22 @@ ren2 AddProp outlineActor
ren1 SetBackground 0.1 0.2 0.4
ren2 SetBackground 0.1 0.2 0.4
# Create a text property for both cube axes
#
vtkTextProperty tprop
tprop SetColor 1 1 1
tprop ShadowOn
# Create a vtkCubeAxesActor2D. Use the outer edges of the bounding box to
# draw the axes. Add the actor to the renderer.
vtkCubeAxesActor2D axes
axes SetInput [normals GetOutput]
axes SetCamera [ren1 GetActiveCamera]
axes SetLabelFormat "%6.4g"
axes ShadowOn
axes SetFlyModeToOuterEdges
axes SetFontFactor 0.8
[axes GetProperty] SetColor 1 1 1
axes SetAxisTitleTextProperty tprop
axes SetAxisLabelTextProperty tprop
ren1 AddProp axes
# Create a vtkCubeAxesActor2D. Use the closest vertex to the camera to
......@@ -93,11 +99,11 @@ vtkCubeAxesActor2D axes2
axes2 SetProp foheActor
axes2 SetCamera [ren2 GetActiveCamera]
axes2 SetLabelFormat "%6.4g"
axes2 ShadowOn
axes2 SetFlyModeToClosestTriad
axes2 SetFontFactor 0.8
[axes2 GetProperty] SetColor 1 1 1
axes2 ScalingOff
axes2 SetAxisTitleTextProperty tprop
axes2 SetAxisLabelTextProperty tprop
ren2 AddProp axes2
# Render
......
......@@ -58,25 +58,29 @@ if { [info command rtExMath] == ""} {
ren1 SetBackground 0.1 0.2 0.4
ren2 SetBackground 0.1 0.2 0.4
vtkTextProperty tprop
tprop SetColor 1 1 1
tprop ShadowOn
vtkCubeAxesActor2D axes
axes SetInput [normals GetOutput]
axes SetCamera [ren1 GetActiveCamera]
axes SetLabelFormat "%6.1f"
axes ShadowOn
axes SetFlyModeToOuterEdges
axes SetFontFactor 0.8
[axes GetProperty] SetColor 1 1 1
axes SetAxisTitleTextProperty tprop
axes SetAxisLabelTextProperty tprop
ren1 AddProp axes
vtkCubeAxesActor2D axes2
axes2 SetProp foheActor
axes2 SetCamera [ren2 GetActiveCamera]
axes2 SetLabelFormat [axes GetLabelFormat]
axes2 SetShadow [axes GetShadow]
axes2 SetFlyModeToClosestTriad
axes2 SetFontFactor [axes GetFontFactor]
[axes2 GetProperty] SetColor 1 1 1
axes2 ScalingOff
axes2 SetAxisTitleTextProperty tprop
axes2 SetAxisLabelTextProperty tprop
ren2 AddProp axes2
renWin Render
......
......@@ -33,7 +33,7 @@
#include "vtkTextProperty.h"
#include "vtkViewport.h"
vtkCxxRevisionMacro(vtkCaptionActor2D, "1.21");
vtkCxxRevisionMacro(vtkCaptionActor2D, "1.22");
vtkStandardNewMacro(vtkCaptionActor2D);
vtkCxxSetObjectMacro(vtkCaptionActor2D,LeaderGlyph,vtkPolyData);
......@@ -508,16 +508,21 @@ void vtkCaptionActor2D::ShallowCopy(vtkProp *prop)
//----------------------------------------------------------------------------
// Backward compatibility calls
#ifndef VTK_REMOVE_LEGACY_CODE
void vtkCaptionActor2D::SetFontFamily(int val)
{
VTK_LEGACY_METHOD(SetFontFamily, "4.2");
if (this->CaptionTextProperty)
{
this->CaptionTextProperty->SetFontFamily(val);
}
}
#endif
#ifndef VTK_REMOVE_LEGACY_CODE
int vtkCaptionActor2D::GetFontFamily()
{
VTK_LEGACY_METHOD(GetFontFamily, "4.2");
if (this->CaptionTextProperty)
{
return this->CaptionTextProperty->GetFontFamily();
......@@ -527,17 +532,23 @@ int vtkCaptionActor2D::GetFontFamily()
return 0;
}
}
#endif
#ifndef VTK_REMOVE_LEGACY_CODE
void vtkCaptionActor2D::SetBold(int val)
{
VTK_LEGACY_METHOD(SetBold, "4.2");
if (this->CaptionTextProperty)
{
this->CaptionTextProperty->SetBold(val);
}
}
#endif
#ifndef VTK_REMOVE_LEGACY_CODE
int vtkCaptionActor2D::GetBold()
{
VTK_LEGACY_METHOD(GetBold, "4.2");
if (this->CaptionTextProperty)
{
return this->CaptionTextProperty->GetBold();
......@@ -547,17 +558,23 @@ int vtkCaptionActor2D::GetBold()
return 0;
}
}
#endif
#ifndef VTK_REMOVE_LEGACY_CODE
void vtkCaptionActor2D::SetItalic(int val)
{
VTK_LEGACY_METHOD(SetItalic, "4.2");
if (this->CaptionTextProperty)
{
this->CaptionTextProperty->SetItalic(val);
}
}
#endif
#ifndef VTK_REMOVE_LEGACY_CODE
int vtkCaptionActor2D::GetItalic()
{
VTK_LEGACY_METHOD(GetItalic, "4.2");
if (this->CaptionTextProperty)
{
return this->CaptionTextProperty->GetItalic();
......@@ -567,17 +584,23 @@ int vtkCaptionActor2D::GetItalic()
return 0;
}
}
#endif
#ifndef VTK_REMOVE_LEGACY_CODE
void vtkCaptionActor2D::SetShadow(int val)
{
VTK_LEGACY_METHOD(SetShadow, "4.2");
if (this->CaptionTextProperty)
{
this->CaptionTextProperty->SetShadow(val);
}
}
#endif
#ifndef VTK_REMOVE_LEGACY_CODE
int vtkCaptionActor2D::GetShadow()
{
VTK_LEGACY_METHOD(GetShadow, "4.2");
if (this->CaptionTextProperty)
{
return this->CaptionTextProperty->GetShadow();
......@@ -587,17 +610,23 @@ int vtkCaptionActor2D::GetShadow()
return 0;
}
}
#endif
#ifndef VTK_REMOVE_LEGACY_CODE
void vtkCaptionActor2D::SetJustification(int val)
{
VTK_LEGACY_METHOD(SetJustification, "4.2");
if (this->CaptionTextProperty)
{
this->CaptionTextProperty->SetJustification(val);
}
}
#endif
#ifndef VTK_REMOVE_LEGACY_CODE
int vtkCaptionActor2D::GetJustification()
{
VTK_LEGACY_METHOD(GetJustification, "4.2");
if (this->CaptionTextProperty)
{
return this->CaptionTextProperty->GetJustification();
......@@ -607,17 +636,23 @@ int vtkCaptionActor2D::GetJustification()
return 0;
}
}
#endif
#ifndef VTK_REMOVE_LEGACY_CODE
void vtkCaptionActor2D::SetVerticalJustification(int val)
{
VTK_LEGACY_METHOD(SetVerticalJustification, "4.2");
if (this->CaptionTextProperty)
{
this->CaptionTextProperty->SetVerticalJustification(val);
}
}
#endif
#ifndef VTK_REMOVE_LEGACY_CODE
int vtkCaptionActor2D::GetVerticalJustification()
{
VTK_LEGACY_METHOD(GetVerticalJustification, "4.2");
if (this->CaptionTextProperty)
{
return this->CaptionTextProperty->GetVerticalJustification();
......@@ -627,3 +662,4 @@ int vtkCaptionActor2D::GetVerticalJustification()
return 0;
}
}
#endif
......@@ -140,6 +140,7 @@ public:
virtual void SetCaptionTextProperty(vtkTextProperty *p);
vtkGetObjectMacro(CaptionTextProperty,vtkTextProperty);
#ifndef VTK_REMOVE_LEGACY_CODE
// Description:
// Set/Get the font family. Three font types are allowed: Arial (VTK_ARIAL),
// Courier (VTK_COURIER), and Times (VTK_TIMES).
......@@ -150,7 +151,9 @@ public:
void SetFontFamilyToArial() { this->SetFontFamily(VTK_ARIAL); };
void SetFontFamilyToCourier() { this->SetFontFamily(VTK_COURIER);};
void SetFontFamilyToTimes() { this->SetFontFamily(VTK_TIMES); };
#endif
#ifndef VTK_REMOVE_LEGACY_CODE
// Description:
// Enable/disable text bolding.
// Warning: these functions remain for backward compatibility. Use the
......@@ -158,7 +161,9 @@ public:
virtual void SetBold(int val);
virtual int GetBold();
vtkBooleanMacro(Bold, int);
#endif
#ifndef VTK_REMOVE_LEGACY_CODE
// Description:
// Enable/disable text italic.
// Warning: these functions remain for backward compatibility. Use the
......@@ -166,7 +171,9 @@ public:
virtual void SetItalic(int val);
virtual int GetItalic();
vtkBooleanMacro(Italic, int);
#endif
#ifndef VTK_REMOVE_LEGACY_CODE
// Description:
// Enable/disable text shadows.
// Warning: these functions remain for backward compatibility. Use the
......@@ -174,7 +181,9 @@ public:
virtual void SetShadow(int val);
virtual int GetShadow();
vtkBooleanMacro(Shadow, int);
#endif
#ifndef VTK_REMOVE_LEGACY_CODE
// Description:
// Set/Get the horizontal justification to left (default), centered,
// or right.
......@@ -188,7 +197,9 @@ public:
{ this->SetJustification(VTK_TEXT_CENTERED);};
void SetJustificationToRight()
{ this->SetJustification(VTK_TEXT_RIGHT);};
#endif
#ifndef VTK_REMOVE_LEGACY_CODE
// Description:
// Set/Get the vertical justification to bottom (default), middle,
// or top.
......@@ -202,6 +213,7 @@ public:
{this->SetVerticalJustification(VTK_TEXT_CENTERED);};
void SetVerticalJustificationToTop()
{this->SetVerticalJustification(VTK_TEXT_TOP);};
#endif
// Description:
// Shallow copy of this scaled text actor. Overloads the virtual
......
......@@ -25,7 +25,7 @@
#include "vtkTextProperty.h"
#include "vtkViewport.h"
vtkCxxRevisionMacro(vtkCubeAxesActor2D, "1.37");
vtkCxxRevisionMacro(vtkCubeAxesActor2D, "1.38");
vtkStandardNewMacro(vtkCubeAxesActor2D);
vtkCxxSetObjectMacro(vtkCubeAxesActor2D,Input, vtkDataSet);
......@@ -1007,8 +1007,10 @@ static int IsInBounds(float x[3], float bounds[6])
//----------------------------------------------------------------------------
// Backward compatibility calls
#ifndef VTK_REMOVE_LEGACY_CODE
void vtkCubeAxesActor2D::SetFontFamily(int val)
{
VTK_LEGACY_METHOD(SetFontFamily, "4.2");
if (this->AxisLabelTextProperty)
{
this->AxisLabelTextProperty->SetFontFamily(val);
......@@ -1018,9 +1020,12 @@ void vtkCubeAxesActor2D::SetFontFamily(int val)
this->AxisTitleTextProperty->SetFontFamily(val);
}
}
#endif
#ifndef VTK_REMOVE_LEGACY_CODE
int vtkCubeAxesActor2D::GetFontFamily()
{
VTK_LEGACY_METHOD(GetFontFamily, "4.2");
if (this->AxisLabelTextProperty)
{
return this->AxisLabelTextProperty->GetFontFamily();
......@@ -1030,9 +1035,12 @@ int vtkCubeAxesActor2D::GetFontFamily()
return 0;
}
}
#endif
#ifndef VTK_REMOVE_LEGACY_CODE
void vtkCubeAxesActor2D::SetBold(int val)
{
VTK_LEGACY_METHOD(SetBold, "4.2");
if (this->AxisLabelTextProperty)
{
this->AxisLabelTextProperty->SetBold(val);
......@@ -1042,9 +1050,12 @@ void vtkCubeAxesActor2D::SetBold(int val)
this->AxisTitleTextProperty->SetBold(val);
}
}
#endif
#ifndef VTK_REMOVE_LEGACY_CODE
int vtkCubeAxesActor2D::GetBold()
{
VTK_LEGACY_METHOD(GetBold, "4.2");
if (this->AxisLabelTextProperty)
{
return this->AxisLabelTextProperty->GetBold();
......@@ -1054,9 +1065,12 @@ int vtkCubeAxesActor2D::GetBold()
return 0;
}
}
#endif
#ifndef VTK_REMOVE_LEGACY_CODE
void vtkCubeAxesActor2D::SetItalic(int val)
{
VTK_LEGACY_METHOD(SetItalic, "4.2");
if (this->AxisLabelTextProperty)
{
this->AxisLabelTextProperty->SetItalic(val);
......@@ -1066,9 +1080,12 @@ void vtkCubeAxesActor2D::SetItalic(int val)
this->AxisTitleTextProperty->SetItalic(val);
}
}
#endif
#ifndef VTK_REMOVE_LEGACY_CODE
int vtkCubeAxesActor2D::GetItalic()
{
VTK_LEGACY_METHOD(GetItalic, "4.2");
if (this->AxisLabelTextProperty)
{
return this->AxisLabelTextProperty->GetItalic();
......@@ -1078,9 +1095,12 @@ int vtkCubeAxesActor2D::GetItalic()
return 0;
}
}
#endif
#ifndef VTK_REMOVE_LEGACY_CODE
void vtkCubeAxesActor2D::SetShadow(int val)
{
VTK_LEGACY_METHOD(SetShadow, "4.2");
if (this->AxisLabelTextProperty)
{
this->AxisLabelTextProperty->SetShadow(val);
......@@ -1090,9 +1110,12 @@ void vtkCubeAxesActor2D::SetShadow(int val)
this->AxisTitleTextProperty->SetShadow(val);
}
}
#endif
#ifndef VTK_REMOVE_LEGACY_CODE
int vtkCubeAxesActor2D::GetShadow()
{
VTK_LEGACY_METHOD(GetShadow, "4.2");
if (this->AxisLabelTextProperty)
{
return this->AxisLabelTextProperty->GetShadow();
......@@ -1102,3 +1125,4 @@ int vtkCubeAxesActor2D::GetShadow()
return 0;
}
}
#endif
......@@ -180,6 +180,7 @@ public:
virtual void SetAxisLabelTextProperty(vtkTextProperty *p);
vtkGetObjectMacro(AxisLabelTextProperty,vtkTextProperty);
#ifndef VTK_REMOVE_LEGACY_CODE
// Description:
// Set/Get the font family. Three font types are allowed: Arial (VTK_ARIAL),
// Courier (VTK_COURIER), and Times (VTK_TIMES).
......@@ -190,7 +191,9 @@ public:
void SetFontFamilyToArial() { this->SetFontFamily(VTK_ARIAL); };
void SetFontFamilyToCourier() { this->SetFontFamily(VTK_COURIER);};
void SetFontFamilyToTimes() { this->SetFontFamily(VTK_TIMES); };
#endif
#ifndef VTK_REMOVE_LEGACY_CODE
// Description:
// Enable/disable text bolding.
// Warning: these functions remain for backward compatibility. Use the
......@@ -198,7 +201,9 @@ public:
virtual void SetBold(int val);
virtual int GetBold();
vtkBooleanMacro(Bold, int);
#endif
#ifndef VTK_REMOVE_LEGACY_CODE
// Description:
// Enable/disable text italic.
// Warning: these functions remain for backward compatibility. Use the
......@@ -206,7 +211,9 @@ public:
virtual void SetItalic(int val);
virtual int GetItalic();
vtkBooleanMacro(Italic, int);
#endif
#ifndef VTK_REMOVE_LEGACY_CODE
// Description:
// Enable/disable text shadows.
// Warning: these functions remain for backward compatibility. Use the
......@@ -214,6 +221,7 @@ public:
virtual void SetShadow(int val);
virtual int GetShadow();
vtkBooleanMacro(Shadow, int);
#endif
// Description:
// Set/Get the format with which to print the labels on each of the
......
......@@ -30,7 +30,7 @@
#include "vtkTransformPolyDataFilter.h"
#include "vtkViewport.h"
vtkCxxRevisionMacro(vtkLegendBoxActor, "1.23");
vtkCxxRevisionMacro(vtkLegendBoxActor, "1.24");
vtkStandardNewMacro(vtkLegendBoxActor);
vtkCxxSetObjectMacro(vtkLegendBoxActor,EntryTextProperty,vtkTextProperty);
......@@ -714,16 +714,21 @@ void vtkLegendBoxActor::ShallowCopy(vtkProp *prop)
//----------------------------------------------------------------------------
// Backward compatibility calls
#ifndef VTK_REMOVE_LEGACY_CODE
void vtkLegendBoxActor::SetFontFamily(int val)
{
VTK_LEGACY_METHOD(SetFontFamily, "4.2");
if (this->EntryTextProperty)
{
this->EntryTextProperty->SetFontFamily(val);
}
}
#endif
#ifndef VTK_REMOVE_LEGACY_CODE
int vtkLegendBoxActor::GetFontFamily()
{
VTK_LEGACY_METHOD(GetFontFamily, "4.2");
if (this->EntryTextProperty)
{
return this->EntryTextProperty->GetFontFamily();
......@@ -733,17 +738,23 @@ int vtkLegendBoxActor::GetFontFamily()
return 0;
}
}
#endif
#ifndef VTK_REMOVE_LEGACY_CODE
void vtkLegendBoxActor::SetBold(int val)
{
VTK_LEGACY_METHOD(SetBold, "4.2");
if (this->EntryTextProperty)
{
this->EntryTextProperty->SetBold(val);
}
}
#endif
#ifndef VTK_REMOVE_LEGACY_CODE
int vtkLegendBoxActor::GetBold()
{
VTK_LEGACY_METHOD(GetBold, "4.2");
if (this->EntryTextProperty)
{
return this->EntryTextProperty->GetBold();
......@@ -753,17 +764,23 @@ int vtkLegendBoxActor::GetBold()
return 0;
}
}
#endif
#ifndef VTK_REMOVE_LEGACY_CODE
void vtkLegendBoxActor::SetItalic(int val)
{
VTK_LEGACY_METHOD(SetItalic, "4.2");
if (this->EntryTextProperty)
{
this->EntryTextProperty->SetItalic(val);
}
}
#endif
#ifndef VTK_REMOVE_LEGACY_CODE
int vtkLegendBoxActor::GetItalic()
{
VTK_LEGACY_METHOD(GetItalic, "4.2");
if (this->EntryTextProperty)
{
return this->EntryTextProperty->GetItalic();
......@@ -773,17 +790,23 @@ int vtkLegendBoxActor::GetItalic()
return 0;
}
}
#endif
#ifndef VTK_REMOVE_LEGACY_CODE
void vtkLegendBoxActor::SetShadow(int val)
{
VTK_LEGACY_METHOD(SetShadow, "4.2");
if (this->EntryTextProperty)
{
this->EntryTextProperty->SetShadow(val);
}
}
#endif
#ifndef VTK_REMOVE_LEGACY_CODE
int vtkLegendBoxActor::GetShadow()
{
VTK_LEGACY_METHOD(GetShadow, "4.2");
if (this->EntryTextProperty)
{
return this->EntryTextProperty->GetShadow();
......@@ -793,3 +816,4 @@ int vtkLegendBoxActor::GetShadow()
return 0;
}
}
#endif
......@@ -91,6 +91,7 @@ public:
virtual void SetEntryTextProperty(vtkTextProperty *p);
vtkGetObjectMacro(EntryTextProperty,vtkTextProperty);
#ifndef VTK_REMOVE_LEGACY_CODE
// Description:
// Set/Get the font family. Three font types are allowed: Arial (VTK_ARIAL),
// Courier (VTK_COURIER), and Times (VTK_TIMES).
......@@ -101,7 +102,9 @@ public:
void SetFontFamilyToArial() { this->SetFontFamily(VTK_ARIAL); };
void SetFontFamilyToCourier() { this->SetFontFamily(VTK_COURIER);};
void SetFontFamilyToTimes() { this->SetFontFamily(VTK_TIMES); };
#endif
#ifndef VTK_REMOVE_LEGACY_CODE
// Description:
// Enable/disable text bolding.
// Warning: these functions remain for backward compatibility. Use the
......@@ -109,7 +112,9 @@ public:
virtual void SetBold(int val);
virtual int GetBold();
vtkBooleanMacro(Bold, int);
#endif
#ifndef VTK_REMOVE_LEGACY_CODE
// Description:
// Enable/disable text italic.
// Warning: these functions remain for backward compatibility. Use the
......@@ -117,7 +122,9 @@ public:
virtual void SetItalic(int val);
virtual int GetItalic();
vtkBooleanMacro(Italic, int);
#endif
#ifndef VTK_REMOVE_LEGACY_CODE
// Description:
// Enable/disable text shadows.
// Warning: these functions remain for backward compatibility. Use the
......@@ -125,6 +132,7 @@ public:
virtual void SetShadow(int val);
virtual int GetShadow();
vtkBooleanMacro(Shadow, int);
#endif
// Description:
// Set/Get the flag that controls whether a border will be drawn
......
......@@ -40,7 +40,7 @@
#define VTK_MAX_PLOTS 50
vtkCxxRevisionMacro(vtkXYPlotActor, "1.42");
vtkCxxRevisionMacro(vtkXYPlotActor, "1.43");
vtkStandardNewMacro(vtkXYPlotActor);
vtkCxxSetObjectMacro(vtkXYPlotActor,TitleTextProperty,vtkTextProperty);
......@@ -2075,11 +2075,46 @@ float *vtkXYPlotActor::TransformPoint(int pos[2], int pos2[2], float x[3], float
return xNew;
}
//----------------------------------------------------------------------------
void vtkXYPlotActor::SetLabelFormat(const char* _arg)
{
if (this->LabelFormat == NULL && _arg == NULL)
{
return;
}
if (this->LabelFormat && _arg && (!strcmp(this->LabelFormat,_arg)))
{
return;
}
if (this->LabelFormat)
{
delete [] this->LabelFormat;
}
if (_arg)
{
this->LabelFormat = new char[strlen(_arg)+1];
strcpy(this->LabelFormat,_arg);
}
else
{
this->LabelFormat = NULL;
}
this->XAxis->SetLabelFormat(this->LabelFormat);
this->YAxis->SetLabelFormat(this->LabelFormat);