VTK  9.1.0
vtkChartLegend.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: Visualization Toolkit
4 Module: vtkChartLegend.h
5
6 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7 All rights reserved.
8 See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9
10 This software is distributed WITHOUT ANY WARRANTY; without even
11 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12 PURPOSE. See the above copyright notice for more information.
13
14=========================================================================*/
15
55#ifndef vtkChartLegend_h
56#define vtkChartLegend_h
57
58#include "vtkChartsCoreModule.h" // For export macro
59#include "vtkContextItem.h"
60#include "vtkNew.h" // For vtkNew
61#include "vtkRect.h" // For vtkRectf return value
62
63class vtkChart;
64class vtkPen;
65class vtkBrush;
66class vtkTextProperty;
67
68class VTKCHARTSCORE_EXPORT vtkChartLegend : public vtkContextItem
69{
70public:
72 void PrintSelf(ostream& os, vtkIndent indent) override;
73
78
80
83 vtkSetVector2Macro(Point, float);
85
87
90 vtkGetVector2Macro(Point, float);
92
93 enum
94 {
95 LEFT = 0,
100 CUSTOM
101 };
102
107
112
114
118 vtkSetMacro(HorizontalAlignment, int);
120
122
125 vtkGetMacro(HorizontalAlignment, int);
127
129
133 vtkSetMacro(VerticalAlignment, int);
135
137
140 vtkGetMacro(VerticalAlignment, int);
142
144
147 vtkSetMacro(Padding, int);
149
151
154 vtkGetMacro(Padding, int);
156
158
161 vtkSetMacro(SymbolWidth, int);
163
165
168 vtkGetMacro(SymbolWidth, int);
170
174 virtual void SetLabelSize(int size);
175
179 virtual int GetLabelSize();
180
182
187 vtkSetMacro(Inline, bool);
188 vtkGetMacro(Inline, bool);
190
192
198 vtkSetMacro(DragEnabled, bool);
199 vtkGetMacro(DragEnabled, bool);
201
205 void SetChart(vtkChart* chart);
206
211
216 void Update() override;
217
221 bool Paint(vtkContext2D* painter) override;
222
230
235
240
245
247
255 vtkSetMacro(CacheBounds, bool);
256 vtkGetMacro(CacheBounds, bool);
257 vtkBooleanMacro(CacheBounds, bool);
259
263 bool Hit(const vtkContextMouseEvent& mouse) override;
264
268 bool MouseMoveEvent(const vtkContextMouseEvent& mouse) override;
269
273 bool MouseButtonPressEvent(const vtkContextMouseEvent& mouse) override;
274
279
280protected:
282 ~vtkChartLegend() override;
283
284 float* Point; // The point the legend is anchored to.
285 int HorizontalAlignment; // Alignment of the legend to the point it is anchored to.
286 int VerticalAlignment; // Alignment of the legend to the point it is anchored to.
287
292
297
302
307
313
318
321
323
328
333
337 bool Inline;
338
339 // Private storage class
340 class Private;
341 Private* Storage;
342
343private:
344 vtkChartLegend(const vtkChartLegend&) = delete;
345 void operator=(const vtkChartLegend&) = delete;
346};
347
348#endif // vtkChartLegend_h
provides a brush that fills shapes drawn by vtkContext2D.
Definition: vtkBrush.h:97
draw the chart legend
vtkBrush * GetBrush()
Get the brush used to draw the legend background.
Private * Storage
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:45
Class for drawing 2D primitives to a graphical context.
Definition: vtkContext2D.h:73
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:113
provides a pen that draws the outlines of shapes drawn by vtkContext2D.
Definition: vtkPen.h:136
represent text properties.
record modification and/or execution time
Definition: vtkTimeStamp.h:52
@ Inline
Definition: vtkX3D.h:119
@ point
Definition: vtkX3D.h:242
@ size
Definition: vtkX3D.h:259