VTK  9.0.20200604
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
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:288
vtkChartLegend::Pen
vtkNew< vtkPen > Pen
The pen used to draw the legend box.
Definition: vtkChartLegend.h:262
vtkChartLegend::RectTime
vtkTimeStamp RectTime
Definition: vtkChartLegend.h:291
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:283
vtkChartLegend::Inline
bool Inline
Should the legend be drawn inline in its chart?
Definition: vtkChartLegend.h:308
vtkX3D::point
Definition: vtkX3D.h:242
vtkRect.h
vtkChartLegend::LabelProperties
vtkNew< vtkTextProperty > LabelProperties
The text properties of the labels used in the legend.
Definition: vtkChartLegend.h:272
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:277
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:259
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:67
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:303
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:293
vtkChartLegend::PlotTime
vtkTimeStamp PlotTime
Definition: vtkChartLegend.h:290
vtkChartLegend::BOTTOM
Definition: vtkChartLegend.h:70
vtkChartLegend::VerticalAlignment
int VerticalAlignment
Definition: vtkChartLegend.h:257
vtkChartLegend::HorizontalAlignment
int HorizontalAlignment
Definition: vtkChartLegend.h:256
vtkChartLegend::Point
float * Point
Definition: vtkChartLegend.h:255
vtkNew.h
vtkX3D::Inline
Definition: vtkX3D.h:119
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:69
vtkChartLegend::Padding
int Padding
Padding between symbol and text.
Definition: vtkChartLegend.h:298
vtkChartLegend::Storage
Private * Storage
Definition: vtkChartLegend.h:311
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:326
vtkVector2f
Definition: vtkVector.h:432
vtkChartLegend::RIGHT
Definition: vtkChartLegend.h:68
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:267