VTK  9.2.6
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 =========================================================================*/
56 #ifndef vtkPieChartActor_h
57 #define vtkPieChartActor_h
58 
59 #include "vtkActor2D.h"
60 #include "vtkRenderingAnnotationModule.h" // For export macro
61 
62 class vtkAlgorithmOutput;
63 class vtkAxisActor2D;
64 class vtkDataObject;
65 class vtkPolyData;
67 class vtkTextMapper;
68 class vtkTextProperty;
69 class vtkLegendBoxActor;
70 class vtkGlyphSource2D;
71 class vtkPieChartActorConnection;
72 class vtkPieceLabelArray;
73 
74 class VTKRENDERINGANNOTATION_EXPORT vtkPieChartActor : public vtkActor2D
75 {
76 public:
78 
81  vtkTypeMacro(vtkPieChartActor, vtkActor2D);
82  void PrintSelf(ostream& os, vtkIndent indent) override;
84 
88  static vtkPieChartActor* New();
89 
91 
96  virtual void SetInputData(vtkDataObject*);
99 
104 
106 
109  vtkSetMacro(TitleVisibility, vtkTypeBool);
110  vtkGetMacro(TitleVisibility, vtkTypeBool);
111  vtkBooleanMacro(TitleVisibility, vtkTypeBool);
113 
115 
118  vtkSetStringMacro(Title);
119  vtkGetStringMacro(Title);
121 
123 
128  vtkGetObjectMacro(TitleTextProperty, vtkTextProperty);
130 
132 
135  vtkSetMacro(LabelVisibility, vtkTypeBool);
136  vtkGetMacro(LabelVisibility, vtkTypeBool);
137  vtkBooleanMacro(LabelVisibility, vtkTypeBool);
139 
141 
146  vtkGetObjectMacro(LabelTextProperty, vtkTextProperty);
148 
150 
154  void SetPieceColor(int i, double r, double g, double b);
155  void SetPieceColor(int i, const double color[3])
156  {
157  this->SetPieceColor(i, color[0], color[1], color[2]);
158  }
159  double* GetPieceColor(int i);
161 
163 
167  void SetPieceLabel(const int i, const char*);
168  const char* GetPieceLabel(int i);
170 
172 
177  vtkSetMacro(LegendVisibility, vtkTypeBool);
178  vtkGetMacro(LegendVisibility, vtkTypeBool);
179  vtkBooleanMacro(LegendVisibility, vtkTypeBool);
181 
183 
187  vtkGetObjectMacro(LegendActor, vtkLegendBoxActor);
189 
191 
194  int RenderOverlay(vtkViewport*) override;
196  int RenderTranslucentPolygonalGeometry(vtkViewport*) override { return 0; }
198 
203 
210 
211 protected:
213  ~vtkPieChartActor() override;
214 
215 private:
216  vtkPieChartActorConnection* ConnectionHolder;
217 
218  vtkIdType ArrayNumber;
219  vtkIdType ComponentNumber;
220  vtkTypeBool TitleVisibility; // Should I see the title?
221  char* Title; // The title string
222  vtkTextProperty* TitleTextProperty;
223  vtkTypeBool LabelVisibility;
224  vtkTextProperty* LabelTextProperty;
225  vtkPieceLabelArray* Labels;
226  vtkTypeBool LegendVisibility;
227  vtkLegendBoxActor* LegendActor;
228  vtkGlyphSource2D* GlyphSource;
229 
230  // Local variables needed to plot
231  vtkIdType N; // The number of values
232  double Total; // The total of all values in the data array
233  double* Fractions; // The fraction of the pie
234 
235  vtkTextMapper** PieceMappers; // a label for each radial spoke
236  vtkActor2D** PieceActors;
237 
238  vtkTextMapper* TitleMapper;
239  vtkActor2D* TitleActor;
240 
241  vtkPolyData* WebData; // The web of the spider plot
242  vtkPolyDataMapper2D* WebMapper;
243  vtkActor2D* WebActor;
244 
245  vtkPolyData* PlotData; // The lines drawn within the axes
246  vtkPolyDataMapper2D* PlotMapper;
247  vtkActor2D* PlotActor;
248 
249  vtkTimeStamp BuildTime;
250 
251  double Center[3];
252  double Radius;
253 
254  int LastPosition[2];
255  int LastPosition2[2];
256  double P1[3];
257  double P2[3];
258 
259  void Initialize();
260  int PlaceAxes(vtkViewport* viewport, const int* size);
261  int BuildPlot(vtkViewport*);
262 
263 private:
264  vtkPieChartActor(const vtkPieChartActor&) = delete;
265  void operator=(const vtkPieChartActor&) = delete;
266 };
267 
268 #endif
a actor that draws 2D data
Definition: vtkActor2D.h:155
Proxy object to connect input/output ports.
Create an axis with tick marks and labels.
general representation of visualization data
create 2D glyphs represented by vtkPolyData
a simple class to control print indentation
Definition: vtkIndent.h:119
draw symbols with text
create a pie chart from an array
virtual void SetInputConnection(vtkAlgorithmOutput *)
Set the input to the pie chart actor.
static vtkPieChartActor * New()
Instantiate this class.
vtkTypeBool HasTranslucentPolygonalGeometry() override
Does this prop have some translucent polygonal geometry?
int RenderOpaqueGeometry(vtkViewport *) override
Draw the pie plot.
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])
Specify colors for each piece of pie.
int RenderTranslucentPolygonalGeometry(vtkViewport *) override
Draw the pie plot.
void ReleaseGraphicsResources(vtkWindow *) override
Release any graphics resources that are being consumed by this actor.
double * GetPieceColor(int i)
Specify colors for each piece of pie.
~vtkPieChartActor() override
int RenderOverlay(vtkViewport *) override
Draw the pie plot.
const char * GetPieceLabel(int i)
Specify the names for each piece of pie.
void PrintSelf(ostream &os, vtkIndent indent) override
Standard methods for type information and printing.
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:200
2D text annotation
represent text properties.
record modification and/or execution time
Definition: vtkTimeStamp.h:55
abstract specification for Viewports
Definition: vtkViewport.h:56
window superclass for vtkRenderWindow
Definition: vtkWindow.h:39
@ color
Definition: vtkX3D.h:227
@ size
Definition: vtkX3D.h:259
int vtkTypeBool
Definition: vtkABI.h:69
int vtkIdType
Definition: vtkType.h:332