VTK  9.3.0
vtkBarChartActor.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2// SPDX-License-Identifier: BSD-3-Clause
25#ifndef vtkBarChartActor_h
26#define vtkBarChartActor_h
27
28#include "vtkActor2D.h"
29#include "vtkRenderingAnnotationModule.h" // For export macro
30
31VTK_ABI_NAMESPACE_BEGIN
32class vtkAxisActor2D;
33class vtkDataObject;
34class vtkPolyData;
36class vtkTextMapper;
37class vtkTextProperty;
40class vtkBarLabelArray;
41
42class VTKRENDERINGANNOTATION_EXPORT vtkBarChartActor : public vtkActor2D
43{
44public:
46
50 void PrintSelf(ostream& os, vtkIndent indent) override;
52
57
61 virtual void SetInput(vtkDataObject*);
62
64
67 vtkGetObjectMacro(Input, vtkDataObject);
69
71
74 vtkSetMacro(TitleVisibility, vtkTypeBool);
75 vtkGetMacro(TitleVisibility, vtkTypeBool);
76 vtkBooleanMacro(TitleVisibility, vtkTypeBool);
78
80
83 vtkSetStringMacro(Title);
84 vtkGetStringMacro(Title);
86
88
93 vtkGetObjectMacro(TitleTextProperty, vtkTextProperty);
95
97
100 vtkSetMacro(LabelVisibility, vtkTypeBool);
101 vtkGetMacro(LabelVisibility, vtkTypeBool);
102 vtkBooleanMacro(LabelVisibility, vtkTypeBool);
104
106
111 vtkGetObjectMacro(LabelTextProperty, vtkTextProperty);
113
115
119 void SetBarColor(int i, double r, double g, double b);
120 void SetBarColor(int i, const double color[3])
121 {
122 this->SetBarColor(i, color[0], color[1], color[2]);
123 }
124 double* GetBarColor(int i);
126
128
132 void SetBarLabel(int i, const char*);
133 const char* GetBarLabel(int i);
135
137
140 vtkSetStringMacro(YTitle);
141 vtkGetStringMacro(YTitle);
143
145
150 vtkSetMacro(LegendVisibility, vtkTypeBool);
151 vtkGetMacro(LegendVisibility, vtkTypeBool);
152 vtkBooleanMacro(LegendVisibility, vtkTypeBool);
154
156
160 vtkGetObjectMacro(LegendActor, vtkLegendBoxActor);
162
164
171
176
183
184protected:
187
188private:
189 vtkDataObject* Input; // List of data sets to plot
190 vtkIdType ArrayNumber;
191 vtkIdType ComponentNumber;
192 vtkTypeBool TitleVisibility; // Should I see the title?
193 char* Title; // The title string
194 vtkTextProperty* TitleTextProperty;
195 vtkTypeBool LabelVisibility;
196 vtkTextProperty* LabelTextProperty;
197 vtkBarLabelArray* Labels;
198 vtkTypeBool LegendVisibility;
199 vtkLegendBoxActor* LegendActor;
200 vtkGlyphSource2D* GlyphSource;
201
202 // Local variables needed to plot
203 vtkIdType N; // The number of values
204 double* Heights; // The heights of each bar
205 double MinHeight; // The maximum and minimum height
206 double MaxHeight;
207 double LowerLeft[2];
208 double UpperRight[2];
209
210 vtkTextMapper** BarMappers; // a label for each bar
211 vtkActor2D** BarActors;
212
213 vtkTextMapper* TitleMapper;
214 vtkActor2D* TitleActor;
215
216 vtkPolyData* PlotData; // The actual bars plus the x-axis
217 vtkPolyDataMapper2D* PlotMapper;
218 vtkActor2D* PlotActor;
219
220 vtkAxisActor2D* YAxis; // The y-axis
221 char* YTitle;
222
223 vtkTimeStamp BuildTime;
224
225 int LastPosition[2];
226 int LastPosition2[2];
227 double P1[3];
228 double P2[3];
229
230 void Initialize();
231 int PlaceAxes(vtkViewport* viewport, const int* size);
232 int BuildPlot(vtkViewport*);
233
234 vtkBarChartActor(const vtkBarChartActor&) = delete;
235 void operator=(const vtkBarChartActor&) = delete;
236};
237
238VTK_ABI_NAMESPACE_END
239#endif
a actor that draws 2D data
Definition vtkActor2D.h:35
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.
~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 SetBarLabel(int i, const char *)
Specify the names of each bar.
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
create 2D glyphs represented by vtkPolyData
a simple class to control print indentation
Definition vtkIndent.h:29
draw symbols with text
draw vtkPolyData onto the image plane
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition vtkPolyData.h:80
2D text annotation
represent text properties.
record modification and/or execution time
abstract specification for Viewports
Definition vtkViewport.h:45
window superclass for vtkRenderWindow
Definition vtkWindow.h:25
int vtkTypeBool
Definition vtkABI.h:64
int vtkIdType
Definition vtkType.h:315