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
28 #ifndef vtkLegendScaleActor_h
29 #define vtkLegendScaleActor_h
30 
31 #include "vtkCoordinate.h" // For vtkViewportCoordinateMacro
32 #include "vtkProp.h"
33 #include "vtkRenderingAnnotationModule.h" // For export macro
34 
35 #include "vtkNew.h" // for vtkNew
36 
37 VTK_ABI_NAMESPACE_BEGIN
38 class vtkAxisActor2D;
39 class vtkTextProperty;
40 class vtkPolyData;
42 class vtkActor2D;
43 class vtkTextMapper;
44 class vtkPoints;
45 class vtkCoordinate;
46 
47 class VTKRENDERINGANNOTATION_EXPORT vtkLegendScaleActor : public vtkProp
48 {
49 public:
54 
56 
59  vtkTypeMacro(vtkLegendScaleActor, vtkProp);
60  void PrintSelf(ostream& os, vtkIndent indent) override;
62 
64  {
65  DISTANCE = 0,
66  XY_COORDINATES = 1
67  };
68 
70 
76  vtkSetClampMacro(LabelMode, int, DISTANCE, XY_COORDINATES);
77  vtkGetMacro(LabelMode, int);
78  void SetLabelModeToDistance() { this->SetLabelMode(DISTANCE); }
79  void SetLabelModeToXYCoordinates() { this->SetLabelMode(XY_COORDINATES); }
81 
83 
87  vtkSetMacro(RightAxisVisibility, vtkTypeBool);
88  vtkGetMacro(RightAxisVisibility, vtkTypeBool);
89  vtkBooleanMacro(RightAxisVisibility, vtkTypeBool);
90  vtkSetMacro(TopAxisVisibility, vtkTypeBool);
91  vtkGetMacro(TopAxisVisibility, vtkTypeBool);
92  vtkBooleanMacro(TopAxisVisibility, vtkTypeBool);
93  vtkSetMacro(LeftAxisVisibility, vtkTypeBool);
94  vtkGetMacro(LeftAxisVisibility, vtkTypeBool);
95  vtkBooleanMacro(LeftAxisVisibility, vtkTypeBool);
96  vtkSetMacro(BottomAxisVisibility, vtkTypeBool);
97  vtkGetMacro(BottomAxisVisibility, vtkTypeBool);
98  vtkBooleanMacro(BottomAxisVisibility, vtkTypeBool);
100 
102 
106  vtkSetMacro(LegendVisibility, vtkTypeBool);
107  vtkGetMacro(LegendVisibility, vtkTypeBool);
108  vtkBooleanMacro(LegendVisibility, vtkTypeBool);
110 
112 
115  void AllAxesOn();
116  void AllAxesOff();
118 
120 
126 
128 
133  vtkSetClampMacro(RightBorderOffset, int, 5, VTK_INT_MAX);
134  vtkGetMacro(RightBorderOffset, int);
136 
138 
143  vtkSetClampMacro(TopBorderOffset, int, 5, VTK_INT_MAX);
144  vtkGetMacro(TopBorderOffset, int);
146 
148 
153  vtkSetClampMacro(LeftBorderOffset, int, 5, VTK_INT_MAX);
154  vtkGetMacro(LeftBorderOffset, int);
156 
158 
163  vtkSetClampMacro(BottomBorderOffset, int, 5, VTK_INT_MAX);
164  vtkGetMacro(BottomBorderOffset, int);
166 
168 
172  vtkSetClampMacro(CornerOffsetFactor, double, 1.0, 10.0);
173  vtkGetMacro(CornerOffsetFactor, double);
175 
177 
180  vtkGetObjectMacro(LegendTitleProperty, vtkTextProperty);
181  vtkGetObjectMacro(LegendLabelProperty, vtkTextProperty);
183 
190 
192  void SetUseFontSizeFromProperty(bool sizeFromProp);
193 
195  void SetAdjustLabels(bool ajust);
197 
199 
204  vtkGetObjectMacro(RightAxis, vtkAxisActor2D);
205  vtkGetObjectMacro(TopAxis, vtkAxisActor2D);
206  vtkGetObjectMacro(LeftAxis, vtkAxisActor2D);
207  vtkGetObjectMacro(BottomAxis, vtkAxisActor2D);
209 
211 
214  virtual void BuildRepresentation(vtkViewport* viewport);
217  int RenderOverlay(vtkViewport*) override;
220 
221 protected:
224 
225  int LabelMode = DISTANCE;
226  int RightBorderOffset = 50;
227  int TopBorderOffset = 30;
228  int LeftBorderOffset = 50;
229  int BottomBorderOffset = 30;
230  double CornerOffsetFactor = 2.;
231 
232  // The four axes around the borders of the renderer
237 
238  // Control the display of the axes
239  vtkTypeBool RightAxisVisibility = 1;
240  vtkTypeBool TopAxisVisibility = 1;
241  vtkTypeBool LeftAxisVisibility = 1;
242  vtkTypeBool BottomAxisVisibility = 1;
243 
244  // Support for the legend.
245  vtkTypeBool LegendVisibility = 1;
250  vtkTextMapper* LabelMappers[6];
251  vtkActor2D* LabelActors[6];
255 
257 
258 private:
259  vtkLegendScaleActor(const vtkLegendScaleActor&) = delete;
260  void operator=(const vtkLegendScaleActor&) = delete;
261 };
262 
263 VTK_ABI_NAMESPACE_END
264 #endif
a actor that draws 2D data
Definition: vtkActor2D.h:35
Create an axis with tick marks and labels.
perform coordinate transformation, and represent position, in a variety of vtk coordinate systems
Definition: vtkCoordinate.h:69
a simple class to control print indentation
Definition: vtkIndent.h:29
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:29
draw vtkPolyData onto the image plane
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:80
an ordered list of Props
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:46
2D text annotation
Definition: vtkTextMapper.h:40
represent text properties.
record modification and/or execution time
Definition: vtkTimeStamp.h:25
abstract specification for Viewports
Definition: vtkViewport.h:45
window superclass for vtkRenderWindow
Definition: vtkWindow.h:28
int vtkTypeBool
Definition: vtkABI.h:64
#define VTK_INT_MAX
Definition: vtkType.h:144