VTK  9.0.1
vtkPieChartActor.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkPieChartActor.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 vtkPieChartActor_h
35 #define vtkPieChartActor_h
36 
37 #include "vtkActor2D.h"
38 #include "vtkRenderingAnnotationModule.h" // For export macro
39 
40 class vtkAlgorithmOutput;
41 class vtkAxisActor2D;
42 class vtkDataObject;
43 class vtkPolyData;
45 class vtkTextMapper;
46 class vtkTextProperty;
47 class vtkLegendBoxActor;
48 class vtkGlyphSource2D;
49 class vtkPieChartActorConnection;
50 class vtkPieceLabelArray;
51 
52 class VTKRENDERINGANNOTATION_EXPORT vtkPieChartActor : public vtkActor2D
53 {
54 public:
56 
59  vtkTypeMacro(vtkPieChartActor, vtkActor2D);
60  void PrintSelf(ostream& os, vtkIndent indent) override;
62 
66  static vtkPieChartActor* New();
67 
69 
74  virtual void SetInputData(vtkDataObject*);
77 
81  virtual vtkDataObject* GetInput();
82 
84 
87  vtkSetMacro(TitleVisibility, vtkTypeBool);
88  vtkGetMacro(TitleVisibility, vtkTypeBool);
89  vtkBooleanMacro(TitleVisibility, vtkTypeBool);
91 
93 
96  vtkSetStringMacro(Title);
97  vtkGetStringMacro(Title);
99 
101 
106  vtkGetObjectMacro(TitleTextProperty, vtkTextProperty);
108 
110 
113  vtkSetMacro(LabelVisibility, vtkTypeBool);
114  vtkGetMacro(LabelVisibility, vtkTypeBool);
115  vtkBooleanMacro(LabelVisibility, vtkTypeBool);
117 
119 
124  vtkGetObjectMacro(LabelTextProperty, vtkTextProperty);
126 
128 
132  void SetPieceColor(int i, double r, double g, double b);
133  void SetPieceColor(int i, const double color[3])
134  {
135  this->SetPieceColor(i, color[0], color[1], color[2]);
136  }
137  double* GetPieceColor(int i);
139 
141 
145  void SetPieceLabel(const int i, const char*);
146  const char* GetPieceLabel(int i);
148 
150 
155  vtkSetMacro(LegendVisibility, vtkTypeBool);
156  vtkGetMacro(LegendVisibility, vtkTypeBool);
157  vtkBooleanMacro(LegendVisibility, vtkTypeBool);
159 
161 
165  vtkGetObjectMacro(LegendActor, vtkLegendBoxActor);
167 
169 
172  int RenderOverlay(vtkViewport*) override;
174  int RenderTranslucentPolygonalGeometry(vtkViewport*) override { return 0; }
176 
181 
188 
189 protected:
191  ~vtkPieChartActor() override;
192 
193 private:
194  vtkPieChartActorConnection* ConnectionHolder;
195 
196  vtkIdType ArrayNumber;
197  vtkIdType ComponentNumber;
198  vtkTypeBool TitleVisibility; // Should I see the title?
199  char* Title; // The title string
200  vtkTextProperty* TitleTextProperty;
201  vtkTypeBool LabelVisibility;
202  vtkTextProperty* LabelTextProperty;
203  vtkPieceLabelArray* Labels;
204  vtkTypeBool LegendVisibility;
205  vtkLegendBoxActor* LegendActor;
206  vtkGlyphSource2D* GlyphSource;
207 
208  // Local variables needed to plot
209  vtkIdType N; // The number of values
210  double Total; // The total of all values in the data array
211  double* Fractions; // The fraction of the pie
212 
213  vtkTextMapper** PieceMappers; // a label for each radial spoke
214  vtkActor2D** PieceActors;
215 
216  vtkTextMapper* TitleMapper;
217  vtkActor2D* TitleActor;
218 
219  vtkPolyData* WebData; // The web of the spider plot
220  vtkPolyDataMapper2D* WebMapper;
221  vtkActor2D* WebActor;
222 
223  vtkPolyData* PlotData; // The lines drawn within the axes
224  vtkPolyDataMapper2D* PlotMapper;
225  vtkActor2D* PlotActor;
226 
227  vtkTimeStamp BuildTime;
228 
229  double Center[3];
230  double Radius;
231 
232  int LastPosition[2];
233  int LastPosition2[2];
234  double P1[3];
235  double P2[3];
236 
237  void Initialize();
238  int PlaceAxes(vtkViewport* viewport, const int* size);
239  int BuildPlot(vtkViewport*);
240 
241 private:
242  vtkPieChartActor(const vtkPieChartActor&) = delete;
243  void operator=(const vtkPieChartActor&) = delete;
244 };
245 
246 #endif
a actor that draws 2D data
Definition: vtkActor2D.h:40
Proxy object to connect input/output ports.
Create an axis with tick marks and labels.
general representation of visualization data
Definition: vtkDataObject.h:60
create 2D glyphs represented by vtkPolyData
a simple class to control print indentation
Definition: vtkIndent.h:34
draw symbols with text
create a pie chart from an array
virtual void SetInputConnection(vtkAlgorithmOutput *)
static vtkPieChartActor * New()
Instantiate this class.
vtkTypeBool HasTranslucentPolygonalGeometry() override
Does this prop have some translucent polygonal geometry?
int RenderOpaqueGeometry(vtkViewport *) override
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE DO NOT USE THESE METHODS OUTSIDE OF THE RENDE...
virtual vtkDataObject * GetInput()
Get the input data object to this actor.
virtual void SetLabelTextProperty(vtkTextProperty *p)
Set/Get the labels text property.
virtual void SetTitleTextProperty(vtkTextProperty *p)
Set/Get the title text property.
void SetPieceColor(int i, const double color[3])
int RenderTranslucentPolygonalGeometry(vtkViewport *) override
void ReleaseGraphicsResources(vtkWindow *) override
Release any graphics resources that are being consumed by this actor.
double * GetPieceColor(int i)
~vtkPieChartActor() override
int RenderOverlay(vtkViewport *) override
Draw the pie plot.
const char * GetPieceLabel(int i)
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
virtual void SetInputData(vtkDataObject *)
Set the input to the pie chart actor.
void SetPieceLabel(const int i, const char *)
Specify the names for each piece of pie.
void SetPieceColor(int i, double r, double g, double b)
Specify colors for each piece of pie.
draw vtkPolyData onto the image plane
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:85
2D text annotation
Definition: vtkTextMapper.h:48
represent text properties.
record modification and/or execution time
Definition: vtkTimeStamp.h:33
abstract specification for Viewports
Definition: vtkViewport.h:45
window superclass for vtkRenderWindow
Definition: vtkWindow.h:35
@ color
Definition: vtkX3D.h:227
@ size
Definition: vtkX3D.h:259
int vtkTypeBool
Definition: vtkABI.h:69
int vtkIdType
Definition: vtkType.h:338