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 
25 VTK_ABI_NAMESPACE_BEGIN
26 class vtkChart;
27 class vtkPen;
28 class vtkBrush;
29 class vtkTextProperty;
30 
31 class VTKCHARTSCORE_EXPORT vtkChartLegend : public vtkContextItem
32 {
33 public:
35  void PrintSelf(ostream& os, vtkIndent indent) override;
36 
40  static vtkChartLegend* New();
41 
43 
46  vtkSetVector2Macro(Point, float);
48 
50 
53  vtkGetVector2Macro(Point, float);
55 
56  enum
57  {
58  LEFT = 0,
61  TOP,
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 
241  bool MouseButtonReleaseEvent(const vtkContextMouseEvent& mouse) override;
242 
243 protected:
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 
280  int Button;
281 
284 
286 
290  int Padding;
291 
296 
300  bool Inline;
301 
302  // Private storage class
303  class Private;
304  Private* Storage;
305 
306 private:
307  vtkChartLegend(const vtkChartLegend&) = delete;
308  void operator=(const vtkChartLegend&) = delete;
309 };
310 
311 VTK_ABI_NAMESPACE_END
312 #endif // vtkChartLegend_h
provides a brush that fills shapes drawn by vtkContext2D.
Definition: vtkBrush.h:30
draw the chart legend
Private * Storage
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.
vtkChart * GetChart()
Get the chart that the legend belongs to and will draw the legend for.
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?
const vtkVector2f & GetPointVector()
Get point the legend box is anchored to.
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
vtkBrush * GetBrush()
Get the brush used to draw the legend background.
void SetChart(vtkChart *chart)
Set the chart that the legend belongs to and will draw the legend for.
virtual int GetLabelSize()
Get the point size of the label text.
bool MouseMoveEvent(const vtkContextMouseEvent &mouse) override
Mouse move event.
vtkTextProperty * GetLabelProperties()
Get the vtkTextProperty for the legend's labels.
virtual vtkRectf GetBoundingRect(vtkContext2D *painter)
Request the space the legend requires to be drawn.
void Update() override
Update the geometry of the axis.
vtkPen * GetPen()
Get the pen used to draw the legend outline.
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.
static vtkChartLegend * New()
Creates a 2D Chart object.
Factory class for drawing 2D charts.
Definition: vtkChart.h:41
Class for drawing 2D primitives to a graphical context.
Definition: vtkContext2D.h:50
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
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
Definition: vtkTimeStamp.h:25
@ Inline
Definition: vtkX3D.h:113
@ point
Definition: vtkX3D.h:236
@ size
Definition: vtkX3D.h:253