VTK  9.3.20240419
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 
46 #ifndef vtkChartLegend_h
47 #define vtkChartLegend_h
48 
49 #include "vtkChartsCoreModule.h" // For export macro
50 #include "vtkContextItem.h"
51 #include "vtkNew.h" // For vtkNew
52 #include "vtkRect.h" // For vtkRectf return value
53 
54 VTK_ABI_NAMESPACE_BEGIN
55 class vtkChart;
56 class vtkPen;
57 class vtkBrush;
58 class vtkTextProperty;
59 
60 class VTKCHARTSCORE_EXPORT vtkChartLegend : public vtkContextItem
61 {
62 public:
64  void PrintSelf(ostream& os, vtkIndent indent) override;
65 
69  static vtkChartLegend* New();
70 
72 
75  vtkSetVector2Macro(Point, float);
77 
79 
82  vtkGetVector2Macro(Point, float);
84 
85  enum
86  {
87  LEFT = 0,
90  TOP,
92  CUSTOM
93  };
94 
98  void SetPoint(const vtkVector2f& point);
99 
104 
106 
110  vtkSetMacro(HorizontalAlignment, int);
112 
114 
117  vtkGetMacro(HorizontalAlignment, int);
119 
121 
125  vtkSetMacro(VerticalAlignment, int);
127 
129 
132  vtkGetMacro(VerticalAlignment, int);
134 
136 
139  vtkSetMacro(Padding, int);
141 
143 
146  vtkGetMacro(Padding, int);
148 
150 
153  vtkSetMacro(SymbolWidth, int);
155 
157 
160  vtkGetMacro(SymbolWidth, int);
162 
166  virtual void SetLabelSize(int size);
167 
171  virtual int GetLabelSize();
172 
174 
179  vtkSetMacro(Inline, bool);
180  vtkGetMacro(Inline, bool);
182 
184 
190  vtkSetMacro(DragEnabled, bool);
191  vtkGetMacro(DragEnabled, bool);
193 
197  void SetChart(vtkChart* chart);
198 
203 
208  void Update() override;
209 
213  bool Paint(vtkContext2D* painter) override;
214 
222 
227 
232 
237 
239 
247  vtkSetMacro(CacheBounds, bool);
248  vtkGetMacro(CacheBounds, bool);
249  vtkBooleanMacro(CacheBounds, bool);
251 
255  bool Hit(const vtkContextMouseEvent& mouse) override;
256 
260  bool MouseMoveEvent(const vtkContextMouseEvent& mouse) override;
261 
265  bool MouseButtonPressEvent(const vtkContextMouseEvent& mouse) override;
266 
270  bool MouseButtonReleaseEvent(const vtkContextMouseEvent& mouse) override;
271 
272 protected:
274  ~vtkChartLegend() override;
275 
276  float* Point; // The point the legend is anchored to.
277  int HorizontalAlignment; // Alignment of the legend to the point it is anchored to.
278  int VerticalAlignment; // Alignment of the legend to the point it is anchored to.
279 
284 
289 
294 
299 
305 
309  int Button;
310 
313 
315 
319  int Padding;
320 
325 
329  bool Inline;
330 
331  // Private storage class
332  class Private;
333  Private* Storage;
334 
335 private:
336  vtkChartLegend(const vtkChartLegend&) = delete;
337  void operator=(const vtkChartLegend&) = delete;
338 };
339 
340 VTK_ABI_NAMESPACE_END
341 #endif // vtkChartLegend_h
provides a brush that fills shapes drawn by vtkContext2D.
Definition: vtkBrush.h:89
draw the chart legend
Private * Storage
bool DragEnabled
Should we move the legend box around in response to the mouse drag?
bool MouseButtonPressEvent(const vtkContextMouseEvent &mouse) override
Mouse button down event.
int SymbolWidth
Width of the symbols in pixels in the legend.
int Button
Last button to be pressed.
vtkChart * GetChart()
Get the chart that the legend belongs to and will draw the legend for.
vtkNew< vtkBrush > Brush
The brush used to render the background of the legend.
~vtkChartLegend() override
bool CacheBounds
Should the legend attempt to avoid recalculating its position & bounds unnecessarily?
const vtkVector2f & GetPointVector()
Get point the legend box is anchored to.
bool Inline
Should the legend be drawn inline in its chart?
bool Paint(vtkContext2D *painter) override
Paint event for the axis, called whenever the axis needs to be drawn.
vtkNew< vtkTextProperty > LabelProperties
The text properties of the labels used in the legend.
int Padding
Padding between symbol and text.
bool Hit(const vtkContextMouseEvent &mouse) override
Return true if the supplied x, y coordinate is inside the item.
vtkNew< vtkPen > Pen
The pen used to draw the legend box.
vtkTimeStamp PlotTime
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
bool MouseButtonReleaseEvent(const vtkContextMouseEvent &mouse) override
Mouse button release event.
vtkTimeStamp RectTime
vtkBrush * GetBrush()
Get the brush used to draw the legend background.
void SetChart(vtkChart *chart)
Set the chart that the legend belongs to and will draw the legend for.
virtual int GetLabelSize()
Get the point size of the label text.
bool MouseMoveEvent(const vtkContextMouseEvent &mouse) override
Mouse move event.
vtkTextProperty * GetLabelProperties()
Get the vtkTextProperty for the legend's labels.
virtual vtkRectf GetBoundingRect(vtkContext2D *painter)
Request the space the legend requires to be drawn.
void Update() override
Update the geometry of the axis.
vtkPen * GetPen()
Get the pen used to draw the legend outline.
virtual void SetLabelSize(int size)
Set the point size of the label text.
void SetPoint(const vtkVector2f &point)
Set point the legend box is anchored to.
static vtkChartLegend * New()
Creates a 2D Chart object.
Factory class for drawing 2D charts.
Definition: vtkChart.h:150
Class for drawing 2D primitives to a graphical context.
Definition: vtkContext2D.h:69
base class for items that are part of a vtkContextScene.
data structure to represent mouse events.
a simple class to control print indentation
Definition: vtkIndent.h:108
provides a pen that draws the outlines of shapes drawn by vtkContext2D.
Definition: vtkPen.h:78
represent text properties.
record modification and/or execution time
Definition: vtkTimeStamp.h:44
@ Inline
Definition: vtkX3D.h:113
@ point
Definition: vtkX3D.h:236
@ size
Definition: vtkX3D.h:253