VTK  9.0.1
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 
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 class vtkChart;
35 class vtkPen;
36 class vtkBrush;
37 class vtkTextProperty;
38 
39 class VTKCHARTSCORE_EXPORT vtkChartLegend : public vtkContextItem
40 {
41 public:
43  void PrintSelf(ostream& os, vtkIndent indent) override;
44 
48  static vtkChartLegend* New();
49 
51 
54  vtkSetVector2Macro(Point, float);
56 
58 
61  vtkGetVector2Macro(Point, float);
63 
64  enum
65  {
66  LEFT = 0,
69  TOP,
71  CUSTOM
72  };
73 
77  void SetPoint(const vtkVector2f& point);
78 
82  const vtkVector2f& GetPointVector();
83 
85 
89  vtkSetMacro(HorizontalAlignment, int);
91 
93 
96  vtkGetMacro(HorizontalAlignment, int);
98 
100 
104  vtkSetMacro(VerticalAlignment, int);
106 
108 
111  vtkGetMacro(VerticalAlignment, int);
113 
115 
118  vtkSetMacro(Padding, int);
120 
122 
125  vtkGetMacro(Padding, int);
127 
129 
132  vtkSetMacro(SymbolWidth, int);
134 
136 
139  vtkGetMacro(SymbolWidth, int);
141 
145  virtual void SetLabelSize(int size);
146 
150  virtual int GetLabelSize();
151 
153 
158  vtkSetMacro(Inline, bool);
159  vtkGetMacro(Inline, bool);
161 
163 
169  vtkSetMacro(DragEnabled, bool);
170  vtkGetMacro(DragEnabled, bool);
172 
176  void SetChart(vtkChart* chart);
177 
181  vtkChart* GetChart();
182 
187  void Update() override;
188 
192  bool Paint(vtkContext2D* painter) override;
193 
200  virtual vtkRectf GetBoundingRect(vtkContext2D* painter);
201 
205  vtkPen* GetPen();
206 
210  vtkBrush* GetBrush();
211 
215  vtkTextProperty* GetLabelProperties();
216 
218 
226  vtkSetMacro(CacheBounds, bool);
227  vtkGetMacro(CacheBounds, bool);
228  vtkBooleanMacro(CacheBounds, bool);
230 
234  bool Hit(const vtkContextMouseEvent& mouse) override;
235 
239  bool MouseMoveEvent(const vtkContextMouseEvent& mouse) override;
240 
244  bool MouseButtonPressEvent(const vtkContextMouseEvent& mouse) override;
245 
249  bool MouseButtonReleaseEvent(const vtkContextMouseEvent& mouse) override;
250 
251 protected:
252  vtkChartLegend();
253  ~vtkChartLegend() override;
254 
255  float* Point; // The point the legend is anchored to.
256  int HorizontalAlignment; // Alignment of the legend to the point it is anchored to.
257  int VerticalAlignment; // Alignment of the legend to the point it is anchored to.
258 
263 
268 
273 
278 
284 
288  int Button;
289 
292 
294 
298  int Padding;
299 
304 
308  bool Inline;
309 
310  // Private storage class
311  class Private;
312  Private* Storage;
313 
314 private:
315  vtkChartLegend(const vtkChartLegend&) = delete;
316  void operator=(const vtkChartLegend&) = delete;
317 };
318 
319 #endif // vtkChartLegend_h
Private * Storage
vtkTimeStamp PlotTime
base class for items that are part of a vtkContextScene.
virtual bool MouseButtonPressEvent(const vtkContextMouseEvent &mouse)
Mouse button down event Return true if the item holds the event, false if the event can be propagated...
virtual bool Paint(vtkContext2D *painter)
Paint event for the item, called whenever the item needs to be drawn.
record modification and/or execution time
Definition: vtkTimeStamp.h:32
bool DragEnabled
Should we move the legend box around in response to the mouse drag?
bool Inline
Should the legend be drawn inline in its chart?
int Padding
Padding between symbol and text.
Class for drawing 2D primitives to a graphical context.
Definition: vtkContext2D.h:52
Factory class for drawing 2D charts.
Definition: vtkChart.h:44
vtkTimeStamp RectTime
provides a brush that fills shapes drawn by vtkContext2D.
Definition: vtkBrush.h:37
data structure to represent mouse events.
a simple class to control print indentation
Definition: vtkIndent.h:33
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
virtual bool MouseButtonReleaseEvent(const vtkContextMouseEvent &mouse)
Mouse button release event.
vtkNew< vtkBrush > Brush
The brush used to render the background of the legend.
provides a pen that draws the outlines of shapes drawn by vtkContext2D.
Definition: vtkPen.h:36
represent text properties.
int SymbolWidth
Width of the symbols in pixels in the legend.
draw the chart legend
int Button
Last button to be pressed.
bool CacheBounds
Should the legend attempt to avoid recalculating its position & bounds unnecessarily?
virtual bool MouseMoveEvent(const vtkContextMouseEvent &mouse)
Mouse move event.
virtual bool Hit(const vtkContextMouseEvent &mouse)
Return true if the supplied x, y coordinate is inside the item.
vtkNew< vtkTextProperty > LabelProperties
The text properties of the labels used in the legend.
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
virtual void Update()
Perform any updates to the item that may be necessary before rendering.
vtkNew< vtkPen > Pen
The pen used to draw the legend box.