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 
30 #ifndef vtkChart_h
31 #define vtkChart_h
32 
33 #include "vtkChartsCoreModule.h" // For export macro
34 #include "vtkContextItem.h"
35 #include "vtkRect.h" // For vtkRectf
36 #include "vtkStdString.h" // For vtkStdString ivars
37 #include "vtkSmartPointer.h" // For SP ivars
38 
39 class vtkTransform2D;
40 class vtkContextScene;
41 class vtkPlot;
42 class vtkAxis;
43 class vtkBrush;
44 class vtkTextProperty;
45 class vtkChartLegend;
46 
47 class vtkInteractorStyle;
48 class vtkAnnotationLink;
49 
50 class VTKCHARTSCORE_EXPORT vtkChart : public vtkContextItem
51 {
52 public:
53  vtkTypeMacro(vtkChart, vtkContextItem);
54  virtual void PrintSelf(ostream &os, vtkIndent indent);
55 
59  enum {
62  BAR,
64  BAG,
66  AREA};
67 
79  enum {
80  PAN = 0,
84  SELECT_RECTANGLE = SELECT,
86  NOTIFY
87  };
88 
92  enum EventIds {
93  UpdateRange = 1002
94  };
95 
99  virtual bool Paint(vtkContext2D *painter) = 0;
100 
104  virtual vtkPlot* AddPlot(int type);
105 
109  virtual vtkIdType AddPlot(vtkPlot* plot);
110 
115  virtual bool RemovePlot(vtkIdType index);
116 
122  virtual bool RemovePlotInstance(vtkPlot* plot);
123 
127  virtual void ClearPlots();
128 
132  virtual vtkPlot* GetPlot(vtkIdType index);
133 
137  virtual vtkIdType GetNumberOfPlots();
138 
143  virtual vtkAxis* GetAxis(int axisIndex);
144 
148  virtual vtkIdType GetNumberOfAxes();
149 
154  virtual void RecalculateBounds();
155 
163  enum {
166  SELECTION_COLUMNS
167  };
168 
170 
178  virtual void SetSelectionMethod(int method);
179  virtual int GetSelectionMethod();
181 
185  virtual void SetAnnotationLink(vtkAnnotationLink *link);
186 
188 
191  vtkGetObjectMacro(AnnotationLink, vtkAnnotationLink);
193 
195 
198  vtkSetVector2Macro(Geometry, int);
199  vtkGetVector2Macro(Geometry, int);
201 
203 
206  vtkSetVector2Macro(Point1, int);
207  vtkGetVector2Macro(Point1, int);
209 
211 
214  vtkSetVector2Macro(Point2, int);
215  vtkGetVector2Macro(Point2, int);
217 
219 
222  virtual void SetShowLegend(bool visible);
223  virtual bool GetShowLegend();
225 
230  virtual vtkChartLegend * GetLegend();
231 
233 
236  virtual void SetTitle(const vtkStdString &title);
237  virtual vtkStdString GetTitle();
239 
241 
244  vtkGetObjectMacro(TitleProperties, vtkTextProperty);
246 
248 
251  void SetBottomBorder(int border);
252  void SetTopBorder(int border);
253  void SetLeftBorder(int border);
254  void SetRightBorder(int border);
256 
260  void SetBorders(int left, int bottom, int right, int top);
261 
267  void SetSize(const vtkRectf &rect);
268 
272  vtkRectf GetSize();
273 
277  enum {
278  FILL_SCENE, // Attempt to fill the entire scene.
279  FILL_RECT, // Attempt to supply the supplied vtkRectf in Size.
280  AXES_TO_RECT // Put the corners of the axes on the vtkRectf in Size.
281  };
282 
284 
289  vtkSetMacro(LayoutStrategy, int);
290  vtkGetMacro(LayoutStrategy, int);
292 
294 
298  virtual void SetAutoSize(bool isAutoSized)
299  {
300  this->LayoutStrategy = isAutoSized ? vtkChart::FILL_SCENE :
302  }
303  virtual bool GetAutoSize()
304  {
305  return this->LayoutStrategy == vtkChart::FILL_SCENE ? true : false;
306  }
308 
310 
318  vtkSetMacro(RenderEmpty, bool);
319  vtkGetMacro(RenderEmpty, bool);
321 
332  virtual void SetActionToButton(int action, int button);
333 
338  virtual int GetActionToButton(int action);
339 
345  virtual void SetClickActionToButton(int action, int button);
346 
352  virtual int GetClickActionToButton(int action);
353 
355 
358  void SetBackgroundBrush(vtkBrush *brush);
359  vtkBrush* GetBackgroundBrush();
361 
363 
368  virtual void SetSelectionMode(int);
369  vtkGetMacro(SelectionMode, int);
371 
372 protected:
373  vtkChart();
374  ~vtkChart();
375 
382  bool CalculatePlotTransform(vtkAxis *x, vtkAxis *y,
383  vtkTransform2D *transform);
384 
388  bool CalculateUnscaledPlotTransform(vtkAxis *x, vtkAxis *y,
389  vtkTransform2D *transform);
390 
394  void AttachAxisRangeListener(vtkAxis*);
395 
396  void AxisRangeForwarderCallback(vtkObject*,unsigned long, void*);
397 
402 
406  int Geometry[2];
407 
411  int Point1[2];
412 
416  int Point2[2];
417 
422 
427 
432 
434  // The layout strategy to employ when fitting the chart into the space.
437 
442 
443  // The mode when the chart is doing selection.
445 
446  // How plot selections are handled, SELECTION_ROWS (default) or
447  // SELECTION_PLOTS - based on the plot that created the selection.
449 
451 
455  {
456  public:
457  MouseActions();
458  enum { MaxAction = 5 };
459  short& Pan() { return Data[0]; }
460  short& Zoom() { return Data[1]; }
461  short& ZoomAxis() { return Data[2]; }
462  short& Select() { return Data[3]; }
463  short& SelectPolygon() { return Data[4]; }
464  short& operator[](int index) { return Data[index]; }
465  short Data[MaxAction];
466  };
468  {
469  public:
471  short& Notify() { return Data[0]; }
472  short& Select() { return Data[1]; }
473  short& operator[](int index) { return Data[index]; }
474  short Data[2];
475  };
477 
480 
481 private:
482  vtkChart(const vtkChart &) VTK_DELETE_FUNCTION;
483  void operator=(const vtkChart &) VTK_DELETE_FUNCTION;
484 };
485 
486 #endif //vtkChart_h
int SelectionMethod
Definition: vtkChart.h:448
MouseClickActions ActionsClick
Definition: vtkChart.h:479
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:47
vtkStdString Title
The title of the chart.
Definition: vtkChart.h:426
vtkTextProperty * TitleProperties
The text properties associated with the chart.
Definition: vtkChart.h:431
short & SelectPolygon()
Definition: vtkChart.h:463
abstract base class for most VTK objects
Definition: vtkObject.h:59
bool RenderEmpty
Definition: vtkChart.h:436
vtkAnnotationLink * AnnotationLink
Our annotation link, used for sharing selections etc.
Definition: vtkChart.h:401
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.
int LayoutStrategy
Definition: vtkChart.h:435
int vtkIdType
Definition: vtkType.h:287
int SelectionMode
Definition: vtkChart.h:444
Class for drawing 2D primitives to a graphical context.
Definition: vtkContext2D.h:57
Factory class for drawing 2D charts.
Definition: vtkChart.h:50
provides a brush that fills shapes drawn by vtkContext2D.
Definition: vtkBrush.h:37
takes care of drawing 2D axes
Definition: vtkAxis.h:71
Provides a 2D scene for vtkContextItem objects.
a simple class to control print indentation
Definition: vtkIndent.h:39
vtkRectf Size
Definition: vtkChart.h:433
virtual void SetAutoSize(bool isAutoSized)
Set/get whether the chart should automatically resize to fill the current render window.
Definition: vtkChart.h:298
bool ShowLegend
Display the legend?
Definition: vtkChart.h:421
virtual bool GetAutoSize()
Set/get whether the chart should automatically resize to fill the current render window.
Definition: vtkChart.h:303
describes linear transformations via a 3x3 matrix
Abstract class for 2D plots.
Definition: vtkPlot.h:52
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:92
short & operator[](int index)
Definition: vtkChart.h:464
draw the chart legend
provide event-driven interface to the rendering window (defines trackball mode)
Hold mouse action mappings.
Definition: vtkChart.h:454
vtkSmartPointer< vtkBrush > BackgroundBrush
Brush to use for drawing the background.
Definition: vtkChart.h:441
virtual void PrintSelf(ostream &os, vtkIndent indent)
Methods invoked by print to print information about the object including superclasses.
short & operator[](int index)
Definition: vtkChart.h:473
MouseActions Actions
Definition: vtkChart.h:478