VTK  9.2.5
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 =========================================================================*/
76 #ifndef vtkBarChartActor_h
77 #define vtkBarChartActor_h
78 
79 #include "vtkActor2D.h"
80 #include "vtkRenderingAnnotationModule.h" // For export macro
81 
82 class vtkAxisActor2D;
83 class vtkDataObject;
84 class vtkPolyData;
86 class vtkTextMapper;
87 class vtkTextProperty;
88 class vtkLegendBoxActor;
89 class vtkGlyphSource2D;
90 class vtkBarLabelArray;
91 
92 class VTKRENDERINGANNOTATION_EXPORT vtkBarChartActor : public vtkActor2D
93 {
94 public:
96 
99  vtkTypeMacro(vtkBarChartActor, vtkActor2D);
100  void PrintSelf(ostream& os, vtkIndent indent) override;
102 
107 
111  virtual void SetInput(vtkDataObject*);
112 
114 
117  vtkGetObjectMacro(Input, vtkDataObject);
119 
121 
124  vtkSetMacro(TitleVisibility, vtkTypeBool);
125  vtkGetMacro(TitleVisibility, vtkTypeBool);
126  vtkBooleanMacro(TitleVisibility, vtkTypeBool);
128 
130 
133  vtkSetStringMacro(Title);
134  vtkGetStringMacro(Title);
136 
138 
143  vtkGetObjectMacro(TitleTextProperty, vtkTextProperty);
145 
147 
150  vtkSetMacro(LabelVisibility, vtkTypeBool);
151  vtkGetMacro(LabelVisibility, vtkTypeBool);
152  vtkBooleanMacro(LabelVisibility, vtkTypeBool);
154 
156 
161  vtkGetObjectMacro(LabelTextProperty, vtkTextProperty);
163 
165 
169  void SetBarColor(int i, double r, double g, double b);
170  void SetBarColor(int i, const double color[3])
171  {
172  this->SetBarColor(i, color[0], color[1], color[2]);
173  }
174  double* GetBarColor(int i);
176 
178 
182  void SetBarLabel(const int i, const char*);
183  const char* GetBarLabel(int i);
185 
187 
190  vtkSetStringMacro(YTitle);
191  vtkGetStringMacro(YTitle);
193 
195 
200  vtkSetMacro(LegendVisibility, vtkTypeBool);
201  vtkGetMacro(LegendVisibility, vtkTypeBool);
202  vtkBooleanMacro(LegendVisibility, vtkTypeBool);
204 
206 
210  vtkGetObjectMacro(LegendActor, vtkLegendBoxActor);
212 
214 
217  int RenderOverlay(vtkViewport*) override;
219  int RenderTranslucentPolygonalGeometry(vtkViewport*) override { return 0; }
221 
226 
233 
234 protected:
236  ~vtkBarChartActor() override;
237 
238 private:
239  vtkDataObject* Input; // List of data sets to plot
240  vtkIdType ArrayNumber;
241  vtkIdType ComponentNumber;
242  vtkTypeBool TitleVisibility; // Should I see the title?
243  char* Title; // The title string
244  vtkTextProperty* TitleTextProperty;
245  vtkTypeBool LabelVisibility;
246  vtkTextProperty* LabelTextProperty;
247  vtkBarLabelArray* Labels;
248  vtkTypeBool LegendVisibility;
249  vtkLegendBoxActor* LegendActor;
250  vtkGlyphSource2D* GlyphSource;
251 
252  // Local variables needed to plot
253  vtkIdType N; // The number of values
254  double* Heights; // The heights of each bar
255  double MinHeight; // The maximum and minimum height
256  double MaxHeight;
257  double LowerLeft[2];
258  double UpperRight[2];
259 
260  vtkTextMapper** BarMappers; // a label for each bar
261  vtkActor2D** BarActors;
262 
263  vtkTextMapper* TitleMapper;
264  vtkActor2D* TitleActor;
265 
266  vtkPolyData* PlotData; // The actual bars plus the x-axis
267  vtkPolyDataMapper2D* PlotMapper;
268  vtkActor2D* PlotActor;
269 
270  vtkAxisActor2D* YAxis; // The y-axis
271  char* YTitle;
272 
273  vtkTimeStamp BuildTime;
274 
275  int LastPosition[2];
276  int LastPosition2[2];
277  double P1[3];
278  double P2[3];
279 
280  void Initialize();
281  int PlaceAxes(vtkViewport* viewport, const int* size);
282  int BuildPlot(vtkViewport*);
283 
284 private:
285  vtkBarChartActor(const vtkBarChartActor&) = delete;
286  void operator=(const vtkBarChartActor&) = delete;
287 };
288 
289 #endif
a actor that draws 2D data
Definition: vtkActor2D.h:155
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
Draw the bar plot.
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
Standard methods for type information and printing.
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)
Specify the names of each bar.
virtual void SetInput(vtkDataObject *)
Set the input to the bar chart actor.
void SetBarColor(int i, const double color[3])
Specify colors for each bar.
void SetBarColor(int i, double r, double g, double b)
Specify colors for each bar.
double * GetBarColor(int i)
Specify colors for each bar.
int RenderTranslucentPolygonalGeometry(vtkViewport *) override
Draw the bar plot.
general representation of visualization data
create 2D glyphs represented by vtkPolyData
a simple class to control print indentation
Definition: vtkIndent.h:119
draw symbols with text
draw vtkPolyData onto the image plane
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:200
2D text annotation
represent text properties.
record modification and/or execution time
Definition: vtkTimeStamp.h:55
abstract specification for Viewports
Definition: vtkViewport.h:56
window superclass for vtkRenderWindow
Definition: vtkWindow.h:39
@ color
Definition: vtkX3D.h:227
@ size
Definition: vtkX3D.h:259
int vtkTypeBool
Definition: vtkABI.h:69
int vtkIdType
Definition: vtkType.h:332