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
vtkChart
Factory class for drawing 2D charts.
Definition: vtkChart.h:44
vtkBrush
provides a brush that fills shapes drawn by vtkContext2D.
Definition: vtkBrush.h:37
vtkContextMouseEvent
data structure to represent mouse events.
Definition: vtkContextMouseEvent.h:34
vtkChartLegend::Button
int Button
Last button to be pressed.
Definition: vtkChartLegend.h:287
vtkChartLegend::Pen
vtkNew< vtkPen > Pen
The pen used to draw the legend box.
Definition: vtkChartLegend.h:261
vtkChartLegend::RectTime
vtkTimeStamp RectTime
Definition: vtkChartLegend.h:290
vtkObject::New
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on.
vtkChartLegend
draw the chart legend
Definition: vtkChartLegend.h:39
vtkTimeStamp
record modification and/or execution time
Definition: vtkTimeStamp.h:32
vtkContext2D
Class for drawing 2D primitives to a graphical context.
Definition: vtkContext2D.h:52
vtkContextItem.h
vtkChartLegend::CacheBounds
bool CacheBounds
Should the legend attempt to avoid recalculating its position & bounds unnecessarily?
Definition: vtkChartLegend.h:282
vtkChartLegend::Inline
bool Inline
Should the legend be drawn inline in its chart?
Definition: vtkChartLegend.h:307
vtkX3D::point
Definition: vtkX3D.h:236
vtkRect.h
vtkChartLegend::LabelProperties
vtkNew< vtkTextProperty > LabelProperties
The text properties of the labels used in the legend.
Definition: vtkChartLegend.h:271
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkChartLegend::DragEnabled
bool DragEnabled
Should we move the legend box around in response to the mouse drag?
Definition: vtkChartLegend.h:276
vtkAbstractContextItem::Hit
virtual bool Hit(const vtkContextMouseEvent &mouse)
Return true if the supplied x, y coordinate is inside the item.
vtkX3D::size
Definition: vtkX3D.h:253
vtkNew< vtkPen >
vtkContextItem::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkChartLegend::CENTER
Definition: vtkChartLegend.h:66
vtkAbstractContextItem::MouseMoveEvent
virtual bool MouseMoveEvent(const vtkContextMouseEvent &mouse)
Mouse move event.
vtkChartLegend::SymbolWidth
int SymbolWidth
Width of the symbols in pixels in the legend.
Definition: vtkChartLegend.h:302
vtkAbstractContextItem::MouseButtonReleaseEvent
virtual bool MouseButtonReleaseEvent(const vtkContextMouseEvent &mouse)
Mouse button release event.
vtkTextProperty
represent text properties.
Definition: vtkTextProperty.h:33
vtkContextItem
base class for items that are part of a vtkContextScene.
Definition: vtkContextItem.h:31
vtkChartLegend::Rect
vtkRectf Rect
Definition: vtkChartLegend.h:292
vtkChartLegend::PlotTime
vtkTimeStamp PlotTime
Definition: vtkChartLegend.h:289
vtkChartLegend::BOTTOM
Definition: vtkChartLegend.h:69
vtkChartLegend::VerticalAlignment
int VerticalAlignment
Definition: vtkChartLegend.h:256
vtkChartLegend::HorizontalAlignment
int HorizontalAlignment
Definition: vtkChartLegend.h:255
vtkChartLegend::Point
float * Point
Definition: vtkChartLegend.h:254
vtkNew.h
vtkX3D::Inline
Definition: vtkX3D.h:113
vtkAbstractContextItem::Paint
virtual bool Paint(vtkContext2D *painter)
Paint event for the item, called whenever the item needs to be drawn.
vtkChartLegend::TOP
Definition: vtkChartLegend.h:68
vtkChartLegend::Padding
int Padding
Padding between symbol and text.
Definition: vtkChartLegend.h:297
vtkChartLegend::Storage
Private * Storage
Definition: vtkChartLegend.h:310
vtkAbstractContextItem::MouseButtonPressEvent
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...
vtkPen
provides a pen that draws the outlines of shapes drawn by vtkContext2D.
Definition: vtkPen.h:36
vtkRectf
Definition: vtkRect.h:293
vtkVector2f
Definition: vtkVector.h:415
vtkChartLegend::RIGHT
Definition: vtkChartLegend.h:67
vtkAbstractContextItem::Update
virtual void Update()
Perform any updates to the item that may be necessary before rendering.
vtkChartLegend::Brush
vtkNew< vtkBrush > Brush
The brush used to render the background of the legend.
Definition: vtkChartLegend.h:266