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 =========================================================================*/
34 #ifndef vtkBarChartActor_h
35 #define vtkBarChartActor_h
36 
37 #include "vtkRenderingAnnotationModule.h" // For export macro
38 #include "vtkActor2D.h"
39 
40 class vtkAxisActor2D;
41 class vtkDataObject;
42 class vtkPolyData;
44 class vtkTextMapper;
45 class vtkTextProperty;
46 class vtkLegendBoxActor;
47 class vtkGlyphSource2D;
48 class vtkBarLabelArray;
49 
50 class VTKRENDERINGANNOTATION_EXPORT vtkBarChartActor : public vtkActor2D
51 {
52 public:
54 
58  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
60 
64  static vtkBarChartActor *New();
65 
69  virtual void SetInput(vtkDataObject*);
70 
72 
75  vtkGetObjectMacro(Input,vtkDataObject);
77 
79 
82  vtkSetMacro(TitleVisibility, int);
83  vtkGetMacro(TitleVisibility, int);
84  vtkBooleanMacro(TitleVisibility, int);
86 
88 
91  vtkSetStringMacro(Title);
92  vtkGetStringMacro(Title);
94 
96 
100  virtual void SetTitleTextProperty(vtkTextProperty *p);
101  vtkGetObjectMacro(TitleTextProperty,vtkTextProperty);
103 
105 
108  vtkSetMacro(LabelVisibility, int);
109  vtkGetMacro(LabelVisibility, int);
110  vtkBooleanMacro(LabelVisibility, int);
112 
114 
118  virtual void SetLabelTextProperty(vtkTextProperty *p);
119  vtkGetObjectMacro(LabelTextProperty,vtkTextProperty);
121 
123 
127  void SetBarColor(int i, double r, double g, double b);
128  void SetBarColor(int i, const double color[3])
129  { this->SetBarColor(i, color[0], color[1], color[2]); }
130  double *GetBarColor(int i);
132 
134 
138  void SetBarLabel(const int i, const char *);
139  const char* GetBarLabel(int i);
141 
143 
146  vtkSetStringMacro(YTitle);
147  vtkGetStringMacro(YTitle);
149 
151 
156  vtkSetMacro(LegendVisibility, int);
157  vtkGetMacro(LegendVisibility, int);
158  vtkBooleanMacro(LegendVisibility, int);
160 
162 
166  vtkGetObjectMacro(LegendActor,vtkLegendBoxActor);
168 
170 
173  int RenderOverlay(vtkViewport*) VTK_OVERRIDE;
174  int RenderOpaqueGeometry(vtkViewport*) VTK_OVERRIDE;
175  int RenderTranslucentPolygonalGeometry(vtkViewport* ) VTK_OVERRIDE {return 0;}
177 
181  int HasTranslucentPolygonalGeometry() VTK_OVERRIDE;
182 
188  void ReleaseGraphicsResources(vtkWindow *) VTK_OVERRIDE;
189 
190 protected:
192  ~vtkBarChartActor() VTK_OVERRIDE;
193 
194 private:
195  vtkDataObject *Input; // List of data sets to plot
196  vtkIdType ArrayNumber;
197  vtkIdType ComponentNumber;
198  int TitleVisibility; // Should I see the title?
199  char *Title; // The title string
200  vtkTextProperty *TitleTextProperty;
201  int LabelVisibility;
202  vtkTextProperty *LabelTextProperty;
203  vtkBarLabelArray *Labels;
204  int LegendVisibility;
205  vtkLegendBoxActor *LegendActor;
206  vtkGlyphSource2D *GlyphSource;
207 
208  // Local variables needed to plot
209  vtkIdType N; // The number of values
210  double *Heights; // The heights of each bar
211  double MinHeight; //The maximum and minimum height
212  double MaxHeight;
213  double LowerLeft[2];
214  double UpperRight[2];
215 
216  vtkTextMapper **BarMappers; //a label for each bar
217  vtkActor2D **BarActors;
218 
219  vtkTextMapper *TitleMapper;
220  vtkActor2D *TitleActor;
221 
222  vtkPolyData *PlotData; // The actual bars plus the x-axis
223  vtkPolyDataMapper2D *PlotMapper;
224  vtkActor2D *PlotActor;
225 
226  vtkAxisActor2D *YAxis; //The y-axis
227  char *YTitle;
228 
230 
231  int LastPosition[2];
232  int LastPosition2[2];
233  double P1[3];
234  double P2[3];
235 
236  void Initialize();
237  int PlaceAxes(vtkViewport *viewport, int *size);
238  int BuildPlot(vtkViewport*);
239 
240 private:
241  vtkBarChartActor(const vtkBarChartActor&) VTK_DELETE_FUNCTION;
242  void operator=(const vtkBarChartActor&) VTK_DELETE_FUNCTION;
243 };
244 
245 
246 #endif
247 
draw symbols with text
vtkTimeStamp BuildTime
int RenderOverlay(vtkViewport *viewport) override
Support the standard render methods.
abstract specification for Viewports
Definition: vtkViewport.h:44
void SetBarColor(int i, const double color[3])
Specify colors for each bar.
a actor that draws 2D data
Definition: vtkActor2D.h:39
record modification and/or execution time
Definition: vtkTimeStamp.h:32
Create an axis with tick marks and labels.
int vtkIdType
Definition: vtkType.h:345
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:79
create a bar chart from an array
2D text annotation
Definition: vtkTextMapper.h:47
window superclass for vtkRenderWindow
Definition: vtkWindow.h:34
a simple class to control print indentation
Definition: vtkIndent.h:33
int HasTranslucentPolygonalGeometry() override
Does this prop have some translucent polygonal geometry?
#define P1
static vtkActor2D * New()
Creates an actor2D with the following defaults: position (0,0) (coordinate system is viewport); at la...
vtkGetStringMacro(ExtensionsString)
Returns a string listing all available extensions.
represent text properties.
vtkSetMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
#define P2
create 2D glyphs represented by vtkPolyData
vtkBooleanMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
general representation of visualization data
Definition: vtkDataObject.h:58
draw vtkPolyData onto the image plane
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.