VTK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 
29 #ifndef __vtkChart_h
30 #define __vtkChart_h
31 
32 #include "vtkChartsCoreModule.h" // For export macro
33 #include "vtkContextItem.h"
34 #include "vtkRect.h" // For vtkRectf
35 #include "vtkStdString.h" // For vtkStdString ivars
36 #include "vtkSmartPointer.h" // For SP ivars
37 
38 class vtkTransform2D;
39 class vtkContextScene;
40 class vtkPlot;
41 class vtkAxis;
42 class vtkBrush;
43 class vtkTextProperty;
44 class vtkChartLegend;
45 
46 class vtkInteractorStyle;
47 class vtkAnnotationLink;
48 
49 class VTKCHARTSCORE_EXPORT vtkChart : public vtkContextItem
50 {
51 public:
52  vtkTypeMacro(vtkChart, vtkContextItem);
53  virtual void PrintSelf(ostream &os, vtkIndent indent);
54 
55 //BTX
57 
58  enum {
61  BAR,
62  STACKED};
64 
66 
67  enum {
68  PAN = 0,
71  SELECT_RECTANGLE = SELECT,
73  NOTIFY
74  };
76 
78 
79  enum EventIds {
80  UpdateRange = 1002
81  };
82 //ETX
84 
87  virtual bool Paint(vtkContext2D *painter) = 0;
88 
90  virtual vtkPlot* AddPlot(int type);
91 
94  virtual vtkIdType AddPlot(vtkPlot* plot);
95 
98  virtual bool RemovePlot(vtkIdType index);
99 
103  virtual bool RemovePlotInstance(vtkPlot* plot);
104 
106  virtual void ClearPlots();
107 
110  virtual vtkPlot* GetPlot(vtkIdType index);
111 
113  virtual vtkIdType GetNumberOfPlots();
114 
118  virtual vtkAxis* GetAxis(int axisIndex);
119 
121  virtual vtkIdType GetNumberOfAxes();
122 
126  virtual void RecalculateBounds();
127 
129 
134  enum {
136  SELECTION_PLOTS
137  };
139 
141 
146  virtual void SetSelectionMethod(int method);
147  virtual int GetSelectionMethod();
149 
151  virtual void SetAnnotationLink(vtkAnnotationLink *link);
152 
154 
155  vtkGetObjectMacro(AnnotationLink, vtkAnnotationLink);
157 
159 
160  vtkSetVector2Macro(Geometry, int);
161  vtkGetVector2Macro(Geometry, int);
163 
165 
166  vtkSetVector2Macro(Point1, int);
167  vtkGetVector2Macro(Point1, int);
169 
171 
172  vtkSetVector2Macro(Point2, int);
173  vtkGetVector2Macro(Point2, int);
175 
177 
178  virtual void SetShowLegend(bool visible);
179  virtual bool GetShowLegend();
181 
184  virtual vtkChartLegend * GetLegend();
185 
187 
188  virtual void SetTitle(const vtkStdString &title);
189  virtual vtkStdString GetTitle();
191 
193 
195  vtkGetObjectMacro(TitleProperties, vtkTextProperty);
197 
199 
200  void SetBottomBorder(int border);
201  void SetTopBorder(int border);
202  void SetLeftBorder(int border);
203  void SetRightBorder(int border);
205 
207  void SetBorders(int left, int bottom, int right, int top);
208 
212  void SetSize(const vtkRectf &rect);
213 
215  vtkRectf GetSize();
216 
218 
219  enum {
220  FILL_SCENE, // Attempt to fill the entire scene.
221  FILL_RECT, // Attempt to supply the supplied vtkRectf in Size.
222  AXES_TO_RECT // Put the corners of the axes on the vtkRectf in Size.
223  };
225 
227 
230  vtkSetMacro(LayoutStrategy, int);
231  vtkGetMacro(LayoutStrategy, int);
233 
235 
237  virtual void SetAutoSize(bool isAutoSized)
238  {
239  this->LayoutStrategy = isAutoSized ? vtkChart::FILL_SCENE :
241  }
242  virtual bool GetAutoSize()
243  {
244  return this->LayoutStrategy == vtkChart::FILL_SCENE ? true : false;
245  }
247 
249 
254  vtkSetMacro(RenderEmpty, bool);
255  vtkGetMacro(RenderEmpty, bool);
257 
265  virtual void SetActionToButton(int action, int button);
266 
270  virtual int GetActionToButton(int action);
271 
275  virtual void SetClickActionToButton(int action, int button);
276 
280  virtual int GetClickActionToButton(int action);
281 
283 
284  void SetBackgroundBrush(vtkBrush *brush);
285  vtkBrush* GetBackgroundBrush();
287 
289 
293  virtual void SetSelectionMode(int);
294  vtkGetMacro(SelectionMode, int);
296 
297 protected:
298  vtkChart();
299  ~vtkChart();
300 
302 
306  bool CalculatePlotTransform(vtkAxis *x, vtkAxis *y,
307  vtkTransform2D *transform);
309 
312  void AttachAxisRangeListener(vtkAxis*);
313 
314  void AxisRangeForwarderCallback(vtkObject*,unsigned long, void*);
315 
317  vtkAnnotationLink *AnnotationLink;
318 
320  int Geometry[2];
321 
323  int Point1[2];
324 
326  int Point2[2];
327 
330 
333 
335  vtkTextProperty* TitleProperties;
336 
337  vtkRectf Size;
338  // The layout strategy to employ when fitting the chart into the space.
341 
344 
345  // The mode when the chart is doing selection.
347 
348  // How plot selections are handled, SELECTION_ROWS (default) or
349  // SELECTION_PLOTS - based on the plot that created the selection.
351 
353 
355  {
356  public:
357  MouseActions();
358  enum { MaxAction = 4 };
359  short& Pan() { return Data[0]; }
360  short& Zoom() { return Data[1]; }
361  short& Select() { return Data[2]; }
362  short& SelectPolygon() { return Data[3]; }
363  short& operator[](int index) { return Data[index]; }
364  short Data[MaxAction];
365  };
367  {
368  public:
370  short& Notify() { return Data[0]; }
371  short& Select() { return Data[1]; }
372  short& operator[](int index) { return Data[index]; }
373  short Data[2];
374  };
376 
379 
380 private:
381  vtkChart(const vtkChart &); // Not implemented.
382  void operator=(const vtkChart &); // Not implemented.
383 };
384 
385 #endif //__vtkChart_h
int SelectionMethod
Definition: vtkChart.h:350
MouseClickActions ActionsClick
Definition: vtkChart.h:378
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:46
vtkStdString Title
Definition: vtkChart.h:332
vtkTextProperty * TitleProperties
Definition: vtkChart.h:335
short & SelectPolygon()
Definition: vtkChart.h:362
abstract base class for most VTK objects
Definition: vtkObject.h:61
bool RenderEmpty
Definition: vtkChart.h:340
vtkAnnotationLink * AnnotationLink
Definition: vtkChart.h:317
int LayoutStrategy
Definition: vtkChart.h:339
int vtkIdType
Definition: vtkType.h:268
int SelectionMode
Definition: vtkChart.h:346
Factory class for drawing 2D charts.
Definition: vtkChart.h:49
takes care of drawing 2D axes
Definition: vtkAxis.h:70
a simple class to control print indentation
Definition: vtkIndent.h:38
vtkRectf Size
Definition: vtkChart.h:337
virtual void SetAutoSize(bool isAutoSized)
Definition: vtkChart.h:237
bool ShowLegend
Definition: vtkChart.h:329
virtual bool GetAutoSize()
Definition: vtkChart.h:242
Abstract class for 2D plots.
Definition: vtkPlot.h:52
short & operator[](int index)
Definition: vtkChart.h:363
draw the chart legend
vtkSmartPointer< vtkBrush > BackgroundBrush
Definition: vtkChart.h:343
short & operator[](int index)
Definition: vtkChart.h:372
MouseActions Actions
Definition: vtkChart.h:377