VTK  9.3.0
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
37 #ifndef vtkLegendScaleActor_h
38 #define vtkLegendScaleActor_h
39 
40 #include "vtkCoordinate.h" // For vtkViewportCoordinateMacro
41 #include "vtkProp.h"
42 #include "vtkRenderingAnnotationModule.h" // For export macro
43 
44 #include "vtkNew.h" // for vtkNew
45 
46 VTK_ABI_NAMESPACE_BEGIN
47 class vtkAxisActor2D;
48 class vtkTextProperty;
49 class vtkPolyData;
51 class vtkActor2D;
52 class vtkTextMapper;
53 class vtkPoints;
54 class vtkCoordinate;
55 
56 class VTKRENDERINGANNOTATION_EXPORT vtkLegendScaleActor : public vtkProp
57 {
58 public:
63 
65 
68  vtkTypeMacro(vtkLegendScaleActor, vtkProp);
69  void PrintSelf(ostream& os, vtkIndent indent) override;
71 
73  {
74  DISTANCE = 0,
75  XY_COORDINATES = 1
76  };
77 
79 
85  vtkSetClampMacro(LabelMode, int, DISTANCE, XY_COORDINATES);
86  vtkGetMacro(LabelMode, int);
87  void SetLabelModeToDistance() { this->SetLabelMode(DISTANCE); }
88  void SetLabelModeToXYCoordinates() { this->SetLabelMode(XY_COORDINATES); }
90 
92 
96  vtkSetMacro(RightAxisVisibility, vtkTypeBool);
97  vtkGetMacro(RightAxisVisibility, vtkTypeBool);
98  vtkBooleanMacro(RightAxisVisibility, vtkTypeBool);
99  vtkSetMacro(TopAxisVisibility, vtkTypeBool);
100  vtkGetMacro(TopAxisVisibility, vtkTypeBool);
101  vtkBooleanMacro(TopAxisVisibility, vtkTypeBool);
102  vtkSetMacro(LeftAxisVisibility, vtkTypeBool);
103  vtkGetMacro(LeftAxisVisibility, vtkTypeBool);
104  vtkBooleanMacro(LeftAxisVisibility, vtkTypeBool);
105  vtkSetMacro(BottomAxisVisibility, vtkTypeBool);
106  vtkGetMacro(BottomAxisVisibility, vtkTypeBool);
107  vtkBooleanMacro(BottomAxisVisibility, vtkTypeBool);
109 
111 
115  vtkSetMacro(LegendVisibility, vtkTypeBool);
116  vtkGetMacro(LegendVisibility, vtkTypeBool);
117  vtkBooleanMacro(LegendVisibility, vtkTypeBool);
119 
121 
124  void AllAxesOn();
125  void AllAxesOff();
127 
129 
135 
137 
142  vtkSetClampMacro(RightBorderOffset, int, 5, VTK_INT_MAX);
143  vtkGetMacro(RightBorderOffset, int);
145 
147 
152  vtkSetClampMacro(TopBorderOffset, int, 5, VTK_INT_MAX);
153  vtkGetMacro(TopBorderOffset, int);
155 
157 
162  vtkSetClampMacro(LeftBorderOffset, int, 5, VTK_INT_MAX);
163  vtkGetMacro(LeftBorderOffset, int);
165 
167 
172  vtkSetClampMacro(BottomBorderOffset, int, 5, VTK_INT_MAX);
173  vtkGetMacro(BottomBorderOffset, int);
175 
177 
181  vtkSetClampMacro(CornerOffsetFactor, double, 1.0, 10.0);
182  vtkGetMacro(CornerOffsetFactor, double);
184 
186 
189  vtkGetObjectMacro(LegendTitleProperty, vtkTextProperty);
190  vtkGetObjectMacro(LegendLabelProperty, vtkTextProperty);
192 
199 
201  void SetUseFontSizeFromProperty(bool sizeFromProp);
202 
204  void SetAdjustLabels(bool ajust);
206 
208 
213  vtkGetObjectMacro(RightAxis, vtkAxisActor2D);
214  vtkGetObjectMacro(TopAxis, vtkAxisActor2D);
215  vtkGetObjectMacro(LeftAxis, vtkAxisActor2D);
216  vtkGetObjectMacro(BottomAxis, vtkAxisActor2D);
218 
220 
223  virtual void BuildRepresentation(vtkViewport* viewport);
226  int RenderOverlay(vtkViewport*) override;
229 
230 protected:
233 
234  int LabelMode = DISTANCE;
235  int RightBorderOffset = 50;
236  int TopBorderOffset = 30;
237  int LeftBorderOffset = 50;
238  int BottomBorderOffset = 30;
239  double CornerOffsetFactor = 2.;
240 
241  // The four axes around the borders of the renderer
246 
247  // Control the display of the axes
248  vtkTypeBool RightAxisVisibility = 1;
249  vtkTypeBool TopAxisVisibility = 1;
250  vtkTypeBool LeftAxisVisibility = 1;
251  vtkTypeBool BottomAxisVisibility = 1;
252 
253  // Support for the legend.
254  vtkTypeBool LegendVisibility = 1;
259  vtkTextMapper* LabelMappers[6];
260  vtkActor2D* LabelActors[6];
264 
266 
267 private:
268  vtkLegendScaleActor(const vtkLegendScaleActor&) = delete;
269  void operator=(const vtkLegendScaleActor&) = delete;
270 };
271 
272 VTK_ABI_NAMESPACE_END
273 #endif
a actor that draws 2D data
Definition: vtkActor2D.h:44
Create an axis with tick marks and labels.
perform coordinate transformation, and represent position, in a variety of vtk coordinate systems
Definition: vtkCoordinate.h:78
a simple class to control print indentation
Definition: vtkIndent.h:38
annotate the render window with scale and distance information
vtkNew< vtkTextProperty > LegendTitleProperty
vtkNew< vtkAxisActor2D > BottomAxis
vtkNew< vtkCoordinate > Coordinate
~vtkLegendScaleActor() override
vtkNew< vtkAxisActor2D > RightAxis
static vtkLegendScaleActor * New()
Instantiate the class.
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.
void SetLabelModeToDistance()
Specify the mode for labeling the scale axes.
void SetAdjustLabels(bool ajust)
Set the axes to adjust labels position to a "nice" one.
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 SetAxesTextProperty(vtkTextProperty *property)
Configuration forwarded to each axis.
void AllAxesOff()
Convenience method that turns all the axes either on or off.
void ReleaseGraphicsResources(vtkWindow *) override
Standard methods supporting the rendering process.
vtkNew< vtkPoints > LegendPoints
virtual void BuildRepresentation(vtkViewport *viewport)
Standard methods supporting the rendering process.
vtkNew< vtkTextProperty > LegendLabelProperty
vtkNew< vtkAxisActor2D > LeftAxis
vtkNew< vtkActor2D > LegendActor
void AllAnnotationsOn()
Convenience method that turns all the axes and the legend scale.
void SetLabelModeToXYCoordinates()
Specify the mode for labeling the scale axes.
void SetUseFontSizeFromProperty(bool sizeFromProp)
Set the axes to get font size from text property.
vtkNew< vtkPolyData > Legend
int RenderOverlay(vtkViewport *) override
Standard methods supporting the rendering process.
vtkNew< vtkPolyDataMapper2D > LegendMapper
represent and manipulate 3D points
Definition: vtkPoints.h:38
draw vtkPolyData onto the image plane
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:89
an ordered list of Props
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:55
2D text annotation
Definition: vtkTextMapper.h:49
represent text properties.
record modification and/or execution time
Definition: vtkTimeStamp.h:34
abstract specification for Viewports
Definition: vtkViewport.h:54
window superclass for vtkRenderWindow
Definition: vtkWindow.h:37
int vtkTypeBool
Definition: vtkABI.h:64
#define VTK_INT_MAX
Definition: vtkType.h:144