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 
29 #ifndef vtkChartLegend_h
30 #define vtkChartLegend_h
31 
32 #include "vtkChartsCoreModule.h" // For export macro
33 #include "vtkContextItem.h"
34 #include "vtkNew.h" // For vtkNew
35 #include "vtkRect.h" // For vtkRectf return value
36 
37 class vtkChart;
38 class vtkPen;
39 class vtkBrush;
40 class vtkTextProperty;
41 
42 class VTKCHARTSCORE_EXPORT vtkChartLegend : public vtkContextItem
43 {
44 public:
46  void PrintSelf(ostream &os, vtkIndent indent) override;
47 
51  static vtkChartLegend *New();
52 
54 
57  vtkSetVector2Macro(Point, float);
59 
61 
64  vtkGetVector2Macro(Point, float);
66 
67  enum {
68  LEFT = 0,
71  TOP,
73  CUSTOM
74  };
75 
79  void SetPoint(const vtkVector2f &point);
80 
85 
87 
91  vtkSetMacro(HorizontalAlignment, int);
93 
95 
98  vtkGetMacro(HorizontalAlignment, int);
100 
102 
106  vtkSetMacro(VerticalAlignment, int);
108 
110 
113  vtkGetMacro(VerticalAlignment, int);
115 
117 
120  vtkSetMacro(Padding, int);
122 
124 
127  vtkGetMacro(Padding, int);
129 
131 
134  vtkSetMacro(SymbolWidth, int);
136 
138 
141  vtkGetMacro(SymbolWidth, int);
143 
147  virtual void SetLabelSize(int size);
148 
152  virtual int GetLabelSize();
153 
155 
160  vtkSetMacro(Inline, bool);
161  vtkGetMacro(Inline, bool);
163 
165 
171  vtkSetMacro(DragEnabled, bool);
172  vtkGetMacro(DragEnabled, bool);
174 
178  void SetChart(vtkChart* chart);
179 
184 
189  void Update() override;
190 
194  bool Paint(vtkContext2D *painter) override;
195 
203 
208 
213 
218 
220 
228  vtkSetMacro(CacheBounds, bool);
229  vtkGetMacro(CacheBounds, bool);
230  vtkBooleanMacro(CacheBounds, bool);
232 
236  bool Hit(const vtkContextMouseEvent &mouse) override;
237 
241  bool MouseMoveEvent(const vtkContextMouseEvent &mouse) override;
242 
246  bool MouseButtonPressEvent(const vtkContextMouseEvent &mouse) override;
247 
251  bool MouseButtonReleaseEvent(const vtkContextMouseEvent &mouse) override;
252 
253 protected:
255  ~vtkChartLegend() override;
256 
257  float* Point; // The point the legend is anchored to.
258  int HorizontalAlignment; // Alignment of the legend to the point it is anchored to.
259  int VerticalAlignment; // Alignment of the legend to the point it is anchored to.
260 
265 
270 
275 
280 
286 
290  int Button;
291 
294 
296 
300  int Padding;
301 
306 
310  bool Inline;
311 
312  // Private storage class
313  class Private;
314  Private* Storage;
315 
316 private:
317  vtkChartLegend(const vtkChartLegend &) = delete;
318  void operator=(const vtkChartLegend &) = delete;
319 };
320 
321 #endif //vtkChartLegend_h
vtkChartLegend::GetLabelSize
virtual int GetLabelSize()
Get the point size of the label text.
vtkChart
Factory class for drawing 2D charts.
Definition: vtkChart.h:51
vtkBrush
provides a brush that fills shapes drawn by vtkContext2D.
Definition: vtkBrush.h:41
vtkContextMouseEvent
data structure to represent mouse events.
Definition: vtkContextMouseEvent.h:41
vtkChartLegend::New
static vtkChartLegend * New()
Creates a 2D Chart object.
vtkChartLegend::Button
int Button
Last button to be pressed.
Definition: vtkChartLegend.h:290
vtkChartLegend::GetLabelProperties
vtkTextProperty * GetLabelProperties()
Get the vtkTextProperty for the legend's labels.
vtkChartLegend::Pen
vtkNew< vtkPen > Pen
The pen used to draw the legend box.
Definition: vtkChartLegend.h:264
vtkChartLegend::SetPoint
void SetPoint(const vtkVector2f &point)
Set point the legend box is anchored to.
vtkChartLegend::RectTime
vtkTimeStamp RectTime
Definition: vtkChartLegend.h:293
vtkChartLegend
draw the chart legend
Definition: vtkChartLegend.h:43
vtkTimeStamp
record modification and/or execution time
Definition: vtkTimeStamp.h:36
vtkContext2D
Class for drawing 2D primitives to a graphical context.
Definition: vtkContext2D.h:59
vtkContextItem.h
vtkChartLegend::CacheBounds
bool CacheBounds
Should the legend attempt to avoid recalculating its position & bounds unnecessarily?
Definition: vtkChartLegend.h:285
vtkChartLegend::Inline
bool Inline
Should the legend be drawn inline in its chart?
Definition: vtkChartLegend.h:310
vtkChartLegend::MouseButtonPressEvent
bool MouseButtonPressEvent(const vtkContextMouseEvent &mouse) override
Mouse button down event.
vtkChartLegend::GetBoundingRect
virtual vtkRectf GetBoundingRect(vtkContext2D *painter)
Request the space the legend requires to be drawn.
vtkChartLegend::GetPen
vtkPen * GetPen()
Get the pen used to draw the legend outline.
vtkChartLegend::GetChart
vtkChart * GetChart()
Get the chart that the legend belongs to and will draw the legend for.
vtkX3D::point
@ point
Definition: vtkX3D.h:236
vtkChartLegend::MouseButtonReleaseEvent
bool MouseButtonReleaseEvent(const vtkContextMouseEvent &mouse) override
Mouse button release event.
vtkChartLegend::MouseMoveEvent
bool MouseMoveEvent(const vtkContextMouseEvent &mouse) override
Mouse move event.
vtkChartLegend::GetPointVector
const vtkVector2f & GetPointVector()
Get point the legend box is anchored to.
vtkRect.h
vtkChartLegend::LabelProperties
vtkNew< vtkTextProperty > LabelProperties
The text properties of the labels used in the legend.
Definition: vtkChartLegend.h:274
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:40
vtkChartLegend::DragEnabled
bool DragEnabled
Should we move the legend box around in response to the mouse drag?
Definition: vtkChartLegend.h:279
vtkX3D::size
@ size
Definition: vtkX3D.h:253
vtkChartLegend::vtkChartLegend
vtkChartLegend()
vtkNew< vtkPen >
vtkChartLegend::GetBrush
vtkBrush * GetBrush()
Get the brush used to draw the legend background.
vtkChartLegend::CENTER
@ CENTER
Definition: vtkChartLegend.h:69
vtkChartLegend::SymbolWidth
int SymbolWidth
Width of the symbols in pixels in the legend.
Definition: vtkChartLegend.h:305
vtkTextProperty
represent text properties.
Definition: vtkTextProperty.h:40
vtkContextItem
base class for items that are part of a vtkContextScene.
Definition: vtkContextItem.h:35
vtkChartLegend::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkChartLegend::Rect
vtkRectf Rect
Definition: vtkChartLegend.h:295
vtkChartLegend::PlotTime
vtkTimeStamp PlotTime
Definition: vtkChartLegend.h:292
vtkChartLegend::Update
void Update() override
Update the geometry of the axis.
vtkChartLegend::BOTTOM
@ BOTTOM
Definition: vtkChartLegend.h:72
vtkChartLegend::VerticalAlignment
int VerticalAlignment
Definition: vtkChartLegend.h:259
vtkChartLegend::HorizontalAlignment
int HorizontalAlignment
Definition: vtkChartLegend.h:258
vtkChartLegend::Point
float * Point
Definition: vtkChartLegend.h:257
vtkNew.h
vtkX3D::Inline
@ Inline
Definition: vtkX3D.h:113
vtkChartLegend::SetChart
void SetChart(vtkChart *chart)
Set the chart that the legend belongs to and will draw the legend for.
vtkChartLegend::TOP
@ TOP
Definition: vtkChartLegend.h:71
vtkChartLegend::Padding
int Padding
Padding between symbol and text.
Definition: vtkChartLegend.h:300
vtkChartLegend::Storage
Private * Storage
Definition: vtkChartLegend.h:313
vtkPen
provides a pen that draws the outlines of shapes drawn by vtkContext2D.
Definition: vtkPen.h:40
vtkChartLegend::SetLabelSize
virtual void SetLabelSize(int size)
Set the point size of the label text.
vtkChartLegend::Paint
bool Paint(vtkContext2D *painter) override
Paint event for the axis, called whenever the axis needs to be drawn.
vtkChartLegend::~vtkChartLegend
~vtkChartLegend() override
vtkRectf
Definition: vtkRect.h:333
vtkVector2f
Definition: vtkVector.h:419
vtkChartLegend::Hit
bool Hit(const vtkContextMouseEvent &mouse) override
Return true if the supplied x, y coordinate is inside the item.
vtkChartLegend::RIGHT
@ RIGHT
Definition: vtkChartLegend.h:70
vtkChartLegend::Brush
vtkNew< vtkBrush > Brush
The brush used to render the background of the legend.
Definition: vtkChartLegend.h:269