VTK  9.0.1
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 =========================================================================*/
34 #ifndef vtkBarChartActor_h
35 #define vtkBarChartActor_h
36 
37 #include "vtkActor2D.h"
38 #include "vtkRenderingAnnotationModule.h" // For export macro
39 
40 class vtkAxisActor2D;
41 class vtkDataObject;
42 class vtkPolyData;
44 class vtkTextMapper;
45 class vtkTextProperty;
46 class vtkLegendBoxActor;
47 class vtkGlyphSource2D;
48 class vtkBarLabelArray;
49 
50 class VTKRENDERINGANNOTATION_EXPORT vtkBarChartActor : public vtkActor2D
51 {
52 public:
54 
57  vtkTypeMacro(vtkBarChartActor, vtkActor2D);
58  void PrintSelf(ostream& os, vtkIndent indent) override;
60 
64  static vtkBarChartActor* New();
65 
69  virtual void SetInput(vtkDataObject*);
70 
72 
75  vtkGetObjectMacro(Input, vtkDataObject);
77 
79 
82  vtkSetMacro(TitleVisibility, vtkTypeBool);
83  vtkGetMacro(TitleVisibility, vtkTypeBool);
84  vtkBooleanMacro(TitleVisibility, vtkTypeBool);
86 
88 
91  vtkSetStringMacro(Title);
92  vtkGetStringMacro(Title);
94 
96 
100  virtual void SetTitleTextProperty(vtkTextProperty* p);
101  vtkGetObjectMacro(TitleTextProperty, vtkTextProperty);
103 
105 
108  vtkSetMacro(LabelVisibility, vtkTypeBool);
109  vtkGetMacro(LabelVisibility, vtkTypeBool);
110  vtkBooleanMacro(LabelVisibility, vtkTypeBool);
112 
114 
118  virtual void SetLabelTextProperty(vtkTextProperty* p);
119  vtkGetObjectMacro(LabelTextProperty, vtkTextProperty);
121 
123 
127  void SetBarColor(int i, double r, double g, double b);
128  void SetBarColor(int i, const double color[3])
129  {
130  this->SetBarColor(i, color[0], color[1], color[2]);
131  }
132  double* GetBarColor(int i);
134 
136 
140  void SetBarLabel(const int i, const char*);
141  const char* GetBarLabel(int i);
143 
145 
148  vtkSetStringMacro(YTitle);
149  vtkGetStringMacro(YTitle);
151 
153 
158  vtkSetMacro(LegendVisibility, vtkTypeBool);
159  vtkGetMacro(LegendVisibility, vtkTypeBool);
160  vtkBooleanMacro(LegendVisibility, vtkTypeBool);
162 
164 
168  vtkGetObjectMacro(LegendActor, vtkLegendBoxActor);
170 
172 
175  int RenderOverlay(vtkViewport*) override;
176  int RenderOpaqueGeometry(vtkViewport*) override;
177  int RenderTranslucentPolygonalGeometry(vtkViewport*) override { return 0; }
179 
184 
190  void ReleaseGraphicsResources(vtkWindow*) override;
191 
192 protected:
194  ~vtkBarChartActor() override;
195 
196 private:
197  vtkDataObject* Input; // List of data sets to plot
198  vtkIdType ArrayNumber;
199  vtkIdType ComponentNumber;
200  vtkTypeBool TitleVisibility; // Should I see the title?
201  char* Title; // The title string
202  vtkTextProperty* TitleTextProperty;
203  vtkTypeBool LabelVisibility;
204  vtkTextProperty* LabelTextProperty;
205  vtkBarLabelArray* Labels;
206  vtkTypeBool LegendVisibility;
207  vtkLegendBoxActor* LegendActor;
208  vtkGlyphSource2D* GlyphSource;
209 
210  // Local variables needed to plot
211  vtkIdType N; // The number of values
212  double* Heights; // The heights of each bar
213  double MinHeight; // The maximum and minimum height
214  double MaxHeight;
215  double LowerLeft[2];
216  double UpperRight[2];
217 
218  vtkTextMapper** BarMappers; // a label for each bar
219  vtkActor2D** BarActors;
220 
221  vtkTextMapper* TitleMapper;
222  vtkActor2D* TitleActor;
223 
224  vtkPolyData* PlotData; // The actual bars plus the x-axis
225  vtkPolyDataMapper2D* PlotMapper;
226  vtkActor2D* PlotActor;
227 
228  vtkAxisActor2D* YAxis; // The y-axis
229  char* YTitle;
230 
231  vtkTimeStamp BuildTime;
232 
233  int LastPosition[2];
234  int LastPosition2[2];
235  double P1[3];
236  double P2[3];
237 
238  void Initialize();
239  int PlaceAxes(vtkViewport* viewport, const int* size);
240  int BuildPlot(vtkViewport*);
241 
242 private:
243  vtkBarChartActor(const vtkBarChartActor&) = delete;
244  void operator=(const vtkBarChartActor&) = delete;
245 };
246 
247 #endif
vtkActor2D::RenderOpaqueGeometry
int RenderOpaqueGeometry(vtkViewport *viewport) override
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE DO NOT USE THESE METHODS OUTSIDE OF THE RENDE...
vtkGlyphSource2D
create 2D glyphs represented by vtkPolyData
Definition: vtkGlyphSource2D.h:56
vtkPolyDataMapper2D
draw vtkPolyData onto the image plane
Definition: vtkPolyDataMapper2D.h:44
vtkIdType
int vtkIdType
Definition: vtkType.h:338
vtkLegendBoxActor
draw symbols with text
Definition: vtkLegendBoxActor.h:58
vtkTimeStamp
record modification and/or execution time
Definition: vtkTimeStamp.h:32
vtkActor2D::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkWindow
window superclass for vtkRenderWindow
Definition: vtkWindow.h:37
vtkX3D::color
@ color
Definition: vtkX3D.h:227
vtkActor2D::ReleaseGraphicsResources
void ReleaseGraphicsResources(vtkWindow *) override
Release any graphics resources that are being consumed by this actor.
vtkTextMapper
2D text annotation
Definition: vtkTextMapper.h:47
vtkActor2D::RenderOverlay
int RenderOverlay(vtkViewport *viewport) override
Support the standard render methods.
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkBarChartActor
create a bar chart from an array
Definition: vtkBarChartActor.h:50
vtkX3D::size
@ size
Definition: vtkX3D.h:259
vtkViewport
abstract specification for Viewports
Definition: vtkViewport.h:44
vtkTextProperty
represent text properties.
Definition: vtkTextProperty.h:33
vtkBarChartActor::RenderTranslucentPolygonalGeometry
int RenderTranslucentPolygonalGeometry(vtkViewport *) override
Definition: vtkBarChartActor.h:177
vtkActor2D
a actor that draws 2D data
Definition: vtkActor2D.h:39
vtkActor2D.h
vtkActor2D::New
static vtkActor2D * New()
Creates an actor2D with the following defaults: position (0,0) (coordinate system is viewport); at la...
vtkBarChartActor::SetBarColor
void SetBarColor(int i, const double color[3])
Definition: vtkBarChartActor.h:128
vtkPolyData
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:84
vtkAxisActor2D
Create an axis with tick marks and labels.
Definition: vtkAxisActor2D.h:69
vtkDataObject
general representation of visualization data
Definition: vtkDataObject.h:59
vtkActor2D::HasTranslucentPolygonalGeometry
vtkTypeBool HasTranslucentPolygonalGeometry() override
Does this prop have some translucent polygonal geometry?
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69