VTK  9.6.1
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
24
25#ifndef vtkBarChartActor_h
26#define vtkBarChartActor_h
27
28#include "vtkActor2D.h"
29#include "vtkNew.h" // For vtkNew
30#include "vtkRenderingAnnotationModule.h" // For export macro
31#include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
32
33VTK_ABI_NAMESPACE_BEGIN
34class vtkAxisActor2D;
35class vtkDataObject;
36class vtkPolyData;
38class vtkTextMapper;
39class vtkTextProperty;
42class vtkBarLabelArray;
43
44class VTKRENDERINGANNOTATION_EXPORT VTK_MARSHALAUTO vtkBarChartActor : public vtkActor2D
45{
46public:
48
52 void PrintSelf(ostream& os, vtkIndent indent) override;
54
59
63 virtual void SetInput(vtkDataObject*);
64
66
69 vtkGetObjectMacro(Input, vtkDataObject);
71
73
76 vtkSetMacro(TitleVisibility, vtkTypeBool);
77 vtkGetMacro(TitleVisibility, vtkTypeBool);
78 vtkBooleanMacro(TitleVisibility, vtkTypeBool);
80
82
85 vtkSetStringMacro(Title);
86 vtkGetStringMacro(Title);
88
90
95 vtkGetObjectMacro(TitleTextProperty, vtkTextProperty);
97
99
102 vtkSetMacro(LabelVisibility, vtkTypeBool);
103 vtkGetMacro(LabelVisibility, vtkTypeBool);
104 vtkBooleanMacro(LabelVisibility, vtkTypeBool);
106
108
113 vtkGetObjectMacro(LabelTextProperty, vtkTextProperty);
115
117
121 void SetBarColor(int i, double r, double g, double b);
122 void SetBarColor(int i, const double color[3])
123 {
124 this->SetBarColor(i, color[0], color[1], color[2]);
125 }
126 double* GetBarColor(int i);
128
130
134 void SetBarLabel(int i, const char*);
135 const char* GetBarLabel(int i);
138
140
143 vtkSetStringMacro(YTitle);
144 vtkGetStringMacro(YTitle);
146
148
153 vtkSetMacro(LegendVisibility, vtkTypeBool);
154 vtkGetMacro(LegendVisibility, vtkTypeBool);
155 vtkBooleanMacro(LegendVisibility, vtkTypeBool);
157
159
163 vtkGetObjectMacro(LegendActor, vtkLegendBoxActor);
165
167
174
179
186
187protected:
190
191private:
192 vtkDataObject* Input; // List of data sets to plot
193 vtkIdType ArrayNumber;
194 vtkIdType ComponentNumber;
195 vtkTypeBool TitleVisibility; // Should I see the title?
196 char* Title; // The title string
197 vtkTextProperty* TitleTextProperty;
198 vtkTypeBool LabelVisibility;
199 vtkTextProperty* LabelTextProperty;
200 vtkBarLabelArray* Labels;
201 vtkTypeBool LegendVisibility;
202 vtkNew<vtkLegendBoxActor> LegendActor;
203 vtkGlyphSource2D* GlyphSource;
204
205 // Local variables needed to plot
206 vtkIdType N; // The number of values
207 double* Heights; // The heights of each bar
208 double MinHeight; // The maximum and minimum height
209 double MaxHeight;
210 double LowerLeft[2];
211 double UpperRight[2];
212
213 vtkTextMapper** BarMappers; // a label for each bar
214 vtkActor2D** BarActors;
215
216 vtkTextMapper* TitleMapper;
217 vtkActor2D* TitleActor;
218
219 vtkPolyData* PlotData; // The actual bars plus the x-axis
220 vtkPolyDataMapper2D* PlotMapper;
221 vtkActor2D* PlotActor;
222
223 vtkAxisActor2D* YAxis; // The y-axis
224 char* YTitle;
225
226 vtkTimeStamp BuildTime;
227
228 int LastPosition[2];
229 int LastPosition2[2];
230 double P1[3];
231 double P2[3];
232
233 void Initialize();
234 int PlaceAxes(vtkViewport* viewport, const int* size);
235 int BuildPlot(vtkViewport*);
236
237 vtkBarChartActor(const vtkBarChartActor&) = delete;
238 void operator=(const vtkBarChartActor&) = delete;
239};
240
241VTK_ABI_NAMESPACE_END
242#endif
Create an axis with tick marks and labels.
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 GetNumberOfBarLabels()
Specify the names of 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
Allocate and hold a VTK object.
Definition vtkNew.h:58
draw vtkPolyData onto the image plane
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition vtkPolyData.h:72
2D text annotation
represent text properties.
record modification and/or execution time
abstract specification for Viewports
Definition vtkViewport.h:47
window superclass for vtkRenderWindow
Definition vtkWindow.h:29
int vtkTypeBool
Definition vtkABI.h:64
virtual void Initialize()
int vtkIdType
Definition vtkType.h:368
#define VTK_MARSHALAUTO