VTK
vtkBarChartActor.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkBarChartActor.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 =========================================================================*/
36 #ifndef __vtkBarChartActor_h
37 #define __vtkBarChartActor_h
38 
39 #include "vtkActor2D.h"
40 
41 class vtkAxisActor2D;
42 class vtkDataObject;
43 class vtkPolyData;
45 class vtkTextMapper;
46 class vtkTextProperty;
47 class vtkLegendBoxActor;
48 class vtkGlyphSource2D;
49 class vtkBarLabelArray;
50 
52 {
53 public:
55 
57  void PrintSelf(ostream& os, vtkIndent indent);
59 
61  static vtkBarChartActor *New();
62 
64  virtual void SetInput(vtkDataObject*);
65 
67 
68  vtkGetObjectMacro(Input,vtkDataObject);
70 
72 
73  vtkSetMacro(TitleVisibility, int);
74  vtkGetMacro(TitleVisibility, int);
75  vtkBooleanMacro(TitleVisibility, int);
77 
79 
80  vtkSetStringMacro(Title);
81  vtkGetStringMacro(Title);
83 
85 
87  virtual void SetTitleTextProperty(vtkTextProperty *p);
88  vtkGetObjectMacro(TitleTextProperty,vtkTextProperty);
90 
92 
93  vtkSetMacro(LabelVisibility, int);
94  vtkGetMacro(LabelVisibility, int);
95  vtkBooleanMacro(LabelVisibility, int);
97 
99 
101  virtual void SetLabelTextProperty(vtkTextProperty *p);
102  vtkGetObjectMacro(LabelTextProperty,vtkTextProperty);
104 
106 
108  void SetBarColor(int i, double r, double g, double b);
109  void SetBarColor(int i, const double color[3])
110  { this->SetBarColor(i, color[0], color[1], color[2]); }
111  double *GetBarColor(int i);
113 
115 
117  void SetBarLabel(const int i, const char *);
118  const char* GetBarLabel(int i);
120 
122 
123  vtkSetStringMacro(YTitle);
124  vtkGetStringMacro(YTitle);
126 
128 
131  vtkSetMacro(LegendVisibility, int);
132  vtkGetMacro(LegendVisibility, int);
133  vtkBooleanMacro(LegendVisibility, int);
135 
137 
139  vtkGetObjectMacro(LegendActor,vtkLegendBoxActor);
141 
143 
148 
150  virtual int HasTranslucentPolygonalGeometry();
151 
156 
157 protected:
159  ~vtkBarChartActor();
160 
161 private:
162  vtkDataObject *Input; // List of data sets to plot
163  vtkIdType ArrayNumber;
164  vtkIdType ComponentNumber;
165  int TitleVisibility; // Should I see the title?
166  char *Title; // The title string
167  vtkTextProperty *TitleTextProperty;
168  int LabelVisibility;
169  vtkTextProperty *LabelTextProperty;
170  vtkBarLabelArray *Labels;
171  int LegendVisibility;
172  vtkLegendBoxActor *LegendActor;
173  vtkGlyphSource2D *GlyphSource;
174 
175  // Local variables needed to plot
176  vtkIdType N; // The number of values
177  double *Heights; // The heights of each bar
178  double MinHeight; //The maximum and minimum height
179  double MaxHeight;
180  double LowerLeft[2];
181  double UpperRight[2];
182 
183  vtkTextMapper **BarMappers; //a label for each bar
184  vtkActor2D **BarActors;
185 
186  vtkTextMapper *TitleMapper;
187  vtkActor2D *TitleActor;
188 
189  vtkPolyData *PlotData; // The actual bars plus the x-axis
190  vtkPolyDataMapper2D *PlotMapper;
191  vtkActor2D *PlotActor;
192 
193  vtkAxisActor2D *YAxis; //The y-axis
194  char *YTitle;
195 
196  vtkTimeStamp BuildTime;
197 
198  int LastPosition[2];
199  int LastPosition2[2];
200  double P1[3];
201  double P2[3];
202 
203  void Initialize();
204  int PlaceAxes(vtkViewport *viewport, int *size);
205  int BuildPlot(vtkViewport*);
206 
207 private:
208  vtkBarChartActor(const vtkBarChartActor&); // Not implemented.
209  void operator=(const vtkBarChartActor&); // Not implemented.
210 };
211 
212 
213 #endif
214