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
35#ifndef vtkChartLegend_h
36#define vtkChartLegend_h
37
38#include "vtkChartsCoreModule.h" // For export macro
39#include "vtkContextItem.h"
40#include "vtkNew.h" // For vtkNew
41#include "vtkRect.h" // For vtkRectf return value
42
43class vtkChart;
44class vtkPen;
45class vtkBrush;
46class vtkTextProperty;
47
48class VTKCHARTSCORE_EXPORT vtkChartLegend : public vtkContextItem
49{
50public:
52 void PrintSelf(ostream& os, vtkIndent indent) override;
53
58
60
63 vtkSetVector2Macro(Point, float);
65
67
70 vtkGetVector2Macro(Point, float);
72
73 enum
74 {
75 LEFT = 0,
80 CUSTOM
81 };
82
87
92
94
98 vtkSetMacro(HorizontalAlignment, int);
100
102
105 vtkGetMacro(HorizontalAlignment, int);
107
109
113 vtkSetMacro(VerticalAlignment, int);
115
117
120 vtkGetMacro(VerticalAlignment, int);
122
124
127 vtkSetMacro(Padding, int);
129
131
134 vtkGetMacro(Padding, int);
136
138
141 vtkSetMacro(SymbolWidth, int);
143
145
148 vtkGetMacro(SymbolWidth, int);
150
154 virtual void SetLabelSize(int size);
155
159 virtual int GetLabelSize();
160
162
167 vtkSetMacro(Inline, bool);
168 vtkGetMacro(Inline, bool);
170
172
178 vtkSetMacro(DragEnabled, bool);
179 vtkGetMacro(DragEnabled, bool);
181
185 void SetChart(vtkChart* chart);
186
191
196 void Update() override;
197
201 bool Paint(vtkContext2D* painter) override;
202
210
215
220
225
227
235 vtkSetMacro(CacheBounds, bool);
236 vtkGetMacro(CacheBounds, bool);
237 vtkBooleanMacro(CacheBounds, bool);
239
243 bool Hit(const vtkContextMouseEvent& mouse) override;
244
248 bool MouseMoveEvent(const vtkContextMouseEvent& mouse) override;
249
253 bool MouseButtonPressEvent(const vtkContextMouseEvent& mouse) override;
254
259
260protected:
262 ~vtkChartLegend() override;
263
264 float* Point; // The point the legend is anchored to.
265 int HorizontalAlignment; // Alignment of the legend to the point it is anchored to.
266 int VerticalAlignment; // Alignment of the legend to the point it is anchored to.
267
272
277
282
287
293
298
301
303
308
313
317 bool Inline;
318
319 // Private storage class
320 class Private;
321 Private* Storage;
322
323private:
324 vtkChartLegend(const vtkChartLegend&) = delete;
325 void operator=(const vtkChartLegend&) = delete;
326};
327
328#endif // vtkChartLegend_h
provides a brush that fills shapes drawn by vtkContext2D.
Definition: vtkBrush.h:47
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:54
Class for drawing 2D primitives to a graphical context.
Definition: vtkContext2D.h:63
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:43
provides a pen that draws the outlines of shapes drawn by vtkContext2D.
Definition: vtkPen.h:46
represent text properties.
record modification and/or execution time
Definition: vtkTimeStamp.h:42
@ Inline
Definition: vtkX3D.h:119
@ point
Definition: vtkX3D.h:242
@ size
Definition: vtkX3D.h:259