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:
52  vtkTypeMacro(vtkChart, vtkContextItem);
53  virtual void PrintSelf(ostream &os, vtkIndent indent);
54 
55 //BTX
57 
58  enum {
61  BAR,
63  BAG,
65  AREA};
67 
69 
75  enum {
76  PAN = 0,
80  SELECT_RECTANGLE = SELECT,
82  NOTIFY
83  };
85 
87 
88  enum EventIds {
89  UpdateRange = 1002
90  };
91 //ETX
93 
96  virtual bool Paint(vtkContext2D *painter) = 0;
97 
99  virtual vtkPlot* AddPlot(int type);
100 
103  virtual vtkIdType AddPlot(vtkPlot* plot);
104 
107  virtual bool RemovePlot(vtkIdType index);
108 
112  virtual bool RemovePlotInstance(vtkPlot* plot);
113 
115  virtual void ClearPlots();
116 
119  virtual vtkPlot* GetPlot(vtkIdType index);
120 
122  virtual vtkIdType GetNumberOfPlots();
123 
127  virtual vtkAxis* GetAxis(int axisIndex);
128 
130  virtual vtkIdType GetNumberOfAxes();
131 
135  virtual void RecalculateBounds();
136 
138 
144  enum {
147  SELECTION_COLUMNS
148  };
150 
152 
158  virtual void SetSelectionMethod(int method);
159  virtual int GetSelectionMethod();
161 
163  virtual void SetAnnotationLink(vtkAnnotationLink *link);
164 
166 
167  vtkGetObjectMacro(AnnotationLink, vtkAnnotationLink);
169 
171 
172  vtkSetVector2Macro(Geometry, int);
173  vtkGetVector2Macro(Geometry, int);
175 
177 
178  vtkSetVector2Macro(Point1, int);
179  vtkGetVector2Macro(Point1, int);
181 
183 
184  vtkSetVector2Macro(Point2, int);
185  vtkGetVector2Macro(Point2, int);
187 
189 
190  virtual void SetShowLegend(bool visible);
191  virtual bool GetShowLegend();
193 
196  virtual vtkChartLegend * GetLegend();
197 
199 
200  virtual void SetTitle(const vtkStdString &title);
201  virtual vtkStdString GetTitle();
203 
205 
207  vtkGetObjectMacro(TitleProperties, vtkTextProperty);
209 
211 
212  void SetBottomBorder(int border);
213  void SetTopBorder(int border);
214  void SetLeftBorder(int border);
215  void SetRightBorder(int border);
217 
219  void SetBorders(int left, int bottom, int right, int top);
220 
224  void SetSize(const vtkRectf &rect);
225 
227  vtkRectf GetSize();
228 
230 
231  enum {
232  FILL_SCENE, // Attempt to fill the entire scene.
233  FILL_RECT, // Attempt to supply the supplied vtkRectf in Size.
234  AXES_TO_RECT // Put the corners of the axes on the vtkRectf in Size.
235  };
237 
239 
242  vtkSetMacro(LayoutStrategy, int);
243  vtkGetMacro(LayoutStrategy, int);
245 
247 
249  virtual void SetAutoSize(bool isAutoSized)
250  {
251  this->LayoutStrategy = isAutoSized ? vtkChart::FILL_SCENE :
253  }
254  virtual bool GetAutoSize()
255  {
256  return this->LayoutStrategy == vtkChart::FILL_SCENE ? true : false;
257  }
259 
261 
266  vtkSetMacro(RenderEmpty, bool);
267  vtkGetMacro(RenderEmpty, bool);
269 
277  virtual void SetActionToButton(int action, int button);
278 
282  virtual int GetActionToButton(int action);
283 
287  virtual void SetClickActionToButton(int action, int button);
288 
292  virtual int GetClickActionToButton(int action);
293 
295 
296  void SetBackgroundBrush(vtkBrush *brush);
297  vtkBrush* GetBackgroundBrush();
299 
301 
305  virtual void SetSelectionMode(int);
306  vtkGetMacro(SelectionMode, int);
308 
309 protected:
310  vtkChart();
311  ~vtkChart();
312 
314 
318  bool CalculatePlotTransform(vtkAxis *x, vtkAxis *y,
319  vtkTransform2D *transform);
321 
323 
325  bool CalculateUnscaledPlotTransform(vtkAxis *x, vtkAxis *y,
326  vtkTransform2D *transform);
328 
331  void AttachAxisRangeListener(vtkAxis*);
332 
333  void AxisRangeForwarderCallback(vtkObject*,unsigned long, void*);
334 
337 
339  int Geometry[2];
340 
342  int Point1[2];
343 
345  int Point2[2];
346 
349 
352 
355 
357  // The layout strategy to employ when fitting the chart into the space.
360 
363 
364  // The mode when the chart is doing selection.
366 
367  // How plot selections are handled, SELECTION_ROWS (default) or
368  // SELECTION_PLOTS - based on the plot that created the selection.
370 
372 
374  {
375  public:
376  MouseActions();
377  enum { MaxAction = 5 };
378  short& Pan() { return Data[0]; }
379  short& Zoom() { return Data[1]; }
380  short& ZoomAxis() { return Data[2]; }
381  short& Select() { return Data[3]; }
382  short& SelectPolygon() { return Data[4]; }
383  short& operator[](int index) { return Data[index]; }
384  short Data[MaxAction];
385  };
387  {
388  public:
390  short& Notify() { return Data[0]; }
391  short& Select() { return Data[1]; }
392  short& operator[](int index) { return Data[index]; }
393  short Data[2];
394  };
396 
399 
400 private:
401  vtkChart(const vtkChart &); // Not implemented.
402  void operator=(const vtkChart &); // Not implemented.
403 };
404 
405 #endif //vtkChart_h
int SelectionMethod
Definition: vtkChart.h:369
MouseClickActions ActionsClick
Definition: vtkChart.h:398
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:46
vtkStdString Title
Definition: vtkChart.h:351
vtkTextProperty * TitleProperties
Definition: vtkChart.h:354
short & SelectPolygon()
Definition: vtkChart.h:382
abstract base class for most VTK objects
Definition: vtkObject.h:61
bool RenderEmpty
Definition: vtkChart.h:359
vtkAnnotationLink * AnnotationLink
Definition: vtkChart.h:336
base class for items that are part of a vtkContextScene.
virtual bool Paint(vtkContext2D *painter)
int LayoutStrategy
Definition: vtkChart.h:358
int vtkIdType
Definition: vtkType.h:275
int SelectionMode
Definition: vtkChart.h:365
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:356
virtual void SetAutoSize(bool isAutoSized)
Definition: vtkChart.h:249
bool ShowLegend
Definition: vtkChart.h:348
virtual bool GetAutoSize()
Definition: vtkChart.h:254
describes linear transformations via a 3x3 matrix
Abstract class for 2D plots.
Definition: vtkPlot.h:51
represent text properties.
short & operator[](int index)
Definition: vtkChart.h:383
draw the chart legend
provide event-driven interface to the rendering window (defines trackball mode)
vtkSmartPointer< vtkBrush > BackgroundBrush
Definition: vtkChart.h:362
virtual void PrintSelf(ostream &os, vtkIndent indent)
#define VTKCHARTSCORE_EXPORT
short & operator[](int index)
Definition: vtkChart.h:392
MouseActions Actions
Definition: vtkChart.h:397