VTK  9.5.20250802
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 "vtkProp.h"
51#include "vtkRenderingAnnotationModule.h" // For export macro
52#include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
53
54#include "vtkNew.h" // for vtkNew
55
56VTK_ABI_NAMESPACE_BEGIN
57class vtkAxisActor2D;
58class vtkProperty2D;
59class vtkTextProperty;
60class vtkPolyData;
62class vtkActor2D;
63class vtkTextMapper;
64class vtkPoints;
65class vtkCoordinate;
67
68class VTKRENDERINGANNOTATION_EXPORT VTK_MARSHALAUTO vtkLegendScaleActor : public vtkProp
69{
70public:
75
77
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 void SetLabelModeToCoordinates() { this->SetLabelMode(COORDINATES); }
103
105
109 vtkSetMacro(RightAxisVisibility, vtkTypeBool);
110 vtkGetMacro(RightAxisVisibility, vtkTypeBool);
111 vtkBooleanMacro(RightAxisVisibility, vtkTypeBool);
112 vtkSetMacro(TopAxisVisibility, vtkTypeBool);
113 vtkGetMacro(TopAxisVisibility, vtkTypeBool);
114 vtkBooleanMacro(TopAxisVisibility, vtkTypeBool);
115 vtkSetMacro(LeftAxisVisibility, vtkTypeBool);
116 vtkGetMacro(LeftAxisVisibility, vtkTypeBool);
117 vtkBooleanMacro(LeftAxisVisibility, vtkTypeBool);
118 vtkSetMacro(BottomAxisVisibility, vtkTypeBool);
119 vtkGetMacro(BottomAxisVisibility, vtkTypeBool);
120 vtkBooleanMacro(BottomAxisVisibility, vtkTypeBool);
122
124
128 vtkSetMacro(LegendVisibility, vtkTypeBool);
129 vtkGetMacro(LegendVisibility, vtkTypeBool);
130 vtkBooleanMacro(LegendVisibility, vtkTypeBool);
132
134
137 void AllAxesOn();
140
142
148
150
153 vtkSetMacro(GridVisibility, bool);
154 vtkGetMacro(GridVisibility, bool);
155 vtkBooleanMacro(GridVisibility, bool);
157
159
164 vtkSetClampMacro(RightBorderOffset, int, 5, VTK_INT_MAX);
165 vtkGetMacro(RightBorderOffset, int);
167
169
174 vtkSetClampMacro(TopBorderOffset, int, 5, VTK_INT_MAX);
175 vtkGetMacro(TopBorderOffset, int);
177
179
184 vtkSetClampMacro(LeftBorderOffset, int, 5, VTK_INT_MAX);
185 vtkGetMacro(LeftBorderOffset, int);
187
189
194 vtkSetClampMacro(BottomBorderOffset, int, 5, VTK_INT_MAX);
195 vtkGetMacro(BottomBorderOffset, int);
197
199
203 vtkSetClampMacro(CornerOffsetFactor, double, 1.0, 10.0);
204 vtkGetMacro(CornerOffsetFactor, double);
206
208
212 void SetNotation(int notation);
215
217
220 void SetPrecision(int val);
223
225
231
233
239
241
245 vtkSetVector3Macro(Origin, double);
246 vtkGetVector3Macro(Origin, double);
248
250
253 vtkGetObjectMacro(LegendTitleProperty, vtkTextProperty);
254 vtkGetObjectMacro(LegendLabelProperty, vtkTextProperty);
256
263
268
274
276 void SetUseFontSizeFromProperty(bool sizeFromProp);
277
283 void SetSnapToGrid(bool snap);
285
287
292 vtkGetObjectMacro(RightAxis, vtkAxisActor2D);
293 vtkGetObjectMacro(TopAxis, vtkAxisActor2D);
294 vtkGetObjectMacro(LeftAxis, vtkAxisActor2D);
295 vtkGetObjectMacro(BottomAxis, vtkAxisActor2D);
297
299
302 virtual void BuildRepresentation(vtkViewport* viewport);
308
309protected:
312
313 int LabelMode = DISTANCE;
314 int RightBorderOffset = 50;
315 int TopBorderOffset = 30;
316 int LeftBorderOffset = 50;
317 int BottomBorderOffset = 30;
318 double CornerOffsetFactor = 2.;
319
320 // The four axes around the borders of the renderer
325
326 // Support for grid
329 bool GridVisibility = false;
330
331 // Control the display of the axes
332 vtkTypeBool RightAxisVisibility = 1;
333 vtkTypeBool TopAxisVisibility = 1;
334 vtkTypeBool LeftAxisVisibility = 1;
335 vtkTypeBool BottomAxisVisibility = 1;
336
337 // Support for the legend.
338 vtkTypeBool LegendVisibility = 1;
343 vtkNew<vtkTextMapper> LabelMappers[6];
344 vtkNew<vtkActor2D> LabelActors[6];
348
350
351private:
353 void operator=(const vtkLegendScaleActor&) = delete;
354
360 void UpdateAxisRange(vtkAxisActor2D* axis, vtkViewport* viewport, bool invert = false);
361
362 double Origin[3] = { 0, 0, 0 };
363};
364
365VTK_ABI_NAMESPACE_END
366#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
vtkNew< vtkTextProperty > LegendTitleProperty
vtkNew< vtkAxisActor2D > BottomAxis
void SetPrecision(int val)
Get/set the numerical precision to use for axis labels, default is 2.
vtkNew< vtkCoordinate > Coordinate
~vtkLegendScaleActor() override
vtkNew< vtkAxisActor2D > RightAxis
void GetActors2D(vtkPropCollection *) override
Standard methods supporting the rendering process.
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.
vtkNew< vtkAxisGridActorInternal > GridActor
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.
int RenderOpaqueGeometry(vtkViewport *) override
Standard methods supporting the rendering process.
vtkNew< vtkAxisActor2D > TopAxis
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,...
vtkNew< vtkPolyDataMapper2D > GridMapper
void AllAxesOff()
Convenience method that turns all the axes either on or off.
void ReleaseGraphicsResources(vtkWindow *) override
Standard methods supporting the rendering process.
void SetAxesProperty(vtkProperty2D *property)
Set the 2D property for both axis and grid.
vtkNew< vtkPoints > LegendPoints
int GetPrecision()
Get/set the numerical precision to use for axis labels, default is 2.
virtual void BuildRepresentation(vtkViewport *viewport)
Standard methods supporting the rendering process.
vtkNew< vtkTextProperty > LegendLabelProperty
static vtkLegendScaleActor * New()
Instantiate the class.
vtkNew< vtkAxisActor2D > LeftAxis
void SetNumberOfHorizontalLabels(int val)
Get/set the number of ticks (and labels) for the horizontal axis, default is 5.
vtkNew< vtkActor2D > LegendActor
void AllAnnotationsOn()
Convenience method that turns all the axes and the legend scale.
void SetSnapToGrid(bool snap)
If on, labels are positioned on rounded values.
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.
vtkNew< vtkPolyData > Legend
int RenderOverlay(vtkViewport *) override
Standard methods supporting the rendering process.
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.
vtkNew< vtkPolyDataMapper2D > LegendMapper
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:69
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:66
window superclass for vtkRenderWindow
Definition vtkWindow.h:48
int vtkTypeBool
Definition vtkABI.h:64
#define VTK_INT_MAX
Definition vtkType.h:161
#define VTK_MARSHALAUTO