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 
31 VTK_ABI_NAMESPACE_BEGIN
32 class vtkAxisActor2D;
33 class vtkDataObject;
34 class vtkPolyData;
36 class vtkTextMapper;
37 class vtkTextProperty;
38 class vtkLegendBoxActor;
39 class vtkGlyphSource2D;
40 class vtkBarLabelArray;
41 
42 class VTKRENDERINGANNOTATION_EXPORT vtkBarChartActor : public vtkActor2D
43 {
44 public:
46 
49  vtkTypeMacro(vtkBarChartActor, vtkActor2D);
50  void PrintSelf(ostream& os, vtkIndent indent) override;
52 
56  static vtkBarChartActor* New();
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 
167  int RenderOverlay(vtkViewport*) override;
169  int RenderTranslucentPolygonalGeometry(vtkViewport*) override { return 0; }
171 
176 
183 
184 protected:
186  ~vtkBarChartActor() override;
187 
188 private:
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 
238 VTK_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
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
Definition: vtkDataObject.h:55
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
Definition: vtkTextMapper.h:40
represent text properties.
record modification and/or execution time
Definition: vtkTimeStamp.h:25
abstract specification for Viewports
Definition: vtkViewport.h:45
window superclass for vtkRenderWindow
Definition: vtkWindow.h:28
@ color
Definition: vtkX3D.h:221
@ size
Definition: vtkX3D.h:253
int vtkTypeBool
Definition: vtkABI.h:64
int vtkIdType
Definition: vtkType.h:315