VTK  9.4.20251203
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
28#ifndef vtkLegendScaleActor_h
29#define vtkLegendScaleActor_h
30
31#include "vtkDeprecation.h" // for deprecation
32#include "vtkProp.h"
33#include "vtkRenderingAnnotationModule.h" // For export macro
34#include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
35
36#include "vtkNew.h" // for vtkNew
37
38VTK_ABI_NAMESPACE_BEGIN
39class vtkAxisActor2D;
40class vtkProperty2D;
41class vtkTextProperty;
42class vtkPolyData;
44class vtkActor2D;
45class vtkTextMapper;
46class vtkPoints;
47class vtkCoordinate;
49
50class VTKRENDERINGANNOTATION_EXPORT VTK_MARSHALAUTO vtkLegendScaleActor : public vtkProp
51{
52public:
57
59
63 void PrintSelf(ostream& os, vtkIndent indent) override;
65
67 {
68 DISTANCE = 0,
69 COORDINATES = 1,
70 XY_COORDINATES = COORDINATES
71 };
72
74
80 vtkSetClampMacro(LabelMode, int, DISTANCE, COORDINATES);
81 vtkGetMacro(LabelMode, int);
82 void SetLabelModeToDistance() { this->SetLabelMode(DISTANCE); }
83 VTK_DEPRECATED_IN_9_4_0("This class can now determine current plane. Please use the generic "
84 "SetLabelModeToCoordinates instead.")
85 void SetLabelModeToXYCoordinates() { this->SetLabelMode(XY_COORDINATES); }
86 void SetLabelModeToCoordinates() { this->SetLabelMode(COORDINATES); }
88
90
94 vtkSetMacro(RightAxisVisibility, vtkTypeBool);
95 vtkGetMacro(RightAxisVisibility, vtkTypeBool);
96 vtkBooleanMacro(RightAxisVisibility, vtkTypeBool);
97 vtkSetMacro(TopAxisVisibility, vtkTypeBool);
98 vtkGetMacro(TopAxisVisibility, vtkTypeBool);
99 vtkBooleanMacro(TopAxisVisibility, vtkTypeBool);
100 vtkSetMacro(LeftAxisVisibility, vtkTypeBool);
101 vtkGetMacro(LeftAxisVisibility, vtkTypeBool);
102 vtkBooleanMacro(LeftAxisVisibility, vtkTypeBool);
103 vtkSetMacro(BottomAxisVisibility, vtkTypeBool);
104 vtkGetMacro(BottomAxisVisibility, vtkTypeBool);
105 vtkBooleanMacro(BottomAxisVisibility, vtkTypeBool);
107
109
113 vtkSetMacro(LegendVisibility, vtkTypeBool);
114 vtkGetMacro(LegendVisibility, vtkTypeBool);
115 vtkBooleanMacro(LegendVisibility, vtkTypeBool);
117
119
122 void AllAxesOn();
125
127
133
135
138 vtkSetMacro(GridVisibility, bool);
139 vtkGetMacro(GridVisibility, bool);
140 vtkBooleanMacro(GridVisibility, bool);
142
144
149 vtkSetClampMacro(RightBorderOffset, int, 5, VTK_INT_MAX);
150 vtkGetMacro(RightBorderOffset, int);
152
154
159 vtkSetClampMacro(TopBorderOffset, int, 5, VTK_INT_MAX);
160 vtkGetMacro(TopBorderOffset, int);
162
164
169 vtkSetClampMacro(LeftBorderOffset, int, 5, VTK_INT_MAX);
170 vtkGetMacro(LeftBorderOffset, int);
172
174
179 vtkSetClampMacro(BottomBorderOffset, int, 5, VTK_INT_MAX);
180 vtkGetMacro(BottomBorderOffset, int);
182
184
188 vtkSetClampMacro(CornerOffsetFactor, double, 1.0, 10.0);
189 vtkGetMacro(CornerOffsetFactor, double);
191
193
197 void SetNotation(int notation);
200
202
205 void SetPrecision(int val);
208
210
216
218
224
226
230 vtkSetVector3Macro(Origin, double);
231 vtkGetVector3Macro(Origin, double);
233
235
238 vtkGetObjectMacro(LegendTitleProperty, vtkTextProperty);
239 vtkGetObjectMacro(LegendLabelProperty, vtkTextProperty);
241
248
253
259
261 void SetUseFontSizeFromProperty(bool sizeFromProp);
262
270 "This does not respect the number of labels. Please use SetSnapToGrid instead.")
271 void SetAdjustLabels(bool adjust);
272
278 void SetSnapToGrid(bool snap);
280
282
287 vtkGetObjectMacro(RightAxis, vtkAxisActor2D);
288 vtkGetObjectMacro(TopAxis, vtkAxisActor2D);
289 vtkGetObjectMacro(LeftAxis, vtkAxisActor2D);
290 vtkGetObjectMacro(BottomAxis, vtkAxisActor2D);
292
294
297 virtual void BuildRepresentation(vtkViewport* viewport);
298 void GetActors2D(vtkPropCollection*) override;
299 void ReleaseGraphicsResources(vtkWindow*) override;
300 int RenderOverlay(vtkViewport*) override;
301 int RenderOpaqueGeometry(vtkViewport*) override;
303
304protected:
307
308 int LabelMode = DISTANCE;
309 int RightBorderOffset = 50;
310 int TopBorderOffset = 30;
311 int LeftBorderOffset = 50;
312 int BottomBorderOffset = 30;
313 double CornerOffsetFactor = 2.;
314
315 // The four axes around the borders of the renderer
320
321 // Support for grid
324 bool GridVisibility = false;
325
326 // Control the display of the axes
327 vtkTypeBool RightAxisVisibility = 1;
328 vtkTypeBool TopAxisVisibility = 1;
329 vtkTypeBool LeftAxisVisibility = 1;
330 vtkTypeBool BottomAxisVisibility = 1;
331
332 // Support for the legend.
333 vtkTypeBool LegendVisibility = 1;
335 vtkNew<vtkPoints> LegendPoints;
337 vtkNew<vtkActor2D> LegendActor;
338 vtkNew<vtkTextMapper> LabelMappers[6];
339 vtkNew<vtkActor2D> LabelActors[6];
340 vtkNew<vtkTextProperty> LegendTitleProperty;
341 vtkNew<vtkTextProperty> LegendLabelProperty;
343
344 vtkTimeStamp BuildTime;
345
346private:
348 void operator=(const vtkLegendScaleActor&) = delete;
349
355 void UpdateAxisRange(vtkAxisActor2D* axis, vtkViewport* viewport, bool invert = false);
356
357 double Origin[3] = { 0, 0, 0 };
358};
359
360VTK_ABI_NAMESPACE_END
361#endif
a actor that draws 2D data
Definition vtkActor2D.h:36
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:29
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.
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.
vtkProperty2D * GetAxesProperty()
Return the property used for the right axis which should be the same as the other ones if set using S...
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.
static vtkLegendScaleActor * New()
Instantiate the class.
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:58
represent and manipulate 3D points
Definition vtkPoints.h:30
draw vtkPolyData onto the image plane
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition vtkPolyData.h:72
an ordered list of Props
abstract superclass for all actors, volumes and annotations
Definition vtkProp.h:47
represent surface properties of a 2D image
2D text annotation
represent text properties.
record modification and/or execution time
abstract specification for Viewports
Definition vtkViewport.h:46
window superclass for vtkRenderWindow
Definition vtkWindow.h:29
int vtkTypeBool
Definition vtkABI.h:64
#define VTK_DEPRECATED_IN_9_4_0(reason)
#define VTK_INT_MAX
Definition vtkType.h:144
#define VTK_MARSHALAUTO