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 =========================================================================*/
37 #ifndef vtkBarChartActor_h
38 #define vtkBarChartActor_h
39 
40 #include "vtkActor2D.h"
41 #include "vtkRenderingAnnotationModule.h" // For export macro
42 
43 class vtkAxisActor2D;
44 class vtkDataObject;
45 class vtkPolyData;
47 class vtkTextMapper;
48 class vtkTextProperty;
49 class vtkLegendBoxActor;
50 class vtkGlyphSource2D;
51 class vtkBarLabelArray;
52 
53 class VTKRENDERINGANNOTATION_EXPORT vtkBarChartActor : public vtkActor2D
54 {
55 public:
57 
60  vtkTypeMacro(vtkBarChartActor, vtkActor2D);
61  void PrintSelf(ostream& os, vtkIndent indent) override;
63 
67  static vtkBarChartActor* New();
68 
72  virtual void SetInput(vtkDataObject*);
73 
75 
78  vtkGetObjectMacro(Input, vtkDataObject);
80 
82 
85  vtkSetMacro(TitleVisibility, vtkTypeBool);
86  vtkGetMacro(TitleVisibility, vtkTypeBool);
87  vtkBooleanMacro(TitleVisibility, vtkTypeBool);
89 
91 
94  vtkSetStringMacro(Title);
95  vtkGetStringMacro(Title);
97 
99 
103  virtual void SetTitleTextProperty(vtkTextProperty* p);
104  vtkGetObjectMacro(TitleTextProperty, vtkTextProperty);
106 
108 
111  vtkSetMacro(LabelVisibility, vtkTypeBool);
112  vtkGetMacro(LabelVisibility, vtkTypeBool);
113  vtkBooleanMacro(LabelVisibility, vtkTypeBool);
115 
117 
121  virtual void SetLabelTextProperty(vtkTextProperty* p);
122  vtkGetObjectMacro(LabelTextProperty, vtkTextProperty);
124 
126 
130  void SetBarColor(int i, double r, double g, double b);
131  void SetBarColor(int i, const double color[3])
132  {
133  this->SetBarColor(i, color[0], color[1], color[2]);
134  }
135  double* GetBarColor(int i);
137 
139 
143  void SetBarLabel(const int i, const char*);
144  const char* GetBarLabel(int i);
146 
148 
151  vtkSetStringMacro(YTitle);
152  vtkGetStringMacro(YTitle);
154 
156 
161  vtkSetMacro(LegendVisibility, vtkTypeBool);
162  vtkGetMacro(LegendVisibility, vtkTypeBool);
163  vtkBooleanMacro(LegendVisibility, vtkTypeBool);
165 
167 
171  vtkGetObjectMacro(LegendActor, vtkLegendBoxActor);
173 
175 
178  int RenderOverlay(vtkViewport*) override;
179  int RenderOpaqueGeometry(vtkViewport*) override;
180  int RenderTranslucentPolygonalGeometry(vtkViewport*) override { return 0; }
182 
187 
193  void ReleaseGraphicsResources(vtkWindow*) override;
194 
195 protected:
197  ~vtkBarChartActor() override;
198 
199 private:
200  vtkDataObject* Input; // List of data sets to plot
201  vtkIdType ArrayNumber;
202  vtkIdType ComponentNumber;
203  vtkTypeBool TitleVisibility; // Should I see the title?
204  char* Title; // The title string
205  vtkTextProperty* TitleTextProperty;
206  vtkTypeBool LabelVisibility;
207  vtkTextProperty* LabelTextProperty;
208  vtkBarLabelArray* Labels;
209  vtkTypeBool LegendVisibility;
210  vtkLegendBoxActor* LegendActor;
211  vtkGlyphSource2D* GlyphSource;
212 
213  // Local variables needed to plot
214  vtkIdType N; // The number of values
215  double* Heights; // The heights of each bar
216  double MinHeight; // The maximum and minimum height
217  double MaxHeight;
218  double LowerLeft[2];
219  double UpperRight[2];
220 
221  vtkTextMapper** BarMappers; // a label for each bar
222  vtkActor2D** BarActors;
223 
224  vtkTextMapper* TitleMapper;
225  vtkActor2D* TitleActor;
226 
227  vtkPolyData* PlotData; // The actual bars plus the x-axis
228  vtkPolyDataMapper2D* PlotMapper;
229  vtkActor2D* PlotActor;
230 
231  vtkAxisActor2D* YAxis; // The y-axis
232  char* YTitle;
233 
234  vtkTimeStamp BuildTime;
235 
236  int LastPosition[2];
237  int LastPosition2[2];
238  double P1[3];
239  double P2[3];
240 
241  void Initialize();
242  int PlaceAxes(vtkViewport* viewport, const int* size);
243  int BuildPlot(vtkViewport*);
244 
245 private:
246  vtkBarChartActor(const vtkBarChartActor&) = delete;
247  void operator=(const vtkBarChartActor&) = delete;
248 };
249 
250 #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:55
void SetBarColor(int i, const double color[3])
Specify colors for each bar.
a actor that draws 2D data
Definition: vtkActor2D.h:45
record modification and/or execution time
Definition: vtkTimeStamp.h:35
Create an axis with tick marks and labels.
int vtkIdType
Definition: vtkType.h:332
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:90
create a bar chart from an array
2D text annotation
Definition: vtkTextMapper.h:50
int vtkTypeBool
Definition: vtkABI.h:69
window superclass for vtkRenderWindow
Definition: vtkWindow.h:38
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:39
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.
create 2D glyphs represented by vtkPolyData
general representation of visualization data
Definition: vtkDataObject.h:65
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.