VTK  9.1.0
vtkAxisActor2D.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: Visualization Toolkit
4 Module: vtkAxisActor2D.h
5
6 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7 All rights reserved.
8 See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9
10 This software is distributed WITHOUT ANY WARRANTY; without even
11 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12 PURPOSE. See the above copyright notice for more information.
13
14=========================================================================*/
67#ifndef vtkAxisActor2D_h
68#define vtkAxisActor2D_h
69
70#include "vtkActor2D.h"
71#include "vtkRenderingAnnotationModule.h" // For export macro
72
74class vtkPolyData;
75class vtkTextMapper;
76class vtkTextProperty;
77
78class VTKRENDERINGANNOTATION_EXPORT vtkAxisActor2D : public vtkActor2D
79{
80public:
81 vtkTypeMacro(vtkAxisActor2D, vtkActor2D);
82 void PrintSelf(ostream& os, vtkIndent indent) override;
83
88
90
95 virtual void SetPoint1(double x[2]) { this->SetPosition(x); }
96 virtual void SetPoint1(double x, double y) { this->SetPosition(x, y); }
97 virtual double* GetPoint1() { return this->GetPosition(); }
99
101
108 virtual void SetPoint2(double x[2]) { this->SetPosition2(x); }
109 virtual void SetPoint2(double x, double y) { this->SetPosition2(x, y); }
110 virtual double* GetPoint2() { return this->GetPosition2(); }
112
114
118 vtkSetVector2Macro(Range, double);
119 vtkGetVectorMacro(Range, double, 2);
121
123
128 vtkSetMacro(RulerMode, vtkTypeBool);
129 vtkGetMacro(RulerMode, vtkTypeBool);
130 vtkBooleanMacro(RulerMode, vtkTypeBool);
132
134
138 vtkSetClampMacro(RulerDistance, double, 0, VTK_FLOAT_MAX);
139 vtkGetMacro(RulerDistance, double);
141
143 {
144 VTK_MAX_LABELS = 25
145 };
146
148
153 vtkSetClampMacro(NumberOfLabels, int, 2, VTK_MAX_LABELS);
154 vtkGetMacro(NumberOfLabels, int);
156
158
162 vtkSetStringMacro(LabelFormat);
163 vtkGetStringMacro(LabelFormat);
165
167
175 vtkSetMacro(AdjustLabels, vtkTypeBool);
176 vtkGetMacro(AdjustLabels, vtkTypeBool);
177 vtkBooleanMacro(AdjustLabels, vtkTypeBool);
178 virtual double* GetAdjustedRange()
179 {
180 this->UpdateAdjustedRange();
181 return this->AdjustedRange;
182 }
183 virtual void GetAdjustedRange(double& _arg1, double& _arg2)
184 {
185 this->UpdateAdjustedRange();
186 _arg1 = this->AdjustedRange[0];
187 _arg2 = this->AdjustedRange[1];
188 };
189 virtual void GetAdjustedRange(double _arg[2]) { this->GetAdjustedRange(_arg[0], _arg[1]); }
191 {
192 this->UpdateAdjustedRange();
193 return this->AdjustedNumberOfLabels;
194 }
196
198
201 vtkSetStringMacro(Title);
202 vtkGetStringMacro(Title);
204
206
210 vtkGetObjectMacro(TitleTextProperty, vtkTextProperty);
212
214
218 vtkGetObjectMacro(LabelTextProperty, vtkTextProperty);
220
222
226 vtkSetClampMacro(TickLength, int, 0, 100);
227 vtkGetMacro(TickLength, int);
229
231
235 vtkSetClampMacro(NumberOfMinorTicks, int, 0, 20);
236 vtkGetMacro(NumberOfMinorTicks, int);
238
240
244 vtkSetClampMacro(MinorTickLength, int, 0, 100);
245 vtkGetMacro(MinorTickLength, int);
247
249
254 vtkSetClampMacro(TickOffset, int, 0, 100);
255 vtkGetMacro(TickOffset, int);
257
259
262 vtkSetMacro(AxisVisibility, vtkTypeBool);
263 vtkGetMacro(AxisVisibility, vtkTypeBool);
264 vtkBooleanMacro(AxisVisibility, vtkTypeBool);
266
268
271 vtkSetMacro(TickVisibility, vtkTypeBool);
272 vtkGetMacro(TickVisibility, vtkTypeBool);
273 vtkBooleanMacro(TickVisibility, vtkTypeBool);
275
277
280 vtkSetMacro(LabelVisibility, vtkTypeBool);
281 vtkGetMacro(LabelVisibility, vtkTypeBool);
282 vtkBooleanMacro(LabelVisibility, vtkTypeBool);
284
286
289 vtkSetMacro(TitleVisibility, vtkTypeBool);
290 vtkGetMacro(TitleVisibility, vtkTypeBool);
291 vtkBooleanMacro(TitleVisibility, vtkTypeBool);
293
295
299 vtkSetMacro(TitlePosition, double);
300 vtkGetMacro(TitlePosition, double);
302
304
309 vtkSetClampMacro(FontFactor, double, 0.1, 2.0);
310 vtkGetMacro(FontFactor, double);
312
314
318 vtkSetClampMacro(LabelFactor, double, 0.1, 2.0);
319 vtkGetMacro(LabelFactor, double);
321
323
326 int RenderOverlay(vtkViewport* viewport) override;
327 int RenderOpaqueGeometry(vtkViewport* viewport) override;
330
335
342
353 static void ComputeRange(
354 double inRange[2], double outRange[2], int inNumTicks, int& outNumTicks, double& interval);
355
364 static int SetMultipleFontSize(vtkViewport* viewport, vtkTextMapper** textMappers,
365 int nbOfMappers, int* targetSize, double factor, int* stringSize);
366
368
372 vtkSetMacro(SizeFontRelativeToAxis, vtkTypeBool);
373 vtkGetMacro(SizeFontRelativeToAxis, vtkTypeBool);
374 vtkBooleanMacro(SizeFontRelativeToAxis, vtkTypeBool);
376
378
383 vtkSetMacro(UseFontSizeFromProperty, vtkTypeBool);
384 vtkGetMacro(UseFontSizeFromProperty, vtkTypeBool);
385 vtkBooleanMacro(UseFontSizeFromProperty, vtkTypeBool);
387
391 void ShallowCopy(vtkProp* prop) override;
392
393protected:
395 ~vtkAxisActor2D() override;
396
399
400 char* Title;
401 double Range[2];
414
415 double AdjustedRange[2];
418
423
424 int LastPosition[2];
425 int LastPosition2[2];
426
427 int LastSize[2];
428 int LastMaxLabelSize[2];
429
432
433 virtual void BuildAxis(vtkViewport* viewport);
434 static double ComputeStringOffset(double width, double height, double theta);
435 static void SetOffsetPosition(double xTick[3], double theta, int stringWidth, int stringHeight,
436 int offset, vtkActor2D* actor);
437 virtual void UpdateAdjustedRange();
438
441
444
448
451
452private:
453 vtkAxisActor2D(const vtkAxisActor2D&) = delete;
454 void operator=(const vtkAxisActor2D&) = delete;
455};
456
457#endif
a actor that draws 2D data
Definition: vtkActor2D.h:49
virtual vtkCoordinate * GetPositionCoordinate()
Get the PositionCoordinate instance of vtkCoordinate.
virtual void SetPosition2(float x[2])
Access the Position2 instance variable.
virtual void SetPosition(float x[2])
Get the PositionCoordinate instance of vtkCoordinate.
virtual vtkCoordinate * GetPosition2Coordinate()
Access the Position2 instance variable.
virtual float * GetPosition2()
Access the Position2 instance variable.
virtual float * GetPosition()
Get the PositionCoordinate instance of vtkCoordinate.
Create an axis with tick marks and labels.
int RenderTranslucentPolygonalGeometry(vtkViewport *) override
Draw the axis.
virtual void SetPoint1(double x[2])
Specify the position of the first point defining the axis.
virtual double * GetAdjustedRange()
Set/Get the flag that controls whether the labels and ticks are adjusted for "nice" numerical values ...
vtkTimeStamp BuildTime
vtkPolyDataMapper2D * AxisMapper
vtkTypeBool AdjustLabels
vtkTextMapper * TitleMapper
vtkTypeBool HasTranslucentPolygonalGeometry() override
Does this prop have some translucent polygonal geometry?
vtkTypeBool TickVisibility
virtual void SetTitleTextProperty(vtkTextProperty *p)
Set/Get the title text property.
vtkActor2D ** LabelActors
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkActor2D * AxisActor
vtkTypeBool LabelVisibility
static void SetOffsetPosition(double xTick[3], double theta, int stringWidth, int stringHeight, int offset, vtkActor2D *actor)
virtual void BuildAxis(vtkViewport *viewport)
static int SetMultipleFontSize(vtkViewport *viewport, vtkTextMapper **textMappers, int nbOfMappers, int *targetSize, double factor, int *stringSize)
General method to computes font size from a representative size on the viewport (given by size[2]).
vtkTextProperty * TitleTextProperty
virtual void SetPoint1(double x, double y)
Specify the position of the first point defining the axis.
static void ComputeRange(double inRange[2], double outRange[2], int inNumTicks, int &outNumTicks, double &interval)
This method computes the range of the axis given an input range.
virtual vtkCoordinate * GetPoint2Coordinate()
Specify the position of the second point defining the axis.
vtkPolyData * Axis
virtual vtkCoordinate * GetPoint1Coordinate()
Specify the position of the first point defining the axis.
int RenderOpaqueGeometry(vtkViewport *viewport) override
Draw the axis.
vtkTimeStamp AdjustedRangeBuildTime
virtual void GetAdjustedRange(double _arg[2])
Set/Get the flag that controls whether the labels and ticks are adjusted for "nice" numerical values ...
void ReleaseGraphicsResources(vtkWindow *) override
Release any graphics resources that are being consumed by this actor.
vtkTextMapper ** LabelMappers
static vtkAxisActor2D * New()
Instantiate object.
vtkTypeBool UseFontSizeFromProperty
vtkTypeBool AxisVisibility
static double ComputeStringOffset(double width, double height, double theta)
int RenderOverlay(vtkViewport *viewport) override
Draw the axis.
virtual double * GetPoint1()
Specify the position of the first point defining the axis.
void ShallowCopy(vtkProp *prop) override
Shallow copy of an axis actor.
virtual void SetPoint2(double x[2])
Specify the position of the second point defining the axis.
virtual void SetLabelTextProperty(vtkTextProperty *p)
Set/Get the labels text property.
virtual double * GetPoint2()
Specify the position of the second point defining the axis.
vtkTypeBool RulerMode
vtkTextProperty * LabelTextProperty
virtual int GetAdjustedNumberOfLabels()
Set/Get the flag that controls whether the labels and ticks are adjusted for "nice" numerical values ...
virtual void GetAdjustedRange(double &_arg1, double &_arg2)
Set/Get the flag that controls whether the labels and ticks are adjusted for "nice" numerical values ...
~vtkAxisActor2D() override
virtual void SetPoint2(double x, double y)
Specify the position of the second point defining the axis.
vtkActor2D * TitleActor
vtkTypeBool TitleVisibility
virtual void UpdateAdjustedRange()
perform coordinate transformation, and represent position, in a variety of vtk coordinate systems
Definition: vtkCoordinate.h:86
a simple class to control print indentation
Definition: vtkIndent.h:43
draw vtkPolyData onto the image plane
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:95
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:57
2D text annotation
Definition: vtkTextMapper.h:57
represent text properties.
record modification and/or execution time
Definition: vtkTimeStamp.h:42
abstract specification for Viewports
Definition: vtkViewport.h:56
window superclass for vtkRenderWindow
Definition: vtkWindow.h:45
@ height
Definition: vtkX3D.h:260
@ offset
Definition: vtkX3D.h:444
auto Range(IterablePtr iterable, Options &&... opts) -> typename detail::IterableTraits< typename detail::StripPointers< IterablePtr >::type >::RangeType
Generate an iterable STL proxy object for a VTK container.
Definition: vtkRange.h:85
int vtkTypeBool
Definition: vtkABI.h:69
#define VTK_FLOAT_MAX
Definition: vtkType.h:163