vtkChart.h 4.99 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/*=========================================================================

  Program:   Visualization Toolkit
  Module:    vtkChart.h

  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
  All rights reserved.
  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.

     This software is distributed WITHOUT ANY WARRANTY; without even
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
     PURPOSE.  See the above copyright notice for more information.

=========================================================================*/

// .NAME vtkChart - Factory class for drawing 2D charts
//
// .SECTION Description
// This defines the interface for a chart.

#ifndef __vtkChart_h
#define __vtkChart_h

#include "vtkContextItem.h"

class vtkContext2D;
class vtkContextScene;
class vtkPlot;
29
class vtkAxis;
30
class vtkTextProperty;
31
32
33
34
35
36
37
38

class vtkInteractorStyle;
class vtkAnnotationLink;
class vtkTable;

class VTK_CHARTS_EXPORT vtkChart : public vtkContextItem
{
public:
39
  vtkTypeMacro(vtkChart, vtkContextItem);
40
41
42
43
44
  virtual void PrintSelf(ostream &os, vtkIndent indent);

//BTX
  // Description:
  // Enum of the available chart types
45
  enum {
46
47
48
49
50
51
52
53
54
55
56
57
    LINE,
    POINTS,
    BAR,
    STACKED};
//ETX

  // Description:
  // Paint event for the chart, called whenever the chart needs to be drawn
  virtual bool Paint(vtkContext2D *painter) = 0;

  // Description:
  // Add a plot to the chart, defaults to using the name of the y column
58
  virtual vtkPlot* AddPlot(int type);
59
60
61
62
63
64

  // Description:
  // Remove the plot at the specified index, returns true if successful,
  // false if the index was invalid.
  virtual bool RemovePlot(vtkIdType index);

65
66
67
68
69
70
  // Description:
  // Remove the given plot.  Returns true if successful, false if the plot
  // was not contained in this chart.  Note, the base implementation of
  // this method performs a linear search to locate the plot.
  virtual bool RemovePlotInstance(vtkPlot* plot);

71
72
73
74
75
76
77
  // Description:
  // Remove all plots from the chart.
  virtual void ClearPlots();

  // Description:
  // Get the plot at the specified index, returns null if the index is invalid.
  virtual vtkPlot* GetPlot(vtkIdType index);
78
79
80

  // Description:
  // Get the number of plots the chart contains.
81
  virtual vtkIdType GetNumberOfPlots();
82

83
84
85
86
87
  // Description:
  // Get the axis specified by axisIndex. 0 is x, 1 is y. This should probably
  // be improved either using a string or enum to select the axis.
  virtual vtkAxis* GetAxis(int axisIndex);

88
89
90
91
  // Description:
  // Get the number of axes in the current chart.
  virtual vtkIdType GetNumberOfAxes();

92
93
94
95
96
  // Description:
  // Request that the chart recalculates the range of its axes. Especially
  // useful in applications after the parameters of plots have been modified.
  virtual void RecalculateBounds();

97
98
99
100
101
102
103
104
105
  // Description:
  // Set the vtkAnnotationLink for the chart.
  virtual void SetAnnotationLink(vtkAnnotationLink *link);

  // Description:
  // Get the vtkAnnotationLink for the chart.
  vtkGetObjectMacro(AnnotationLink, vtkAnnotationLink);

  // Description:
106
107
108
109
110
111
112
113
114
115
116
117
118
119
  // Set/get the width and the height of the chart.
  vtkSetVector2Macro(Geometry, int);
  vtkGetVector2Macro(Geometry, int);

  // Description:
  // Set/get the first point in the chart (the bottom left).
  vtkSetVector2Macro(Point1, int);
  vtkGetVector2Macro(Point1, int);

  // Description:
  // Set/get the second point in the chart (the top right).
  vtkSetVector2Macro(Point2, int);
  vtkGetVector2Macro(Point2, int);

120
121
122
123
124
  // Description:
  // Set/get whether the chart should draw a legend.
  vtkSetMacro(ShowLegend, bool);
  vtkGetMacro(ShowLegend, bool);

125
126
127
128
129
  // Description:
  // Get/set the title text of the chart.
  vtkSetStringMacro(Title);
  vtkGetStringMacro(Title);

130
131
132
133
  // Description:
  // Get the vtkTextProperty that governs how the chart title is displayed.
  vtkGetObjectMacro(TitleProperties, vtkTextProperty);

134
135
136
137
138
139
140
141
142
143
  // Description:
  // Set/get the borders of the chart (space in pixels around the chart).
  void SetBottomBorder(int border);
  void SetTopBorder(int border);
  void SetLeftBorder(int border);
  void SetRightBorder(int border);

  // Description:
  // Set/get the borders of the chart (space in pixels around the chart).
  void SetBorders(int left, int right, int top, int bottom);
144
145
146
147
148
149
150
151
152
153

//BTX
protected:
  vtkChart();
  ~vtkChart();

  // Description:
  // Our annotation link, used for sharing selections etc.
  vtkAnnotationLink *AnnotationLink;

154
155
156
157
158
159
160
161
162
163
164
  // Description:
  // The width and the height of the chart.
  int Geometry[2];

  // Description:
  // The position of the lower left corner of the chart.
  int Point1[2];

  // Description:
  // The position of the upper right corner of the chart.
  int Point2[2];
165

166
167
168
169
  // Description:
  // Display the legend?
  bool ShowLegend;

170
171
172
173
  // Description:
  // The title of the chart
  char* Title;

174
175
176
177
  // Description:
  // The text properties associated with the chart
  vtkTextProperty* TitleProperties;

178
179
180
181
182
183
184
private:
  vtkChart(const vtkChart &); // Not implemented.
  void operator=(const vtkChart &);   // Not implemented.
//ETX
};

#endif //__vtkChart_h