VTK  9.2.6
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 =========================================================================*/
70 #ifndef vtkAxisActor2D_h
71 #define vtkAxisActor2D_h
72 
73 #include "vtkActor2D.h"
74 #include "vtkRenderingAnnotationModule.h" // For export macro
75 
77 class vtkPolyData;
78 class vtkTextMapper;
79 class vtkTextProperty;
80 
81 class VTKRENDERINGANNOTATION_EXPORT vtkAxisActor2D : public vtkActor2D
82 {
83 public:
84  vtkTypeMacro(vtkAxisActor2D, vtkActor2D);
85  void PrintSelf(ostream& os, vtkIndent indent) override;
86 
90  static vtkAxisActor2D* New();
91 
93 
98  virtual void SetPoint1(double x[2]) { this->SetPosition(x); }
99  virtual void SetPoint1(double x, double y) { this->SetPosition(x, y); }
100  virtual double* GetPoint1() { return this->GetPosition(); }
102 
104 
111  virtual void SetPoint2(double x[2]) { this->SetPosition2(x); }
112  virtual void SetPoint2(double x, double y) { this->SetPosition2(x, y); }
113  virtual double* GetPoint2() { return this->GetPosition2(); }
115 
117 
121  vtkSetVector2Macro(Range, double);
122  vtkGetVectorMacro(Range, double, 2);
124 
126 
131  vtkSetMacro(RulerMode, vtkTypeBool);
132  vtkGetMacro(RulerMode, vtkTypeBool);
133  vtkBooleanMacro(RulerMode, vtkTypeBool);
135 
137 
141  vtkSetClampMacro(RulerDistance, double, 0, VTK_FLOAT_MAX);
142  vtkGetMacro(RulerDistance, double);
144 
145  enum LabelMax
146  {
147  VTK_MAX_LABELS = 25
148  };
149 
151 
156  vtkSetClampMacro(NumberOfLabels, int, 2, VTK_MAX_LABELS);
157  vtkGetMacro(NumberOfLabels, int);
159 
161 
165  vtkSetStringMacro(LabelFormat);
166  vtkGetStringMacro(LabelFormat);
168 
170 
178  vtkSetMacro(AdjustLabels, vtkTypeBool);
179  vtkGetMacro(AdjustLabels, vtkTypeBool);
180  vtkBooleanMacro(AdjustLabels, vtkTypeBool);
181  virtual double* GetAdjustedRange()
182  {
183  this->UpdateAdjustedRange();
184  return this->AdjustedRange;
185  }
186  virtual void GetAdjustedRange(double& _arg1, double& _arg2)
187  {
188  this->UpdateAdjustedRange();
189  _arg1 = this->AdjustedRange[0];
190  _arg2 = this->AdjustedRange[1];
191  };
192  virtual void GetAdjustedRange(double _arg[2]) { this->GetAdjustedRange(_arg[0], _arg[1]); }
194  {
195  this->UpdateAdjustedRange();
196  return this->AdjustedNumberOfLabels;
197  }
199 
201 
204  vtkSetStringMacro(Title);
205  vtkGetStringMacro(Title);
207 
209 
213  vtkGetObjectMacro(TitleTextProperty, vtkTextProperty);
215 
217 
221  vtkGetObjectMacro(LabelTextProperty, vtkTextProperty);
223 
225 
229  vtkSetClampMacro(TickLength, int, 0, 100);
230  vtkGetMacro(TickLength, int);
232 
234 
238  vtkSetClampMacro(NumberOfMinorTicks, int, 0, 20);
239  vtkGetMacro(NumberOfMinorTicks, int);
241 
243 
247  vtkSetClampMacro(MinorTickLength, int, 0, 100);
248  vtkGetMacro(MinorTickLength, int);
250 
252 
257  vtkSetClampMacro(TickOffset, int, 0, 100);
258  vtkGetMacro(TickOffset, int);
260 
262 
265  vtkSetMacro(AxisVisibility, vtkTypeBool);
266  vtkGetMacro(AxisVisibility, vtkTypeBool);
267  vtkBooleanMacro(AxisVisibility, vtkTypeBool);
269 
271 
274  vtkSetMacro(TickVisibility, vtkTypeBool);
275  vtkGetMacro(TickVisibility, vtkTypeBool);
276  vtkBooleanMacro(TickVisibility, vtkTypeBool);
278 
280 
283  vtkSetMacro(LabelVisibility, vtkTypeBool);
284  vtkGetMacro(LabelVisibility, vtkTypeBool);
285  vtkBooleanMacro(LabelVisibility, vtkTypeBool);
287 
289 
292  vtkSetMacro(TitleVisibility, vtkTypeBool);
293  vtkGetMacro(TitleVisibility, vtkTypeBool);
294  vtkBooleanMacro(TitleVisibility, vtkTypeBool);
296 
298 
302  vtkSetMacro(TitlePosition, double);
303  vtkGetMacro(TitlePosition, double);
305 
307 
312  vtkSetClampMacro(FontFactor, double, 0.1, 2.0);
313  vtkGetMacro(FontFactor, double);
315 
317 
321  vtkSetClampMacro(LabelFactor, double, 0.1, 2.0);
322  vtkGetMacro(LabelFactor, double);
324 
326 
329  int RenderOverlay(vtkViewport* viewport) override;
330  int RenderOpaqueGeometry(vtkViewport* viewport) override;
331  int RenderTranslucentPolygonalGeometry(vtkViewport*) override { return 0; }
333 
338 
345 
356  static void ComputeRange(
357  double inRange[2], double outRange[2], int inNumTicks, int& outNumTicks, double& interval);
358 
367  static int SetMultipleFontSize(vtkViewport* viewport, vtkTextMapper** textMappers,
368  int nbOfMappers, int* targetSize, double factor, int* stringSize);
369 
371 
375  vtkSetMacro(SizeFontRelativeToAxis, vtkTypeBool);
376  vtkGetMacro(SizeFontRelativeToAxis, vtkTypeBool);
377  vtkBooleanMacro(SizeFontRelativeToAxis, vtkTypeBool);
379 
381 
386  vtkSetMacro(UseFontSizeFromProperty, vtkTypeBool);
387  vtkGetMacro(UseFontSizeFromProperty, vtkTypeBool);
388  vtkBooleanMacro(UseFontSizeFromProperty, vtkTypeBool);
390 
394  void ShallowCopy(vtkProp* prop) override;
395 
396 protected:
398  ~vtkAxisActor2D() override;
399 
402 
403  char* Title;
404  double Range[2];
409  char* LabelFormat;
411  double FontFactor;
412  double LabelFactor;
417 
418  double AdjustedRange[2];
421 
426 
427  int LastPosition[2];
428  int LastPosition2[2];
429 
430  int LastSize[2];
431  int LastMaxLabelSize[2];
432 
435 
436  virtual void BuildAxis(vtkViewport* viewport);
437  static double ComputeStringOffset(double width, double height, double theta);
438  static void SetOffsetPosition(double xTick[3], double theta, int stringWidth, int stringHeight,
439  int offset, vtkActor2D* actor);
440  virtual void UpdateAdjustedRange();
441 
444 
447 
451 
454 
455 private:
456  vtkAxisActor2D(const vtkAxisActor2D&) = delete;
457  void operator=(const vtkAxisActor2D&) = delete;
458 };
459 
460 #endif
a actor that draws 2D data
Definition: vtkActor2D.h:55
virtual vtkCoordinate * GetPositionCoordinate()
Get the PositionCoordinate instance of vtkCoordinate.
virtual void SetPosition2(float x[2])
Access the Position2 instance variable.
virtual vtkCoordinate * GetPosition2Coordinate()
Access the Position2 instance variable.
virtual float * GetPosition2()
Access the Position2 instance variable.
virtual void SetPosition(float x[2])
Get the PositionCoordinate instance of vtkCoordinate.
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.
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.
virtual double * GetPoint2()
Specify the position of the second point defining the axis.
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 vtkAxisActor2D * New()
Instantiate object.
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 * GetPoint1Coordinate()
Specify the position of the first point defining the axis.
vtkPolyData * Axis
virtual double * GetPoint1()
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 ...
virtual double * GetAdjustedRange()
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
vtkTypeBool UseFontSizeFromProperty
vtkTypeBool AxisVisibility
static double ComputeStringOffset(double width, double height, double theta)
int RenderOverlay(vtkViewport *viewport) override
Draw 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.
vtkTypeBool RulerMode
virtual vtkCoordinate * GetPoint2Coordinate()
Specify the position of the second point defining the axis.
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:89
a simple class to control print indentation
Definition: vtkIndent.h:49
draw vtkPolyData onto the image plane
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:100
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:66
2D text annotation
Definition: vtkTextMapper.h:60
represent text properties.
record modification and/or execution time
Definition: vtkTimeStamp.h:45
abstract specification for Viewports
Definition: vtkViewport.h:65
window superclass for vtkRenderWindow
Definition: vtkWindow.h:48
@ 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