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
takes care of drawing 2D axes
Definition: vtkAxis.h:72
provides a brush that fills shapes drawn by vtkContext2D.
Definition: vtkBrush.h:38
draw the chart legend
Hold mouse action mappings.
Definition: vtkChart.h:455
short & SelectPolygon()
Definition: vtkChart.h:463
short & operator[](int index)
Definition: vtkChart.h:464
short & operator[](int index)
Definition: vtkChart.h:473
Factory class for drawing 2D charts.
Definition: vtkChart.h:51
MouseClickActions ActionsClick
Definition: vtkChart.h:479
void AxisRangeForwarderCallback(vtkObject *, unsigned long, void *)
virtual void SetAutoSize(bool isAutoSized)
Set/get whether the chart should automatically resize to fill the current render window.
Definition: vtkChart.h:298
virtual bool GetShowLegend()
virtual vtkStdString GetTitle()
virtual vtkPlot * AddPlot(int type)
Add a plot to the chart, defaults to using the name of the y column.
virtual void ClearPlots()
Remove all plots from the chart.
int LayoutStrategy
Definition: vtkChart.h:435
virtual void SetTitle(const vtkStdString &title)
Get/set the title text of the chart.
vtkStdString Title
The title of the chart.
Definition: vtkChart.h:426
@ FUNCTIONALBAG
Definition: vtkChart.h:65
@ LINE
Definition: vtkChart.h:60
@ STACKED
Definition: vtkChart.h:63
@ POINTS
Definition: vtkChart.h:61
vtkTextProperty * TitleProperties
The text properties associated with the chart.
Definition: vtkChart.h:431
bool CalculateUnscaledPlotTransform(vtkAxis *x, vtkAxis *y, vtkTransform2D *transform)
Calculate the unshifted, and unscaled plot transform for the x and y axis.
@ SELECTION_PLOTS
Definition: vtkChart.h:165
@ SELECTION_ROWS
Definition: vtkChart.h:164
virtual bool GetAutoSize()
Definition: vtkChart.h:303
int SelectionMethod
Definition: vtkChart.h:448
virtual void SetAnnotationLink(vtkAnnotationLink *link)
Set the vtkAnnotationLink for the chart.
virtual int GetActionToButton(int action)
Get the mouse button associated with the supplied action.
virtual bool Paint(vtkContext2D *painter)=0
Paint event for the chart, called whenever the chart needs to be drawn.
MouseActions Actions
Definition: vtkChart.h:478
@ FILL_SCENE
Definition: vtkChart.h:278
@ FILL_RECT
Definition: vtkChart.h:279
void SetRightBorder(int border)
vtkAnnotationLink * AnnotationLink
Our annotation link, used for sharing selections etc.
Definition: vtkChart.h:401
vtkRectf GetSize()
Get the current size of the chart.
void SetBottomBorder(int border)
Set/get the borders of the chart (space in pixels around the chart).
@ SELECT_POLYGON
Definition: vtkChart.h:85
@ ZOOM_AXIS
Definition: vtkChart.h:82
@ SELECT
Definition: vtkChart.h:83
@ ZOOM
Definition: vtkChart.h:81
virtual int GetClickActionToButton(int action)
Get the mouse button associated with the supplied click action.
vtkRectf Size
Definition: vtkChart.h:433
virtual void SetSelectionMethod(int method)
Set the selection method, which controls how selections are handled by the chart.
virtual vtkAxis * GetAxis(int axisIndex)
Get the axis specified by axisIndex.
vtkSmartPointer< vtkBrush > BackgroundBrush
Brush to use for drawing the background.
Definition: vtkChart.h:441
virtual void SetClickActionToButton(int action, int button)
Assign action types to single mouse clicks.
EventIds
Enum of event type that are triggered by the charts.
Definition: vtkChart.h:92
virtual bool RemovePlotInstance(vtkPlot *plot)
Remove the given plot.
int SelectionMode
Definition: vtkChart.h:444
void SetTopBorder(int border)
bool RenderEmpty
Definition: vtkChart.h:436
void SetBackgroundBrush(vtkBrush *brush)
Set/Get the brush to use for the background color.
virtual void SetShowLegend(bool visible)
Set/get whether the chart should draw a legend.
void SetSize(const vtkRectf &rect)
Set the size of the chart.
virtual vtkIdType GetNumberOfPlots()
Get the number of plots the chart contains.
virtual void RecalculateBounds()
Request that the chart recalculates the range of its axes.
virtual void SetSelectionMode(int)
Set/get the Selection Mode that will be used by the chart while doing selection.
virtual bool RemovePlot(vtkIdType index)
Remove the plot at the specified index, returns true if successful, false if the index was invalid.
virtual vtkChartLegend * GetLegend()
Get the legend for the chart, if available.
virtual vtkIdType GetNumberOfAxes()
Get the number of axes in the current chart.
virtual void SetActionToButton(int action, int button)
Assign action types to mouse buttons.
void AttachAxisRangeListener(vtkAxis *)
Attach axis range listener so we can forward those events at the chart level.
virtual vtkIdType AddPlot(vtkPlot *plot)
Add a plot to the chart.
vtkBrush * GetBackgroundBrush()
virtual void PrintSelf(ostream &os, vtkIndent indent)
Methods invoked by print to print information about the object including superclasses.
virtual int GetSelectionMethod()
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 ...
virtual vtkPlot * GetPlot(vtkIdType index)
Get the plot at the specified index, returns null if the index is invalid.
void SetLeftBorder(int border)
bool ShowLegend
Display the legend?
Definition: vtkChart.h:421
void SetBorders(int left, int bottom, int right, int top)
Set/get the borders of the chart (space in pixels around the chart).
Class for drawing 2D primitives to a graphical context.
Definition: vtkContext2D.h:58
base class for items that are part of a vtkContextScene.
Provides a 2D scene for vtkContextItem objects.
a simple class to control print indentation
Definition: vtkIndent.h:40
provide event-driven interface to the rendering window (defines trackball mode)
abstract base class for most VTK objects
Definition: vtkObject.h:60
Abstract class for 2D plots.
Definition: vtkPlot.h:53
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:49
represent text properties.
describes linear transformations via a 3x3 matrix
@ top
Definition: vtkX3D.h:502
@ type
Definition: vtkX3D.h:516
@ bottom
Definition: vtkX3D.h:290
@ index
Definition: vtkX3D.h:246
@ title
Definition: vtkX3D.h:500
vtkSetMacro(IgnoreDriverBugs, bool)
Updates the extensions string.
int vtkIdType
Definition: vtkType.h:287