VTK
vtkChart.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkChart.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 
30 #ifndef vtkChart_h
31 #define vtkChart_h
32 
33 #include "vtkChartsCoreModule.h" // For export macro
34 #include "vtkContextItem.h"
35 #include "vtkRect.h" // For vtkRectf
36 #include "vtkStdString.h" // For vtkStdString ivars
37 #include "vtkSmartPointer.h" // For SP ivars
38 
39 class vtkTransform2D;
40 class vtkContextScene;
41 class vtkPlot;
42 class vtkAxis;
43 class vtkBrush;
44 class vtkTextProperty;
45 class vtkChartLegend;
46 
47 class vtkInteractorStyle;
48 class vtkAnnotationLink;
49 
50 class VTKCHARTSCORE_EXPORT vtkChart : public vtkContextItem
51 {
52 public:
53  vtkTypeMacro(vtkChart, vtkContextItem);
54  virtual void PrintSelf(ostream &os, vtkIndent indent);
55 
59  enum {
62  BAR,
64  BAG,
66  AREA};
67 
79  enum {
80  PAN = 0,
84  SELECT_RECTANGLE = SELECT,
86  NOTIFY
87  };
88 
92  enum EventIds {
93  UpdateRange = 1002
94  };
95 
99  virtual bool Paint(vtkContext2D *painter) = 0;
100 
104  virtual vtkPlot* AddPlot(int type);
105 
109  virtual vtkIdType AddPlot(vtkPlot* plot);
110 
115  virtual bool RemovePlot(vtkIdType index);
116 
122  virtual bool RemovePlotInstance(vtkPlot* plot);
123 
127  virtual void ClearPlots();
128 
133 
138 
143  virtual vtkAxis* GetAxis(int axisIndex);
144 
149 
154  virtual void RecalculateBounds();
155 
163  enum {
166  SELECTION_COLUMNS
167  };
168 
170 
178  virtual void SetSelectionMethod(int method);
179  virtual int GetSelectionMethod();
181 
186 
188 
191  vtkGetObjectMacro(AnnotationLink, vtkAnnotationLink);
193 
195 
198  vtkSetVector2Macro(Geometry, int);
199  vtkGetVector2Macro(Geometry, int);
201 
203 
206  vtkSetVector2Macro(Point1, int);
207  vtkGetVector2Macro(Point1, int);
209 
211 
214  vtkSetVector2Macro(Point2, int);
215  vtkGetVector2Macro(Point2, int);
217 
219 
222  virtual void SetShowLegend(bool visible);
223  virtual bool GetShowLegend();
225 
231 
233 
236  virtual void SetTitle(const vtkStdString &title);
239 
241 
244  vtkGetObjectMacro(TitleProperties, vtkTextProperty);
246 
248 
251  void SetBottomBorder(int border);
252  void SetTopBorder(int border);
253  void SetLeftBorder(int border);
254  void SetRightBorder(int border);
256 
260  void SetBorders(int left, int bottom, int right, int top);
261 
267  void SetSize(const vtkRectf &rect);
268 
273 
277  enum {
278  FILL_SCENE, // Attempt to fill the entire scene.
279  FILL_RECT, // Attempt to supply the supplied vtkRectf in Size.
280  AXES_TO_RECT // Put the corners of the axes on the vtkRectf in Size.
281  };
282 
284 
289  vtkSetMacro(LayoutStrategy, int);
290  vtkGetMacro(LayoutStrategy, int);
292 
294 
298  virtual void SetAutoSize(bool isAutoSized)
299  {
300  this->LayoutStrategy = isAutoSized ? vtkChart::FILL_SCENE :
302  }
303  virtual bool GetAutoSize()
304  {
305  return this->LayoutStrategy == vtkChart::FILL_SCENE ? true : false;
306  }
308 
310 
318  vtkSetMacro(RenderEmpty, bool);
319  vtkGetMacro(RenderEmpty, bool);
321 
332  virtual void SetActionToButton(int action, int button);
333 
338  virtual int GetActionToButton(int action);
339 
345  virtual void SetClickActionToButton(int action, int button);
346 
352  virtual int GetClickActionToButton(int action);
353 
355 
361 
363 
368  virtual void SetSelectionMode(int);
369  vtkGetMacro(SelectionMode, int);
371 
372 protected:
375 
383  vtkTransform2D *transform);
384 
389  vtkTransform2D *transform);
390 
395 
396  void AxisRangeForwarderCallback(vtkObject*,unsigned long, void*);
397 
402 
406  int Geometry[2];
407 
411  int Point1[2];
412 
416  int Point2[2];
417 
422 
427 
432 
434  // The layout strategy to employ when fitting the chart into the space.
437 
442 
443  // The mode when the chart is doing selection.
445 
446  // How plot selections are handled, SELECTION_ROWS (default) or
447  // SELECTION_PLOTS - based on the plot that created the selection.
449 
451 
455  {
456  public:
458  enum { MaxAction = 5 };
459  short& Pan() { return Data[0]; }
460  short& Zoom() { return Data[1]; }
461  short& ZoomAxis() { return Data[2]; }
462  short& Select() { return Data[3]; }
463  short& SelectPolygon() { return Data[4]; }
464  short& operator[](int index) { return Data[index]; }
465  short Data[MaxAction];
466  };
468  {
469  public:
471  short& Notify() { return Data[0]; }
472  short& Select() { return Data[1]; }
473  short& operator[](int index) { return Data[index]; }
474  short Data[2];
475  };
477 
480 
481 private:
482  vtkChart(const vtkChart &) VTK_DELETE_FUNCTION;
483  void operator=(const vtkChart &) VTK_DELETE_FUNCTION;
484 };
485 
486 #endif //vtkChart_h
vtkChart
Factory class for drawing 2D charts.
Definition: vtkChart.h:51
vtkBrush
provides a brush that fills shapes drawn by vtkContext2D.
Definition: vtkBrush.h:38
vtkChart::Actions
MouseActions Actions
Definition: vtkChart.h:478
vtkChart::MouseClickActions::operator[]
short & operator[](int index)
Definition: vtkChart.h:473
vtkChart::GetNumberOfPlots
virtual vtkIdType GetNumberOfPlots()
Get the number of plots the chart contains.
vtkStdString.h
vtkChart::MouseActions
Hold mouse action mappings.
Definition: vtkChart.h:455
vtkChart::MouseActions::MouseActions
MouseActions()
vtkChart::RemovePlot
virtual bool RemovePlot(vtkIdType index)
Remove the plot at the specified index, returns true if successful, false if the index was invalid.
vtkChart::MouseClickActions
Definition: vtkChart.h:468
vtkChart::FILL_SCENE
@ FILL_SCENE
Definition: vtkChart.h:278
vtkChart::MouseClickActions::Select
short & Select()
Definition: vtkChart.h:472
vtkChart::SetLeftBorder
void SetLeftBorder(int border)
vtkChart::SetSelectionMethod
virtual void SetSelectionMethod(int method)
Set the selection method, which controls how selections are handled by the chart.
vtkChart::POINTS
@ POINTS
Definition: vtkChart.h:61
vtkChart::GetShowLegend
virtual bool GetShowLegend()
vtkChart::SetBorders
void SetBorders(int left, int bottom, int right, int top)
Set/get the borders of the chart (space in pixels around the chart).
vtkChart::ZOOM
@ ZOOM
Definition: vtkChart.h:81
vtkChart::ZOOM_AXIS
@ ZOOM_AXIS
Definition: vtkChart.h:82
vtkChart::GetBackgroundBrush
vtkBrush * GetBackgroundBrush()
vtkX3D::type
@ type
Definition: vtkX3D.h:516
vtkIdType
int vtkIdType
Definition: vtkType.h:287
vtkTransform2D
describes linear transformations via a 3x3 matrix
Definition: vtkTransform2D.h:52
vtkChart::SetSelectionMode
virtual void SetSelectionMode(int)
Set/get the Selection Mode that will be used by the chart while doing selection.
vtkChart::ActionsClick
MouseClickActions ActionsClick
Definition: vtkChart.h:479
vtkChartLegend
draw the chart legend
Definition: vtkChartLegend.h:43
vtkChart::SELECTION_ROWS
@ SELECTION_ROWS
Definition: vtkChart.h:164
vtkChart::STACKED
@ STACKED
Definition: vtkChart.h:63
vtkChart::RenderEmpty
bool RenderEmpty
Definition: vtkChart.h:436
vtkChart::AddPlot
virtual vtkIdType AddPlot(vtkPlot *plot)
Add a plot to the chart.
vtkChart::~vtkChart
~vtkChart()
vtkChart::LINE
@ LINE
Definition: vtkChart.h:60
vtkSmartPointer< vtkBrush >
vtkObject
abstract base class for most VTK objects
Definition: vtkObject.h:60
vtkChart::CalculatePlotTransform
bool CalculatePlotTransform(vtkAxis *x, vtkAxis *y, vtkTransform2D *transform)
Given the x and y vtkAxis, and a transform, calculate the transform that the points in a chart would ...
vtkChart::BackgroundBrush
vtkSmartPointer< vtkBrush > BackgroundBrush
Brush to use for drawing the background.
Definition: vtkChart.h:441
vtkChart::Paint
virtual bool Paint(vtkContext2D *painter)=0
Paint event for the chart, called whenever the chart needs to be drawn.
vtkChart::SetAnnotationLink
virtual void SetAnnotationLink(vtkAnnotationLink *link)
Set the vtkAnnotationLink for the chart.
vtkContext2D
Class for drawing 2D primitives to a graphical context.
Definition: vtkContext2D.h:58
vtkChart::AddPlot
virtual vtkPlot * AddPlot(int type)
Add a plot to the chart, defaults to using the name of the y column.
vtkContextItem.h
vtkX3D::top
@ top
Definition: vtkX3D.h:502
vtkPlot
Abstract class for 2D plots.
Definition: vtkPlot.h:53
vtkChart::GetClickActionToButton
virtual int GetClickActionToButton(int action)
Get the mouse button associated with the supplied click action.
vtkChart::AnnotationLink
vtkAnnotationLink * AnnotationLink
Our annotation link, used for sharing selections etc.
Definition: vtkChart.h:401
vtkChart::SELECTION_PLOTS
@ SELECTION_PLOTS
Definition: vtkChart.h:165
vtkChart::GetTitle
virtual vtkStdString GetTitle()
vtkChart::SetBackgroundBrush
void SetBackgroundBrush(vtkBrush *brush)
Set/Get the brush to use for the background color.
vtkChart::SELECT
@ SELECT
Definition: vtkChart.h:83
vtkChart::CalculateUnscaledPlotTransform
bool CalculateUnscaledPlotTransform(vtkAxis *x, vtkAxis *y, vtkTransform2D *transform)
Calculate the unshifted, and unscaled plot transform for the x and y axis.
vtkChart::ShowLegend
bool ShowLegend
Display the legend?
Definition: vtkChart.h:421
vtkChart::GetActionToButton
virtual int GetActionToButton(int action)
Get the mouse button associated with the supplied action.
vtkX3D::title
@ title
Definition: vtkX3D.h:500
vtkContextScene
Provides a 2D scene for vtkContextItem objects.
Definition: vtkContextScene.h:51
vtkChart::MouseClickActions::Notify
short & Notify()
Definition: vtkChart.h:471
vtkChart::SetSize
void SetSize(const vtkRectf &rect)
Set the size of the chart.
vtkX3D::bottom
@ bottom
Definition: vtkX3D.h:290
vtkChart::PrintSelf
virtual void PrintSelf(ostream &os, vtkIndent indent)
Methods invoked by print to print information about the object including superclasses.
vtkChart::GetSize
vtkRectf GetSize()
Get the current size of the chart.
vtkChart::SetClickActionToButton
virtual void SetClickActionToButton(int action, int button)
Assign action types to single mouse clicks.
vtkChart::GetLegend
virtual vtkChartLegend * GetLegend()
Get the legend for the chart, if available.
vtkChart::BAG
@ BAG
Definition: vtkChart.h:64
vtkChart::MouseActions::operator[]
short & operator[](int index)
Definition: vtkChart.h:464
vtkChart::AttachAxisRangeListener
void AttachAxisRangeListener(vtkAxis *)
Attach axis range listener so we can forward those events at the chart level.
vtkRect.h
vtkChart::MouseClickActions::MouseClickActions
MouseClickActions()
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:40
vtkChart::RemovePlotInstance
virtual bool RemovePlotInstance(vtkPlot *plot)
Remove the given plot.
vtkChart::GetPlot
virtual vtkPlot * GetPlot(vtkIdType index)
Get the plot at the specified index, returns null if the index is invalid.
vtkSmartPointer.h
vtkChart::SetActionToButton
virtual void SetActionToButton(int action, int button)
Assign action types to mouse buttons.
vtkChart::vtkChart
vtkChart()
vtkChart::SelectionMode
int SelectionMode
Definition: vtkChart.h:444
vtkChart::GetAutoSize
virtual bool GetAutoSize()
Definition: vtkChart.h:303
vtkChart::Size
vtkRectf Size
Definition: vtkChart.h:433
vtkChart::FILL_RECT
@ FILL_RECT
Definition: vtkChart.h:279
vtkInteractorStyle
provide event-driven interface to the rendering window (defines trackball mode)
Definition: vtkInteractorStyle.h:134
vtkTextProperty
represent text properties.
Definition: vtkTextProperty.h:40
vtkChart::FUNCTIONALBAG
@ FUNCTIONALBAG
Definition: vtkChart.h:65
vtkContextItem
base class for items that are part of a vtkContextScene.
Definition: vtkContextItem.h:35
vtkSetMacro
vtkSetMacro(IgnoreDriverBugs, bool)
Updates the extensions string.
vtkChart::EventIds
EventIds
Enum of event type that are triggered by the charts.
Definition: vtkChart.h:92
vtkChart::MouseActions::Select
short & Select()
Definition: vtkChart.h:462
vtkChart::Title
vtkStdString Title
The title of the chart.
Definition: vtkChart.h:426
vtkChart::LayoutStrategy
int LayoutStrategy
Definition: vtkChart.h:435
vtkChart::SetAutoSize
virtual void SetAutoSize(bool isAutoSized)
Set/get whether the chart should automatically resize to fill the current render window.
Definition: vtkChart.h:298
vtkAxis
takes care of drawing 2D axes
Definition: vtkAxis.h:72
vtkChart::MouseActions::ZoomAxis
short & ZoomAxis()
Definition: vtkChart.h:461
vtkChart::GetSelectionMethod
virtual int GetSelectionMethod()
vtkChart::ClearPlots
virtual void ClearPlots()
Remove all plots from the chart.
vtkChart::RecalculateBounds
virtual void RecalculateBounds()
Request that the chart recalculates the range of its axes.
vtkChart::MouseActions::Pan
short & Pan()
Definition: vtkChart.h:459
vtkChart::MouseActions::SelectPolygon
short & SelectPolygon()
Definition: vtkChart.h:463
vtkChart::SetBottomBorder
void SetBottomBorder(int border)
Set/get the borders of the chart (space in pixels around the chart).
vtkChart::TitleProperties
vtkTextProperty * TitleProperties
The text properties associated with the chart.
Definition: vtkChart.h:431
vtkChart::GetNumberOfAxes
virtual vtkIdType GetNumberOfAxes()
Get the number of axes in the current chart.
vtkChart::MouseActions::Zoom
short & Zoom()
Definition: vtkChart.h:460
vtkChart::SelectionMethod
int SelectionMethod
Definition: vtkChart.h:448
vtkStdString
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:49
vtkChart::SELECT_POLYGON
@ SELECT_POLYGON
Definition: vtkChart.h:85
vtkChart::BAR
@ BAR
Definition: vtkChart.h:62
vtkX3D::index
@ index
Definition: vtkX3D.h:246
vtkChart::GetAxis
virtual vtkAxis * GetAxis(int axisIndex)
Get the axis specified by axisIndex.
vtkChart::SetTitle
virtual void SetTitle(const vtkStdString &title)
Get/set the title text of the chart.
vtkChart::AxisRangeForwarderCallback
void AxisRangeForwarderCallback(vtkObject *, unsigned long, void *)
vtkRectf
Definition: vtkRect.h:297
vtkChart::SetTopBorder
void SetTopBorder(int border)
vtkChart::SetShowLegend
virtual void SetShowLegend(bool visible)
Set/get whether the chart should draw a legend.
vtkChart::SetRightBorder
void SetRightBorder(int border)