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 "vtkChartsCoreModule.h" // For export macro
37 #include "vtkChart.h"
38 #include "vtkSmartPointer.h" // For SP ivars
39 #include "vtkVector.h" // For vtkVector2f in struct
40 #include "vtkContextPolygon.h" // For vtkContextPolygon
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  virtual void PrintSelf(ostream &os, vtkIndent indent);
54 
58  static vtkChartXY *New();
59 
65  virtual void Update();
66 
70  virtual bool Paint(vtkContext2D *painter);
71 
75  virtual vtkPlot * AddPlot(int type);
76 
80  virtual vtkIdType AddPlot(vtkPlot* plot);
81 
86  virtual bool RemovePlot(vtkIdType index);
87 
91  virtual void ClearPlots();
92 
97 
103 
110 
117  virtual vtkIdType StackPlotAbove(vtkPlot* plot, vtkPlot* under);
118 
125 
132  virtual vtkIdType StackPlotUnder(vtkPlot* plot, vtkPlot* above);
133 
138 
142  int GetPlotCorner(vtkPlot *plot);
143 
147  void SetPlotCorner(vtkPlot *plot, int corner);
148 
154  virtual vtkAxis* GetAxis(int axisIndex);
155 
159  virtual void SetShowLegend(bool visible);
160 
165 
169  virtual void SetTooltip(vtkTooltipItem *tooltip);
170 
175 
180 
185  virtual void RecalculateBounds();
186 
194  virtual void SetSelectionMethod(int method);
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 &,
273  const vtkVector2d &,
274  vtkIdType, vtkPlot*,
275  vtkIdType segmentIndex = -1);
276 
280  virtual bool Hit(const vtkContextMouseEvent &mouse);
281 
285  virtual bool MouseEnterEvent(const vtkContextMouseEvent &mouse);
286 
290  virtual bool MouseMoveEvent(const vtkContextMouseEvent &mouse);
291 
295  virtual bool MouseLeaveEvent(const vtkContextMouseEvent &mouse);
296 
300  virtual bool MouseButtonPressEvent(const vtkContextMouseEvent &mouse);
301 
305  virtual bool MouseButtonReleaseEvent(const vtkContextMouseEvent &mouse);
306 
310  virtual bool MouseWheelEvent(const vtkContextMouseEvent &mouse, int delta);
311 
315  virtual bool KeyPressEvent(const vtkContextKeyEvent &key);
316 
317 protected:
320 
325 
331 
337  virtual bool UpdateLayout(vtkContext2D* painter);
338 
344  virtual int GetLegendBorder(vtkContext2D* painter, int axisPosition);
345 
350  virtual void SetLegendPosition(const vtkRectf& rect);
351 
356 
361 
366 
371 
375  bool DrawBox;
376 
382 
387 
392 
399 
403  bool AutoAxes;
404 
409 
415 
421 
428 
434 
440 
441 private:
442  vtkChartXY(const vtkChartXY &) VTK_DELETE_FUNCTION;
443  void operator=(const vtkChartXY &) VTK_DELETE_FUNCTION;
444 
445  vtkChartXYPrivate *ChartPrivate; // Private class where I hide my STL containers
446 
450  void CalculateBarPlots();
451 
457  bool LocatePointInPlots(const vtkContextMouseEvent &mouse,
458  int invokeEvent = -1);
459 
460  int LocatePointInPlot(const vtkVector2f &position,
461  const vtkVector2f &tolerance, vtkVector2f &plotPos,
462  vtkPlot *plot, vtkIdType &segmentIndex);
463 
467  bool RemovePlotFromCorners(vtkPlot *plot);
468 
469  void ZoomInAxes(vtkAxis *x, vtkAxis *y, float *orign, float *max);
470 
474  void TransformBoxOrPolygon(bool polygonMode, vtkTransform2D *transform,
475  const vtkVector2f &mousePosition,
476  vtkVector2f &min, vtkVector2f &max,
477  vtkContextPolygon &polygon);
478 
479 };
480 
482 
488 {
492  int Index;
493 };
495 
496 #endif //vtkChartXY_h
vtkChart
Factory class for drawing 2D charts.
Definition: vtkChart.h:51
vtkChartXY::MouseBox
vtkRectf MouseBox
The box created as the mouse is dragged around the screen.
Definition: vtkChartXY.h:370
vtkChartXY::AddPlot
virtual vtkIdType AddPlot(vtkPlot *plot)
Adds a plot to the chart.
vtkContextPolygon.h
vtkContextMouseEvent
data structure to represent mouse events.
Definition: vtkContextMouseEvent.h:41
vtkChartXY::GetPlotIndex
virtual vtkIdType GetPlotIndex(vtkPlot *)
Get the index of the specified plot, returns -1 if the plot does not belong to the chart.
vtkContextKeyEvent
data structure to represent key events.
Definition: vtkContextKeyEvent.h:35
vtkChartXY::GetLegend
virtual vtkChartLegend * GetLegend()
Get the vtkChartLegend object that will be displayed by the chart.
vtkChartXY::StackPlotAbove
virtual vtkIdType StackPlotAbove(vtkPlot *plot, vtkPlot *under)
Raises the plot above the under plot.
vtkChartXY::Legend
vtkSmartPointer< vtkChartLegend > Legend
The legend for the chart.
Definition: vtkChartXY.h:355
vtkX3D::type
@ type
Definition: vtkX3D.h:516
vtkIdType
int vtkIdType
Definition: vtkType.h:287
vtkChartXY::MouseButtonPressEvent
virtual bool MouseButtonPressEvent(const vtkContextMouseEvent &mouse)
Mouse button down event.
vtkChartPlotData
Small struct used by InvokeEvent to send some information about the point that was clicked on.
Definition: vtkChartXY.h:488
vtkChartXY::RaisePlot
vtkIdType RaisePlot(vtkPlot *plot)
Raises the plot to the top of the plot's stack.
vtkTransform2D
describes linear transformations via a 3x3 matrix
Definition: vtkTransform2D.h:52
vtkX3D::key
@ key
Definition: vtkX3D.h:257
vtkChartLegend
draw the chart legend
Definition: vtkChartLegend.h:43
vtkChart.h
vtkChartXY::GetNumberOfAxes
virtual vtkIdType GetNumberOfAxes()
Get the number of axes in the current chart.
vtkChartXY::~vtkChartXY
~vtkChartXY()
vtkChartXY::GetAxis
virtual vtkAxis * GetAxis(int axisIndex)
Get the axis specified by axisIndex.
vtkChartPlotData::SeriesName
vtkStdString SeriesName
Definition: vtkChartXY.h:489
vtkChartXY::Hit
virtual bool Hit(const vtkContextMouseEvent &mouse)
Return true if the supplied x, y coordinate is inside the item.
vtkChartXY::Tooltip
vtkSmartPointer< vtkTooltipItem > Tooltip
The tooltip item for the chart - can be used to display extra information.
Definition: vtkChartXY.h:360
vtkSmartPointer< vtkChartLegend >
vtkChartXY::RemovePlot
virtual bool RemovePlot(vtkIdType index)
Remove the plot at the specified index, returns true if successful, false if the index was invalid.
vtkVector.h
vtkChartXY::GetNumberOfPlots
virtual vtkIdType GetNumberOfPlots()
Get the number of plots the chart contains.
vtkChartXY::SetLegendPosition
virtual void SetLegendPosition(const vtkRectf &rect)
Called after the edges of the chart are decided, set the position of the legend, depends upon its ali...
vtkChartXY::LowerPlot
vtkIdType LowerPlot(vtkPlot *plot)
Lowers the plot to the bottom of the plot's stack.
vtkTooltipItem
takes care of drawing 2D axes
Definition: vtkTooltipItem.h:40
vtkChartXY::LayoutChanged
bool LayoutChanged
Indicate if the layout has changed in some way that would require layout code to be called.
Definition: vtkChartXY.h:420
vtkChartXY::ClearPlots
virtual void ClearPlots()
Remove all plots from the chart.
vtkContext2D
Class for drawing 2D primitives to a graphical context.
Definition: vtkContext2D.h:58
vtkPlot
Abstract class for 2D plots.
Definition: vtkPlot.h:53
vtkChartXY::AutoAxes
bool AutoAxes
Should axes be turned on and off automatically - defaults to on.
Definition: vtkChartXY.h:403
vtkChartXY::BarWidthFraction
float BarWidthFraction
The fraction of the interval taken up along the x axis by any bars that are drawn on the chart.
Definition: vtkChartXY.h:414
vtkChartXY::DrawNearestPoint
bool DrawNearestPoint
Should we draw the location of the nearest point on the plot?
Definition: vtkChartXY.h:391
vtkChartXY::RecalculateBounds
virtual void RecalculateBounds()
Request that the chart recalculates the range of its axes.
max
#define max(a, b)
Definition: vtkX3DExporterFIWriterHelper.h:31
vtkVector2d
Definition: vtkVector.h:347
vtkChartXY::ZoomWithMouseWheel
bool ZoomWithMouseWheel
Property to enable zooming the chart with the mouse wheel.
Definition: vtkChartXY.h:433
vtkX3D::position
@ position
Definition: vtkX3D.h:261
vtkChartXY::PrintSelf
virtual void PrintSelf(ostream &os, vtkIndent indent)
Methods invoked by print to print information about the object including superclasses.
vtkChartXY::MouseMoveEvent
virtual bool MouseMoveEvent(const vtkContextMouseEvent &mouse)
Mouse move event.
vtkChartXY::DrawAxesAtOrigin
bool DrawAxesAtOrigin
Keep the axes drawn at the origin? This will attempt to keep the axes drawn at the origin,...
Definition: vtkChartXY.h:398
vtkChartXY::RecalculatePlotBounds
void RecalculatePlotBounds()
Calculate the optimal zoom level such that all of the points to be plotted will fit into the plot are...
vtkChartXY::New
static vtkChartXY * New()
Creates a 2D Chart object.
vtkChartXY::GetPlot
virtual vtkPlot * GetPlot(vtkIdType index)
Get the plot at the specified index, returns null if the index is invalid.
vtkChartXY::MouseWheelEvent
virtual bool MouseWheelEvent(const vtkContextMouseEvent &mouse, int delta)
Mouse wheel event, positive delta indicates forward movement of the wheel.
vtkPlotGrid
takes care of drawing the plot grid
Definition: vtkPlotGrid.h:39
vtkChartXY::Paint
virtual bool Paint(vtkContext2D *painter)
Paint event for the chart, called whenever the chart needs to be drawn.
vtkChartXY::AdjustLowerBoundForLogPlot
bool AdjustLowerBoundForLogPlot
Property to adjust the minimum of a logarithmic axis to be greater than 0, regardless of the minimum ...
Definition: vtkChartXY.h:439
vtkChartXY::ForceAxesToBounds
bool ForceAxesToBounds
Property to force the axes to have their Minimum and Maximum properties inside the plot boundaries.
Definition: vtkChartXY.h:427
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:40
vtkChartXY::PlotTransformValid
bool PlotTransformValid
Does the plot area transform need to be recalculated?
Definition: vtkChartXY.h:365
vtkChartXY::GetTooltip
virtual vtkTooltipItem * GetTooltip()
Get the vtkTooltipItem object that will be displayed by the chart.
vtkChartXY::RecalculatePlotTransforms
void RecalculatePlotTransforms()
Recalculate the necessary transforms.
vtkSmartPointer.h
vtkChartXY::Update
virtual void Update()
Perform any updates to the item that may be necessary before rendering.
vtkContextPolygon
Definition: vtkContextPolygon.h:27
vtkChartXY::KeyPressEvent
virtual bool KeyPressEvent(const vtkContextKeyEvent &key)
Key press event.
vtkChartXY::GetLegendBorder
virtual int GetLegendBorder(vtkContext2D *painter, int axisPosition)
Layout for the legend if it is visible.
vtkChartPlotData::ScreenPosition
vtkVector2i ScreenPosition
Definition: vtkChartXY.h:491
vtkChartXY::SetSelectionMethod
virtual void SetSelectionMethod(int method)
Set the selection method, which controls how selections are handled by the chart.
vtkChartXY::HiddenAxisBorder
int HiddenAxisBorder
Size of the border when an axis is hidden.
Definition: vtkChartXY.h:408
vtkBooleanMacro
vtkBooleanMacro(IgnoreDriverBugs, bool)
Updates the extensions string.
vtkSetMacro
vtkSetMacro(IgnoreDriverBugs, bool)
Updates the extensions string.
vtkAxis
takes care of drawing 2D axes
Definition: vtkAxis.h:72
vtkChartXY::SetTooltipInfo
virtual void SetTooltipInfo(const vtkContextMouseEvent &, const vtkVector2d &, vtkIdType, vtkPlot *, vtkIdType segmentIndex=-1)
Set the information passed to the tooltip.
vtkChartPlotData::Position
vtkVector2f Position
Definition: vtkChartXY.h:490
vtkChartXY::SelectionPolygon
vtkContextPolygon SelectionPolygon
The polygon created as the mouse is dragged around the screen when in polygonal selection mode.
Definition: vtkChartXY.h:381
vtkChartXY::UpdateLayout
virtual bool UpdateLayout(vtkContext2D *painter)
Update the layout of the chart, this may require the vtkContext2D in order to get font metrics etc.
vtkChartXY::MouseLeaveEvent
virtual bool MouseLeaveEvent(const vtkContextMouseEvent &mouse)
Mouse leave event.
vtkVector2i
Some derived classes for the different vectors commonly used.
Definition: vtkVector.h:328
vtkChartPlotData::Index
int Index
Definition: vtkChartXY.h:492
vtkChartXY
Factory class for drawing XY charts.
Definition: vtkChartXY.h:50
vtkStdString
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:49
vtkChartXY::GetPlotCorner
int GetPlotCorner(vtkPlot *plot)
Figure out which quadrant the plot is in.
vtkChartXY::DrawSelectionPolygon
bool DrawSelectionPolygon
Should the selection polygon be drawn.
Definition: vtkChartXY.h:386
vtkChartXY::DrawBox
bool DrawBox
Should the box be drawn (could be selection, zoom etc).
Definition: vtkChartXY.h:375
vtkX3D::index
@ index
Definition: vtkX3D.h:246
vtkChartXY::MouseEnterEvent
virtual bool MouseEnterEvent(const vtkContextMouseEvent &mouse)
Mouse enter event.
vtkRectf
Definition: vtkRect.h:297
vtkChartXY::AddPlot
virtual vtkPlot * AddPlot(int type)
Add a plot to the chart, defaults to using the name of the y column.
vtkVector2f
Definition: vtkVector.h:338
vtkChartXY::StackPlotUnder
virtual vtkIdType StackPlotUnder(vtkPlot *plot, vtkPlot *above)
Lowers the plot under the above plot.
vtkChartXY::SetPlotCorner
void SetPlotCorner(vtkPlot *plot, int corner)
Figure out which quadrant the plot is in.
vtkChartXY::vtkChartXY
vtkChartXY()
vtkChartXY::MouseButtonReleaseEvent
virtual bool MouseButtonReleaseEvent(const vtkContextMouseEvent &mouse)
Mouse button release event.
vtkChartXY::SetShowLegend
virtual void SetShowLegend(bool visible)
Set whether the chart should draw a legend.
vtkChartXY::SetTooltip
virtual void SetTooltip(vtkTooltipItem *tooltip)
Set the vtkTooltipItem object that will be displayed by the chart.