Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Christian Butz
VTK
Commits
8dd0c44f
Commit
8dd0c44f
authored
Nov 18, 2011
by
Philippe Pébay
Browse files
Created a separate handling of the polar axis from other radial axes
Change-Id: Ica590d2611782515f31a697004a64976e46e45f2
parent
f97646aa
Changes
4
Hide whitespace changes
Inline
Side-by-side
Examples/Hybrid/Python/CylinderAndPolarAxes.py
View file @
8dd0c44f
...
...
@@ -42,7 +42,7 @@ polaxes.SetNumberOfRadialAxes( 10 )
polaxes
.
SetNumberOfPolarAxisTicks
(
12
)
polaxes
.
SetAutoSubdividePolarAxis
(
0
)
polaxes
.
SetCamera
(
camera
)
polaxes
.
Set
Radial
LabelFormat
(
"%6.1f"
)
polaxes
.
Set
Polar
LabelFormat
(
"%6.1f"
)
polaxes
.
GetRadialAxesProperty
().
SetColor
(
.
0
,
.
0
,
1.
)
polaxes
.
GetPolarArcsProperty
().
SetColor
(
1.
,
.
0
,
0.
)
polaxes
.
GetPolarAxisTitleTextProperty
().
SetColor
(
1.
,
0.
,
0.
)
...
...
Hybrid/Testing/Cxx/TestPolarAxes.cxx
View file @
8dd0c44f
...
...
@@ -85,7 +85,7 @@ int TestPolarAxes( int argc, char * argv [] )
polaxes
->
SetMaximumAngle
(
210.
);
polaxes
->
SetNumberOfRadialAxes
(
8
);
polaxes
->
SetCamera
(
renderer
->
GetActiveCamera
()
);
polaxes
->
Set
Radial
LabelFormat
(
"%6.1f"
);
polaxes
->
Set
Polar
LabelFormat
(
"%6.1f"
);
polaxes
->
GetRadialAxesProperty
()
->
SetColor
(
.0
,
.0
,
1.
);
polaxes
->
GetPolarArcsProperty
()
->
SetColor
(
1.
,
.0
,
0.
);
polaxes
->
GetPolarAxisTitleTextProperty
()
->
SetColor
(
1.
,
0.
,
0.
);
...
...
Hybrid/vtkPolarAxesActor.cxx
View file @
8dd0c44f
...
...
@@ -82,25 +82,27 @@ void vtkPolarAxesActor::PrintSelf( ostream& os, vtkIndent indent )
}
os
<<
indent
<<
"Polar Axis Title: "
<<
this
->
PolarAxisTitle
<<
"
\n
"
;
os
<<
indent
<<
"Polar Label Format: "
<<
this
->
PolarLabelFormat
<<
"
\n
"
;
os
<<
indent
<<
"PolarAxisLabelTextProperty: "
<<
this
->
PolarAxisLabelTextProperty
<<
endl
;
os
<<
indent
<<
"PolarAxisTitleTextProperty: "
<<
this
->
PolarAxisTitleTextProperty
<<
endl
;
os
<<
indent
<<
"Polar Axis Visibility: "
<<
(
this
->
PolarAxisVisibility
?
"On
\n
"
:
"Off
\n
"
);
os
<<
indent
<<
"Polar Title Visibility: "
<<
(
this
->
PolarTitleVisibility
?
"On"
:
"Off"
)
<<
endl
;
os
<<
indent
<<
"Polar Label Visibility: "
<<
(
this
->
PolarLabelVisibility
?
"On"
:
"Off"
)
<<
endl
;
os
<<
indent
<<
"Polar Tick Visibility: "
<<
(
this
->
PolarTickVisibility
?
"On"
:
"Off"
)
<<
endl
;
os
<<
indent
<<
"Radial Axes Visibility: "
<<
(
this
->
RadialAxesVisibility
?
"On
\n
"
:
"Off
\n
"
);
os
<<
indent
<<
"Radial Title Visibility: "
<<
(
this
->
RadialTitleVisibility
?
"On"
:
"Off"
)
<<
endl
;
os
<<
indent
<<
"Polar Label Visibility: "
<<
(
this
->
PolarLabelVisibility
?
"On"
:
"Off"
)
<<
endl
;
os
<<
indent
<<
"Polar Tick Visibility: "
<<
(
this
->
PolarTickVisibility
?
"On"
:
"Off"
)
<<
endl
;
os
<<
indent
<<
"Polar Arcs Visibility: "
<<
(
this
->
PolarArcsVisibility
?
"On"
:
"Off"
)
<<
endl
;
os
<<
indent
<<
"Radial Axes Label Format: "
<<
this
->
RadialLabelFormat
<<
"
\n
"
;
os
<<
indent
<<
"Tick Location: "
<<
this
->
TickLocation
<<
endl
;
}
...
...
@@ -148,11 +150,10 @@ vtkPolarAxesActor::vtkPolarAxesActor() : vtkActor()
// hence ( this->ScreenSize * 0.5 ).
this
->
LabelScreenOffset
=
15.0
+
this
->
ScreenSize
*
0.5
;
// Properties of the radial axes, with default color black
this
->
RadialAxesProperty
=
vtkProperty
::
New
();
this
->
RadialAxesProperty
->
SetColor
(
0.
,
0.
,
0.
);
// Text properties of polar axis title and labels, with default color white
// Properties of the radial axes, with default color black
this
->
PolarAxisProperty
=
vtkProperty
::
New
();
this
->
PolarAxisProperty
->
SetColor
(
0.
,
0.
,
0.
);
this
->
PolarAxisTitleTextProperty
=
vtkTextProperty
::
New
();
this
->
PolarAxisTitleTextProperty
->
SetColor
(
1.
,
1.
,
1.
);
this
->
PolarAxisTitleTextProperty
->
SetFontFamilyToArial
();
...
...
@@ -160,7 +161,33 @@ vtkPolarAxesActor::vtkPolarAxesActor() : vtkActor()
this
->
PolarAxisLabelTextProperty
->
SetColor
(
1.
,
1.
,
1.
);
this
->
PolarAxisLabelTextProperty
->
SetFontFamilyToArial
();
// Create and set radial axes
// Create and set polar axis of type X
this
->
PolarAxis
=
vtkAxisActor
::
New
();
this
->
PolarAxis
->
SetAxisTypeToX
();
this
->
PolarAxis
->
SetAxisPositionToMinMax
();
this
->
PolarAxis
->
SetCalculateTitleOffset
(
0
);
this
->
PolarAxis
->
SetCalculateLabelOffset
(
0
);
// Base offset for followers
double
offset
=
this
->
LabelScreenOffset
+
this
->
ScreenSize
*
0.5
;
// Using twice the base offset and a little for the title of the polar axis.
vtkAxisFollower
*
follower
=
this
->
PolarAxis
->
GetTitleActor
();
follower
->
SetAxis
(
this
->
PolarAxis
);
follower
->
SetScreenOffset
(
2.0
*
offset
+
5
);
vtkAxisFollower
**
labelActors
=
this
->
PolarAxis
->
GetLabelActors
();
int
numberOfLabels
=
this
->
PolarAxis
->
GetNumberOfLabelsBuilt
();
for
(
int
i
=
0
;
i
<
numberOfLabels
;
++
i
)
{
labelActors
[
i
]
->
SetScreenOffset
(
offset
);
}
// Properties of the radial axes, with default color black
this
->
RadialAxesProperty
=
vtkProperty
::
New
();
this
->
RadialAxesProperty
->
SetColor
(
0.
,
0.
,
0.
);
// Create and set radial axes of type X
this
->
RadialAxes
=
new
vtkAxisActor
*
[
VTK_MAXIMUM_NUMBER_OF_RADIAL_AXES
];
for
(
int
i
=
0
;
i
<
VTK_MAXIMUM_NUMBER_OF_RADIAL_AXES
;
++
i
)
{
...
...
@@ -172,28 +199,10 @@ vtkPolarAxesActor::vtkPolarAxesActor() : vtkActor()
axis
->
SetCalculateTitleOffset
(
0
);
axis
->
SetCalculateLabelOffset
(
0
);
// Pass information to axes followers
vtkAxisFollower
*
follower
=
axis
->
GetTitleActor
();
follower
->
SetAxis
(
axis
);
double
offset
=
this
->
LabelScreenOffset
+
this
->
ScreenSize
*
0.5
;
// Using 2/3 of base offset if not a polar axis.
follower
->
SetScreenOffset
(
.67
*
offset
);
if
(
!
i
)
{
// Using twice the base offset and a little for the title of the polar axis.
follower
->
SetScreenOffset
(
2.0
*
offset
+
5
);
vtkAxisFollower
**
labelActors
=
axis
->
GetLabelActors
();
int
numberOfLabels
=
axis
->
GetNumberOfLabelsBuilt
();
for
(
int
k
=
0
;
k
<
numberOfLabels
;
++
k
)
{
labelActors
[
k
]
->
SetScreenOffset
(
offset
);
}
}
}
// Using 2/3 of base offset if not for non-polar radial axes.
axis
->
GetTitleActor
()
->
SetAxis
(
axis
);
axis
->
GetTitleActor
()
->
SetScreenOffset
(
.67
*
offset
);
}
// for ( int i = 0; i < VTK_MAXIMUM_NUMBER_OF_RADIAL_AXES; ++ i )
// Default tick location, defined in vtkAxisActor
this
->
TickLocation
=
VTK_TICKS_BOTH
;
...
...
@@ -206,19 +215,24 @@ vtkPolarAxesActor::vtkPolarAxesActor() : vtkActor()
this
->
PolarArcsActor
->
SetMapper
(
this
->
PolarArcsMapper
);
this
->
PolarArcsActor
->
GetProperty
()
->
SetColor
(
1.
,
1.
,
1.
);
// By default all features are visible
this
->
RadialAxesVisibility
=
1
;
this
->
RadialTitleVisibility
=
1
;
this
->
PolarLabelVisibility
=
1
;
this
->
PolarTickVisibility
=
1
;
this
->
PolarArcsVisibility
=
1
;
// Default title for polar axis (can also be called "Radius")
this
->
PolarAxisTitle
=
new
char
[
16
];
sprintf
(
this
->
PolarAxisTitle
,
"%s"
,
"Radial Distance"
);
this
->
PolarLabelFormat
=
new
char
[
8
];
sprintf
(
this
->
PolarLabelFormat
,
"%s"
,
"%-#6.3g"
);
this
->
RadialLabelFormat
=
new
char
[
8
];
sprintf
(
this
->
RadialLabelFormat
,
"%s"
,
"%-#6.3g"
);
// By default all polar axis features are visible
this
->
PolarAxisVisibility
=
1
;
this
->
PolarTitleVisibility
=
1
;
this
->
PolarLabelVisibility
=
1
;
this
->
PolarTickVisibility
=
1
;
// By default all radial axes features are visible
this
->
RadialAxesVisibility
=
1
;
this
->
RadialTitleVisibility
=
1
;
// By default polar arcs are visible
this
->
PolarArcsVisibility
=
1
;
this
->
RenderCount
=
0
;
...
...
@@ -233,15 +247,20 @@ vtkPolarAxesActor::~vtkPolarAxesActor()
{
this
->
SetCamera
(
NULL
);
if
(
this
->
PolarAxisProperty
)
{
this
->
PolarAxisProperty
->
Delete
();
}
if
(
this
->
RadialAxesProperty
)
{
this
->
RadialAxesProperty
->
Delete
();
}
if
(
this
->
Radial
LabelFormat
)
if
(
this
->
Polar
LabelFormat
)
{
delete
[]
this
->
Radial
LabelFormat
;
this
->
Radial
LabelFormat
=
NULL
;
delete
[]
this
->
Polar
LabelFormat
;
this
->
Polar
LabelFormat
=
NULL
;
}
if
(
this
->
PolarAxisTitle
)
...
...
@@ -262,6 +281,12 @@ vtkPolarAxesActor::~vtkPolarAxesActor()
this
->
PolarAxisLabelTextProperty
=
NULL
;
}
if
(
this
->
PolarAxis
)
{
this
->
PolarAxis
->
Delete
();
this
->
PolarAxis
=
NULL
;
}
if
(
this
->
RadialAxes
)
{
for
(
int
i
=
0
;
i
<
VTK_MAXIMUM_NUMBER_OF_RADIAL_AXES
;
++
i
)
...
...
@@ -703,11 +728,10 @@ void vtkPolarAxesActor::BuildPolarAxisLabelsArcs( double* O )
double
thetaMax
=
vtkMath
::
RadiansFromDegrees
(
this
->
MaximumAngle
);
double
cosThetaMax
=
cos
(
thetaMax
);
double
sinThetaMax
=
sin
(
thetaMax
);
double
angularSector
=
this
->
MaximumAngle
-
this
->
MinimumAngle
;
vtkIdType
arcResolution
=
static_cast
<
vtkIdType
>
(
angularSector
*
VTK_POLAR_ARC_RESOLUTION_PER_DEG
);
cerr
<<
"ANG = "
<<
angularSector
<<
endl
;
// Arc points
vtkPoints
*
polarArcsPoints
=
vtkPoints
::
New
();
this
->
PolarArcs
->
SetPoints
(
polarArcsPoints
);
...
...
@@ -722,7 +746,7 @@ void vtkPolarAxesActor::BuildPolarAxisLabelsArcs( double* O )
vtkAxisActor
*
axis
=
this
->
RadialAxes
[
0
];
double
deltaMajor
=
axis
->
GetDeltaMajor
(
VTK_AXIS_TYPE_X
);
double
val
=
axis
->
GetMajorRangeStart
();
const
char
*
format
=
this
->
Radial
LabelFormat
;
const
char
*
format
=
this
->
Polar
LabelFormat
;
char
label
[
64
];
vtkIdType
pointIdOffset
=
0
;
for
(
int
i
=
0
;
i
<
this
->
NumberOfPolarAxisTicks
;
++
i
)
...
...
Hybrid/vtkPolarAxesActor.h
View file @
8dd0c44f
...
...
@@ -136,10 +136,9 @@ public:
vtkGetStringMacro
(
PolarAxisTitle
);
// Description:
// Set/Get the format with which to print the labels on each of the
// radial axes.
vtkSetStringMacro
(
RadialLabelFormat
);
vtkGetStringMacro
(
RadialLabelFormat
);
// Set/Get the format with which to print the polar axis labels
vtkSetStringMacro
(
PolarLabelFormat
);
vtkGetStringMacro
(
PolarLabelFormat
);
// Description:
// Release any graphics resources that are being consumed by this actor.
...
...
@@ -321,8 +320,9 @@ protected:
// Description:
// Title to be used for the polar axis
// NB:
The other
axes use the polar angle
value as a title
// NB:
Non-polar radial
axes use the polar angle
as title and have no labels
char
*
PolarAxisTitle
;
char
*
PolarLabelFormat
;
// Description:
// Use angle units (degrees) to label radial axes
...
...
@@ -343,8 +343,6 @@ protected:
// Visibility of polar arcs
int
PolarArcsVisibility
;
char
*
RadialLabelFormat
;
int
RenderCount
;
int
RenderSomething
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment