VTK  9.3.0
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
25VTK_ABI_NAMESPACE_BEGIN
26class vtkChart;
27class vtkPen;
28class vtkBrush;
29class vtkTextProperty;
30
31class VTKCHARTSCORE_EXPORT vtkChartLegend : public vtkContextItem
32{
33public:
35 void PrintSelf(ostream& os, vtkIndent indent) override;
36
41
43
46 vtkSetVector2Macro(Point, float);
48
50
53 vtkGetVector2Macro(Point, float);
55
56 enum
57 {
58 LEFT = 0,
63 CUSTOM
64 };
65
69 void SetPoint(const vtkVector2f& point);
70
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
174
179 void Update() override;
180
184 bool Paint(vtkContext2D* painter) override;
185
193
198
203
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
242
243protected:
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
281
284
286
291
296
300 bool Inline;
301
302 // Private storage class
303 class Private;
304 Private* Storage;
305
306private:
307 vtkChartLegend(const vtkChartLegend&) = delete;
308 void operator=(const vtkChartLegend&) = delete;
309};
310
311VTK_ABI_NAMESPACE_END
312#endif // vtkChartLegend_h
provides a brush that fills shapes drawn by vtkContext2D.
Definition vtkBrush.h:30
draw the chart legend
vtkBrush * GetBrush()
Get the brush used to draw the legend background.
const vtkVector2f & GetPointVector()
Get point the legend box is anchored to.
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.
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?
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
void SetChart(vtkChart *chart)
Set the chart that the legend belongs to and will draw the legend for.
vtkPen * GetPen()
Get the pen used to draw the legend outline.
virtual int GetLabelSize()
Get the point size of the label text.
bool MouseMoveEvent(const vtkContextMouseEvent &mouse) override
Mouse move event.
virtual vtkRectf GetBoundingRect(vtkContext2D *painter)
Request the space the legend requires to be drawn.
void Update() override
Update the geometry of the axis.
static vtkChartLegend * New()
Creates a 2D Chart object.
vtkTextProperty * GetLabelProperties()
Get the vtkTextProperty for the legend's labels.
vtkChart * GetChart()
Get the chart that the legend belongs to and will draw the legend for.
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.
Factory class for drawing 2D charts.
Definition vtkChart.h:41
Class for drawing 2D primitives to a graphical context.
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:29
Allocate and hold a VTK object.
Definition vtkNew.h:51
provides a pen that draws the outlines of shapes drawn by vtkContext2D.
Definition vtkPen.h:29
represent text properties.
record modification and/or execution time