VTK  9.0.3
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 "vtkActor2D.h"
38 #include "vtkRenderingAnnotationModule.h" // For export macro
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 
57  vtkTypeMacro(vtkBarChartActor, vtkActor2D);
58  void PrintSelf(ostream& os, vtkIndent indent) override;
60 
64  static vtkBarChartActor* New();
65 
69  virtual void SetInput(vtkDataObject*);
70 
72 
75  vtkGetObjectMacro(Input, vtkDataObject);
77 
79 
82  vtkSetMacro(TitleVisibility, vtkTypeBool);
83  vtkGetMacro(TitleVisibility, vtkTypeBool);
84  vtkBooleanMacro(TitleVisibility, vtkTypeBool);
86 
88 
91  vtkSetStringMacro(Title);
92  vtkGetStringMacro(Title);
94 
96 
101  vtkGetObjectMacro(TitleTextProperty, vtkTextProperty);
103 
105 
108  vtkSetMacro(LabelVisibility, vtkTypeBool);
109  vtkGetMacro(LabelVisibility, vtkTypeBool);
110  vtkBooleanMacro(LabelVisibility, vtkTypeBool);
112 
114 
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  {
130  this->SetBarColor(i, color[0], color[1], color[2]);
131  }
132  double* GetBarColor(int i);
134 
136 
140  void SetBarLabel(const int i, const char*);
141  const char* GetBarLabel(int i);
143 
145 
148  vtkSetStringMacro(YTitle);
149  vtkGetStringMacro(YTitle);
151 
153 
158  vtkSetMacro(LegendVisibility, vtkTypeBool);
159  vtkGetMacro(LegendVisibility, vtkTypeBool);
160  vtkBooleanMacro(LegendVisibility, vtkTypeBool);
162 
164 
168  vtkGetObjectMacro(LegendActor, vtkLegendBoxActor);
170 
172 
175  int RenderOverlay(vtkViewport*) override;
177  int RenderTranslucentPolygonalGeometry(vtkViewport*) override { return 0; }
179 
184 
191 
192 protected:
194  ~vtkBarChartActor() override;
195 
196 private:
197  vtkDataObject* Input; // List of data sets to plot
198  vtkIdType ArrayNumber;
199  vtkIdType ComponentNumber;
200  vtkTypeBool TitleVisibility; // Should I see the title?
201  char* Title; // The title string
202  vtkTextProperty* TitleTextProperty;
203  vtkTypeBool LabelVisibility;
204  vtkTextProperty* LabelTextProperty;
205  vtkBarLabelArray* Labels;
206  vtkTypeBool LegendVisibility;
207  vtkLegendBoxActor* LegendActor;
208  vtkGlyphSource2D* GlyphSource;
209 
210  // Local variables needed to plot
211  vtkIdType N; // The number of values
212  double* Heights; // The heights of each bar
213  double MinHeight; // The maximum and minimum height
214  double MaxHeight;
215  double LowerLeft[2];
216  double UpperRight[2];
217 
218  vtkTextMapper** BarMappers; // a label for each bar
219  vtkActor2D** BarActors;
220 
221  vtkTextMapper* TitleMapper;
222  vtkActor2D* TitleActor;
223 
224  vtkPolyData* PlotData; // The actual bars plus the x-axis
225  vtkPolyDataMapper2D* PlotMapper;
226  vtkActor2D* PlotActor;
227 
228  vtkAxisActor2D* YAxis; // The y-axis
229  char* YTitle;
230 
231  vtkTimeStamp BuildTime;
232 
233  int LastPosition[2];
234  int LastPosition2[2];
235  double P1[3];
236  double P2[3];
237 
238  void Initialize();
239  int PlaceAxes(vtkViewport* viewport, const int* size);
240  int BuildPlot(vtkViewport*);
241 
242 private:
243  vtkBarChartActor(const vtkBarChartActor&) = delete;
244  void operator=(const vtkBarChartActor&) = delete;
245 };
246 
247 #endif
a actor that draws 2D data
Definition: vtkActor2D.h:40
Create an axis with tick marks and labels.
create a bar chart from an array
static vtkBarChartActor * New()
Instantiate this class.
int RenderOpaqueGeometry(vtkViewport *) override
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE DO NOT USE THESE METHODS OUTSIDE OF THE RENDE...
int RenderOverlay(vtkViewport *) override
Draw the bar plot.
vtkTypeBool HasTranslucentPolygonalGeometry() override
Does this prop have some translucent polygonal geometry?
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void SetBarLabel(const int i, const char *)
Specify the names of each bar.
~vtkBarChartActor() override
void ReleaseGraphicsResources(vtkWindow *) override
Release any graphics resources that are being consumed by this actor.
virtual void SetLabelTextProperty(vtkTextProperty *p)
Set/Get the labels text property.
virtual void SetTitleTextProperty(vtkTextProperty *p)
Set/Get the title text property.
const char * GetBarLabel(int i)
virtual void SetInput(vtkDataObject *)
Set the input to the bar chart actor.
void SetBarColor(int i, const double color[3])
void SetBarColor(int i, double r, double g, double b)
Specify colors for each bar.
double * GetBarColor(int i)
int RenderTranslucentPolygonalGeometry(vtkViewport *) override
general representation of visualization data
Definition: vtkDataObject.h:60
create 2D glyphs represented by vtkPolyData
a simple class to control print indentation
Definition: vtkIndent.h:34
draw symbols with text
draw vtkPolyData onto the image plane
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:85
2D text annotation
Definition: vtkTextMapper.h:48
represent text properties.
record modification and/or execution time
Definition: vtkTimeStamp.h:33
abstract specification for Viewports
Definition: vtkViewport.h:45
window superclass for vtkRenderWindow
Definition: vtkWindow.h:38
@ color
Definition: vtkX3D.h:227
@ size
Definition: vtkX3D.h:259
int vtkTypeBool
Definition: vtkABI.h:69
int vtkIdType
Definition: vtkType.h:338