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 
33 #ifndef vtkChartXY_h
34 #define vtkChartXY_h
35 
36 #include "vtkChart.h"
37 #include "vtkChartsCoreModule.h" // For export macro
38 #include "vtkContextPolygon.h" // For vtkContextPolygon
39 #include "vtkSmartPointer.h" // For SP ivars
40 #include "vtkVector.h" // For vtkVector2f in struct
41 
42 class vtkPlot;
43 class vtkAxis;
44 class vtkPlotGrid;
45 class vtkChartLegend;
46 class vtkTooltipItem;
47 class vtkChartXYPrivate; // Private class to keep my STL vector in...
48 
49 class VTKCHARTSCORE_EXPORT vtkChartXY : public vtkChart
50 {
51 public:
52  vtkTypeMacro(vtkChartXY, vtkChart);
53  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
54 
58  static vtkChartXY* New();
59 
65  void Update() VTK_OVERRIDE;
66 
70  bool Paint(vtkContext2D* painter) VTK_OVERRIDE;
71 
75  vtkPlot* AddPlot(int type) VTK_OVERRIDE;
76 
80  vtkIdType AddPlot(vtkPlot* plot) VTK_OVERRIDE;
81 
86  bool RemovePlot(vtkIdType index) VTK_OVERRIDE;
87 
91  void ClearPlots() VTK_OVERRIDE;
92 
96  vtkPlot* GetPlot(vtkIdType index) VTK_OVERRIDE;
97 
102  virtual vtkIdType GetPlotIndex(vtkPlot*);
103 
109  vtkIdType RaisePlot(vtkPlot* plot);
110 
117  virtual vtkIdType StackPlotAbove(vtkPlot* plot, vtkPlot* under);
118 
124  vtkIdType LowerPlot(vtkPlot* plot);
125 
132  virtual vtkIdType StackPlotUnder(vtkPlot* plot, vtkPlot* above);
133 
137  vtkIdType GetNumberOfPlots() VTK_OVERRIDE;
138 
142  int GetPlotCorner(vtkPlot* plot);
143 
147  void SetPlotCorner(vtkPlot* plot, int corner);
148 
154  vtkAxis* GetAxis(int axisIndex) VTK_OVERRIDE;
155 
159  void SetShowLegend(bool visible) VTK_OVERRIDE;
160 
164  vtkChartLegend* GetLegend() VTK_OVERRIDE;
165 
169  virtual void SetTooltip(vtkTooltipItem* tooltip);
170 
174  virtual vtkTooltipItem* GetTooltip();
175 
179  vtkIdType GetNumberOfAxes() VTK_OVERRIDE;
180 
185  void RecalculateBounds() VTK_OVERRIDE;
186 
194  void SetSelectionMethod(int method) VTK_OVERRIDE;
195 
197 
200  vtkSetMacro(DrawAxesAtOrigin, bool);
201  vtkGetMacro(DrawAxesAtOrigin, bool);
202  vtkBooleanMacro(DrawAxesAtOrigin, bool);
204 
206 
210  vtkSetMacro(AutoAxes, bool);
211  vtkGetMacro(AutoAxes, bool);
212  vtkBooleanMacro(AutoAxes, bool);
214 
216 
219  vtkSetMacro(HiddenAxisBorder, int);
220  vtkGetMacro(HiddenAxisBorder, int);
222 
224 
229  vtkSetMacro(ForceAxesToBounds, bool);
230  vtkGetMacro(ForceAxesToBounds, bool);
231  vtkBooleanMacro(ForceAxesToBounds, bool);
233 
235 
242  vtkSetMacro(BarWidthFraction, float);
243  vtkGetMacro(BarWidthFraction, float);
245 
247 
253  vtkSetMacro(ZoomWithMouseWheel, bool);
254  vtkGetMacro(ZoomWithMouseWheel, bool);
255  vtkBooleanMacro(ZoomWithMouseWheel, bool);
257 
259 
264  vtkSetMacro(AdjustLowerBoundForLogPlot, bool);
265  vtkGetMacro(AdjustLowerBoundForLogPlot, bool);
266  vtkBooleanMacro(AdjustLowerBoundForLogPlot, bool);
268 
272  virtual void SetTooltipInfo(const vtkContextMouseEvent&, const vtkVector2d&, vtkIdType, vtkPlot*,
273  vtkIdType segmentIndex = -1);
274 
278  bool Hit(const vtkContextMouseEvent& mouse) VTK_OVERRIDE;
279 
283  bool MouseEnterEvent(const vtkContextMouseEvent& mouse) VTK_OVERRIDE;
284 
288  bool MouseMoveEvent(const vtkContextMouseEvent& mouse) VTK_OVERRIDE;
289 
293  bool MouseLeaveEvent(const vtkContextMouseEvent& mouse) VTK_OVERRIDE;
294 
298  bool MouseButtonPressEvent(const vtkContextMouseEvent& mouse) VTK_OVERRIDE;
299 
303  bool MouseButtonReleaseEvent(const vtkContextMouseEvent& mouse) VTK_OVERRIDE;
304 
308  bool MouseWheelEvent(const vtkContextMouseEvent& mouse, int delta) VTK_OVERRIDE;
309 
313  bool KeyPressEvent(const vtkContextKeyEvent& key) VTK_OVERRIDE;
314 
315 protected:
316  vtkChartXY();
317  ~vtkChartXY() VTK_OVERRIDE;
318 
322  void RecalculatePlotTransforms();
323 
328  void RecalculatePlotBounds();
329 
335  virtual bool UpdateLayout(vtkContext2D* painter);
336 
342  virtual int GetLegendBorder(vtkContext2D* painter, int axisPosition);
343 
348  virtual void SetLegendPosition(const vtkRectf& rect);
349 
354 
359 
363  bool PlotTransformValid;
364 
368  vtkRectf MouseBox;
369 
373  bool DrawBox;
374 
379  vtkContextPolygon SelectionPolygon;
380 
384  bool DrawSelectionPolygon;
385 
389  bool DrawNearestPoint;
390 
396  bool DrawAxesAtOrigin;
397 
401  bool AutoAxes;
402 
406  int HiddenAxisBorder;
407 
412  float BarWidthFraction;
413 
419  bool ForceAxesToBounds;
420 
425  bool ZoomWithMouseWheel;
426 
431  bool AdjustLowerBoundForLogPlot;
432 
433 private:
434  vtkChartXY(const vtkChartXY&) VTK_DELETE_FUNCTION;
435  void operator=(const vtkChartXY&) VTK_DELETE_FUNCTION;
436 
437  vtkChartXYPrivate* ChartPrivate; // Private class where I hide my STL containers
438 
442  void CalculateBarPlots();
443 
449  bool LocatePointInPlots(const vtkContextMouseEvent& mouse, int invokeEvent = -1);
450 
451  int LocatePointInPlot(const vtkVector2f& position, const vtkVector2f& tolerance,
452  vtkVector2f& plotPos, vtkPlot* plot, vtkIdType& segmentIndex);
453 
457  bool RemovePlotFromCorners(vtkPlot* plot);
458 
459  void ZoomInAxes(vtkAxis* x, vtkAxis* y, float* orign, float* max);
460 
464  void TransformBoxOrPolygon(bool polygonMode, vtkTransform2D* transform,
465  const vtkVector2f& mousePosition, vtkVector2f& min, vtkVector2f& max,
466  vtkContextPolygon& polygon);
467 };
468 
470 
476 {
480  int Index;
481 };
483 
484 #endif // vtkChartXY_h
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:47
data structure to represent key events.
Hold a reference to a vtkObjectBase instance.
int vtkIdType
Definition: vtkType.h:345
vtkStdString SeriesName
Definition: vtkChartXY.h:477
Class for drawing 2D primitives to a graphical context.
Definition: vtkContext2D.h:58
Factory class for drawing 2D charts.
Definition: vtkChart.h:50
takes care of drawing 2D axes
Definition: vtkAxis.h:71
data structure to represent mouse events.
vtkVector2i ScreenPosition
Definition: vtkChartXY.h:479
a simple class to control print indentation
Definition: vtkIndent.h:39
Some derived classes for the different vectors commonly used.
Definition: vtkVector.h:327
describes linear transformations via a 3x3 matrix
Abstract class for 2D plots.
Definition: vtkPlot.h:52
vtkVector2f Position
Definition: vtkChartXY.h:478
vtkSetMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
Factory class for drawing XY charts.
Definition: vtkChartXY.h:49
draw the chart legend
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
Small struct used by InvokeEvent to send some information about the point that was clicked on...
Definition: vtkChartXY.h:475
takes care of drawing the plot grid
Definition: vtkPlotGrid.h:38
takes care of drawing 2D axes
vtkBooleanMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
virtual void Update()
Perform any updates to the item that may be necessary before rendering.
#define max(a, b)