VTK  9.0.1
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 =========================================================================*/
58 #ifndef vtkAxisActor2D_h
59 #define vtkAxisActor2D_h
60 
61 #include "vtkActor2D.h"
62 #include "vtkRenderingAnnotationModule.h" // For export macro
63 
65 class vtkPolyData;
66 class vtkTextMapper;
67 class vtkTextProperty;
68 
69 class VTKRENDERINGANNOTATION_EXPORT vtkAxisActor2D : public vtkActor2D
70 {
71 public:
72  vtkTypeMacro(vtkAxisActor2D, vtkActor2D);
73  void PrintSelf(ostream& os, vtkIndent indent) override;
74 
78  static vtkAxisActor2D* New();
79 
81 
86  virtual void SetPoint1(double x[2]) { this->SetPosition(x); }
87  virtual void SetPoint1(double x, double y) { this->SetPosition(x, y); }
88  virtual double* GetPoint1() { return this->GetPosition(); }
90 
92 
99  virtual void SetPoint2(double x[2]) { this->SetPosition2(x); }
100  virtual void SetPoint2(double x, double y) { this->SetPosition2(x, y); }
101  virtual double* GetPoint2() { return this->GetPosition2(); }
103 
105 
109  vtkSetVector2Macro(Range, double);
110  vtkGetVectorMacro(Range, double, 2);
112 
114 
119  vtkSetMacro(RulerMode, vtkTypeBool);
120  vtkGetMacro(RulerMode, vtkTypeBool);
121  vtkBooleanMacro(RulerMode, vtkTypeBool);
123 
125 
129  vtkSetClampMacro(RulerDistance, double, 0, VTK_FLOAT_MAX);
130  vtkGetMacro(RulerDistance, double);
132 
133  enum LabelMax
134  {
135  VTK_MAX_LABELS = 25
136  };
137 
139 
144  vtkSetClampMacro(NumberOfLabels, int, 2, VTK_MAX_LABELS);
145  vtkGetMacro(NumberOfLabels, int);
147 
149 
153  vtkSetStringMacro(LabelFormat);
154  vtkGetStringMacro(LabelFormat);
156 
158 
166  vtkSetMacro(AdjustLabels, vtkTypeBool);
167  vtkGetMacro(AdjustLabels, vtkTypeBool);
168  vtkBooleanMacro(AdjustLabels, vtkTypeBool);
169  virtual double* GetAdjustedRange()
170  {
171  this->UpdateAdjustedRange();
172  return this->AdjustedRange;
173  }
174  virtual void GetAdjustedRange(double& _arg1, double& _arg2)
175  {
176  this->UpdateAdjustedRange();
177  _arg1 = this->AdjustedRange[0];
178  _arg2 = this->AdjustedRange[1];
179  };
180  virtual void GetAdjustedRange(double _arg[2]) { this->GetAdjustedRange(_arg[0], _arg[1]); }
182  {
183  this->UpdateAdjustedRange();
184  return this->AdjustedNumberOfLabels;
185  }
187 
189 
192  vtkSetStringMacro(Title);
193  vtkGetStringMacro(Title);
195 
197 
200  virtual void SetTitleTextProperty(vtkTextProperty* p);
201  vtkGetObjectMacro(TitleTextProperty, vtkTextProperty);
203 
205 
208  virtual void SetLabelTextProperty(vtkTextProperty* p);
209  vtkGetObjectMacro(LabelTextProperty, vtkTextProperty);
211 
213 
217  vtkSetClampMacro(TickLength, int, 0, 100);
218  vtkGetMacro(TickLength, int);
220 
222 
226  vtkSetClampMacro(NumberOfMinorTicks, int, 0, 20);
227  vtkGetMacro(NumberOfMinorTicks, int);
229 
231 
235  vtkSetClampMacro(MinorTickLength, int, 0, 100);
236  vtkGetMacro(MinorTickLength, int);
238 
240 
245  vtkSetClampMacro(TickOffset, int, 0, 100);
246  vtkGetMacro(TickOffset, int);
248 
250 
253  vtkSetMacro(AxisVisibility, vtkTypeBool);
254  vtkGetMacro(AxisVisibility, vtkTypeBool);
255  vtkBooleanMacro(AxisVisibility, vtkTypeBool);
257 
259 
262  vtkSetMacro(TickVisibility, vtkTypeBool);
263  vtkGetMacro(TickVisibility, vtkTypeBool);
264  vtkBooleanMacro(TickVisibility, vtkTypeBool);
266 
268 
271  vtkSetMacro(LabelVisibility, vtkTypeBool);
272  vtkGetMacro(LabelVisibility, vtkTypeBool);
273  vtkBooleanMacro(LabelVisibility, vtkTypeBool);
275 
277 
280  vtkSetMacro(TitleVisibility, vtkTypeBool);
281  vtkGetMacro(TitleVisibility, vtkTypeBool);
282  vtkBooleanMacro(TitleVisibility, vtkTypeBool);
284 
286 
290  vtkSetMacro(TitlePosition, double);
291  vtkGetMacro(TitlePosition, double);
293 
295 
300  vtkSetClampMacro(FontFactor, double, 0.1, 2.0);
301  vtkGetMacro(FontFactor, double);
303 
305 
309  vtkSetClampMacro(LabelFactor, double, 0.1, 2.0);
310  vtkGetMacro(LabelFactor, double);
312 
314 
317  int RenderOverlay(vtkViewport* viewport) override;
318  int RenderOpaqueGeometry(vtkViewport* viewport) override;
319  int RenderTranslucentPolygonalGeometry(vtkViewport*) override { return 0; }
321 
326 
332  void ReleaseGraphicsResources(vtkWindow*) override;
333 
344  static void ComputeRange(
345  double inRange[2], double outRange[2], int inNumTicks, int& outNumTicks, double& interval);
346 
355  static int SetMultipleFontSize(vtkViewport* viewport, vtkTextMapper** textMappers,
356  int nbOfMappers, int* targetSize, double factor, int* stringSize);
357 
359 
363  vtkSetMacro(SizeFontRelativeToAxis, vtkTypeBool);
364  vtkGetMacro(SizeFontRelativeToAxis, vtkTypeBool);
365  vtkBooleanMacro(SizeFontRelativeToAxis, vtkTypeBool);
367 
369 
374  vtkSetMacro(UseFontSizeFromProperty, vtkTypeBool);
375  vtkGetMacro(UseFontSizeFromProperty, vtkTypeBool);
376  vtkBooleanMacro(UseFontSizeFromProperty, vtkTypeBool);
378 
382  void ShallowCopy(vtkProp* prop) override;
383 
384 protected:
385  vtkAxisActor2D();
386  ~vtkAxisActor2D() override;
387 
390 
391  char* Title;
392  double Range[2];
397  char* LabelFormat;
399  double FontFactor;
400  double LabelFactor;
405 
406  double AdjustedRange[2];
409 
414 
415  int LastPosition[2];
416  int LastPosition2[2];
417 
418  int LastSize[2];
419  int LastMaxLabelSize[2];
420 
423 
424  virtual void BuildAxis(vtkViewport* viewport);
425  static double ComputeStringOffset(double width, double height, double theta);
426  static void SetOffsetPosition(double xTick[3], double theta, int stringWidth, int stringHeight,
427  int offset, vtkActor2D* actor);
428  virtual void UpdateAdjustedRange();
429 
432 
435 
439 
442 
443 private:
444  vtkAxisActor2D(const vtkAxisActor2D&) = delete;
445  void operator=(const vtkAxisActor2D&) = delete;
446 };
447 
448 #endif
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:53
virtual void GetAdjustedRange(double _arg[2])
Set/Get the flag that controls whether the labels and ticks are adjusted for "nice" numerical values ...
vtkTypeBool RulerMode
virtual void SetPosition(float x[2])
Get the PositionCoordinate instance of vtkCoordinate.
int RenderOverlay(vtkViewport *viewport) override
Support the standard render methods.
vtkActor2D * TitleActor
abstract specification for Viewports
Definition: vtkViewport.h:44
virtual double * GetPoint1()
Specify the position of the first point defining the axis.
a actor that draws 2D data
Definition: vtkActor2D.h:39
record modification and/or execution time
Definition: vtkTimeStamp.h:32
vtkActor2D ** LabelActors
virtual vtkCoordinate * GetPositionCoordinate()
Get the PositionCoordinate instance of vtkCoordinate.
Create an axis with tick marks and labels.
vtkTextProperty * TitleTextProperty
virtual void SetPoint1(double x, double y)
Specify the position of the first point defining the axis.
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:84
void ShallowCopy(vtkProp *prop) override
Shallow copy of this vtkActor2D.
vtkActor2D * AxisActor
virtual void SetPoint2(double x, double y)
Specify the position of the second point defining the axis.
virtual float * GetPosition2()
Access the Position2 instance variable.
vtkTypeBool TickVisibility
2D text annotation
Definition: vtkTextMapper.h:47
virtual vtkCoordinate * GetPoint2Coordinate()
Specify the position of the second point defining the axis.
virtual void GetAdjustedRange(double &_arg1, double &_arg2)
Set/Get the flag that controls whether the labels and ticks are adjusted for "nice" numerical values ...
int vtkTypeBool
Definition: vtkABI.h:69
virtual vtkCoordinate * GetPoint1Coordinate()
Specify the position of the first point defining the axis.
vtkPolyData * Axis
window superclass for vtkRenderWindow
Definition: vtkWindow.h:37
virtual double * GetAdjustedRange()
Set/Get the flag that controls whether the labels and ticks are adjusted for "nice" numerical values ...
vtkTimeStamp AdjustedRangeBuildTime
#define VTK_FLOAT_MAX
Definition: vtkType.h:163
vtkPolyDataMapper2D * AxisMapper
vtkTypeBool TitleVisibility
virtual double * GetPoint2()
Specify the position of the second point defining the axis.
void ReleaseGraphicsResources(vtkWindow *) override
Release any graphics resources that are being consumed by this actor.
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkTypeBool LabelVisibility
vtkTextMapper * TitleMapper
static vtkActor2D * New()
Creates an actor2D with the following defaults: position (0,0) (coordinate system is viewport); at la...
vtkTextMapper ** LabelMappers
virtual void SetPosition2(float x[2])
Access the Position2 instance variable.
vtkTypeBool UseFontSizeFromProperty
virtual float * GetPosition()
Get the PositionCoordinate instance of vtkCoordinate.
virtual void SetPoint2(double x[2])
Specify the position of the second point defining the axis.
virtual vtkCoordinate * GetPosition2Coordinate()
Access the Position2 instance variable.
int RenderTranslucentPolygonalGeometry(vtkViewport *) override
Draw the axis.
represent text properties.
vtkTextProperty * LabelTextProperty
perform coordinate transformation, and represent position, in a variety of vtk coordinate systems ...
Definition: vtkCoordinate.h:76
vtkTypeBool AxisVisibility
virtual void SetPoint1(double x[2])
Specify the position of the first point defining the axis.
vtkTypeBool HasTranslucentPolygonalGeometry() override
Does this prop have some translucent polygonal geometry?
int RenderOpaqueGeometry(vtkViewport *viewport) override
Support the standard render methods.
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
virtual int GetAdjustedNumberOfLabels()
Set/Get the flag that controls whether the labels and ticks are adjusted for "nice" numerical values ...
vtkTimeStamp BuildTime
draw vtkPolyData onto the image plane
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkTypeBool AdjustLabels