VTK  9.3.1
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:
53  static vtkLegendScaleActor* New();
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 
123  void AllAnnotationsOn();
124  void AllAnnotationsOff();
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 
187  void SetAxesTextProperty(vtkTextProperty* property);
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);
215  void GetActors2D(vtkPropCollection*) override;
216  void ReleaseGraphicsResources(vtkWindow*) override;
217  int RenderOverlay(vtkViewport*) override;
218  int RenderOpaqueGeometry(vtkViewport*) override;
220 
221 protected:
223  ~vtkLegendScaleActor() override;
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
vtkNew< vtkPolyDataMapper2D > LegendMapper
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:45
abstract specification for Viewports
Definition: vtkViewport.h:44
virtual int RenderOpaqueGeometry(vtkViewport *)
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE DO NOT USE THESE METHODS OUTSIDE OF THE RENDE...
Definition: vtkProp.h:213
virtual int RenderOverlay(vtkViewport *)
Definition: vtkProp.h:216
#define VTK_INT_MAX
Definition: vtkType.h:144
a actor that draws 2D data
Definition: vtkActor2D.h:34
record modification and/or execution time
Definition: vtkTimeStamp.h:24
Create an axis with tick marks and labels.
vtkNew< vtkAxisActor2D > RightAxis
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:79
2D text annotation
Definition: vtkTextMapper.h:39
annotate the render window with scale and distance information
an ordered list of Props
int vtkTypeBool
Definition: vtkABI.h:64
virtual void ReleaseGraphicsResources(vtkWindow *)
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE Release any graphics resources that are being...
Definition: vtkProp.h:298
window superclass for vtkRenderWindow
Definition: vtkWindow.h:27
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkNew< vtkActor2D > LegendActor
vtkNew< vtkTextProperty > LegendTitleProperty
a simple class to control print indentation
Definition: vtkIndent.h:28
vtkNew< vtkPolyData > Legend
vtkNew< vtkPoints > LegendPoints
vtkNew< vtkAxisActor2D > BottomAxis
vtkNew< vtkTextProperty > LegendLabelProperty
void SetLabelModeToXYCoordinates()
Specify the mode for labeling the scale axes.
represent text properties.
vtkNew< vtkCoordinate > Coordinate
perform coordinate transformation, and represent position, in a variety of vtk coordinate systems ...
Definition: vtkCoordinate.h:68
void SetLabelModeToDistance()
Specify the mode for labeling the scale axes.
virtual void GetActors2D(vtkPropCollection *)
Definition: vtkProp.h:57
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
vtkNew< vtkAxisActor2D > TopAxis
vtkNew< vtkAxisActor2D > LeftAxis
draw vtkPolyData onto the image plane
represent and manipulate 3D points
Definition: vtkPoints.h:28