VTK  9.7.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
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 
33 VTK_ABI_NAMESPACE_BEGIN
34 class vtkAxisActor2D;
35 class vtkDataObject;
36 class vtkPolyData;
38 class vtkTextMapper;
39 class vtkTextProperty;
40 class vtkLegendBoxActor;
41 class vtkGlyphSource2D;
42 class vtkBarLabelArray;
43 
44 class VTKRENDERINGANNOTATION_EXPORT VTK_MARSHALAUTO vtkBarChartActor : public vtkActor2D
45 {
46 public:
48 
51  vtkTypeMacro(vtkBarChartActor, vtkActor2D);
52  void PrintSelf(ostream& os, vtkIndent indent) override;
54 
58  static vtkBarChartActor* New();
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 
94  virtual void SetTitleTextProperty(vtkTextProperty* p);
95  vtkGetObjectMacro(TitleTextProperty, vtkTextProperty);
97 
99 
102  vtkSetMacro(LabelVisibility, vtkTypeBool);
103  vtkGetMacro(LabelVisibility, vtkTypeBool);
104  vtkBooleanMacro(LabelVisibility, vtkTypeBool);
106 
108 
112  virtual void SetLabelTextProperty(vtkTextProperty* p);
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);
136  int GetNumberOfBarLabels();
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 
170  int RenderOverlay(vtkViewport*) override;
171  int RenderOpaqueGeometry(vtkViewport*) override;
172  int RenderTranslucentPolygonalGeometry(vtkViewport*) override { return 0; }
174 
179 
185  void ReleaseGraphicsResources(vtkWindow*) override;
186 
187 protected:
189  ~vtkBarChartActor() override;
190 
191 private:
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 
241 VTK_ABI_NAMESPACE_END
242 #endif
draw symbols with text
int RenderTranslucentPolygonalGeometry(vtkViewport *) override
Draw the bar plot.
int RenderOverlay(vtkViewport *viewport) override
Support the standard render methods.
abstract specification for Viewports
Definition: vtkViewport.h:46
void SetBarColor(int i, const double color[3])
Specify colors for each bar.
a actor that draws 2D data
Definition: vtkActor2D.h:35
record modification and/or execution time
Definition: vtkTimeStamp.h:24
Create an axis with tick marks and labels.
int vtkIdType
Definition: vtkType.h:363
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:71
create a bar chart from an array
2D text annotation
Definition: vtkTextMapper.h:39
int vtkTypeBool
Definition: vtkABI.h:64
window superclass for vtkRenderWindow
Definition: vtkWindow.h:41
void ReleaseGraphicsResources(vtkWindow *) override
Release any graphics resources that are being consumed by this actor.
a simple class to control print indentation
Definition: vtkIndent.h:28
static vtkActor2D * New()
Creates an actor2D with the following defaults: position (0,0) (coordinate system is viewport); at la...
represent text properties.
vtkTypeBool HasTranslucentPolygonalGeometry() override
Does this prop have some translucent polygonal geometry?
int RenderOpaqueGeometry(vtkViewport *viewport) override
Support the standard render methods.
#define VTK_MARSHALAUTO
create 2D glyphs represented by vtkPolyData
general representation of visualization data
Definition: vtkDataObject.h:55
draw vtkPolyData onto the image plane
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.