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 
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:
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,
70  TOP,
72  CUSTOM
73  };
74 
78  void SetPoint(const vtkVector2f& point);
79 
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 
183 
188  void Update() override;
189 
193  bool Paint(vtkContext2D* painter) override;
194 
202 
207 
212 
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:
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 
264 
269 
274 
279 
285 
289  int Button;
290 
293 
295 
299  int Padding;
300 
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
provides a brush that fills shapes drawn by vtkContext2D.
Definition: vtkBrush.h:39
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:50
Class for drawing 2D primitives to a graphical context.
Definition: vtkContext2D.h:59
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:38
provides a pen that draws the outlines of shapes drawn by vtkContext2D.
Definition: vtkPen.h:38
represent text properties.
record modification and/or execution time
Definition: vtkTimeStamp.h:34
@ Inline
Definition: vtkX3D.h:113
@ point
Definition: vtkX3D.h:236
@ size
Definition: vtkX3D.h:253