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 "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 
50 {
51 public:
53  virtual void PrintSelf(ostream &os, vtkIndent indent);
54 
55 //BTX
57 
58  enum {
61  BAR,
63  BAG,
64  FUNCTIONALBAG};
66 
68 
74  enum {
75  PAN = 0,
79  SELECT_RECTANGLE = SELECT,
81  NOTIFY
82  };
84 
86 
87  enum EventIds {
88  UpdateRange = 1002
89  };
90 //ETX
92 
95  virtual bool Paint(vtkContext2D *painter) = 0;
96 
98  virtual vtkPlot* AddPlot(int type);
99 
102  virtual vtkIdType AddPlot(vtkPlot* plot);
103 
106  virtual bool RemovePlot(vtkIdType index);
107 
111  virtual bool RemovePlotInstance(vtkPlot* plot);
112 
114  virtual void ClearPlots();
115 
118  virtual vtkPlot* GetPlot(vtkIdType index);
119 
121  virtual vtkIdType GetNumberOfPlots();
122 
126  virtual vtkAxis* GetAxis(int axisIndex);
127 
129  virtual vtkIdType GetNumberOfAxes();
130 
134  virtual void RecalculateBounds();
135 
137 
143  enum {
146  SELECTION_COLUMNS
147  };
149 
151 
157  virtual void SetSelectionMethod(int method);
158  virtual int GetSelectionMethod();
160 
162  virtual void SetAnnotationLink(vtkAnnotationLink *link);
163 
165 
166  vtkGetObjectMacro(AnnotationLink, vtkAnnotationLink);
168 
170 
171  vtkSetVector2Macro(Geometry, int);
172  vtkGetVector2Macro(Geometry, int);
174 
176 
177  vtkSetVector2Macro(Point1, int);
178  vtkGetVector2Macro(Point1, int);
180 
182 
183  vtkSetVector2Macro(Point2, int);
184  vtkGetVector2Macro(Point2, int);
186 
188 
189  virtual void SetShowLegend(bool visible);
190  virtual bool GetShowLegend();
192 
195  virtual vtkChartLegend * GetLegend();
196 
198 
199  virtual void SetTitle(const vtkStdString &title);
200  virtual vtkStdString GetTitle();
202 
204 
206  vtkGetObjectMacro(TitleProperties, vtkTextProperty);
208 
210 
211  void SetBottomBorder(int border);
212  void SetTopBorder(int border);
213  void SetLeftBorder(int border);
214  void SetRightBorder(int border);
216 
218  void SetBorders(int left, int bottom, int right, int top);
219 
223  void SetSize(const vtkRectf &rect);
224 
226  vtkRectf GetSize();
227 
229 
230  enum {
231  FILL_SCENE, // Attempt to fill the entire scene.
232  FILL_RECT, // Attempt to supply the supplied vtkRectf in Size.
233  AXES_TO_RECT // Put the corners of the axes on the vtkRectf in Size.
234  };
236 
238 
241  vtkSetMacro(LayoutStrategy, int);
242  vtkGetMacro(LayoutStrategy, int);
244 
246 
248  virtual void SetAutoSize(bool isAutoSized)
249  {
250  this->LayoutStrategy = isAutoSized ? vtkChart::FILL_SCENE :
252  }
253  virtual bool GetAutoSize()
254  {
255  return this->LayoutStrategy == vtkChart::FILL_SCENE ? true : false;
256  }
258 
260 
265  vtkSetMacro(RenderEmpty, bool);
266  vtkGetMacro(RenderEmpty, bool);
268 
276  virtual void SetActionToButton(int action, int button);
277 
281  virtual int GetActionToButton(int action);
282 
286  virtual void SetClickActionToButton(int action, int button);
287 
291  virtual int GetClickActionToButton(int action);
292 
294 
295  void SetBackgroundBrush(vtkBrush *brush);
296  vtkBrush* GetBackgroundBrush();
298 
300 
304  virtual void SetSelectionMode(int);
305  vtkGetMacro(SelectionMode, int);
307 
308 protected:
309  vtkChart();
310  ~vtkChart();
311 
313 
317  bool CalculatePlotTransform(vtkAxis *x, vtkAxis *y,
320 
322 
324  bool CalculateUnscaledPlotTransform(vtkAxis *x, vtkAxis *y,
325  vtkTransform2D *transform);
327 
330  void AttachAxisRangeListener(vtkAxis*);
331 
332  void AxisRangeForwarderCallback(vtkObject*,unsigned long, void*);
333 
336 
338  int Geometry[2];
339 
341  int Point1[2];
342 
344  int Point2[2];
345 
348 
351 
354 
356  // The layout strategy to employ when fitting the chart into the space.
359 
362 
363  // The mode when the chart is doing selection.
365 
366  // How plot selections are handled, SELECTION_ROWS (default) or
367  // SELECTION_PLOTS - based on the plot that created the selection.
369 
371 
373  {
374  public:
375  MouseActions();
376  enum { MaxAction = 5 };
377  short& Pan() { return Data[0]; }
378  short& Zoom() { return Data[1]; }
379  short& ZoomAxis() { return Data[2]; }
380  short& Select() { return Data[3]; }
381  short& SelectPolygon() { return Data[4]; }
382  short& operator[](int index) { return Data[index]; }
383  short Data[MaxAction];
384  };
386  {
387  public:
389  short& Notify() { return Data[0]; }
390  short& Select() { return Data[1]; }
391  short& operator[](int index) { return Data[index]; }
392  short Data[2];
393  };
395 
398 
399 private:
400  vtkChart(const vtkChart &); // Not implemented.
401  void operator=(const vtkChart &); // Not implemented.
402 };
403 
404 #endif //vtkChart_h
int SelectionMethod
Definition: vtkChart.h:368
MouseClickActions ActionsClick
Definition: vtkChart.h:397
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:46
GLuint GLenum GLenum transform
Definition: vtkgl.h:16451
vtkStdString Title
Definition: vtkChart.h:350
GLuint GLuint GLsizei GLenum type
Definition: vtkgl.h:11315
vtkTextProperty * TitleProperties
Definition: vtkChart.h:353
short & SelectPolygon()
Definition: vtkChart.h:381
abstract base class for most VTK objects
Definition: vtkObject.h:61
bool RenderEmpty
Definition: vtkChart.h:358
GLuint index
Definition: vtkgl.h:11983
vtkAnnotationLink * AnnotationLink
Definition: vtkChart.h:335
base class for items that are part of a vtkContextScene.
GLint GLint GLsizei GLsizei GLsizei GLint border
Definition: vtkgl.h:11316
virtual bool Paint(vtkContext2D *painter)
#define vtkGetMacro(name, type)
Definition: vtkSetGet.h:83
GLdouble GLdouble right
Definition: vtkgl.h:18180
int LayoutStrategy
Definition: vtkChart.h:357
int vtkIdType
Definition: vtkType.h:281
GLint GLint GLint GLint GLint GLint y
Definition: vtkgl.h:11318
#define vtkTypeMacro(thisClass, superclass)
Definition: vtkSetGet.h:632
int SelectionMode
Definition: vtkChart.h:364
GLint GLint GLint GLint GLint x
Definition: vtkgl.h:11318
Class for drawing 2D primitives to a graphical context.
Definition: vtkContext2D.h:56
Factory class for drawing 2D charts.
Definition: vtkChart.h:49
provides a brush that fills shapes drawn by vtkContext2D.
Definition: vtkBrush.h:36
takes care of drawing 2D axes
Definition: vtkAxis.h:70
Provides a 2D scene for vtkContextItem objects.
a simple class to control print indentation
Definition: vtkIndent.h:38
vtkRectf Size
Definition: vtkChart.h:355
virtual void SetAutoSize(bool isAutoSized)
Definition: vtkChart.h:248
bool ShowLegend
Definition: vtkChart.h:347
GLdouble GLdouble GLdouble GLdouble top
Definition: vtkgl.h:18180
virtual bool GetAutoSize()
Definition: vtkChart.h:253
describes linear transformations via a 3x3 matrix
Abstract class for 2D plots.
Definition: vtkPlot.h:51
represent text properties.
#define vtkGetObjectMacro(name, type)
Definition: vtkSetGet.h:222
GLint left
Definition: vtkgl.h:14367
short & operator[](int index)
Definition: vtkChart.h:382
#define vtkGetVector2Macro(name, type)
Definition: vtkSetGet.h:260
draw the chart legend
provide event-driven interface to the rendering window (defines trackball mode)
vtkSmartPointer< vtkBrush > BackgroundBrush
Definition: vtkChart.h:361
virtual void PrintSelf(ostream &os, vtkIndent indent)
GLint GLint bottom
Definition: vtkgl.h:14367
#define vtkSetVector2Macro(name, type)
Definition: vtkSetGet.h:244
#define VTKCHARTSCORE_EXPORT
short & operator[](int index)
Definition: vtkChart.h:391
MouseActions Actions
Definition: vtkChart.h:396
#define vtkSetMacro(name, type)
Definition: vtkSetGet.h:69