VTK
TestAxisActorInternal.h
Go to the documentation of this file.
1 #ifndef TestAxisActorInternal_h
2 #define TestAxisActorInternal_h
3 
4 #include "vtkAxisActor.h"
5 #include "vtkCamera.h"
6 #include "vtkNew.h"
7 #include "vtkPolyDataMapper.h"
8 #include "vtkProperty.h"
9 #include "vtkRenderWindow.h"
11 #include "vtkRenderer.h"
12 #include "vtkSphereSource.h"
13 #include "vtkStringArray.h"
14 #include "vtkTextProperty.h"
15 
16 inline int TestAxisActorInternal(int use2dMode, int use3dProp)
17 {
19  labels->SetNumberOfTuples(6);
20  labels->SetValue(0, "0");
21  labels->SetValue(1, "2");
22  labels->SetValue(2, "4");
23  labels->SetValue(3, "6");
24  labels->SetValue(4, "8");
25  labels->SetValue(5, "10");
26 
27  vtkNew<vtkTextProperty> textProp1;
28  textProp1->SetColor(0., 0., 1.);
29  textProp1->SetOpacity(0.9);
30 
31  vtkNew<vtkTextProperty> textProp2;
32  textProp2->SetColor(1., 0., 0.);
33  textProp2->SetOpacity(0.6);
34 
35  vtkNew<vtkTextProperty> textProp3;
36  textProp3->SetColor(0., 1., 0.);
37  textProp3->SetOpacity(1);
38 
39  vtkNew<vtkProperty> prop1;
40  prop1->SetColor(1., 0., 1.);
41 
42  vtkNew<vtkProperty> prop2;
43  prop2->SetColor(1., 1., 0.);
44 
45  vtkNew<vtkProperty> prop3;
46  prop3->SetColor(0., 1., 1.);
47 
48  //------------- X Axis -------------
49  vtkNew<vtkAxisActor> axisXActor;
50  axisXActor->SetUse2DMode(use2dMode);
51  axisXActor->SetUseTextActor3D(use3dProp);
52  axisXActor->GetProperty()->SetAmbient(1);
53  axisXActor->GetProperty()->SetDiffuse(0);
54  axisXActor->SetPoint1(0, 0, 0);
55  axisXActor->SetPoint2(10, 0, 0);
56  axisXActor->SetTitle("X Axis");
57  axisXActor->SetBounds(0, 10, 0, 0, 0, 0);
58  axisXActor->SetTickLocationToBoth();
59  axisXActor->SetAxisTypeToX();
60  axisXActor->SetRange(0, 10);
61  axisXActor->SetLabels(labels);
62  axisXActor->SetDeltaRangeMajor(2);
63  axisXActor->SetDeltaRangeMinor(0.5);
64  axisXActor->SetExponent("+00");
65  axisXActor->SetExponentVisibility(true);
66  axisXActor->SetTitleScale(0.8);
67  axisXActor->SetLabelScale(0.5);
68  axisXActor->SetTitleOffset(3);
69  axisXActor->SetExponentOffset(3);
70  axisXActor->SetLabelOffset(5);
71  axisXActor->SetTitleTextProperty(textProp1);
72  axisXActor->SetLabelTextProperty(textProp2);
73  axisXActor->SetAxisMainLineProperty(prop1);
74  axisXActor->SetAxisMajorTicksProperty(prop2);
75  axisXActor->SetAxisMinorTicksProperty(prop3);
76 
77  //------------- Y Axis -------------
78  vtkNew<vtkAxisActor> axisYActor;
79  axisYActor->SetUse2DMode(use2dMode);
80  axisYActor->SetUseTextActor3D(use3dProp);
81  axisYActor->GetProperty()->SetAmbient(1);
82  axisYActor->GetProperty()->SetDiffuse(0);
83  axisYActor->SetPoint1(0, 0, 0);
84  axisYActor->SetPoint2(0, 10, 0);
85  axisYActor->SetTitle("Y Axis");
86  axisYActor->SetBounds(0, 0, 0, 10, 0, 0);
87  axisYActor->SetTickLocationToInside();
88  axisYActor->SetAxisTypeToY();
89  axisYActor->SetRange(0.1, 500);
90  axisYActor->SetMajorRangeStart(0.1);
91  axisYActor->SetMinorRangeStart(0.1);
92  axisYActor->SetMinorTicksVisible(true);
94  axisYActor->SetExponent("+00");
95  axisYActor->SetExponentVisibility(true);
97  axisYActor->SetTitleScale(0.8);
98  axisYActor->SetLabelScale(0.5);
99  axisYActor->SetTitleOffset(3);
100  axisYActor->SetExponentOffset(5);
101  axisYActor->SetLabelOffset(5);
102  axisYActor->SetTitleTextProperty(textProp2);
103  axisYActor->SetLog(true);
104  axisYActor->SetAxisLinesProperty(prop1);
105 
106  //------------- Z Axis -------------
107  vtkNew<vtkAxisActor> axisZActor;
108  axisZActor->SetUse2DMode(use2dMode);
109  axisZActor->SetUseTextActor3D(use3dProp);
110  axisZActor->GetProperty()->SetAmbient(1);
111  axisZActor->GetProperty()->SetDiffuse(0);
112  axisZActor->SetPoint1(0, 0, 0);
113  axisZActor->SetPoint2(0, 0, 10);
114  axisZActor->SetTitle("Z Axis");
115  axisZActor->SetBounds(0, 0, 0, 0, 0, 10);
116  axisZActor->SetTickLocationToOutside();
117  axisZActor->SetAxisTypeToZ();
118  axisZActor->SetRange(0, 10);
120  axisZActor->SetExponent("+00");
121  axisZActor->SetExponentVisibility(true);
123  axisZActor->SetTitleScale(0.8);
124  axisZActor->SetLabelScale(0.5);
125  axisZActor->SetTitleOffset(3);
126  axisZActor->SetExponentOffset(3);
127  axisZActor->SetLabelOffset(5);
128  axisZActor->SetTitleTextProperty(textProp3);
129  axisZActor->SetMajorTickSize(3);
130  axisZActor->SetMinorTickSize(1);
131  axisZActor->SetDeltaRangeMajor(2);
132  axisZActor->SetDeltaRangeMinor(0.1);
133 
134  vtkNew<vtkRenderer> renderer;
135  vtkNew<vtkRenderWindow> renderWindow;
136  renderWindow->AddRenderer(renderer);
137  vtkNew<vtkRenderWindowInteractor> renderWindowInteractor;
138  renderWindowInteractor->SetRenderWindow(renderWindow);
139  renderer->AddActor(axisXActor);
140  renderer->AddActor(axisYActor);
141  renderer->AddActor(axisZActor);
142  renderer->SetBackground(.5, .5, .5);
143 
144  vtkCamera* camera = renderer->GetActiveCamera();
145  axisXActor->SetCamera(camera);
146  axisYActor->SetCamera(camera);
147  axisZActor->SetCamera(camera);
148  renderWindow->SetSize(300, 300);
149 
150  camera->SetPosition(-10.0, 22.0, -29);
151  camera->SetFocalPoint(-2, 8.5, -9.);
152 
153  renderWindow->SetMultiSamples(0);
154  renderWindow->Render();
155  renderWindowInteractor->Start();
156 
157  return EXIT_SUCCESS;
158 }
159 
160 #endif
vtkRenderWindowInteractor::SetRenderWindow
void SetRenderWindow(vtkRenderWindow *aren)
Set/Get the rendering window being controlled by this object.
vtkAxisActor::SetTitleScale
void SetTitleScale(const double scale)
vtkAxisActor::SetExponentLocation
virtual void SetExponentLocation(int location)
Get/Set the location of the Detached Exponent related to the axis.
vtkAxisActor::SetMinorTicksVisible
virtual void SetMinorTicksVisible(vtkTypeBool)
Set/Get the flag that controls whether the minor ticks are visible.
vtkWindow::SetSize
virtual void SetSize(int, int)
vtkAxisActor::SetAxisMajorTicksProperty
void SetAxisMajorTicksProperty(vtkProperty *)
Get/Set axis actor property (axis and its ticks)
vtkViewport::SetBackground
virtual void SetBackground(double, double, double)
Set/Get the background color of the rendering screen using an rgb color specification.
vtkAxisActor::SetAxisMinorTicksProperty
void SetAxisMinorTicksProperty(vtkProperty *)
Get/Set axis actor property (axis and its ticks)
vtkRenderer::AddActor
void AddActor(vtkProp *p)
Add/Remove different types of props to the renderer.
vtkActor::GetProperty
vtkProperty * GetProperty()
vtkAxisActor::SetBounds
void SetBounds(const double bounds[6])
Set or get the bounds for this Actor as (Xmin,Xmax,Ymin,Ymax,Zmin,Zmax).
vtkAxisActor::SetTickLocationToInside
void SetTickLocationToInside(void)
Definition: vtkAxisActor.h:202
vtkAxisActor::SetDeltaRangeMinor
virtual void SetDeltaRangeMinor(double)
vtkAxisActor::SetExponentVisibility
virtual void SetExponentVisibility(bool)
Set/Get visibility of the axis detached exponent.
vtkTextProperty::SetColor
virtual void SetColor(double, double, double)
Set the color of the text.
vtkAxisActor::SetCamera
virtual void SetCamera(vtkCamera *)
Set/Get the camera for this axis.
vtkAxisActor::SetMajorTickSize
virtual void SetMajorTickSize(double)
Set/Get the size of the major tick marks.
TestAxisActorInternal
int TestAxisActorInternal(int use2dMode, int use3dProp)
Definition: TestAxisActorInternal.h:16
vtkRenderWindow.h
vtkRenderer.h
vtkAxisActor::SetUse2DMode
virtual void SetUse2DMode(int)
Set/Get the 2D mode.
vtkAxisActor::SetAxisTypeToY
void SetAxisTypeToY(void)
Definition: vtkAxisActor.h:425
vtkAxisActor::SetLog
virtual void SetLog(bool)
Set/Get The type of scale, enable logarithmic scale or linear by default.
vtkAxisActor::SetTitle
void SetTitle(const char *t)
Set/Get the title of the axis actor,.
vtkTextProperty.h
vtkCamera::SetFocalPoint
void SetFocalPoint(double x, double y, double z)
Set/Get the focal of the camera in world coordinates.
vtkRenderer::GetActiveCamera
vtkCamera * GetActiveCamera()
Get the current camera.
vtkProperty.h
vtkStringArray.h
vtkTextProperty::SetOpacity
virtual void SetOpacity(double)
Set/Get the text's opacity.
vtkAxisActor::SetDeltaRangeMajor
virtual void SetDeltaRangeMajor(double)
vtkAxisActor::VTK_ALIGN_POINT2
Definition: vtkAxisActor.h:265
vtkRenderWindow::AddRenderer
virtual void AddRenderer(vtkRenderer *)
Add a renderer to the list of renderers.
vtkRenderWindow::Render
void Render() override
Ask each renderer owned by this RenderWindow to render its image and synchronize this process.
vtkStringArray::SetValue
void SetValue(vtkIdType id, vtkStdString value)
Set the data at a particular index.
Definition: vtkStringArray.h:187
vtkCamera
a virtual camera for 3D rendering
Definition: vtkCamera.h:50
vtkAxisActor::SetTitleAlignLocation
virtual void SetTitleAlignLocation(int location)
Get/Set the alignment of the title related to the axis.
vtkAxisActor::SetExponent
void SetExponent(const char *t)
Set/Get the common exponent of the labels values.
vtkAxisActor::SetAxisTypeToX
void SetAxisTypeToX(void)
Definition: vtkAxisActor.h:424
vtkCamera::SetPosition
void SetPosition(double x, double y, double z)
Set/Get the position of the camera in world coordinates.
vtkNew< vtkStringArray >
vtkSphereSource.h
vtkCamera.h
vtkAxisActor::SetAxisTypeToZ
void SetAxisTypeToZ(void)
Definition: vtkAxisActor.h:426
vtkProperty::SetColor
virtual void SetColor(double r, double g, double b)
Set the color of the object.
vtkAxisActor::SetMinorTickSize
virtual void SetMinorTickSize(double)
Set/Get the size of the major tick marks.
vtkAxisActor::SetTickLocationToBoth
void SetTickLocationToBoth(void)
Definition: vtkAxisActor.h:204
vtkAxisActor.h
vtkAxisActor::SetRange
virtual void SetRange(double, double)
Specify the (min,max) axis range.
vtkAxisActor::SetTickLocationToOutside
void SetTickLocationToOutside(void)
Definition: vtkAxisActor.h:203
vtkAxisActor::SetAxisLinesProperty
void SetAxisLinesProperty(vtkProperty *)
Get/Set axis actor property (axis and its ticks) (kept for compatibility)
vtkNew.h
vtkAxisActor::SetLabels
void SetLabels(vtkStringArray *labels)
vtkAxisActor::SetExponentOffset
virtual void SetExponentOffset(double)
vtkAxisActor::SetLabelTextProperty
virtual void SetLabelTextProperty(vtkTextProperty *p)
Set/Get the axis labels text property.
vtkRenderWindowInteractor::Start
virtual void Start()
Start the event loop.
vtkAxisActor::SetLabelOffset
virtual void SetLabelOffset(double)
Set/Get the offsets used to position texts.
vtkAxisActor::SetPoint1
virtual void SetPoint1(double x[3])
Definition: vtkAxisActor.h:90
vtkAxisActor::SetMinorRangeStart
virtual void SetMinorRangeStart(double)
Set/Get the starting position for minor and major tick points on the range and the delta values that ...
vtkPolyDataMapper.h
vtkRenderWindowInteractor.h
vtkAxisActor::SetAxisMainLineProperty
void SetAxisMainLineProperty(vtkProperty *)
Get/Set main line axis actor property.
vtkRenderWindow::SetMultiSamples
virtual void SetMultiSamples(int)
Set / Get the number of multisamples to use for hardware antialiasing.
vtkProperty::SetAmbient
virtual void SetAmbient(double)
Set/Get the ambient lighting coefficient.
vtkAxisActor::SetLabelScale
void SetLabelScale(const double scale)
vtkAxisActor::SetTitleOffset
virtual void SetTitleOffset(double)
vtkAxisActor::SetTitleTextProperty
virtual void SetTitleTextProperty(vtkTextProperty *p)
Set/Get the axis title text property.
vtkAxisActor::VTK_ALIGN_POINT1
Definition: vtkAxisActor.h:264
vtkAxisActor::VTK_ALIGN_TOP
Definition: vtkAxisActor.h:262
vtkAxisActor::SetUseTextActor3D
virtual void SetUseTextActor3D(int)
Render text as polygons (vtkVectorText) or as sprites (vtkTextActor3D).
vtkAxisActor::SetPoint2
virtual void SetPoint2(double x[3])
Definition: vtkAxisActor.h:100
vtkProperty::SetDiffuse
virtual void SetDiffuse(double)
Set/Get the diffuse lighting coefficient.
vtkStringArray::SetNumberOfTuples
void SetNumberOfTuples(vtkIdType number) override
Set the number of tuples (a component group) in the array.
Definition: vtkStringArray.h:199
vtkAxisActor::SetMajorRangeStart
virtual void SetMajorRangeStart(double)