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 
27 #ifndef vtkChartXY_h
28 #define vtkChartXY_h
29 
30 #include "vtkChart.h"
31 #include "vtkChartsCoreModule.h" // For export macro
32 #include "vtkContextPolygon.h" // For vtkContextPolygon
33 #include "vtkSmartPointer.h" // For SP ivars
34 #include "vtkVector.h" // For vtkVector2f in struct
35 
36 class vtkPlot;
37 class vtkAxis;
38 class vtkPlotGrid;
39 class vtkChartLegend;
40 class vtkTooltipItem;
41 class vtkChartXYPrivate; // Private class to keep my STL vector in...
42 
43 class VTKCHARTSCORE_EXPORT vtkChartXY : public vtkChart
44 {
45 public:
46  vtkTypeMacro(vtkChartXY, vtkChart);
47  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
48 
52  static vtkChartXY* New();
53 
59  void Update() VTK_OVERRIDE;
60 
64  bool Paint(vtkContext2D* painter) VTK_OVERRIDE;
65 
69  vtkPlot* AddPlot(int type) VTK_OVERRIDE;
70 
74  vtkIdType AddPlot(vtkPlot* plot) VTK_OVERRIDE;
75 
80  bool RemovePlot(vtkIdType index) VTK_OVERRIDE;
81 
85  void ClearPlots() VTK_OVERRIDE;
86 
90  vtkPlot* GetPlot(vtkIdType index) VTK_OVERRIDE;
91 
96  virtual vtkIdType GetPlotIndex(vtkPlot*);
97 
103  vtkIdType RaisePlot(vtkPlot* plot);
104 
111  virtual vtkIdType StackPlotAbove(vtkPlot* plot, vtkPlot* under);
112 
118  vtkIdType LowerPlot(vtkPlot* plot);
119 
126  virtual vtkIdType StackPlotUnder(vtkPlot* plot, vtkPlot* above);
127 
131  vtkIdType GetNumberOfPlots() VTK_OVERRIDE;
132 
136  int GetPlotCorner(vtkPlot* plot);
137 
141  void SetPlotCorner(vtkPlot* plot, int corner);
142 
148  vtkAxis* GetAxis(int axisIndex) VTK_OVERRIDE;
149 
153  void SetShowLegend(bool visible) VTK_OVERRIDE;
154 
158  vtkChartLegend* GetLegend() VTK_OVERRIDE;
159 
163  virtual void SetTooltip(vtkTooltipItem* tooltip);
164 
168  virtual vtkTooltipItem* GetTooltip();
169 
173  vtkIdType GetNumberOfAxes() VTK_OVERRIDE;
174 
179  void RecalculateBounds() VTK_OVERRIDE;
180 
188  void SetSelectionMethod(int method) VTK_OVERRIDE;
189 
191 
194  vtkSetMacro(DrawAxesAtOrigin, bool);
195  vtkGetMacro(DrawAxesAtOrigin, bool);
196  vtkBooleanMacro(DrawAxesAtOrigin, bool);
198 
200 
204  vtkSetMacro(AutoAxes, bool);
205  vtkGetMacro(AutoAxes, bool);
206  vtkBooleanMacro(AutoAxes, bool);
208 
210 
213  vtkSetMacro(HiddenAxisBorder, int);
214  vtkGetMacro(HiddenAxisBorder, int);
216 
218 
223  vtkSetMacro(ForceAxesToBounds, bool);
224  vtkGetMacro(ForceAxesToBounds, bool);
225  vtkBooleanMacro(ForceAxesToBounds, bool);
227 
229 
236  vtkSetMacro(BarWidthFraction, float);
237  vtkGetMacro(BarWidthFraction, float);
239 
241 
247  vtkSetMacro(ZoomWithMouseWheel, bool);
248  vtkGetMacro(ZoomWithMouseWheel, bool);
249  vtkBooleanMacro(ZoomWithMouseWheel, bool);
251 
253 
258  vtkSetMacro(AdjustLowerBoundForLogPlot, bool);
259  vtkGetMacro(AdjustLowerBoundForLogPlot, bool);
260  vtkBooleanMacro(AdjustLowerBoundForLogPlot, bool);
262 
266  virtual void SetTooltipInfo(const vtkContextMouseEvent&, const vtkVector2d&, vtkIdType, vtkPlot*,
267  vtkIdType segmentIndex = -1);
268 
272  bool Hit(const vtkContextMouseEvent& mouse) VTK_OVERRIDE;
273 
277  bool MouseEnterEvent(const vtkContextMouseEvent& mouse) VTK_OVERRIDE;
278 
282  bool MouseMoveEvent(const vtkContextMouseEvent& mouse) VTK_OVERRIDE;
283 
287  bool MouseLeaveEvent(const vtkContextMouseEvent& mouse) VTK_OVERRIDE;
288 
292  bool MouseButtonPressEvent(const vtkContextMouseEvent& mouse) VTK_OVERRIDE;
293 
297  bool MouseButtonReleaseEvent(const vtkContextMouseEvent& mouse) VTK_OVERRIDE;
298 
302  bool MouseWheelEvent(const vtkContextMouseEvent& mouse, int delta) VTK_OVERRIDE;
303 
307  bool KeyPressEvent(const vtkContextKeyEvent& key) VTK_OVERRIDE;
308 
309 protected:
310  vtkChartXY();
311  ~vtkChartXY() VTK_OVERRIDE;
312 
316  void RecalculatePlotTransforms();
317 
322  void RecalculatePlotBounds();
323 
329  virtual bool UpdateLayout(vtkContext2D* painter);
330 
336  virtual int GetLegendBorder(vtkContext2D* painter, int axisPosition);
337 
342  virtual void SetLegendPosition(const vtkRectf& rect);
343 
348 
353 
357  bool PlotTransformValid;
358 
362  vtkRectf MouseBox;
363 
367  bool DrawBox;
368 
373  vtkContextPolygon SelectionPolygon;
374 
378  bool DrawSelectionPolygon;
379 
383  bool DrawNearestPoint;
384 
390  bool DrawAxesAtOrigin;
391 
395  bool AutoAxes;
396 
400  int HiddenAxisBorder;
401 
406  float BarWidthFraction;
407 
413  bool ForceAxesToBounds;
414 
419  bool ZoomWithMouseWheel;
420 
425  bool AdjustLowerBoundForLogPlot;
426 
427 private:
428  vtkChartXY(const vtkChartXY&) VTK_DELETE_FUNCTION;
429  void operator=(const vtkChartXY&) VTK_DELETE_FUNCTION;
430 
431  vtkChartXYPrivate* ChartPrivate; // Private class where I hide my STL containers
432 
436  void CalculateBarPlots();
437 
443  bool LocatePointInPlots(const vtkContextMouseEvent& mouse, int invokeEvent = -1);
444 
445  int LocatePointInPlot(const vtkVector2f& position, const vtkVector2f& tolerance,
446  vtkVector2f& plotPos, vtkPlot* plot, vtkIdType& segmentIndex);
447 
451  bool RemovePlotFromCorners(vtkPlot* plot);
452 
453  void ZoomInAxes(vtkAxis* x, vtkAxis* y, float* orign, float* max);
454 
458  void TransformBoxOrPolygon(bool polygonMode, vtkTransform2D* transform,
459  const vtkVector2f& mousePosition, vtkVector2f& min, vtkVector2f& max,
460  vtkContextPolygon& polygon);
461 };
462 
464 
470 {
474  int Index;
475 };
477 
478 #endif // vtkChartXY_h
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:41
data structure to represent key events.
Hold a reference to a vtkObjectBase instance.
int vtkIdType
Definition: vtkType.h:345
vtkStdString SeriesName
Definition: vtkChartXY.h:471
Class for drawing 2D primitives to a graphical context.
Definition: vtkContext2D.h:52
Factory class for drawing 2D charts.
Definition: vtkChart.h:44
takes care of drawing 2D axes
Definition: vtkAxis.h:68
data structure to represent mouse events.
vtkVector2i ScreenPosition
Definition: vtkChartXY.h:473
a simple class to control print indentation
Definition: vtkIndent.h:33
Some derived classes for the different vectors commonly used.
Definition: vtkVector.h:324
describes linear transformations via a 3x3 matrix
Abstract class for 2D plots.
Definition: vtkPlot.h:46
vtkVector2f Position
Definition: vtkChartXY.h:472
vtkSetMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
Factory class for drawing XY charts.
Definition: vtkChartXY.h:43
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:469
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)