VTK
vtkChartXY.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkChartXY.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 
32 #ifndef vtkChartXY_h
33 #define vtkChartXY_h
34 
35 #include "vtkChartsCoreModule.h" // For export macro
36 #include "vtkChart.h"
37 #include "vtkSmartPointer.h" // For SP ivars
38 #include "vtkVector.h" // For vtkVector2f in struct
39 #include "vtkContextPolygon.h" // For vtkContextPolygon
40 
41 class vtkPlot;
42 class vtkAxis;
43 class vtkPlotGrid;
44 class vtkChartLegend;
45 class vtkTooltipItem;
46 class vtkChartXYPrivate; // Private class to keep my STL vector in...
47 
49 {
50 public:
51  vtkTypeMacro(vtkChartXY, vtkChart);
52  virtual void PrintSelf(ostream &os, vtkIndent indent);
53 
55  static vtkChartXY *New();
56 
60  virtual void Update();
61 
64  virtual bool Paint(vtkContext2D *painter);
65 
67  virtual vtkPlot * AddPlot(int type);
68 
70  virtual vtkIdType AddPlot(vtkPlot* plot);
71 
74  virtual bool RemovePlot(vtkIdType index);
75 
77  virtual void ClearPlots();
78 
81  virtual vtkPlot* GetPlot(vtkIdType index);
82 
85  virtual vtkIdType GetPlotIndex(vtkPlot*);
86 
89  vtkIdType RaisePlot(vtkPlot* plot);
90 
94  virtual vtkIdType StackPlotAbove(vtkPlot* plot, vtkPlot* under);
95 
98  vtkIdType LowerPlot(vtkPlot* plot);
99 
103  virtual vtkIdType StackPlotUnder(vtkPlot* plot, vtkPlot* above);
104 
106  virtual vtkIdType GetNumberOfPlots();
107 
109  int GetPlotCorner(vtkPlot *plot);
110 
112  void SetPlotCorner(vtkPlot *plot, int corner);
113 
117  virtual vtkAxis* GetAxis(int axisIndex);
118 
120  virtual void SetShowLegend(bool visible);
121 
123  virtual vtkChartLegend* GetLegend();
124 
126  virtual void SetTooltip(vtkTooltipItem *tooltip);
127 
129  virtual vtkTooltipItem* GetTooltip();
130 
132  virtual vtkIdType GetNumberOfAxes();
133 
137  virtual void RecalculateBounds();
138 
144  virtual void SetSelectionMethod(int method);
145 
147 
148  vtkSetMacro(DrawAxesAtOrigin, bool);
149  vtkGetMacro(DrawAxesAtOrigin, bool);
150  vtkBooleanMacro(DrawAxesAtOrigin, bool);
152 
154 
156  vtkSetMacro(AutoAxes, bool);
157  vtkGetMacro(AutoAxes, bool);
158  vtkBooleanMacro(AutoAxes, bool);
160 
162 
163  vtkSetMacro(HiddenAxisBorder, int);
164  vtkGetMacro(HiddenAxisBorder, int);
166 
168 
171  vtkSetMacro(ForceAxesToBounds, bool);
172  vtkGetMacro(ForceAxesToBounds, bool);
173  vtkBooleanMacro(ForceAxesToBounds, bool);
175 
177 
183  vtkSetMacro(BarWidthFraction, float);
184  vtkGetMacro(BarWidthFraction, float);
186 
188 
192  vtkSetMacro(ZoomWithMouseWheel, bool);
193  vtkGetMacro(ZoomWithMouseWheel, bool);
194  vtkBooleanMacro(ZoomWithMouseWheel, bool);
196 
198 
199  virtual void SetTooltipInfo(const vtkContextMouseEvent &,
200  const vtkVector2d &,
201  vtkIdType, vtkPlot*,
202  vtkIdType segmentIndex = -1);
204 
205 //BTX
207  virtual bool Hit(const vtkContextMouseEvent &mouse);
208 
210  virtual bool MouseEnterEvent(const vtkContextMouseEvent &mouse);
211 
213  virtual bool MouseMoveEvent(const vtkContextMouseEvent &mouse);
214 
216  virtual bool MouseLeaveEvent(const vtkContextMouseEvent &mouse);
217 
219  virtual bool MouseButtonPressEvent(const vtkContextMouseEvent &mouse);
220 
222  virtual bool MouseButtonReleaseEvent(const vtkContextMouseEvent &mouse);
223 
226  virtual bool MouseWheelEvent(const vtkContextMouseEvent &mouse, int delta);
227 
229 
230  virtual bool KeyPressEvent(const vtkContextKeyEvent &key);
231 //ETX
233 
234 //BTX
235 protected:
236  vtkChartXY();
237  ~vtkChartXY();
238 
240  void RecalculatePlotTransforms();
241 
244  void RecalculatePlotBounds();
245 
249  virtual bool UpdateLayout(vtkContext2D* painter);
250 
254  virtual int GetLegendBorder(vtkContext2D* painter, int axisPosition);
255 
258  virtual void SetLegendPosition(const vtkRectf& rect);
259 
262 
266 
269 
272 
274  bool DrawBox;
275 
279 
282 
285 
290 
292  bool AutoAxes;
293 
296 
300 
304 
309 
313 
314 private:
315  vtkChartXY(const vtkChartXY &); // Not implemented.
316  void operator=(const vtkChartXY &); // Not implemented.
317 
318  vtkChartXYPrivate *ChartPrivate; // Private class where I hide my STL containers
319 
322  void CalculateBarPlots();
323 
325 
328  bool LocatePointInPlots(const vtkContextMouseEvent &mouse,
329  int invokeEvent = -1);
331 
332  int LocatePointInPlot(const vtkVector2f &position,
333  const vtkVector2f &tolerance, vtkVector2f &plotPos,
334  vtkPlot *plot, vtkIdType &segmentIndex);
335 
337  bool RemovePlotFromCorners(vtkPlot *plot);
338 
339  void ZoomInAxes(vtkAxis *x, vtkAxis *y, float *orign, float *max);
340 
342 
343  void TransformBoxOrPolygon(bool polygonMode, vtkTransform2D *transform,
344  const vtkVector2f &mousePosition,
345  vtkVector2f &min, vtkVector2f &max,
346  vtkContextPolygon &polygon);
348 
349 //ETX
350 };
351 
353 
357 {
361  int Index;
362 };
364 
365 #endif //vtkChartXY_h
bool DrawAxesAtOrigin
Definition: vtkChartXY.h:289
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:46
data structure to represent key events.
virtual void SetShowLegend(bool visible)
virtual bool MouseButtonPressEvent(const vtkContextMouseEvent &mouse)
vtkContextPolygon SelectionPolygon
Definition: vtkChartXY.h:278
virtual vtkIdType GetNumberOfAxes()
bool ForceAxesToBounds
Definition: vtkChartXY.h:308
virtual void RecalculateBounds()
virtual void PrintSelf(ostream &os, vtkIndent indent)
int vtkIdType
Definition: vtkType.h:247
int HiddenAxisBorder
Definition: vtkChartXY.h:295
bool DrawSelectionPolygon
Definition: vtkChartXY.h:281
vtkRectf MouseBox
Definition: vtkChartXY.h:271
vtkStdString SeriesName
Definition: vtkChartXY.h:358
virtual void ClearPlots()
Class for drawing 2D primitives to a graphical context.
Definition: vtkContext2D.h:56
Factory class for drawing 2D charts.
Definition: vtkChart.h:49
virtual bool RemovePlot(vtkIdType index)
virtual bool MouseWheelEvent(const vtkContextMouseEvent &mouse, int delta)
takes care of drawing 2D axes
Definition: vtkAxis.h:70
data structure to represent mouse events.
vtkVector2i ScreenPosition
Definition: vtkChartXY.h:360
virtual vtkChartLegend * GetLegend()
a simple class to control print indentation
Definition: vtkIndent.h:38
bool DrawBox
Definition: vtkChartXY.h:274
virtual bool MouseButtonReleaseEvent(const vtkContextMouseEvent &mouse)
virtual vtkIdType GetNumberOfPlots()
describes linear transformations via a 3x3 matrix
Abstract class for 2D plots.
Definition: vtkPlot.h:51
vtkVector2f Position
Definition: vtkChartXY.h:359
virtual bool KeyPressEvent(const vtkContextKeyEvent &key)
vtkSmartPointer< vtkChartLegend > Legend
Definition: vtkChartXY.h:261
virtual bool MouseEnterEvent(const vtkContextMouseEvent &mouse)
Factory class for drawing XY charts.
Definition: vtkChartXY.h:48
draw the chart legend
virtual bool Paint(vtkContext2D *painter)=0
virtual bool MouseMoveEvent(const vtkContextMouseEvent &mouse)
takes care of drawing the plot grid
Definition: vtkPlotGrid.h:37
virtual bool Hit(const vtkContextMouseEvent &mouse)
virtual vtkPlot * GetPlot(vtkIdType index)
bool LayoutChanged
Definition: vtkChartXY.h:303
bool ZoomWithMouseWheel
Definition: vtkChartXY.h:312
takes care of drawing 2D axes
bool AutoAxes
Definition: vtkChartXY.h:292
static vtkObject * New()
vtkSmartPointer< vtkTooltipItem > Tooltip
Definition: vtkChartXY.h:265
float BarWidthFraction
Definition: vtkChartXY.h:299
virtual void SetSelectionMethod(int method)
virtual void Update()
virtual bool MouseLeaveEvent(const vtkContextMouseEvent &mouse)
virtual vtkPlot * AddPlot(int type)
#define max(a, b)
#define VTKCHARTSCORE_EXPORT
virtual vtkAxis * GetAxis(int axisIndex)
bool DrawNearestPoint
Definition: vtkChartXY.h:284
bool PlotTransformValid
Definition: vtkChartXY.h:268