VTK  9.0.1
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 
24 #ifndef vtkChart_h
25 #define vtkChart_h
26 
27 #include "vtkChartsCoreModule.h" // For export macro
28 #include "vtkContextItem.h"
29 #include "vtkRect.h" // For vtkRectf
30 #include "vtkSmartPointer.h" // For SP ivars
31 #include "vtkStdString.h" // For vtkStdString ivars
32 
33 class vtkTransform2D;
34 class vtkContextScene;
35 class vtkPlot;
36 class vtkAxis;
37 class vtkBrush;
38 class vtkTextProperty;
39 class vtkChartLegend;
40 
41 class vtkInteractorStyle;
42 class vtkAnnotationLink;
43 
44 class VTKCHARTSCORE_EXPORT vtkChart : public vtkContextItem
45 {
46 public:
47  vtkTypeMacro(vtkChart, vtkContextItem);
48  void PrintSelf(ostream& os, vtkIndent indent) override;
49 
53  enum
54  {
57  BAR,
59  BAG,
61  AREA
62  };
63 
76  enum
77  {
78  PAN = 0,
82  SELECT_RECTANGLE = SELECT,
85  NOTIFY
86  };
87 
91  enum EventIds
92  {
93  UpdateRange = 1002
94  };
95 
99  bool Paint(vtkContext2D* painter) override = 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  virtual void SetAxis(int axisIndex, vtkAxis*);
150 
155 
160  virtual void RecalculateBounds();
161 
169  enum
170  {
173  SELECTION_COLUMNS
174  };
175 
177 
185  virtual void SetSelectionMethod(int method);
186  virtual int GetSelectionMethod();
188 
193 
195 
198  vtkGetObjectMacro(AnnotationLink, vtkAnnotationLink);
200 
202 
205  vtkSetVector2Macro(Geometry, int);
206  vtkGetVector2Macro(Geometry, int);
208 
210 
213  vtkSetVector2Macro(Point1, int);
214  vtkGetVector2Macro(Point1, int);
216 
218 
221  vtkSetVector2Macro(Point2, int);
222  vtkGetVector2Macro(Point2, int);
224 
226 
229  virtual void SetShowLegend(bool visible);
230  virtual bool GetShowLegend();
232 
238 
240 
243  virtual void SetTitle(const vtkStdString& title);
246 
248 
251  vtkGetObjectMacro(TitleProperties, vtkTextProperty);
253 
255 
258  void SetBottomBorder(int border);
259  void SetTopBorder(int border);
260  void SetLeftBorder(int border);
261  void SetRightBorder(int border);
263 
267  void SetBorders(int left, int bottom, int right, int top);
268 
274  void SetSize(const vtkRectf& rect);
275 
280 
284  enum
285  {
286  FILL_SCENE, // Attempt to fill the entire scene.
287  FILL_RECT, // Attempt to supply the supplied vtkRectf in Size.
288  AXES_TO_RECT // Put the corners of the axes on the vtkRectf in Size.
289  };
290 
292 
297  vtkSetMacro(LayoutStrategy, int);
298  vtkGetMacro(LayoutStrategy, int);
300 
302 
306  virtual void SetAutoSize(bool isAutoSized)
307  {
308  this->LayoutStrategy = isAutoSized ? vtkChart::FILL_SCENE : vtkChart::FILL_RECT;
309  }
310  virtual bool GetAutoSize() { return this->LayoutStrategy == vtkChart::FILL_SCENE ? true : false; }
312 
314 
322  vtkSetMacro(RenderEmpty, bool);
323  vtkGetMacro(RenderEmpty, bool);
325 
336  virtual void SetActionToButton(int action, int button);
337 
342  virtual int GetActionToButton(int action);
343 
349  virtual void SetClickActionToButton(int action, int button);
350 
356  virtual int GetClickActionToButton(int action);
357 
359 
365 
367 
372  virtual void SetSelectionMode(int);
373  vtkGetMacro(SelectionMode, int);
375 
376 protected:
378  ~vtkChart() override;
379 
387 
392 
397 
398  void AxisRangeForwarderCallback(vtkObject*, unsigned long, void*);
399 
404 
408  int Geometry[2];
409 
413  int Point1[2];
414 
418  int Point2[2];
419 
424 
429 
434 
436  // The layout strategy to employ when fitting the chart into the space.
439 
444 
445  // The mode when the chart is doing selection.
447 
448  // How plot selections are handled, SELECTION_ROWS (default) or
449  // SELECTION_PLOTS - based on the plot that created the selection.
451 
453 
457  {
458  public:
460  enum
461  {
462  MaxAction = 6
463  };
464  short& Pan() { return Data[0]; }
465  short& Zoom() { return Data[1]; }
466  short& ZoomAxis() { return Data[2]; }
467  short& Select() { return Data[3]; }
468  short& SelectPolygon() { return Data[4]; }
469  short& ClickAndDrag() { return Data[5]; }
470  short& operator[](int index) { return Data[index]; }
471  short Data[MaxAction];
472  };
474  {
475  public:
477  short& Notify() { return Data[0]; }
478  short& Select() { return Data[1]; }
479  short& operator[](int index) { return Data[index]; }
480  short Data[2];
481  };
483 
486 
487 private:
488  vtkChart(const vtkChart&) = delete;
489  void operator=(const vtkChart&) = delete;
490 };
491 
492 #endif // vtkChart_h
vtkChart
Factory class for drawing 2D charts.
Definition: vtkChart.h:45
vtkBrush
provides a brush that fills shapes drawn by vtkContext2D.
Definition: vtkBrush.h:38
vtkChart::Actions
MouseActions Actions
Definition: vtkChart.h:484
vtkChart::MouseClickActions::operator[]
short & operator[](int index)
Definition: vtkChart.h:479
vtkChart::GetNumberOfPlots
virtual vtkIdType GetNumberOfPlots()
Get the number of plots the chart contains.
vtkStdString.h
vtkChart::MouseActions
Hold mouse action mappings.
Definition: vtkChart.h:457
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:474
vtkChart::MouseClickActions::Select
short & Select()
Definition: vtkChart.h:478
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::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::GetBackgroundBrush
vtkBrush * GetBackgroundBrush()
vtkX3D::type
@ type
Definition: vtkX3D.h:522
vtkIdType
int vtkIdType
Definition: vtkType.h:338
vtkChart::ZOOM_AXIS
@ ZOOM_AXIS
Definition: vtkChart.h:80
vtkTransform2D
describes linear transformations via a 3x3 matrix
Definition: vtkTransform2D.h:46
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:485
vtkChartLegend
draw the chart legend
Definition: vtkChartLegend.h:40
vtkChart::MouseActions::ClickAndDrag
short & ClickAndDrag()
Definition: vtkChart.h:469
vtkChart::RenderEmpty
bool RenderEmpty
Definition: vtkChart.h:438
vtkChart::AddPlot
virtual vtkIdType AddPlot(vtkPlot *plot)
Add a plot to the chart.
vtkSmartPointer< vtkBrush >
vtkObject
abstract base class for most VTK objects
Definition: vtkObject.h:54
vtkChart::SELECTION_PLOTS
@ SELECTION_PLOTS
Definition: vtkChart.h:172
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::SELECT
@ SELECT
Definition: vtkChart.h:81
vtkChart::POINTS
@ POINTS
Definition: vtkChart.h:56
vtkChart::BackgroundBrush
vtkSmartPointer< vtkBrush > BackgroundBrush
Brush to use for drawing the background.
Definition: vtkChart.h:443
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:53
vtkChart::SetAxis
virtual void SetAxis(int axisIndex, vtkAxis *)
Set the axis specified by axisIndex.
vtkChart::AddPlot
virtual vtkPlot * AddPlot(int type)
Add a plot to the chart, defaults to using the name of the y column.
vtkContextItem.h
vtkChart::BAG
@ BAG
Definition: vtkChart.h:59
vtkX3D::top
@ top
Definition: vtkX3D.h:508
vtkPlot
Abstract class for 2D plots.
Definition: vtkPlot.h:47
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:403
vtkChart::GetTitle
virtual vtkStdString GetTitle()
vtkChart::SetBackgroundBrush
void SetBackgroundBrush(vtkBrush *brush)
Set/Get the brush to use for the background color.
vtkChart::FILL_SCENE
@ FILL_SCENE
Definition: vtkChart.h:286
vtkChart::~vtkChart
~vtkChart() override
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:423
vtkChart::SELECTION_ROWS
@ SELECTION_ROWS
Definition: vtkChart.h:171
vtkChart::GetActionToButton
virtual int GetActionToButton(int action)
Get the mouse button associated with the supplied action.
vtkX3D::title
@ title
Definition: vtkX3D.h:506
vtkContextScene
Provides a 2D scene for vtkContextItem objects.
Definition: vtkContextScene.h:48
vtkChart::MouseClickActions::Notify
short & Notify()
Definition: vtkChart.h:477
vtkChart::SetSize
void SetSize(const vtkRectf &rect)
Set the size of the chart.
vtkChart::Paint
bool Paint(vtkContext2D *painter) override=0
Paint event for the chart, called whenever the chart needs to be drawn.
vtkX3D::bottom
@ bottom
Definition: vtkX3D.h:296
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::MouseActions::operator[]
short & operator[](int index)
Definition: vtkChart.h:470
vtkChart::AttachAxisRangeListener
void AttachAxisRangeListener(vtkAxis *)
Attach axis range listener so we can forward those events at the chart level.
vtkRect.h
vtkChart::STACKED
@ STACKED
Definition: vtkChart.h:58
vtkChart::MouseClickActions::MouseClickActions
MouseClickActions()
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:34
vtkChart::RemovePlotInstance
virtual bool RemovePlotInstance(vtkPlot *plot)
Remove the given plot.
vtkChart::FILL_RECT
@ FILL_RECT
Definition: vtkChart.h:287
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:446
vtkChart::GetAutoSize
virtual bool GetAutoSize()
Definition: vtkChart.h:310
vtkChart::Size
vtkRectf Size
Definition: vtkChart.h:435
vtkChart::CLICK_AND_DRAG
@ CLICK_AND_DRAG
Definition: vtkChart.h:84
vtkInteractorStyle
provide event-driven interface to the rendering window (defines trackball mode)
Definition: vtkInteractorStyle.h:139
vtkTextProperty
represent text properties.
Definition: vtkTextProperty.h:34
vtkContextItem
base class for items that are part of a vtkContextScene.
Definition: vtkContextItem.h:32
vtkChart::LINE
@ LINE
Definition: vtkChart.h:55
vtkChart::FUNCTIONALBAG
@ FUNCTIONALBAG
Definition: vtkChart.h:60
vtkChart::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
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:467
vtkChart::Title
vtkStdString Title
The title of the chart.
Definition: vtkChart.h:428
vtkChart::LayoutStrategy
int LayoutStrategy
Definition: vtkChart.h:437
vtkChart::SetAutoSize
virtual void SetAutoSize(bool isAutoSized)
Set/get whether the chart should automatically resize to fill the current render window.
Definition: vtkChart.h:306
vtkChart::BAR
@ BAR
Definition: vtkChart.h:57
vtkAxis
takes care of drawing 2D axes
Definition: vtkAxis.h:69
vtkChart::MouseActions::ZoomAxis
short & ZoomAxis()
Definition: vtkChart.h:466
vtkChart::GetSelectionMethod
virtual int GetSelectionMethod()
vtkChart::ClearPlots
virtual void ClearPlots()
Remove all plots from the chart.
vtkChart::ZOOM
@ ZOOM
Definition: vtkChart.h:79
vtkChart::RecalculateBounds
virtual void RecalculateBounds()
Request that the chart recalculates the range of its axes.
vtkChart::MouseActions::Pan
short & Pan()
Definition: vtkChart.h:464
vtkChart::MouseActions::SelectPolygon
short & SelectPolygon()
Definition: vtkChart.h:468
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:433
vtkChart::GetNumberOfAxes
virtual vtkIdType GetNumberOfAxes()
Get the number of axes in the current chart.
vtkChart::MouseActions::Zoom
short & Zoom()
Definition: vtkChart.h:465
vtkChart::SelectionMethod
int SelectionMethod
Definition: vtkChart.h:450
vtkStdString
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:35
vtkX3D::index
@ index
Definition: vtkX3D.h:252
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 *)
vtkChart::SELECT_POLYGON
@ SELECT_POLYGON
Definition: vtkChart.h:83
vtkRectf
Definition: vtkRect.h:327
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)