VTK  9.2.6
vtkBarChartActor.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkBarChartActor.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
46 #ifndef vtkBarChartActor_h
47 #define vtkBarChartActor_h
48 
49 #include "vtkActor2D.h"
50 #include "vtkRenderingAnnotationModule.h" // For export macro
51 
52 class vtkAxisActor2D;
53 class vtkDataObject;
54 class vtkPolyData;
56 class vtkTextMapper;
57 class vtkTextProperty;
58 class vtkLegendBoxActor;
59 class vtkGlyphSource2D;
60 class vtkBarLabelArray;
61 
62 class VTKRENDERINGANNOTATION_EXPORT vtkBarChartActor : public vtkActor2D
63 {
64 public:
66 
69  vtkTypeMacro(vtkBarChartActor, vtkActor2D);
70  void PrintSelf(ostream& os, vtkIndent indent) override;
72 
76  static vtkBarChartActor* New();
77 
81  virtual void SetInput(vtkDataObject*);
82 
84 
87  vtkGetObjectMacro(Input, vtkDataObject);
89 
91 
94  vtkSetMacro(TitleVisibility, vtkTypeBool);
95  vtkGetMacro(TitleVisibility, vtkTypeBool);
96  vtkBooleanMacro(TitleVisibility, vtkTypeBool);
98 
100 
103  vtkSetStringMacro(Title);
104  vtkGetStringMacro(Title);
106 
108 
113  vtkGetObjectMacro(TitleTextProperty, vtkTextProperty);
115 
117 
120  vtkSetMacro(LabelVisibility, vtkTypeBool);
121  vtkGetMacro(LabelVisibility, vtkTypeBool);
122  vtkBooleanMacro(LabelVisibility, vtkTypeBool);
124 
126 
131  vtkGetObjectMacro(LabelTextProperty, vtkTextProperty);
133 
135 
139  void SetBarColor(int i, double r, double g, double b);
140  void SetBarColor(int i, const double color[3])
141  {
142  this->SetBarColor(i, color[0], color[1], color[2]);
143  }
144  double* GetBarColor(int i);
146 
148 
152  void SetBarLabel(const int i, const char*);
153  const char* GetBarLabel(int i);
155 
157 
160  vtkSetStringMacro(YTitle);
161  vtkGetStringMacro(YTitle);
163 
165 
170  vtkSetMacro(LegendVisibility, vtkTypeBool);
171  vtkGetMacro(LegendVisibility, vtkTypeBool);
172  vtkBooleanMacro(LegendVisibility, vtkTypeBool);
174 
176 
180  vtkGetObjectMacro(LegendActor, vtkLegendBoxActor);
182 
184 
187  int RenderOverlay(vtkViewport*) override;
189  int RenderTranslucentPolygonalGeometry(vtkViewport*) override { return 0; }
191 
196 
203 
204 protected:
206  ~vtkBarChartActor() override;
207 
208 private:
209  vtkDataObject* Input; // List of data sets to plot
210  vtkIdType ArrayNumber;
211  vtkIdType ComponentNumber;
212  vtkTypeBool TitleVisibility; // Should I see the title?
213  char* Title; // The title string
214  vtkTextProperty* TitleTextProperty;
215  vtkTypeBool LabelVisibility;
216  vtkTextProperty* LabelTextProperty;
217  vtkBarLabelArray* Labels;
218  vtkTypeBool LegendVisibility;
219  vtkLegendBoxActor* LegendActor;
220  vtkGlyphSource2D* GlyphSource;
221 
222  // Local variables needed to plot
223  vtkIdType N; // The number of values
224  double* Heights; // The heights of each bar
225  double MinHeight; // The maximum and minimum height
226  double MaxHeight;
227  double LowerLeft[2];
228  double UpperRight[2];
229 
230  vtkTextMapper** BarMappers; // a label for each bar
231  vtkActor2D** BarActors;
232 
233  vtkTextMapper* TitleMapper;
234  vtkActor2D* TitleActor;
235 
236  vtkPolyData* PlotData; // The actual bars plus the x-axis
237  vtkPolyDataMapper2D* PlotMapper;
238  vtkActor2D* PlotActor;
239 
240  vtkAxisActor2D* YAxis; // The y-axis
241  char* YTitle;
242 
243  vtkTimeStamp BuildTime;
244 
245  int LastPosition[2];
246  int LastPosition2[2];
247  double P1[3];
248  double P2[3];
249 
250  void Initialize();
251  int PlaceAxes(vtkViewport* viewport, const int* size);
252  int BuildPlot(vtkViewport*);
253 
254 private:
255  vtkBarChartActor(const vtkBarChartActor&) = delete;
256  void operator=(const vtkBarChartActor&) = delete;
257 };
258 
259 #endif
a actor that draws 2D data
Definition: vtkActor2D.h:55
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.
void SetBarLabel(const int i, const char *)
Specify the names of each bar.
~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 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:75
create 2D glyphs represented by vtkPolyData
a simple class to control print indentation
Definition: vtkIndent.h:49
draw symbols with text
draw vtkPolyData onto the image plane
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:100
2D text annotation
Definition: vtkTextMapper.h:60
represent text properties.
record modification and/or execution time
Definition: vtkTimeStamp.h:45
abstract specification for Viewports
Definition: vtkViewport.h:65
window superclass for vtkRenderWindow
Definition: vtkWindow.h:48
@ color
Definition: vtkX3D.h:227
@ size
Definition: vtkX3D.h:259
int vtkTypeBool
Definition: vtkABI.h:69
int vtkIdType
Definition: vtkType.h:332