VTK  9.3.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 
25 VTK_ABI_NAMESPACE_BEGIN
26 class vtkChart;
27 class vtkPen;
28 class vtkBrush;
29 class vtkTextProperty;
30 
31 class VTKCHARTSCORE_EXPORT vtkChartLegend : public vtkContextItem
32 {
33 public:
35  void PrintSelf(ostream& os, vtkIndent indent) override;
36 
40  static vtkChartLegend* New();
41 
43 
46  vtkSetVector2Macro(Point, float);
48 
50 
53  vtkGetVector2Macro(Point, float);
55 
56  enum
57  {
58  LEFT = 0,
61  TOP,
63  CUSTOM
64  };
65 
69  void SetPoint(const vtkVector2f& point);
70 
74  const vtkVector2f& GetPointVector();
75 
77 
81  vtkSetMacro(HorizontalAlignment, int);
83 
85 
88  vtkGetMacro(HorizontalAlignment, int);
90 
92 
96  vtkSetMacro(VerticalAlignment, int);
98 
100 
103  vtkGetMacro(VerticalAlignment, int);
105 
107 
110  vtkSetMacro(Padding, int);
112 
114 
117  vtkGetMacro(Padding, int);
119 
121 
124  vtkSetMacro(SymbolWidth, int);
126 
128 
131  vtkGetMacro(SymbolWidth, int);
133 
137  virtual void SetLabelSize(int size);
138 
142  virtual int GetLabelSize();
143 
145 
150  vtkSetMacro(Inline, bool);
151  vtkGetMacro(Inline, bool);
153 
155 
161  vtkSetMacro(DragEnabled, bool);
162  vtkGetMacro(DragEnabled, bool);
164 
168  void SetChart(vtkChart* chart);
169 
173  vtkChart* GetChart();
174 
179  void Update() override;
180 
184  bool Paint(vtkContext2D* painter) override;
185 
192  virtual vtkRectf GetBoundingRect(vtkContext2D* painter);
193 
197  vtkPen* GetPen();
198 
202  vtkBrush* GetBrush();
203 
207  vtkTextProperty* GetLabelProperties();
208 
210 
218  vtkSetMacro(CacheBounds, bool);
219  vtkGetMacro(CacheBounds, bool);
220  vtkBooleanMacro(CacheBounds, bool);
222 
226  bool Hit(const vtkContextMouseEvent& mouse) override;
227 
231  bool MouseMoveEvent(const vtkContextMouseEvent& mouse) override;
232 
236  bool MouseButtonPressEvent(const vtkContextMouseEvent& mouse) override;
237 
241  bool MouseButtonReleaseEvent(const vtkContextMouseEvent& mouse) override;
242 
243 protected:
244  vtkChartLegend();
245  ~vtkChartLegend() override;
246 
247  float* Point; // The point the legend is anchored to.
248  int HorizontalAlignment; // Alignment of the legend to the point it is anchored to.
249  int VerticalAlignment; // Alignment of the legend to the point it is anchored to.
250 
255 
260 
265 
270 
276 
280  int Button;
281 
284 
286 
290  int Padding;
291 
296 
300  bool Inline;
301 
302  // Private storage class
303  class Private;
304  Private* Storage;
305 
306 private:
307  vtkChartLegend(const vtkChartLegend&) = delete;
308  void operator=(const vtkChartLegend&) = delete;
309 };
310 
311 VTK_ABI_NAMESPACE_END
312 #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:40
vtkTimeStamp RectTime
provides a brush that fills shapes drawn by vtkContext2D.
Definition: vtkBrush.h:29
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:28
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.
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.