VTK  9.4.20250113
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#include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
54
55VTK_ABI_NAMESPACE_BEGIN
56class vtkChart;
57class vtkPen;
58class vtkBrush;
59class vtkTextProperty;
60
61class VTKCHARTSCORE_EXPORT VTK_MARSHALAUTO vtkChartLegend : public vtkContextItem
62{
63public:
65 void PrintSelf(ostream& os, vtkIndent indent) override;
66
71
73
76 vtkSetVector2Macro(Point, float);
78
80
83 vtkGetVector2Macro(Point, float);
85
86 enum
87 {
88 LEFT = 0,
93 CUSTOM
94 };
95
99 void SetPoint(const vtkVector2f& point);
100
105
107
111 vtkSetMacro(PointIsNormalized, bool);
112 vtkGetMacro(PointIsNormalized, bool);
113 vtkBooleanMacro(PointIsNormalized, bool);
115
117
121 vtkSetMacro(HorizontalAlignment, int);
123
125
128 vtkGetMacro(HorizontalAlignment, int);
130
132
136 vtkSetMacro(VerticalAlignment, int);
138
140
143 vtkGetMacro(VerticalAlignment, int);
145
147
150 vtkSetMacro(Padding, int);
152
154
157 vtkGetMacro(Padding, int);
159
161
164 vtkSetMacro(SymbolWidth, int);
166
168
171 vtkGetMacro(SymbolWidth, int);
173
177 virtual void SetLabelSize(int size);
178
182 virtual int GetLabelSize();
183
185
190 vtkSetMacro(Inline, bool);
191 vtkGetMacro(Inline, bool);
193
195
201 vtkSetMacro(DragEnabled, bool);
202 vtkGetMacro(DragEnabled, bool);
204
208 void SetChart(vtkChart* chart);
209
214
219 void Update() override;
220
224 bool Paint(vtkContext2D* painter) override;
225
233
238
243
248
250
258 vtkSetMacro(CacheBounds, bool);
259 vtkGetMacro(CacheBounds, bool);
260 vtkBooleanMacro(CacheBounds, bool);
262
266 bool Hit(const vtkContextMouseEvent& mouse) override;
267
271 bool MouseMoveEvent(const vtkContextMouseEvent& mouse) override;
272
276 bool MouseButtonPressEvent(const vtkContextMouseEvent& mouse) override;
277
282
283protected:
285 ~vtkChartLegend() override;
286
287 float* Point; // The point the legend is anchored to.
288 int HorizontalAlignment; // Alignment of the legend to the point it is anchored to.
289 int VerticalAlignment; // Alignment of the legend to the point it is anchored to.
290 bool PointIsNormalized; // Allow specifying the point in normalized coordinates
291
296
301
306
311
317
322
325
327
332
337
341 bool Inline;
342
343 // Private storage class
344 class Private;
345 Private* Storage;
346
347private:
348 vtkChartLegend(const vtkChartLegend&) = delete;
349 void operator=(const vtkChartLegend&) = delete;
350};
351
352VTK_ABI_NAMESPACE_END
353#endif // vtkChartLegend_h
provides a brush that fills shapes drawn by vtkContext2D.
Definition vtkBrush.h:90
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:151
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:108
Allocate and hold a VTK object.
Definition vtkNew.h:167
provides a pen that draws the outlines of shapes drawn by vtkContext2D.
Definition vtkPen.h:79
represent text properties.
record modification and/or execution time
#define VTK_MARSHALAUTO