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 
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 "vtkStdString.h" // For vtkStdString ivars
31 #include "vtkSmartPointer.h" // For SP 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) VTK_OVERRIDE;
49 
53  enum {
56  BAR,
58  BAG,
60  AREA};
61 
73  enum {
74  PAN = 0,
78  SELECT_RECTANGLE = SELECT,
80  NOTIFY
81  };
82 
86  enum EventIds {
87  UpdateRange = 1002
88  };
89 
93  bool Paint(vtkContext2D *painter) VTK_OVERRIDE = 0;
94 
98  virtual vtkPlot* AddPlot(int type);
99 
103  virtual vtkIdType AddPlot(vtkPlot* plot);
104 
109  virtual bool RemovePlot(vtkIdType index);
110 
116  virtual bool RemovePlotInstance(vtkPlot* plot);
117 
121  virtual void ClearPlots();
122 
126  virtual vtkPlot* GetPlot(vtkIdType index);
127 
131  virtual vtkIdType GetNumberOfPlots();
132 
137  virtual vtkAxis* GetAxis(int axisIndex);
138 
142  virtual vtkIdType GetNumberOfAxes();
143 
148  virtual void RecalculateBounds();
149 
157  enum {
160  SELECTION_COLUMNS
161  };
162 
164 
172  virtual void SetSelectionMethod(int method);
173  virtual int GetSelectionMethod();
175 
179  virtual void SetAnnotationLink(vtkAnnotationLink *link);
180 
182 
185  vtkGetObjectMacro(AnnotationLink, vtkAnnotationLink);
187 
189 
192  vtkSetVector2Macro(Geometry, int);
193  vtkGetVector2Macro(Geometry, int);
195 
197 
200  vtkSetVector2Macro(Point1, int);
201  vtkGetVector2Macro(Point1, int);
203 
205 
208  vtkSetVector2Macro(Point2, int);
209  vtkGetVector2Macro(Point2, int);
211 
213 
216  virtual void SetShowLegend(bool visible);
217  virtual bool GetShowLegend();
219 
224  virtual vtkChartLegend * GetLegend();
225 
227 
230  virtual void SetTitle(const vtkStdString &title);
231  virtual vtkStdString GetTitle();
233 
235 
238  vtkGetObjectMacro(TitleProperties, vtkTextProperty);
240 
242 
245  void SetBottomBorder(int border);
246  void SetTopBorder(int border);
247  void SetLeftBorder(int border);
248  void SetRightBorder(int border);
250 
254  void SetBorders(int left, int bottom, int right, int top);
255 
261  void SetSize(const vtkRectf &rect);
262 
266  vtkRectf GetSize();
267 
271  enum {
272  FILL_SCENE, // Attempt to fill the entire scene.
273  FILL_RECT, // Attempt to supply the supplied vtkRectf in Size.
274  AXES_TO_RECT // Put the corners of the axes on the vtkRectf in Size.
275  };
276 
278 
283  vtkSetMacro(LayoutStrategy, int);
284  vtkGetMacro(LayoutStrategy, int);
286 
288 
292  virtual void SetAutoSize(bool isAutoSized)
293  {
294  this->LayoutStrategy = isAutoSized ? vtkChart::FILL_SCENE :
296  }
297  virtual bool GetAutoSize()
298  {
299  return this->LayoutStrategy == vtkChart::FILL_SCENE ? true : false;
300  }
302 
304 
312  vtkSetMacro(RenderEmpty, bool);
313  vtkGetMacro(RenderEmpty, bool);
315 
326  virtual void SetActionToButton(int action, int button);
327 
332  virtual int GetActionToButton(int action);
333 
339  virtual void SetClickActionToButton(int action, int button);
340 
346  virtual int GetClickActionToButton(int action);
347 
349 
352  void SetBackgroundBrush(vtkBrush *brush);
353  vtkBrush* GetBackgroundBrush();
355 
357 
362  virtual void SetSelectionMode(int);
363  vtkGetMacro(SelectionMode, int);
365 
366 protected:
367  vtkChart();
368  ~vtkChart() VTK_OVERRIDE;
369 
376  bool CalculatePlotTransform(vtkAxis *x, vtkAxis *y,
377  vtkTransform2D *transform);
378 
382  bool CalculateUnscaledPlotTransform(vtkAxis *x, vtkAxis *y,
383  vtkTransform2D *transform);
384 
388  void AttachAxisRangeListener(vtkAxis*);
389 
390  void AxisRangeForwarderCallback(vtkObject*,unsigned long, void*);
391 
395  vtkAnnotationLink *AnnotationLink;
396 
400  int Geometry[2];
401 
405  int Point1[2];
406 
410  int Point2[2];
411 
415  bool ShowLegend;
416 
421 
425  vtkTextProperty* TitleProperties;
426 
427  vtkRectf Size;
428  // The layout strategy to employ when fitting the chart into the space.
429  int LayoutStrategy;
430  bool RenderEmpty;
431 
435  vtkSmartPointer<vtkBrush> BackgroundBrush;
436 
437  // The mode when the chart is doing selection.
438  int SelectionMode;
439 
440  // How plot selections are handled, SELECTION_ROWS (default) or
441  // SELECTION_PLOTS - based on the plot that created the selection.
442  int SelectionMethod;
443 
445 
449  {
450  public:
451  MouseActions();
452  enum { MaxAction = 5 };
453  short& Pan() { return Data[0]; }
454  short& Zoom() { return Data[1]; }
455  short& ZoomAxis() { return Data[2]; }
456  short& Select() { return Data[3]; }
457  short& SelectPolygon() { return Data[4]; }
458  short& operator[](int index) { return Data[index]; }
459  short Data[MaxAction];
460  };
462  {
463  public:
465  short& Notify() { return Data[0]; }
466  short& Select() { return Data[1]; }
467  short& operator[](int index) { return Data[index]; }
468  short Data[2];
469  };
471 
474 
475 private:
476  vtkChart(const vtkChart &) VTK_DELETE_FUNCTION;
477  void operator=(const vtkChart &) VTK_DELETE_FUNCTION;
478 };
479 
480 #endif //vtkChart_h
MouseClickActions ActionsClick
Definition: vtkChart.h:473
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:41
short & SelectPolygon()
Definition: vtkChart.h:457
abstract base class for most VTK objects
Definition: vtkObject.h:53
base class for items that are part of a vtkContextScene.
virtual bool Paint(vtkContext2D *painter)
Paint event for the item, called whenever the item needs to be drawn.
Hold a reference to a vtkObjectBase instance.
int vtkIdType
Definition: vtkType.h:345
Class for drawing 2D primitives to a graphical context.
Definition: vtkContext2D.h:52
Factory class for drawing 2D charts.
Definition: vtkChart.h:44
provides a brush that fills shapes drawn by vtkContext2D.
Definition: vtkBrush.h:37
takes care of drawing 2D axes
Definition: vtkAxis.h:68
Provides a 2D scene for vtkContextItem objects.
a simple class to control print indentation
Definition: vtkIndent.h:33
virtual void SetAutoSize(bool isAutoSized)
Set/get whether the chart should automatically resize to fill the current render window.
Definition: vtkChart.h:292
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
virtual bool GetAutoSize()
Set/get whether the chart should automatically resize to fill the current render window.
Definition: vtkChart.h:297
describes linear transformations via a 3x3 matrix
Abstract class for 2D plots.
Definition: vtkPlot.h:46
represent text properties.
vtkSetMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
EventIds
Enum of event type that are triggered by the charts.
Definition: vtkChart.h:86
short & operator[](int index)
Definition: vtkChart.h:458
draw the chart legend
provide event-driven interface to the rendering window (defines trackball mode)
Hold mouse action mappings.
Definition: vtkChart.h:448
short & operator[](int index)
Definition: vtkChart.h:467
MouseActions Actions
Definition: vtkChart.h:472