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
virtual void SetPoint1(double x[3])
Specify the position of the first point defining the axis.
Definition: vtkAxisActor.h:90
virtual void SetMinorRangeStart(double)
Set/Get the starting position for minor and major tick points on the range and the delta values that ...
void AddActor(vtkProp *p)
Add/Remove different types of props to the renderer.
void SetLabelScale(const double scale)
virtual void SetColor(double, double, double)
Set the color of the text.
void SetAxisTypeToY(void)
Set/Get the type of this axis.
Definition: vtkAxisActor.h:425
virtual void SetDiffuse(double)
Set/Get the diffuse lighting coefficient.
vtkProperty * GetProperty()
Set/Get the property object that controls this actors surface properties.
virtual void SetPoint2(double x[3])
Specify the position of the second point defining the axis.
Definition: vtkAxisActor.h:100
void SetRenderWindow(vtkRenderWindow *aren)
Set/Get the rendering window being controlled by this object.
virtual void SetBackground(double, double, double)
Set/Get the background color of the rendering screen using an rgb color specification.
void SetTitleScale(const double scale)
void SetTickLocationToInside(void)
Definition: vtkAxisActor.h:202
virtual void AddRenderer(vtkRenderer *)
Add a renderer to the list of renderers.
void Render() override
Ask each renderer owned by this RenderWindow to render its image and synchronize this process...
virtual void SetDeltaRangeMinor(double)
Set/Get the starting position for minor and major tick points on the range and the delta values that ...
void SetPosition(double x, double y, double z)
Set/Get the position of the camera in world coordinates.
void SetBounds(const double bounds[6])
Set or get the bounds for this Actor as (Xmin,Xmax,Ymin,Ymax,Zmin,Zmax).
vtkCamera * GetActiveCamera()
Get the current camera.
virtual void SetSize(int, int)
Set/Get the size of the window in screen coordinates in pixels.
void SetValue(vtkIdType id, vtkStdString value)
Set the data at a particular index.
virtual void SetCamera(vtkCamera *)
Set/Get the camera for this axis.
virtual void SetTitleAlignLocation(int location)
Get/Set the alignment of the title related to the axis.
void SetAxisTypeToX(void)
Set/Get the type of this axis.
Definition: vtkAxisActor.h:424
virtual void SetMajorTickSize(double)
Set/Get the size of the major tick marks.
void SetNumberOfTuples(vtkIdType number) override
Set the number of tuples (a component group) in the array.
virtual void Start()
Start the event loop.
virtual void SetMinorTickSize(double)
Set/Get the size of the major tick marks.
virtual void SetUse2DMode(int)
Set/Get the 2D mode.
void SetTitle(const char *t)
Set/Get the title of the axis actor,.
virtual void SetLog(bool)
Set/Get The type of scale, enable logarithmic scale or linear by default.
a virtual camera for 3D rendering
Definition: vtkCamera.h:50
void SetAxisLinesProperty(vtkProperty *)
Get/Set axis actor property (axis and its ticks) (kept for compatibility)
void SetTickLocationToBoth(void)
Definition: vtkAxisActor.h:204
void SetLabels(vtkStringArray *labels)
virtual void SetOpacity(double)
Set/Get the text&#39;s opacity.
virtual void SetExponentOffset(double)
Set/Get the offsets used to position texts.
void SetFocalPoint(double x, double y, double z)
Set/Get the focal of the camera in world coordinates.
void SetAxisMainLineProperty(vtkProperty *)
Get/Set main line axis actor property.
virtual void SetLabelOffset(double)
Set/Get the offsets used to position texts.
virtual void SetDeltaRangeMajor(double)
Set/Get the starting position for minor and major tick points on the range and the delta values that ...
virtual void SetTitleOffset(double)
Set/Get the offsets used to position texts.
virtual void SetMultiSamples(int)
Set / Get the number of multisamples to use for hardware antialiasing.
void SetExponent(const char *t)
Set/Get the common exponent of the labels values.
virtual void SetAmbient(double)
Set/Get the ambient lighting coefficient.
virtual void SetUseTextActor3D(int)
Render text as polygons (vtkVectorText) or as sprites (vtkTextActor3D).
virtual void SetTitleTextProperty(vtkTextProperty *p)
Set/Get the axis title text property.
int TestAxisActorInternal(int use2dMode, int use3dProp)
virtual void SetColor(double r, double g, double b)
Set the color of the object.
virtual void SetMajorRangeStart(double)
Set/Get the starting position for minor and major tick points on the range and the delta values that ...
void SetAxisTypeToZ(void)
Set/Get the type of this axis.
Definition: vtkAxisActor.h:426
void SetAxisMajorTicksProperty(vtkProperty *)
Get/Set axis actor property (axis and its ticks)
virtual void SetRange(double, double)
Specify the (min,max) axis range.
void SetTickLocationToOutside(void)
Definition: vtkAxisActor.h:203
virtual void SetExponentLocation(int location)
Get/Set the location of the Detached Exponent related to the axis.
void SetAxisMinorTicksProperty(vtkProperty *)
Get/Set axis actor property (axis and its ticks)
virtual void SetMinorTicksVisible(vtkTypeBool)
Set/Get the flag that controls whether the minor ticks are visible.
virtual void SetLabelTextProperty(vtkTextProperty *p)
Set/Get the axis labels text property.
virtual void SetExponentVisibility(bool)
Set/Get visibility of the axis detached exponent.