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 
29 #ifndef __vtkChart_h
30 #define __vtkChart_h
31 
32 #include "vtkContextItem.h"
33 #include "vtkRect.h" // For vtkRectf
34 #include "vtkStdString.h" // For vtkStdString ivars
35 #include "vtkSmartPointer.h" // For SP ivars
36 
37 class vtkTransform2D;
38 class vtkContextScene;
39 class vtkPlot;
40 class vtkAxis;
41 class vtkBrush;
42 class vtkTextProperty;
43 class vtkChartLegend;
44 
45 class vtkInteractorStyle;
46 class vtkAnnotationLink;
47 
49 {
50 public:
51  vtkTypeMacro(vtkChart, vtkContextItem);
52  virtual void PrintSelf(ostream &os, vtkIndent indent);
53 
54 //BTX
56 
57  enum {
60  BAR,
61  STACKED};
63 
65 
66  enum {
67  PAN = 0,
70  NOTIFY
71  };
73 
75 
76  enum EventIds {
77  UpdateRange = 1002
78  };
79 //ETX
81 
84  virtual bool Paint(vtkContext2D *painter) = 0;
85 
87  virtual vtkPlot* AddPlot(int type);
88 
91  virtual vtkIdType AddPlot(vtkPlot* plot);
92 
95  virtual bool RemovePlot(vtkIdType index);
96 
100  virtual bool RemovePlotInstance(vtkPlot* plot);
101 
103  virtual void ClearPlots();
104 
107  virtual vtkPlot* GetPlot(vtkIdType index);
108 
110  virtual vtkIdType GetNumberOfPlots();
111 
115  virtual vtkAxis* GetAxis(int axisIndex);
116 
118  virtual vtkIdType GetNumberOfAxes();
119 
123  virtual void RecalculateBounds();
124 
126  virtual void SetAnnotationLink(vtkAnnotationLink *link);
127 
129 
130  vtkGetObjectMacro(AnnotationLink, vtkAnnotationLink);
132 
134 
135  vtkSetVector2Macro(Geometry, int);
136  vtkGetVector2Macro(Geometry, int);
138 
140 
141  vtkSetVector2Macro(Point1, int);
142  vtkGetVector2Macro(Point1, int);
144 
146 
147  vtkSetVector2Macro(Point2, int);
148  vtkGetVector2Macro(Point2, int);
150 
152 
153  virtual void SetShowLegend(bool visible);
154  virtual bool GetShowLegend();
156 
159  virtual vtkChartLegend * GetLegend();
160 
162 
163  virtual void SetTitle(const vtkStdString &title);
164  virtual vtkStdString GetTitle();
166 
168 
170  vtkGetObjectMacro(TitleProperties, vtkTextProperty);
172 
174 
175  void SetBottomBorder(int border);
176  void SetTopBorder(int border);
177  void SetLeftBorder(int border);
178  void SetRightBorder(int border);
180 
182  void SetBorders(int left, int bottom, int right, int top);
183 
187  void SetSize(const vtkRectf &rect);
188 
190  vtkRectf GetSize();
191 
193 
194  enum {
195  FILL_SCENE, // Attempt to fill the entire scene.
196  FILL_RECT, // Attempt to supply the supplied vtkRectf in Size.
197  AXES_TO_RECT // Put the corners of the axes on the vtkRectf in Size.
198  };
200 
202 
205  vtkSetMacro(LayoutStrategy, int);
206  vtkGetMacro(LayoutStrategy, int);
208 
210 
212  virtual void SetAutoSize(bool isAutoSized)
213  {
214  this->LayoutStrategy = isAutoSized ? vtkChart::FILL_SCENE :
216  }
217  virtual bool GetAutoSize()
218  {
219  return this->LayoutStrategy == vtkChart::FILL_SCENE ? true : false;
220  }
222 
224 
229  vtkSetMacro(RenderEmpty, bool);
230  vtkGetMacro(RenderEmpty, bool);
232 
240  virtual void SetActionToButton(int action, int button);
241 
245  virtual int GetActionToButton(int action);
246 
250  virtual void SetClickActionToButton(int action, int button);
251 
255  virtual int GetClickActionToButton(int action);
256 
258 
259  void SetBackgroundBrush(vtkBrush *brush);
260  vtkBrush* GetBackgroundBrush();
262 
264 
268  virtual void SetSelectionMode(int);
269  vtkGetMacro(SelectionMode, int);
271 
272 protected:
273  vtkChart();
274  ~vtkChart();
275 
277 
281  bool CalculatePlotTransform(vtkAxis *x, vtkAxis *y,
282  vtkTransform2D *transform);
284 
287  void AttachAxisRangeListener(vtkAxis*);
288 
289  void AxisRangeForwarderCallback(vtkObject*,unsigned long, void*);
290 
293 
295  int Geometry[2];
296 
298  int Point1[2];
299 
301  int Point2[2];
302 
305 
308 
311 
313  // The layout strategy to employ when fitting the chart into the space.
316 
319 
320  // The mode when the chart is doing selection.
322 
324 
326  {
327  public:
328  MouseActions();
329  short& Pan() { return Data[0]; }
330  short& Zoom() { return Data[1]; }
331  short& Select() { return Data[2]; }
332  short& operator[](int index) { return Data[index]; }
333  short Data[3];
334  };
336  {
337  public:
339  short& Notify() { return Data[0]; }
340  short& Select() { return Data[1]; }
341  short& operator[](int index) { return Data[index]; }
342  short Data[2];
343  };
345 
348 
349 private:
350  vtkChart(const vtkChart &); // Not implemented.
351  void operator=(const vtkChart &); // Not implemented.
352 };
353 
354 #endif //__vtkChart_h