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 
189  virtual void SetTooltipInfo(const vtkContextMouseEvent &,
190  const vtkVector2d &,
191  vtkIdType, vtkPlot*,
192  vtkIdType segmentIndex = -1);
194 
195 //BTX
197  virtual bool Hit(const vtkContextMouseEvent &mouse);
198 
200  virtual bool MouseEnterEvent(const vtkContextMouseEvent &mouse);
201 
203  virtual bool MouseMoveEvent(const vtkContextMouseEvent &mouse);
204 
206  virtual bool MouseLeaveEvent(const vtkContextMouseEvent &mouse);
207 
209  virtual bool MouseButtonPressEvent(const vtkContextMouseEvent &mouse);
210 
212  virtual bool MouseButtonReleaseEvent(const vtkContextMouseEvent &mouse);
213 
216  virtual bool MouseWheelEvent(const vtkContextMouseEvent &mouse, int delta);
217 
219 
220  virtual bool KeyPressEvent(const vtkContextKeyEvent &key);
221 //ETX
223 
224 //BTX
225 protected:
226  vtkChartXY();
227  ~vtkChartXY();
228 
230  void RecalculatePlotTransforms();
231 
234  void RecalculatePlotBounds();
235 
239  virtual bool UpdateLayout(vtkContext2D* painter);
240 
244  virtual int GetLegendBorder(vtkContext2D* painter, int axisPosition);
245 
248  virtual void SetLegendPosition(const vtkRectf& rect);
249 
252 
256 
259 
262 
264  bool DrawBox;
265 
269 
272 
275 
280 
282  bool AutoAxes;
283 
286 
290 
294 
299 
300 private:
301  vtkChartXY(const vtkChartXY &); // Not implemented.
302  void operator=(const vtkChartXY &); // Not implemented.
303 
304  vtkChartXYPrivate *ChartPrivate; // Private class where I hide my STL containers
305 
308  void CalculateBarPlots();
309 
311 
314  bool LocatePointInPlots(const vtkContextMouseEvent &mouse,
315  int invokeEvent = -1);
317 
318  int LocatePointInPlot(const vtkVector2f &position,
319  const vtkVector2f &tolerance, vtkVector2f &plotPos,
320  vtkPlot *plot, vtkIdType &segmentIndex);
321 
323  bool RemovePlotFromCorners(vtkPlot *plot);
324 
325  void ZoomInAxes(vtkAxis *x, vtkAxis *y, float *orign, float *max);
326 
328 
329  void TransformBoxOrPolygon(bool polygonMode, vtkTransform2D *transform,
330  const vtkVector2f &mousePosition,
331  vtkVector2f &min, vtkVector2f &max,
332  vtkContextPolygon &polygon);
334 
335 //ETX
336 };
337 
339 
343 {
347  int Index;
348 };
350 
351 #endif //vtkChartXY_h
bool DrawAxesAtOrigin
Definition: vtkChartXY.h:279
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:268
virtual vtkIdType GetNumberOfAxes()
bool ForceAxesToBounds
Definition: vtkChartXY.h:298
virtual void RecalculateBounds()
virtual void PrintSelf(ostream &os, vtkIndent indent)
int vtkIdType
Definition: vtkType.h:275
int HiddenAxisBorder
Definition: vtkChartXY.h:285
bool DrawSelectionPolygon
Definition: vtkChartXY.h:271
vtkRectf MouseBox
Definition: vtkChartXY.h:261
vtkStdString SeriesName
Definition: vtkChartXY.h:344
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:346
virtual vtkChartLegend * GetLegend()
a simple class to control print indentation
Definition: vtkIndent.h:38
bool DrawBox
Definition: vtkChartXY.h:264
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:345
virtual bool KeyPressEvent(const vtkContextKeyEvent &key)
vtkSmartPointer< vtkChartLegend > Legend
Definition: vtkChartXY.h:251
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:293
takes care of drawing 2D axes
bool AutoAxes
Definition: vtkChartXY.h:282
static vtkObject * New()
vtkSmartPointer< vtkTooltipItem > Tooltip
Definition: vtkChartXY.h:255
float BarWidthFraction
Definition: vtkChartXY.h:289
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:274
bool PlotTransformValid
Definition: vtkChartXY.h:258