VTK  9.7.1
vtkChartLegend.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
3 
17 #ifndef vtkChartLegend_h
18 #define vtkChartLegend_h
19 
20 #include "vtkChartsCoreModule.h" // For export macro
21 #include "vtkContextItem.h"
22 #include "vtkNew.h" // For vtkNew
23 #include "vtkRect.h" // For vtkRectf return value
24 #include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
25 
26 VTK_ABI_NAMESPACE_BEGIN
27 class vtkChart;
28 class vtkPen;
29 class vtkBrush;
30 class vtkTextProperty;
31 
32 class VTKCHARTSCORE_EXPORT VTK_MARSHALAUTO vtkChartLegend : public vtkContextItem
33 {
34 public:
36  void PrintSelf(ostream& os, vtkIndent indent) override;
37 
41  static vtkChartLegend* New();
42 
44 
47  vtkSetVector2Macro(Point, float);
49 
51 
54  vtkGetVector2Macro(Point, float);
56 
57  enum
58  {
59  LEFT = 0,
62  TOP,
64  CUSTOM
65  };
66 
70  void SetPoint(const vtkVector2f& point);
71 
75  const vtkVector2f& GetPointVector();
76 
78 
82  vtkSetMacro(PointIsNormalized, bool);
83  vtkGetMacro(PointIsNormalized, bool);
84  vtkBooleanMacro(PointIsNormalized, bool);
86 
88 
92  vtkSetMacro(HorizontalAlignment, int);
94 
96 
99  vtkGetMacro(HorizontalAlignment, int);
101 
103 
107  vtkSetMacro(VerticalAlignment, int);
109 
111 
114  vtkGetMacro(VerticalAlignment, int);
116 
118 
121  vtkSetMacro(Padding, int);
123 
125 
128  vtkGetMacro(Padding, int);
130 
132 
135  vtkSetMacro(SymbolWidth, int);
137 
139 
142  vtkGetMacro(SymbolWidth, int);
144 
148  virtual void SetLabelSize(int size);
149 
153  virtual int GetLabelSize();
154 
156 
161  vtkSetMacro(Inline, bool);
162  vtkGetMacro(Inline, bool);
164 
166 
172  vtkSetMacro(DragEnabled, bool);
173  vtkGetMacro(DragEnabled, bool);
175 
179  void SetChart(vtkChart* chart);
180 
184  vtkChart* GetChart();
185 
190  void Update() override;
191 
195  bool Paint(vtkContext2D* painter) override;
196 
203  virtual vtkRectf GetBoundingRect(vtkContext2D* painter);
204 
208  vtkPen* GetPen();
209 
213  vtkBrush* GetBrush();
214 
218  vtkTextProperty* GetLabelProperties();
219 
221 
229  vtkSetMacro(CacheBounds, bool);
230  vtkGetMacro(CacheBounds, bool);
231  vtkBooleanMacro(CacheBounds, bool);
233 
237  bool Hit(const vtkContextMouseEvent& mouse) override;
238 
242  bool MouseMoveEvent(const vtkContextMouseEvent& mouse) override;
243 
247  bool MouseButtonPressEvent(const vtkContextMouseEvent& mouse) override;
248 
252  bool MouseButtonReleaseEvent(const vtkContextMouseEvent& mouse) override;
253 
254 protected:
255  vtkChartLegend();
256  ~vtkChartLegend() override;
257 
258  float* Point; // The point the legend is anchored to.
259  int HorizontalAlignment; // Alignment of the legend to the point it is anchored to.
260  int VerticalAlignment; // Alignment of the legend to the point it is anchored to.
261  bool PointIsNormalized; // Allow specifying the point in normalized coordinates
262 
267 
272 
277 
282 
288 
292  int Button;
293 
296 
298 
302  int Padding;
303 
308 
312  bool Inline;
313 
314  // Private storage class
315  class Private;
316  Private* Storage;
317 
318 private:
319  vtkChartLegend(const vtkChartLegend&) = delete;
320  void operator=(const vtkChartLegend&) = delete;
321 };
322 
323 VTK_ABI_NAMESPACE_END
324 #endif // vtkChartLegend_h
Private * Storage
vtkTimeStamp PlotTime
base class for items that are part of a vtkContextScene.
virtual bool MouseButtonPressEvent(const vtkContextMouseEvent &mouse)
Mouse button down event Return true if the item holds the event, false if the event can be propagated...
virtual bool Paint(vtkContext2D *painter)
Paint event for the item, called whenever the item needs to be drawn.
record modification and/or execution time
Definition: vtkTimeStamp.h:24
bool DragEnabled
Should we move the legend box around in response to the mouse drag?
bool Inline
Should the legend be drawn inline in its chart?
int Padding
Padding between symbol and text.
Class for drawing 2D primitives to a graphical context.
Definition: vtkContext2D.h:49
Factory class for drawing 2D charts.
Definition: vtkChart.h:41
vtkTimeStamp RectTime
provides a brush that fills shapes drawn by vtkContext2D.
Definition: vtkBrush.h:30
data structure to represent mouse events.
a simple class to control print indentation
Definition: vtkIndent.h:28
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
virtual bool MouseButtonReleaseEvent(const vtkContextMouseEvent &mouse)
Mouse button release event.
vtkNew< vtkBrush > Brush
The brush used to render the background of the legend.
provides a pen that draws the outlines of shapes drawn by vtkContext2D.
Definition: vtkPen.h:29
represent text properties.
int SymbolWidth
Width of the symbols in pixels in the legend.
draw the chart legend
int Button
Last button to be pressed.
bool CacheBounds
Should the legend attempt to avoid recalculating its position & bounds unnecessarily?
virtual bool MouseMoveEvent(const vtkContextMouseEvent &mouse)
Mouse move event.
virtual bool Hit(const vtkContextMouseEvent &mouse)
Return true if the supplied x, y coordinate is inside the item.
#define VTK_MARSHALAUTO
vtkNew< vtkTextProperty > LabelProperties
The text properties of the labels used in the legend.
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
virtual void Update()
Perform any updates to the item that may be necessary before rendering.
vtkNew< vtkPen > Pen
The pen used to draw the legend box.