VTK  9.3.20240328
vtkLegendScaleActor.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
47 #ifndef vtkLegendScaleActor_h
48 #define vtkLegendScaleActor_h
49 
50 #include "vtkDeprecation.h" // for deprecation
51 #include "vtkProp.h"
52 #include "vtkRenderingAnnotationModule.h" // For export macro
53 
54 #include "vtkNew.h" // for vtkNew
55 
56 VTK_ABI_NAMESPACE_BEGIN
57 class vtkAxisActor2D;
58 class vtkProperty2D;
59 class vtkTextProperty;
60 class vtkPolyData;
62 class vtkActor2D;
63 class vtkTextMapper;
64 class vtkPoints;
65 class vtkCoordinate;
67 
68 class VTKRENDERINGANNOTATION_EXPORT vtkLegendScaleActor : public vtkProp
69 {
70 public:
75 
77 
80  vtkTypeMacro(vtkLegendScaleActor, vtkProp);
81  void PrintSelf(ostream& os, vtkIndent indent) override;
83 
85  {
86  DISTANCE = 0,
87  COORDINATES = 1,
88  XY_COORDINATES = COORDINATES
89  };
90 
92 
98  vtkSetClampMacro(LabelMode, int, DISTANCE, COORDINATES);
99  vtkGetMacro(LabelMode, int);
100  void SetLabelModeToDistance() { this->SetLabelMode(DISTANCE); }
101  VTK_DEPRECATED_IN_9_4_0("This class can now determine current plane. Please use the generic "
102  "SetLabelModeToCoordinates instead.")
103  void SetLabelModeToXYCoordinates() { this->SetLabelMode(XY_COORDINATES); }
104  void SetLabelModeToCoordinates() { this->SetLabelMode(COORDINATES); }
106 
108 
112  vtkSetMacro(RightAxisVisibility, vtkTypeBool);
113  vtkGetMacro(RightAxisVisibility, vtkTypeBool);
114  vtkBooleanMacro(RightAxisVisibility, vtkTypeBool);
115  vtkSetMacro(TopAxisVisibility, vtkTypeBool);
116  vtkGetMacro(TopAxisVisibility, vtkTypeBool);
117  vtkBooleanMacro(TopAxisVisibility, vtkTypeBool);
118  vtkSetMacro(LeftAxisVisibility, vtkTypeBool);
119  vtkGetMacro(LeftAxisVisibility, vtkTypeBool);
120  vtkBooleanMacro(LeftAxisVisibility, vtkTypeBool);
121  vtkSetMacro(BottomAxisVisibility, vtkTypeBool);
122  vtkGetMacro(BottomAxisVisibility, vtkTypeBool);
123  vtkBooleanMacro(BottomAxisVisibility, vtkTypeBool);
125 
127 
131  vtkSetMacro(LegendVisibility, vtkTypeBool);
132  vtkGetMacro(LegendVisibility, vtkTypeBool);
133  vtkBooleanMacro(LegendVisibility, vtkTypeBool);
135 
137 
140  void AllAxesOn();
141  void AllAxesOff();
143 
145 
151 
153 
156  vtkSetMacro(GridVisibility, bool);
157  vtkGetMacro(GridVisibility, bool);
158  vtkBooleanMacro(GridVisibility, bool);
160 
162 
167  vtkSetClampMacro(RightBorderOffset, int, 5, VTK_INT_MAX);
168  vtkGetMacro(RightBorderOffset, int);
170 
172 
177  vtkSetClampMacro(TopBorderOffset, int, 5, VTK_INT_MAX);
178  vtkGetMacro(TopBorderOffset, int);
180 
182 
187  vtkSetClampMacro(LeftBorderOffset, int, 5, VTK_INT_MAX);
188  vtkGetMacro(LeftBorderOffset, int);
190 
192 
197  vtkSetClampMacro(BottomBorderOffset, int, 5, VTK_INT_MAX);
198  vtkGetMacro(BottomBorderOffset, int);
200 
202 
206  vtkSetClampMacro(CornerOffsetFactor, double, 1.0, 10.0);
207  vtkGetMacro(CornerOffsetFactor, double);
209 
211 
215  void SetNotation(int notation);
216  int GetNotation();
218 
220 
223  void SetPrecision(int val);
226 
228 
234 
236 
242 
244 
248  vtkSetVector3Macro(Origin, double);
249  vtkGetVector3Macro(Origin, double);
251 
253 
256  vtkGetObjectMacro(LegendTitleProperty, vtkTextProperty);
257  vtkGetObjectMacro(LegendLabelProperty, vtkTextProperty);
259 
266 
271 
277 
279  void SetUseFontSizeFromProperty(bool sizeFromProp);
280 
288  "This does not respect the number of labels. Please use SetSnapToGrid instead.")
289  void SetAdjustLabels(bool adjust);
290 
296  void SetSnapToGrid(bool snap);
298 
300 
305  vtkGetObjectMacro(RightAxis, vtkAxisActor2D);
306  vtkGetObjectMacro(TopAxis, vtkAxisActor2D);
307  vtkGetObjectMacro(LeftAxis, vtkAxisActor2D);
308  vtkGetObjectMacro(BottomAxis, vtkAxisActor2D);
310 
312 
315  virtual void BuildRepresentation(vtkViewport* viewport);
316  void GetActors2D(vtkPropCollection*) override;
317  void ReleaseGraphicsResources(vtkWindow*) override;
318  int RenderOverlay(vtkViewport*) override;
319  int RenderOpaqueGeometry(vtkViewport*) override;
321 
322 protected:
324  ~vtkLegendScaleActor() override;
325 
326  int LabelMode = DISTANCE;
327  int RightBorderOffset = 50;
328  int TopBorderOffset = 30;
329  int LeftBorderOffset = 50;
330  int BottomBorderOffset = 30;
331  double CornerOffsetFactor = 2.;
332 
333  // The four axes around the borders of the renderer
334  vtkNew<vtkAxisActor2D> RightAxis;
337  vtkNew<vtkAxisActor2D> BottomAxis;
338 
339  // Support for grid
342  bool GridVisibility = false;
343 
344  // Control the display of the axes
345  vtkTypeBool RightAxisVisibility = 1;
346  vtkTypeBool TopAxisVisibility = 1;
347  vtkTypeBool LeftAxisVisibility = 1;
348  vtkTypeBool BottomAxisVisibility = 1;
349 
350  // Support for the legend.
351  vtkTypeBool LegendVisibility = 1;
353  vtkNew<vtkPoints> LegendPoints;
355  vtkNew<vtkActor2D> LegendActor;
356  vtkNew<vtkTextMapper> LabelMappers[6];
357  vtkNew<vtkActor2D> LabelActors[6];
358  vtkNew<vtkTextProperty> LegendTitleProperty;
359  vtkNew<vtkTextProperty> LegendLabelProperty;
361 
362  vtkTimeStamp BuildTime;
363 
364 private:
365  vtkLegendScaleActor(const vtkLegendScaleActor&) = delete;
366  void operator=(const vtkLegendScaleActor&) = delete;
367 
373  void UpdateAxisRange(vtkAxisActor2D* axis, vtkViewport* viewport, bool invert = false);
374 
375  double Origin[3] = { 0, 0, 0 };
376 };
377 
378 VTK_ABI_NAMESPACE_END
379 #endif
a actor that draws 2D data
Definition: vtkActor2D.h:144
Create an axis with tick marks and labels.
renders a 2D grid given pairs of point positions
perform coordinate transformation, and represent position, in a variety of vtk coordinate systems
a simple class to control print indentation
Definition: vtkIndent.h:108
annotate the render window with scale and distance information
void SetPrecision(int val)
Get/set the numerical precision to use for axis labels, default is 2.
vtkProperty2D * GetAxesProperty()
Return the property used for the right axis which should be the same as the other ones if set using S...
static vtkLegendScaleActor * New()
Instantiate the class.
void PrintSelf(ostream &os, vtkIndent indent) override
Standard methods for the class.
void AllAnnotationsOff()
Convenience method that turns all the axes and the legend scale.
void SetLabelModeToDistance()
Specify the mode for labeling the scale axes.
void AllAxesOn()
Convenience method that turns all the axes either on or off.
void SetNumberOfVerticalLabels(int val)
Get/set the number of ticks (and labels) for the vertical axis, default is 5.
void SetAxesTextProperty(vtkTextProperty *property)
Configuration forwarded to each axis.
int GetNotation()
Get/set the numerical notation for axes labels: standard, scientific or mixed (0, 1,...
void AllAxesOff()
Convenience method that turns all the axes either on or off.
void SetAxesProperty(vtkProperty2D *property)
Set the 2D property for both axis and grid.
int GetPrecision()
Get/set the numerical precision to use for axis labels, default is 2.
void SetNumberOfHorizontalLabels(int val)
Get/set the number of ticks (and labels) for the horizontal axis, default is 5.
void AllAnnotationsOn()
Convenience method that turns all the axes and the legend scale.
void SetUseFontSizeFromProperty(bool sizeFromProp)
Set the axes to get font size from text property.
int GetNumberOfHorizontalLabels()
Get/set the number of ticks (and labels) for the horizontal axis, default is 5.
void SetNotation(int notation)
Get/set the numerical notation for axes labels: standard, scientific or mixed (0, 1,...
int GetNumberOfVerticalLabels()
Get/set the number of ticks (and labels) for the vertical axis, default is 5.
void SetLabelModeToCoordinates()
Specify the mode for labeling the scale axes.
Allocate and hold a VTK object.
Definition: vtkNew.h:160
represent and manipulate 3D points
Definition: vtkPoints.h:138
draw vtkPolyData onto the image plane
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:180
an ordered list of Props
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:65
represent surface properties of a 2D image
2D text annotation
represent text properties.
record modification and/or execution time
Definition: vtkTimeStamp.h:44
abstract specification for Viewports
Definition: vtkViewport.h:64
window superclass for vtkRenderWindow
Definition: vtkWindow.h:47
@ Coordinate
Definition: vtkX3D.h:44
int vtkTypeBool
Definition: vtkABI.h:64
#define VTK_DEPRECATED_IN_9_4_0(reason)
#define VTK_INT_MAX
Definition: vtkType.h:144