VTK  9.3.20240418
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 #include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
70 
71 VTK_ABI_NAMESPACE_BEGIN
72 class vtkAxisActor2D;
73 class vtkDataObject;
74 class vtkPolyData;
76 class vtkTextMapper;
77 class vtkTextProperty;
78 class vtkLegendBoxActor;
79 class vtkGlyphSource2D;
80 class vtkBarLabelArray;
81 
82 class VTKRENDERINGANNOTATION_EXPORT VTK_MARSHALAUTO vtkBarChartActor : public vtkActor2D
83 {
84 public:
86 
89  vtkTypeMacro(vtkBarChartActor, vtkActor2D);
90  void PrintSelf(ostream& os, vtkIndent indent) override;
92 
96  static vtkBarChartActor* New();
97 
101  virtual void SetInput(vtkDataObject*);
102 
104 
107  vtkGetObjectMacro(Input, vtkDataObject);
109 
111 
114  vtkSetMacro(TitleVisibility, vtkTypeBool);
115  vtkGetMacro(TitleVisibility, vtkTypeBool);
116  vtkBooleanMacro(TitleVisibility, vtkTypeBool);
118 
120 
123  vtkSetStringMacro(Title);
124  vtkGetStringMacro(Title);
126 
128 
133  vtkGetObjectMacro(TitleTextProperty, vtkTextProperty);
135 
137 
140  vtkSetMacro(LabelVisibility, vtkTypeBool);
141  vtkGetMacro(LabelVisibility, vtkTypeBool);
142  vtkBooleanMacro(LabelVisibility, vtkTypeBool);
144 
146 
151  vtkGetObjectMacro(LabelTextProperty, vtkTextProperty);
153 
155 
159  void SetBarColor(int i, double r, double g, double b);
160  void SetBarColor(int i, const double color[3])
161  {
162  this->SetBarColor(i, color[0], color[1], color[2]);
163  }
164  double* GetBarColor(int i);
166 
168 
172  void SetBarLabel(int i, const char*);
173  const char* GetBarLabel(int i);
175 
177 
180  vtkSetStringMacro(YTitle);
181  vtkGetStringMacro(YTitle);
183 
185 
190  vtkSetMacro(LegendVisibility, vtkTypeBool);
191  vtkGetMacro(LegendVisibility, vtkTypeBool);
192  vtkBooleanMacro(LegendVisibility, vtkTypeBool);
194 
196 
200  vtkGetObjectMacro(LegendActor, vtkLegendBoxActor);
202 
204 
207  int RenderOverlay(vtkViewport*) override;
209  int RenderTranslucentPolygonalGeometry(vtkViewport*) override { return 0; }
211 
216 
223 
224 protected:
226  ~vtkBarChartActor() override;
227 
228 private:
229  vtkDataObject* Input; // List of data sets to plot
230  vtkIdType ArrayNumber;
231  vtkIdType ComponentNumber;
232  vtkTypeBool TitleVisibility; // Should I see the title?
233  char* Title; // The title string
234  vtkTextProperty* TitleTextProperty;
235  vtkTypeBool LabelVisibility;
236  vtkTextProperty* LabelTextProperty;
237  vtkBarLabelArray* Labels;
238  vtkTypeBool LegendVisibility;
239  vtkLegendBoxActor* LegendActor;
240  vtkGlyphSource2D* GlyphSource;
241 
242  // Local variables needed to plot
243  vtkIdType N; // The number of values
244  double* Heights; // The heights of each bar
245  double MinHeight; // The maximum and minimum height
246  double MaxHeight;
247  double LowerLeft[2];
248  double UpperRight[2];
249 
250  vtkTextMapper** BarMappers; // a label for each bar
251  vtkActor2D** BarActors;
252 
253  vtkTextMapper* TitleMapper;
254  vtkActor2D* TitleActor;
255 
256  vtkPolyData* PlotData; // The actual bars plus the x-axis
257  vtkPolyDataMapper2D* PlotMapper;
258  vtkActor2D* PlotActor;
259 
260  vtkAxisActor2D* YAxis; // The y-axis
261  char* YTitle;
262 
263  vtkTimeStamp BuildTime;
264 
265  int LastPosition[2];
266  int LastPosition2[2];
267  double P1[3];
268  double P2[3];
269 
270  void Initialize();
271  int PlaceAxes(vtkViewport* viewport, const int* size);
272  int BuildPlot(vtkViewport*);
273 
274  vtkBarChartActor(const vtkBarChartActor&) = delete;
275  void operator=(const vtkBarChartActor&) = delete;
276 };
277 
278 VTK_ABI_NAMESPACE_END
279 #endif
a actor that draws 2D data
Definition: vtkActor2D.h:145
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:181
2D text annotation
represent text properties.
record modification and/or execution time
Definition: vtkTimeStamp.h:44
abstract specification for Viewports
Definition: vtkViewport.h:65
window superclass for vtkRenderWindow
Definition: vtkWindow.h:48
@ color
Definition: vtkX3D.h:221
@ size
Definition: vtkX3D.h:253
int vtkTypeBool
Definition: vtkABI.h:64
int vtkIdType
Definition: vtkType.h:315
#define VTK_MARSHALAUTO