VTK  9.4.2
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#include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
54
55#include "vtkNew.h" // for vtkNew
56
57VTK_ABI_NAMESPACE_BEGIN
58class vtkAxisActor2D;
59class vtkProperty2D;
60class vtkTextProperty;
61class vtkPolyData;
63class vtkActor2D;
64class vtkTextMapper;
65class vtkPoints;
66class vtkCoordinate;
68
69class VTKRENDERINGANNOTATION_EXPORT VTK_MARSHALAUTO vtkLegendScaleActor : public vtkProp
70{
71public:
76
78
82 void PrintSelf(ostream& os, vtkIndent indent) override;
84
86 {
87 DISTANCE = 0,
88 COORDINATES = 1,
89 XY_COORDINATES = COORDINATES
90 };
91
93
99 vtkSetClampMacro(LabelMode, int, DISTANCE, COORDINATES);
100 vtkGetMacro(LabelMode, int);
101 void SetLabelModeToDistance() { this->SetLabelMode(DISTANCE); }
102 VTK_DEPRECATED_IN_9_4_0("This class can now determine current plane. Please use the generic "
103 "SetLabelModeToCoordinates instead.")
104 void SetLabelModeToXYCoordinates() { this->SetLabelMode(XY_COORDINATES); }
105 void SetLabelModeToCoordinates() { this->SetLabelMode(COORDINATES); }
107
109
113 vtkSetMacro(RightAxisVisibility, vtkTypeBool);
114 vtkGetMacro(RightAxisVisibility, vtkTypeBool);
115 vtkBooleanMacro(RightAxisVisibility, vtkTypeBool);
116 vtkSetMacro(TopAxisVisibility, vtkTypeBool);
117 vtkGetMacro(TopAxisVisibility, vtkTypeBool);
118 vtkBooleanMacro(TopAxisVisibility, vtkTypeBool);
119 vtkSetMacro(LeftAxisVisibility, vtkTypeBool);
120 vtkGetMacro(LeftAxisVisibility, vtkTypeBool);
121 vtkBooleanMacro(LeftAxisVisibility, vtkTypeBool);
122 vtkSetMacro(BottomAxisVisibility, vtkTypeBool);
123 vtkGetMacro(BottomAxisVisibility, vtkTypeBool);
124 vtkBooleanMacro(BottomAxisVisibility, vtkTypeBool);
126
128
132 vtkSetMacro(LegendVisibility, vtkTypeBool);
133 vtkGetMacro(LegendVisibility, vtkTypeBool);
134 vtkBooleanMacro(LegendVisibility, vtkTypeBool);
136
138
141 void AllAxesOn();
144
146
152
154
157 vtkSetMacro(GridVisibility, bool);
158 vtkGetMacro(GridVisibility, bool);
159 vtkBooleanMacro(GridVisibility, bool);
161
163
168 vtkSetClampMacro(RightBorderOffset, int, 5, VTK_INT_MAX);
169 vtkGetMacro(RightBorderOffset, int);
171
173
178 vtkSetClampMacro(TopBorderOffset, int, 5, VTK_INT_MAX);
179 vtkGetMacro(TopBorderOffset, int);
181
183
188 vtkSetClampMacro(LeftBorderOffset, int, 5, VTK_INT_MAX);
189 vtkGetMacro(LeftBorderOffset, int);
191
193
198 vtkSetClampMacro(BottomBorderOffset, int, 5, VTK_INT_MAX);
199 vtkGetMacro(BottomBorderOffset, int);
201
203
207 vtkSetClampMacro(CornerOffsetFactor, double, 1.0, 10.0);
208 vtkGetMacro(CornerOffsetFactor, double);
210
212
216 void SetNotation(int notation);
219
221
224 void SetPrecision(int val);
227
229
235
237
243
245
249 vtkSetVector3Macro(Origin, double);
250 vtkGetVector3Macro(Origin, double);
252
254
257 vtkGetObjectMacro(LegendTitleProperty, vtkTextProperty);
258 vtkGetObjectMacro(LegendLabelProperty, vtkTextProperty);
260
267
272
278
280 void SetUseFontSizeFromProperty(bool sizeFromProp);
281
289 "This does not respect the number of labels. Please use SetSnapToGrid instead.")
290 void SetAdjustLabels(bool adjust);
291
297 void SetSnapToGrid(bool snap);
299
301
306 vtkGetObjectMacro(RightAxis, vtkAxisActor2D);
307 vtkGetObjectMacro(TopAxis, vtkAxisActor2D);
308 vtkGetObjectMacro(LeftAxis, vtkAxisActor2D);
309 vtkGetObjectMacro(BottomAxis, vtkAxisActor2D);
311
313
316 virtual void BuildRepresentation(vtkViewport* viewport);
317 void GetActors2D(vtkPropCollection*) override;
318 void ReleaseGraphicsResources(vtkWindow*) override;
319 int RenderOverlay(vtkViewport*) override;
320 int RenderOpaqueGeometry(vtkViewport*) override;
322
323protected:
326
327 int LabelMode = DISTANCE;
328 int RightBorderOffset = 50;
329 int TopBorderOffset = 30;
330 int LeftBorderOffset = 50;
331 int BottomBorderOffset = 30;
332 double CornerOffsetFactor = 2.;
333
334 // The four axes around the borders of the renderer
339
340 // Support for grid
343 bool GridVisibility = false;
344
345 // Control the display of the axes
346 vtkTypeBool RightAxisVisibility = 1;
347 vtkTypeBool TopAxisVisibility = 1;
348 vtkTypeBool LeftAxisVisibility = 1;
349 vtkTypeBool BottomAxisVisibility = 1;
350
351 // Support for the legend.
352 vtkTypeBool LegendVisibility = 1;
354 vtkNew<vtkPoints> LegendPoints;
356 vtkNew<vtkActor2D> LegendActor;
357 vtkNew<vtkTextMapper> LabelMappers[6];
358 vtkNew<vtkActor2D> LabelActors[6];
359 vtkNew<vtkTextProperty> LegendTitleProperty;
360 vtkNew<vtkTextProperty> LegendLabelProperty;
362
363 vtkTimeStamp BuildTime;
364
365private:
367 void operator=(const vtkLegendScaleActor&) = delete;
368
374 void UpdateAxisRange(vtkAxisActor2D* axis, vtkViewport* viewport, bool invert = false);
375
376 double Origin[3] = { 0, 0, 0 };
377};
378
379VTK_ABI_NAMESPACE_END
380#endif
a actor that draws 2D data
Definition vtkActor2D.h:145
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.
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:167
represent and manipulate 3D points
Definition vtkPoints.h:139
draw vtkPolyData onto the image plane
concrete dataset represents vertices, lines, polygons, and triangle strips
an ordered list of Props
abstract superclass for all actors, volumes and annotations
Definition vtkProp.h:66
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:65
window superclass for vtkRenderWindow
Definition vtkWindow.h:48
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