VTK  9.7.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 "vtkProp.h"
32 #include "vtkRenderingAnnotationModule.h" // For export macro
33 #include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
34 
35 #include "vtkNew.h" // for vtkNew
36 
37 VTK_ABI_NAMESPACE_BEGIN
38 class vtkAxisActor2D;
39 class vtkProperty2D;
40 class vtkTextProperty;
41 class vtkPolyData;
43 class vtkActor2D;
44 class vtkTextMapper;
45 class vtkPoints;
46 class vtkCoordinate;
48 
49 class VTKRENDERINGANNOTATION_EXPORT VTK_MARSHALAUTO vtkLegendScaleActor : public vtkProp
50 {
51 public:
55  static vtkLegendScaleActor* New();
56 
58 
61  vtkTypeMacro(vtkLegendScaleActor, vtkProp);
62  void PrintSelf(ostream& os, vtkIndent indent) override;
64 
66  {
67  DISTANCE = 0,
68  COORDINATES = 1,
69  XY_COORDINATES = COORDINATES
70  };
71 
73 
79  vtkSetClampMacro(LabelMode, int, DISTANCE, COORDINATES);
80  vtkGetMacro(LabelMode, int);
81  void SetLabelModeToDistance() { this->SetLabelMode(DISTANCE); }
82  void SetLabelModeToCoordinates() { this->SetLabelMode(COORDINATES); }
84 
86 
90  vtkSetMacro(RightAxisVisibility, vtkTypeBool);
91  vtkGetMacro(RightAxisVisibility, vtkTypeBool);
92  vtkBooleanMacro(RightAxisVisibility, vtkTypeBool);
93  vtkSetMacro(TopAxisVisibility, vtkTypeBool);
94  vtkGetMacro(TopAxisVisibility, vtkTypeBool);
95  vtkBooleanMacro(TopAxisVisibility, vtkTypeBool);
96  vtkSetMacro(LeftAxisVisibility, vtkTypeBool);
97  vtkGetMacro(LeftAxisVisibility, vtkTypeBool);
98  vtkBooleanMacro(LeftAxisVisibility, vtkTypeBool);
99  vtkSetMacro(BottomAxisVisibility, vtkTypeBool);
100  vtkGetMacro(BottomAxisVisibility, vtkTypeBool);
101  vtkBooleanMacro(BottomAxisVisibility, vtkTypeBool);
103 
105 
109  vtkSetMacro(LegendVisibility, vtkTypeBool);
110  vtkGetMacro(LegendVisibility, vtkTypeBool);
111  vtkBooleanMacro(LegendVisibility, vtkTypeBool);
113 
115 
118  void AllAxesOn();
119  void AllAxesOff();
121 
123 
126  void AllAnnotationsOn();
127  void AllAnnotationsOff();
129 
131 
134  vtkSetMacro(GridVisibility, bool);
135  vtkGetMacro(GridVisibility, bool);
136  vtkBooleanMacro(GridVisibility, bool);
138 
140 
145  vtkSetClampMacro(RightBorderOffset, int, 5, VTK_INT_MAX);
146  vtkGetMacro(RightBorderOffset, int);
148 
150 
155  vtkSetClampMacro(TopBorderOffset, int, 5, VTK_INT_MAX);
156  vtkGetMacro(TopBorderOffset, int);
158 
160 
165  vtkSetClampMacro(LeftBorderOffset, int, 5, VTK_INT_MAX);
166  vtkGetMacro(LeftBorderOffset, int);
168 
170 
175  vtkSetClampMacro(BottomBorderOffset, int, 5, VTK_INT_MAX);
176  vtkGetMacro(BottomBorderOffset, int);
178 
180 
184  vtkSetClampMacro(CornerOffsetFactor, double, 1.0, 10.0);
185  vtkGetMacro(CornerOffsetFactor, double);
187 
189 
193  void SetNotation(int notation);
194  int GetNotation();
196 
198 
201  void SetPrecision(int val);
202  int GetPrecision();
204 
206 
209  void SetNumberOfHorizontalLabels(int val);
210  int GetNumberOfHorizontalLabels();
212 
214 
217  void SetNumberOfVerticalLabels(int val);
218  int GetNumberOfVerticalLabels();
220 
222 
226  vtkSetVector3Macro(Origin, double);
227  vtkGetVector3Macro(Origin, double);
229 
231 
234  vtkGetObjectMacro(LegendTitleProperty, vtkTextProperty);
235  vtkGetObjectMacro(LegendLabelProperty, vtkTextProperty);
237 
241  void SetAxesTextProperty(vtkTextProperty* property);
244 
248  void SetAxesProperty(vtkProperty2D* property);
249 
254  vtkProperty2D* GetAxesProperty();
255 
257  void SetUseFontSizeFromProperty(bool sizeFromProp);
258 
264  void SetSnapToGrid(bool snap);
266 
268 
273  vtkGetObjectMacro(RightAxis, vtkAxisActor2D);
274  vtkGetObjectMacro(TopAxis, vtkAxisActor2D);
275  vtkGetObjectMacro(LeftAxis, vtkAxisActor2D);
276  vtkGetObjectMacro(BottomAxis, vtkAxisActor2D);
278 
280 
283  virtual void BuildRepresentation(vtkViewport* viewport);
284  void GetActors2D(vtkPropCollection*) override;
285  void ReleaseGraphicsResources(vtkWindow*) override;
286  int RenderOverlay(vtkViewport*) override;
287  int RenderOpaqueGeometry(vtkViewport*) override;
289 
290 protected:
292  ~vtkLegendScaleActor() override;
293 
294  int LabelMode = DISTANCE;
295  int RightBorderOffset = 50;
296  int TopBorderOffset = 30;
297  int LeftBorderOffset = 50;
298  int BottomBorderOffset = 30;
299  double CornerOffsetFactor = 2.;
300 
301  // The four axes around the borders of the renderer
306 
307  // Support for grid
310  bool GridVisibility = false;
311 
312  // Control the display of the axes
313  vtkTypeBool RightAxisVisibility = 1;
314  vtkTypeBool TopAxisVisibility = 1;
315  vtkTypeBool LeftAxisVisibility = 1;
316  vtkTypeBool BottomAxisVisibility = 1;
317 
318  // Support for the legend.
319  vtkTypeBool LegendVisibility = 1;
324  vtkNew<vtkTextMapper> LabelMappers[6];
325  vtkNew<vtkActor2D> LabelActors[6];
329 
331 
332 private:
333  vtkLegendScaleActor(const vtkLegendScaleActor&) = delete;
334  void operator=(const vtkLegendScaleActor&) = delete;
335 
341  void UpdateAxisRange(vtkAxisActor2D* axis, vtkViewport* viewport, bool invert = false);
342 
343  double Origin[3] = { 0, 0, 0 };
344 };
345 
346 VTK_ABI_NAMESPACE_END
347 #endif
vtkNew< vtkPolyDataMapper2D > LegendMapper
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:49
abstract specification for Viewports
Definition: vtkViewport.h:46
virtual int RenderOpaqueGeometry(vtkViewport *)
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE DO NOT USE THESE METHODS OUTSIDE OF THE RENDE...
Definition: vtkProp.h:236
virtual int RenderOverlay(vtkViewport *)
Definition: vtkProp.h:239
renders a 2D grid given pairs of point positions
#define VTK_INT_MAX
Definition: vtkType.h:192
a actor that draws 2D data
Definition: vtkActor2D.h:35
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:71
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:321
window superclass for vtkRenderWindow
Definition: vtkWindow.h:41
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
represent text properties.
vtkNew< vtkCoordinate > Coordinate
void SetLabelModeToCoordinates()
Specify the mode for labeling the scale axes.
perform coordinate transformation, and represent position, in a variety of vtk coordinate systems ...
Definition: vtkCoordinate.h:69
vtkNew< vtkAxisGridActorInternal > GridActor
void SetLabelModeToDistance()
Specify the mode for labeling the scale axes.
virtual void GetActors2D(vtkPropCollection *)
Definition: vtkProp.h:61
represent surface properties of a 2D image
Definition: vtkProperty2D.h:30
#define VTK_MARSHALAUTO
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
vtkNew< vtkPolyDataMapper2D > GridMapper
vtkNew< vtkAxisActor2D > TopAxis
vtkNew< vtkAxisActor2D > LeftAxis
draw vtkPolyData onto the image plane
represent and manipulate 3D points
Definition: vtkPoints.h:30