VTK  9.2.6
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 
38 #ifndef vtkChartLegend_h
39 #define vtkChartLegend_h
40 
41 #include "vtkChartsCoreModule.h" // For export macro
42 #include "vtkContextItem.h"
43 #include "vtkNew.h" // For vtkNew
44 #include "vtkRect.h" // For vtkRectf return value
45 
46 class vtkChart;
47 class vtkPen;
48 class vtkBrush;
49 class vtkTextProperty;
50 
51 class VTKCHARTSCORE_EXPORT vtkChartLegend : public vtkContextItem
52 {
53 public:
55  void PrintSelf(ostream& os, vtkIndent indent) override;
56 
60  static vtkChartLegend* New();
61 
63 
66  vtkSetVector2Macro(Point, float);
68 
70 
73  vtkGetVector2Macro(Point, float);
75 
76  enum
77  {
78  LEFT = 0,
81  TOP,
83  CUSTOM
84  };
85 
89  void SetPoint(const vtkVector2f& point);
90 
95 
97 
101  vtkSetMacro(HorizontalAlignment, int);
103 
105 
108  vtkGetMacro(HorizontalAlignment, int);
110 
112 
116  vtkSetMacro(VerticalAlignment, int);
118 
120 
123  vtkGetMacro(VerticalAlignment, int);
125 
127 
130  vtkSetMacro(Padding, int);
132 
134 
137  vtkGetMacro(Padding, int);
139 
141 
144  vtkSetMacro(SymbolWidth, int);
146 
148 
151  vtkGetMacro(SymbolWidth, int);
153 
157  virtual void SetLabelSize(int size);
158 
162  virtual int GetLabelSize();
163 
165 
170  vtkSetMacro(Inline, bool);
171  vtkGetMacro(Inline, bool);
173 
175 
181  vtkSetMacro(DragEnabled, bool);
182  vtkGetMacro(DragEnabled, bool);
184 
188  void SetChart(vtkChart* chart);
189 
194 
199  void Update() override;
200 
204  bool Paint(vtkContext2D* painter) override;
205 
213 
218 
223 
228 
230 
238  vtkSetMacro(CacheBounds, bool);
239  vtkGetMacro(CacheBounds, bool);
240  vtkBooleanMacro(CacheBounds, bool);
242 
246  bool Hit(const vtkContextMouseEvent& mouse) override;
247 
251  bool MouseMoveEvent(const vtkContextMouseEvent& mouse) override;
252 
256  bool MouseButtonPressEvent(const vtkContextMouseEvent& mouse) override;
257 
261  bool MouseButtonReleaseEvent(const vtkContextMouseEvent& mouse) override;
262 
263 protected:
265  ~vtkChartLegend() override;
266 
267  float* Point; // The point the legend is anchored to.
268  int HorizontalAlignment; // Alignment of the legend to the point it is anchored to.
269  int VerticalAlignment; // Alignment of the legend to the point it is anchored to.
270 
275 
280 
285 
290 
296 
300  int Button;
301 
304 
306 
310  int Padding;
311 
316 
320  bool Inline;
321 
322  // Private storage class
323  class Private;
324  Private* Storage;
325 
326 private:
327  vtkChartLegend(const vtkChartLegend&) = delete;
328  void operator=(const vtkChartLegend&) = delete;
329 };
330 
331 #endif // vtkChartLegend_h
provides a brush that fills shapes drawn by vtkContext2D.
Definition: vtkBrush.h:50
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:61
Class for drawing 2D primitives to a graphical context.
Definition: vtkContext2D.h:67
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:49
provides a pen that draws the outlines of shapes drawn by vtkContext2D.
Definition: vtkPen.h:49
represent text properties.
record modification and/or execution time
Definition: vtkTimeStamp.h:45
@ Inline
Definition: vtkX3D.h:119
@ point
Definition: vtkX3D.h:242
@ size
Definition: vtkX3D.h:259