VTK
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  LEFT = 0,
68  TOP,
70  CUSTOM
71  };
72 
76  void SetPoint(const vtkVector2f &point);
77 
81  const vtkVector2f& GetPointVector();
82 
84 
88  vtkSetMacro(HorizontalAlignment, int);
90 
92 
95  vtkGetMacro(HorizontalAlignment, int);
97 
99 
103  vtkSetMacro(VerticalAlignment, int);
105 
107 
110  vtkGetMacro(VerticalAlignment, int);
112 
114 
117  vtkSetMacro(Padding, int);
119 
121 
124  vtkGetMacro(Padding, int);
126 
128 
131  vtkSetMacro(SymbolWidth, int);
133 
135 
138  vtkGetMacro(SymbolWidth, int);
140 
144  virtual void SetLabelSize(int size);
145 
149  virtual int GetLabelSize();
150 
152 
157  vtkSetMacro(Inline, bool);
158  vtkGetMacro(Inline, bool);
160 
162 
168  vtkSetMacro(DragEnabled, bool);
169  vtkGetMacro(DragEnabled, bool);
171 
175  void SetChart(vtkChart* chart);
176 
180  vtkChart* GetChart();
181 
186  void Update() override;
187 
191  bool Paint(vtkContext2D *painter) override;
192 
199  virtual vtkRectf GetBoundingRect(vtkContext2D* painter);
200 
204  vtkPen * GetPen();
205 
209  vtkBrush * GetBrush();
210 
214  vtkTextProperty * GetLabelProperties();
215 
217 
225  vtkSetMacro(CacheBounds, bool);
226  vtkGetMacro(CacheBounds, bool);
227  vtkBooleanMacro(CacheBounds, bool);
229 
233  bool Hit(const vtkContextMouseEvent &mouse) override;
234 
238  bool MouseMoveEvent(const vtkContextMouseEvent &mouse) override;
239 
243  bool MouseButtonPressEvent(const vtkContextMouseEvent &mouse) override;
244 
248  bool MouseButtonReleaseEvent(const vtkContextMouseEvent &mouse) override;
249 
250 protected:
251  vtkChartLegend();
252  ~vtkChartLegend() override;
253 
254  float* Point; // The point the legend is anchored to.
255  int HorizontalAlignment; // Alignment of the legend to the point it is anchored to.
256  int VerticalAlignment; // Alignment of the legend to the point it is anchored to.
257 
262 
267 
272 
277 
283 
287  int Button;
288 
291 
293 
297  int Padding;
298 
303 
307  bool Inline;
308 
309  // Private storage class
310  class Private;
311  Private* Storage;
312 
313 private:
314  vtkChartLegend(const vtkChartLegend &) = delete;
315  void operator=(const vtkChartLegend &) = delete;
316 };
317 
318 #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.