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 =========================================================================*/
61 #ifndef vtkAxisActor2D_h
62 #define vtkAxisActor2D_h
63 
64 #include "vtkActor2D.h"
65 #include "vtkRenderingAnnotationModule.h" // For export macro
66 
68 class vtkPolyData;
69 class vtkTextMapper;
70 class vtkTextProperty;
71 
72 class VTKRENDERINGANNOTATION_EXPORT vtkAxisActor2D : public vtkActor2D
73 {
74 public:
75  vtkTypeMacro(vtkAxisActor2D, vtkActor2D);
76  void PrintSelf(ostream& os, vtkIndent indent) override;
77 
81  static vtkAxisActor2D* New();
82 
84 
89  virtual void SetPoint1(double x[2]) { this->SetPosition(x); }
90  virtual void SetPoint1(double x, double y) { this->SetPosition(x, y); }
91  virtual double* GetPoint1() { return this->GetPosition(); }
93 
95 
102  virtual void SetPoint2(double x[2]) { this->SetPosition2(x); }
103  virtual void SetPoint2(double x, double y) { this->SetPosition2(x, y); }
104  virtual double* GetPoint2() { return this->GetPosition2(); }
106 
108 
112  vtkSetVector2Macro(Range, double);
113  vtkGetVectorMacro(Range, double, 2);
115 
117 
122  vtkSetMacro(RulerMode, vtkTypeBool);
123  vtkGetMacro(RulerMode, vtkTypeBool);
124  vtkBooleanMacro(RulerMode, vtkTypeBool);
126 
128 
132  vtkSetClampMacro(RulerDistance, double, 0, VTK_FLOAT_MAX);
133  vtkGetMacro(RulerDistance, double);
135 
136  enum LabelMax
137  {
138  VTK_MAX_LABELS = 25
139  };
140 
142 
147  vtkSetClampMacro(NumberOfLabels, int, 2, VTK_MAX_LABELS);
148  vtkGetMacro(NumberOfLabels, int);
150 
152 
156  vtkSetStringMacro(LabelFormat);
157  vtkGetStringMacro(LabelFormat);
159 
161 
169  vtkSetMacro(AdjustLabels, vtkTypeBool);
170  vtkGetMacro(AdjustLabels, vtkTypeBool);
171  vtkBooleanMacro(AdjustLabels, vtkTypeBool);
172  virtual double* GetAdjustedRange()
173  {
174  this->UpdateAdjustedRange();
175  return this->AdjustedRange;
176  }
177  virtual void GetAdjustedRange(double& _arg1, double& _arg2)
178  {
179  this->UpdateAdjustedRange();
180  _arg1 = this->AdjustedRange[0];
181  _arg2 = this->AdjustedRange[1];
182  };
183  virtual void GetAdjustedRange(double _arg[2]) { this->GetAdjustedRange(_arg[0], _arg[1]); }
185  {
186  this->UpdateAdjustedRange();
187  return this->AdjustedNumberOfLabels;
188  }
190 
192 
195  vtkSetStringMacro(Title);
196  vtkGetStringMacro(Title);
198 
200 
203  virtual void SetTitleTextProperty(vtkTextProperty* p);
204  vtkGetObjectMacro(TitleTextProperty, vtkTextProperty);
206 
208 
211  virtual void SetLabelTextProperty(vtkTextProperty* p);
212  vtkGetObjectMacro(LabelTextProperty, vtkTextProperty);
214 
216 
220  vtkSetClampMacro(TickLength, int, 0, 100);
221  vtkGetMacro(TickLength, int);
223 
225 
229  vtkSetClampMacro(NumberOfMinorTicks, int, 0, 20);
230  vtkGetMacro(NumberOfMinorTicks, int);
232 
234 
238  vtkSetClampMacro(MinorTickLength, int, 0, 100);
239  vtkGetMacro(MinorTickLength, int);
241 
243 
248  vtkSetClampMacro(TickOffset, int, 0, 100);
249  vtkGetMacro(TickOffset, int);
251 
253 
256  vtkSetMacro(AxisVisibility, vtkTypeBool);
257  vtkGetMacro(AxisVisibility, vtkTypeBool);
258  vtkBooleanMacro(AxisVisibility, vtkTypeBool);
260 
262 
265  vtkSetMacro(TickVisibility, vtkTypeBool);
266  vtkGetMacro(TickVisibility, vtkTypeBool);
267  vtkBooleanMacro(TickVisibility, vtkTypeBool);
269 
271 
274  vtkSetMacro(LabelVisibility, vtkTypeBool);
275  vtkGetMacro(LabelVisibility, vtkTypeBool);
276  vtkBooleanMacro(LabelVisibility, vtkTypeBool);
278 
280 
283  vtkSetMacro(TitleVisibility, vtkTypeBool);
284  vtkGetMacro(TitleVisibility, vtkTypeBool);
285  vtkBooleanMacro(TitleVisibility, vtkTypeBool);
287 
289 
293  vtkSetMacro(TitlePosition, double);
294  vtkGetMacro(TitlePosition, double);
296 
298 
303  vtkSetClampMacro(FontFactor, double, 0.1, 2.0);
304  vtkGetMacro(FontFactor, double);
306 
308 
312  vtkSetClampMacro(LabelFactor, double, 0.1, 2.0);
313  vtkGetMacro(LabelFactor, double);
315 
317 
320  int RenderOverlay(vtkViewport* viewport) override;
321  int RenderOpaqueGeometry(vtkViewport* viewport) override;
322  int RenderTranslucentPolygonalGeometry(vtkViewport*) override { return 0; }
324 
329 
335  void ReleaseGraphicsResources(vtkWindow*) override;
336 
347  static void ComputeRange(
348  double inRange[2], double outRange[2], int inNumTicks, int& outNumTicks, double& interval);
349 
358  static int SetMultipleFontSize(vtkViewport* viewport, vtkTextMapper** textMappers,
359  int nbOfMappers, int* targetSize, double factor, int* stringSize);
360 
362 
366  vtkSetMacro(SizeFontRelativeToAxis, vtkTypeBool);
367  vtkGetMacro(SizeFontRelativeToAxis, vtkTypeBool);
368  vtkBooleanMacro(SizeFontRelativeToAxis, vtkTypeBool);
370 
372 
377  vtkSetMacro(UseFontSizeFromProperty, vtkTypeBool);
378  vtkGetMacro(UseFontSizeFromProperty, vtkTypeBool);
379  vtkBooleanMacro(UseFontSizeFromProperty, vtkTypeBool);
381 
385  void ShallowCopy(vtkProp* prop) override;
386 
387 protected:
388  vtkAxisActor2D();
389  ~vtkAxisActor2D() override;
390 
393 
394  char* Title;
395  double Range[2];
400  char* LabelFormat;
402  double FontFactor;
403  double LabelFactor;
408 
409  double AdjustedRange[2];
412 
417 
418  int LastPosition[2];
419  int LastPosition2[2];
420 
421  int LastSize[2];
422  int LastMaxLabelSize[2];
423 
426 
427  virtual void BuildAxis(vtkViewport* viewport);
428  static double ComputeStringOffset(double width, double height, double theta);
429  static void SetOffsetPosition(double xTick[3], double theta, int stringWidth, int stringHeight,
430  int offset, vtkActor2D* actor);
431  virtual void UpdateAdjustedRange();
432 
435 
438 
442 
445 
446 private:
447  vtkAxisActor2D(const vtkAxisActor2D&) = delete;
448  void operator=(const vtkAxisActor2D&) = delete;
449 };
450 
451 #endif
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:56
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:55
virtual double * GetPoint1()
Specify the position of the first point defining the axis.
a actor that draws 2D data
Definition: vtkActor2D.h:45
record modification and/or execution time
Definition: vtkTimeStamp.h:35
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:90
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:50
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:38
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 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:39
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:79
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.
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