VTK  9.2.6
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=========================================================================*/
37#ifndef vtkBarChartActor_h
38#define vtkBarChartActor_h
39
40#include "vtkActor2D.h"
41#include "vtkRenderingAnnotationModule.h" // For export macro
42
43class vtkAxisActor2D;
44class vtkDataObject;
45class vtkPolyData;
47class vtkTextMapper;
48class vtkTextProperty;
51class vtkBarLabelArray;
52
53class VTKRENDERINGANNOTATION_EXPORT vtkBarChartActor : public vtkActor2D
54{
55public:
57
61 void PrintSelf(ostream& os, vtkIndent indent) override;
63
68
72 virtual void SetInput(vtkDataObject*);
73
75
78 vtkGetObjectMacro(Input, vtkDataObject);
80
82
85 vtkSetMacro(TitleVisibility, vtkTypeBool);
86 vtkGetMacro(TitleVisibility, vtkTypeBool);
87 vtkBooleanMacro(TitleVisibility, vtkTypeBool);
89
91
94 vtkSetStringMacro(Title);
95 vtkGetStringMacro(Title);
97
99
104 vtkGetObjectMacro(TitleTextProperty, vtkTextProperty);
106
108
111 vtkSetMacro(LabelVisibility, vtkTypeBool);
112 vtkGetMacro(LabelVisibility, vtkTypeBool);
113 vtkBooleanMacro(LabelVisibility, vtkTypeBool);
115
117
122 vtkGetObjectMacro(LabelTextProperty, vtkTextProperty);
124
126
130 void SetBarColor(int i, double r, double g, double b);
131 void SetBarColor(int i, const double color[3])
132 {
133 this->SetBarColor(i, color[0], color[1], color[2]);
134 }
135 double* GetBarColor(int i);
137
139
143 void SetBarLabel(const int i, const char*);
144 const char* GetBarLabel(int i);
146
148
151 vtkSetStringMacro(YTitle);
152 vtkGetStringMacro(YTitle);
154
156
161 vtkSetMacro(LegendVisibility, vtkTypeBool);
162 vtkGetMacro(LegendVisibility, vtkTypeBool);
163 vtkBooleanMacro(LegendVisibility, vtkTypeBool);
165
167
171 vtkGetObjectMacro(LegendActor, vtkLegendBoxActor);
173
175
182
187
194
195protected:
198
199private:
200 vtkDataObject* Input; // List of data sets to plot
201 vtkIdType ArrayNumber;
202 vtkIdType ComponentNumber;
203 vtkTypeBool TitleVisibility; // Should I see the title?
204 char* Title; // The title string
205 vtkTextProperty* TitleTextProperty;
206 vtkTypeBool LabelVisibility;
207 vtkTextProperty* LabelTextProperty;
208 vtkBarLabelArray* Labels;
209 vtkTypeBool LegendVisibility;
210 vtkLegendBoxActor* LegendActor;
211 vtkGlyphSource2D* GlyphSource;
212
213 // Local variables needed to plot
214 vtkIdType N; // The number of values
215 double* Heights; // The heights of each bar
216 double MinHeight; // The maximum and minimum height
217 double MaxHeight;
218 double LowerLeft[2];
219 double UpperRight[2];
220
221 vtkTextMapper** BarMappers; // a label for each bar
222 vtkActor2D** BarActors;
223
224 vtkTextMapper* TitleMapper;
225 vtkActor2D* TitleActor;
226
227 vtkPolyData* PlotData; // The actual bars plus the x-axis
228 vtkPolyDataMapper2D* PlotMapper;
229 vtkActor2D* PlotActor;
230
231 vtkAxisActor2D* YAxis; // The y-axis
232 char* YTitle;
233
234 vtkTimeStamp BuildTime;
235
236 int LastPosition[2];
237 int LastPosition2[2];
238 double P1[3];
239 double P2[3];
240
241 void Initialize();
242 int PlaceAxes(vtkViewport* viewport, const int* size);
243 int BuildPlot(vtkViewport*);
244
245private:
246 vtkBarChartActor(const vtkBarChartActor&) = delete;
247 void operator=(const vtkBarChartActor&) = delete;
248};
249
250#endif
a actor that draws 2D data
Definition: vtkActor2D.h:46
Create an axis with tick marks and labels.
create a bar chart from an array
int RenderOpaqueGeometry(vtkViewport *) override
Draw the bar plot.
const char * GetBarLabel(int i)
Specify the names of each bar.
int RenderOverlay(vtkViewport *) override
Draw the bar plot.
double * GetBarColor(int i)
Specify colors for each bar.
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.
static vtkBarChartActor * New()
Instantiate this class.
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.
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.
int RenderTranslucentPolygonalGeometry(vtkViewport *) override
Draw the bar plot.
general representation of visualization data
Definition: vtkDataObject.h:66
create 2D glyphs represented by vtkPolyData
a simple class to control print indentation
Definition: vtkIndent.h:40
draw symbols with text
draw vtkPolyData onto the image plane
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:91
2D text annotation
Definition: vtkTextMapper.h:51
represent text properties.
record modification and/or execution time
Definition: vtkTimeStamp.h:36
abstract specification for Viewports
Definition: vtkViewport.h:56
window superclass for vtkRenderWindow
Definition: vtkWindow.h:39
int vtkTypeBool
Definition: vtkABI.h:69
int vtkIdType
Definition: vtkType.h:332