VTK: Charts/Core/vtkChartLegend.h Source File

| 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
26 #ifndef vtkChartLegend_h
27 #define vtkChartLegend_h
28
29 #include "vtkChartsCoreModule.h" // For export macro
30 #include "vtkContextItem.h"
31 #include "vtkNew.h" // For vtkNew
32 #include "vtkRect.h" // For vtkRectf return value
33
34 VTK_ABI_NAMESPACE_BEGIN
35 class vtkChart;
36 class vtkPen;
37 class vtkBrush;
38 class vtkTextProperty;
39
40 class VTKCHARTSCORE_EXPORT vtkChartLegend : public vtkContextItem
41 {
42 public:
43 vtkTypeMacro(vtkChartLegend, vtkContextItem);
44 void PrintSelf(ostream& os, vtkIndent indent) override;
45
49 static vtkChartLegend* New();
50
52
55 vtkSetVector2Macro(Point, float);
57
59
62 vtkGetVector2Macro(Point, float);
64
65 enum
66 {
67 LEFT = 0,
68 CENTER,
69 RIGHT,
70 TOP,
71 BOTTOM,
72 CUSTOM
73 };
74
78 void SetPoint(const vtkVector2f& point);
79
83 const vtkVector2f& GetPointVector();
84
86
90 vtkSetMacro(HorizontalAlignment, int);
92
94
97 vtkGetMacro(HorizontalAlignment, int);
99
101
105 vtkSetMacro(VerticalAlignment, int);
107
109
112 vtkGetMacro(VerticalAlignment, int);
114
116
119 vtkSetMacro(Padding, int);
121
123
126 vtkGetMacro(Padding, int);
128
130
133 vtkSetMacro(SymbolWidth, int);
135
137
140 vtkGetMacro(SymbolWidth, int);
142
146 virtual void SetLabelSize(int size);
147
151 virtual int GetLabelSize();
152
154
159 vtkSetMacro(Inline, bool);
160 vtkGetMacro(Inline, bool);
162
164
170 vtkSetMacro(DragEnabled, bool);
171 vtkGetMacro(DragEnabled, bool);
173
177 void SetChart(vtkChart* chart);
178
182 vtkChart* GetChart();
183
188 void Update() override;
189
193 bool Paint(vtkContext2D* painter) override;
194
201 virtual vtkRectf GetBoundingRect(vtkContext2D* painter);
202
206 vtkPen* GetPen();
207
211 vtkBrush* GetBrush();
212
216 vtkTextProperty* GetLabelProperties();
217
219
227 vtkSetMacro(CacheBounds, bool);
228 vtkGetMacro(CacheBounds, bool);
229 vtkBooleanMacro(CacheBounds, bool);
231
235 bool Hit(const vtkContextMouseEvent& mouse) override;
236
240 bool MouseMoveEvent(const vtkContextMouseEvent& mouse) override;
241
245 bool MouseButtonPressEvent(const vtkContextMouseEvent& mouse) override;
246
250 bool MouseButtonReleaseEvent(const vtkContextMouseEvent& mouse) override;
251
252 protected:
253 vtkChartLegend();
254 ~vtkChartLegend() override;
255
256 float* Point; // The point the legend is anchored to.
257 int HorizontalAlignment; // Alignment of the legend to the point it is anchored to.
258 int VerticalAlignment; // Alignment of the legend to the point it is anchored to.
259
263 vtkNew<vtkPen> Pen;
264
268 vtkNew<vtkBrush> Brush;
269
273 vtkNew<vtkTextProperty> LabelProperties;
274
278 bool DragEnabled;
279
284 bool CacheBounds;
285
289 int Button;
290
291 vtkTimeStamp PlotTime;
292 vtkTimeStamp RectTime;
293
294 vtkRectf Rect;
295
299 int Padding;
300
304 int SymbolWidth;
305
309 bool Inline;
310
311 // Private storage class
312 class Private;
313 Private* Storage;
314
315 private:
316 vtkChartLegend(const vtkChartLegend&) = delete;
317 void operator=(const vtkChartLegend&) = delete;
318 };
319
320 VTK_ABI_NAMESPACE_END
321 #endif // vtkChartLegend_h
vtkBrush
provides a brush that fills shapes drawn by vtkContext2D.
Definition: vtkBrush.h:39
vtkChartLegend
draw the chart legend
Definition: vtkChartLegend.h:41
vtkChartLegend::Point
float * Point
Definition: vtkChartLegend.h:256
vtkChartLegend::Storage
Private * Storage
Definition: vtkChartLegend.h:312
vtkChartLegend::DragEnabled
bool DragEnabled
Should we move the legend box around in response to the mouse drag?
Definition: vtkChartLegend.h:278
vtkChartLegend::MouseButtonPressEvent
bool MouseButtonPressEvent(const vtkContextMouseEvent &mouse) override
Mouse button down event.
vtkChartLegend::SymbolWidth
int SymbolWidth
Width of the symbols in pixels in the legend.
Definition: vtkChartLegend.h:304
vtkChartLegend::vtkChartLegend
vtkChartLegend()
vtkChartLegend::Button
int Button
Last button to be pressed.
Definition: vtkChartLegend.h:289
vtkChartLegend::GetChart
vtkChart * GetChart()
Get the chart that the legend belongs to and will draw the legend for.
vtkChartLegend::Brush
vtkNew< vtkBrush > Brush
The brush used to render the background of the legend.
Definition: vtkChartLegend.h:268
vtkChartLegend::~vtkChartLegend
~vtkChartLegend() override
vtkChartLegend::CacheBounds
bool CacheBounds
Should the legend attempt to avoid recalculating its position & bounds unnecessarily?
Definition: vtkChartLegend.h:284
vtkChartLegend::GetPointVector
const vtkVector2f & GetPointVector()
Get point the legend box is anchored to.
vtkChartLegend::Inline
bool Inline
Should the legend be drawn inline in its chart?
Definition: vtkChartLegend.h:309
vtkChartLegend::Paint
bool Paint(vtkContext2D *painter) override
Paint event for the axis, called whenever the axis needs to be drawn.
vtkChartLegend::LabelProperties
vtkNew< vtkTextProperty > LabelProperties
The text properties of the labels used in the legend.
Definition: vtkChartLegend.h:273
vtkChartLegend::Padding
int Padding
Padding between symbol and text.
Definition: vtkChartLegend.h:299
vtkChartLegend::Hit
bool Hit(const vtkContextMouseEvent &mouse) override
Return true if the supplied x, y coordinate is inside the item.
vtkChartLegend::Pen
vtkNew< vtkPen > Pen
The pen used to draw the legend box.
Definition: vtkChartLegend.h:263
vtkChartLegend::PlotTime
vtkTimeStamp PlotTime
Definition: vtkChartLegend.h:291
vtkChartLegend::VerticalAlignment
int VerticalAlignment
Definition: vtkChartLegend.h:258
vtkChartLegend::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkChartLegend::MouseButtonReleaseEvent
bool MouseButtonReleaseEvent(const vtkContextMouseEvent &mouse) override
Mouse button release event.
vtkChartLegend::HorizontalAlignment
int HorizontalAlignment
Definition: vtkChartLegend.h:257
vtkChartLegend::RectTime
vtkTimeStamp RectTime
Definition: vtkChartLegend.h:292
vtkChartLegend::GetBrush
vtkBrush * GetBrush()
Get the brush used to draw the legend background.
vtkChartLegend::RIGHT
@ RIGHT
Definition: vtkChartLegend.h:69
vtkChartLegend::CENTER
@ CENTER
Definition: vtkChartLegend.h:68
vtkChartLegend::BOTTOM
@ BOTTOM
Definition: vtkChartLegend.h:71
vtkChartLegend::TOP
@ TOP
Definition: vtkChartLegend.h:70
vtkChartLegend::SetChart
void SetChart(vtkChart *chart)
Set the chart that the legend belongs to and will draw the legend for.
vtkChartLegend::GetLabelSize
virtual int GetLabelSize()
Get the point size of the label text.
vtkChartLegend::Rect
vtkRectf Rect
Definition: vtkChartLegend.h:294
vtkChartLegend::MouseMoveEvent
bool MouseMoveEvent(const vtkContextMouseEvent &mouse) override
Mouse move event.
vtkChartLegend::GetLabelProperties
vtkTextProperty * GetLabelProperties()
Get the vtkTextProperty for the legend's labels.
vtkChartLegend::GetBoundingRect
virtual vtkRectf GetBoundingRect(vtkContext2D *painter)
Request the space the legend requires to be drawn.
vtkChartLegend::Update
void Update() override
Update the geometry of the axis.
vtkChartLegend::GetPen
vtkPen * GetPen()
Get the pen used to draw the legend outline.
vtkChartLegend::SetLabelSize
virtual void SetLabelSize(int size)
Set the point size of the label text.
vtkChartLegend::SetPoint
void SetPoint(const vtkVector2f &point)
Set point the legend box is anchored to.
vtkChartLegend::New
static vtkChartLegend * New()
Creates a 2D Chart object.
vtkChart
Factory class for drawing 2D charts.
Definition: vtkChart.h:50
vtkContext2D
Class for drawing 2D primitives to a graphical context.
Definition: vtkContext2D.h:59
vtkContextItem
base class for items that are part of a vtkContextScene.
Definition: vtkContextItem.h:35
vtkContextMouseEvent
data structure to represent mouse events.
Definition: vtkContextMouseEvent.h:39
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:38
vtkNew< vtkPen >
vtkPen
provides a pen that draws the outlines of shapes drawn by vtkContext2D.
Definition: vtkPen.h:38
vtkRectf
Definition: vtkRect.h:328
vtkTextProperty
represent text properties.
Definition: vtkTextProperty.h:35
vtkTimeStamp
record modification and/or execution time
Definition: vtkTimeStamp.h:34
vtkVector2f
Definition: vtkVector.h:463
vtkX3D::Inline
@ Inline
Definition: vtkX3D.h:113
vtkX3D::point
@ point
Definition: vtkX3D.h:236
vtkX3D::size
@ size
Definition: vtkX3D.h:253
vtkContextItem.h
vtkNew.h
vtkRect.h