VTK  9.3.20240327
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
64 #ifndef vtkBarChartActor_h
65 #define vtkBarChartActor_h
66 
67 #include "vtkActor2D.h"
68 #include "vtkRenderingAnnotationModule.h" // For export macro
69 
70 VTK_ABI_NAMESPACE_BEGIN
71 class vtkAxisActor2D;
72 class vtkDataObject;
73 class vtkPolyData;
75 class vtkTextMapper;
76 class vtkTextProperty;
77 class vtkLegendBoxActor;
78 class vtkGlyphSource2D;
79 class vtkBarLabelArray;
80 
81 class VTKRENDERINGANNOTATION_EXPORT vtkBarChartActor : public vtkActor2D
82 {
83 public:
85 
88  vtkTypeMacro(vtkBarChartActor, vtkActor2D);
89  void PrintSelf(ostream& os, vtkIndent indent) override;
91 
95  static vtkBarChartActor* New();
96 
100  virtual void SetInput(vtkDataObject*);
101 
103 
106  vtkGetObjectMacro(Input, vtkDataObject);
108 
110 
113  vtkSetMacro(TitleVisibility, vtkTypeBool);
114  vtkGetMacro(TitleVisibility, vtkTypeBool);
115  vtkBooleanMacro(TitleVisibility, vtkTypeBool);
117 
119 
122  vtkSetStringMacro(Title);
123  vtkGetStringMacro(Title);
125 
127 
132  vtkGetObjectMacro(TitleTextProperty, vtkTextProperty);
134 
136 
139  vtkSetMacro(LabelVisibility, vtkTypeBool);
140  vtkGetMacro(LabelVisibility, vtkTypeBool);
141  vtkBooleanMacro(LabelVisibility, vtkTypeBool);
143 
145 
150  vtkGetObjectMacro(LabelTextProperty, vtkTextProperty);
152 
154 
158  void SetBarColor(int i, double r, double g, double b);
159  void SetBarColor(int i, const double color[3])
160  {
161  this->SetBarColor(i, color[0], color[1], color[2]);
162  }
163  double* GetBarColor(int i);
165 
167 
171  void SetBarLabel(int i, const char*);
172  const char* GetBarLabel(int i);
174 
176 
179  vtkSetStringMacro(YTitle);
180  vtkGetStringMacro(YTitle);
182 
184 
189  vtkSetMacro(LegendVisibility, vtkTypeBool);
190  vtkGetMacro(LegendVisibility, vtkTypeBool);
191  vtkBooleanMacro(LegendVisibility, vtkTypeBool);
193 
195 
199  vtkGetObjectMacro(LegendActor, vtkLegendBoxActor);
201 
203 
206  int RenderOverlay(vtkViewport*) override;
208  int RenderTranslucentPolygonalGeometry(vtkViewport*) override { return 0; }
210 
215 
222 
223 protected:
225  ~vtkBarChartActor() override;
226 
227 private:
228  vtkDataObject* Input; // List of data sets to plot
229  vtkIdType ArrayNumber;
230  vtkIdType ComponentNumber;
231  vtkTypeBool TitleVisibility; // Should I see the title?
232  char* Title; // The title string
233  vtkTextProperty* TitleTextProperty;
234  vtkTypeBool LabelVisibility;
235  vtkTextProperty* LabelTextProperty;
236  vtkBarLabelArray* Labels;
237  vtkTypeBool LegendVisibility;
238  vtkLegendBoxActor* LegendActor;
239  vtkGlyphSource2D* GlyphSource;
240 
241  // Local variables needed to plot
242  vtkIdType N; // The number of values
243  double* Heights; // The heights of each bar
244  double MinHeight; // The maximum and minimum height
245  double MaxHeight;
246  double LowerLeft[2];
247  double UpperRight[2];
248 
249  vtkTextMapper** BarMappers; // a label for each bar
250  vtkActor2D** BarActors;
251 
252  vtkTextMapper* TitleMapper;
253  vtkActor2D* TitleActor;
254 
255  vtkPolyData* PlotData; // The actual bars plus the x-axis
256  vtkPolyDataMapper2D* PlotMapper;
257  vtkActor2D* PlotActor;
258 
259  vtkAxisActor2D* YAxis; // The y-axis
260  char* YTitle;
261 
262  vtkTimeStamp BuildTime;
263 
264  int LastPosition[2];
265  int LastPosition2[2];
266  double P1[3];
267  double P2[3];
268 
269  void Initialize();
270  int PlaceAxes(vtkViewport* viewport, const int* size);
271  int BuildPlot(vtkViewport*);
272 
273  vtkBarChartActor(const vtkBarChartActor&) = delete;
274  void operator=(const vtkBarChartActor&) = delete;
275 };
276 
277 VTK_ABI_NAMESPACE_END
278 #endif
a actor that draws 2D data
Definition: vtkActor2D.h:144
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.
~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 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.
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:108
draw symbols with text
draw vtkPolyData onto the image plane
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:180
2D text annotation
represent text properties.
record modification and/or execution time
Definition: vtkTimeStamp.h:44
abstract specification for Viewports
Definition: vtkViewport.h:64
window superclass for vtkRenderWindow
Definition: vtkWindow.h:47
@ color
Definition: vtkX3D.h:221
@ size
Definition: vtkX3D.h:253
int vtkTypeBool
Definition: vtkABI.h:64
int vtkIdType
Definition: vtkType.h:315