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 =========================================================================*/
46 #ifndef vtkPieChartActor_h
47 #define vtkPieChartActor_h
48 
49 #include "vtkActor2D.h"
50 #include "vtkRenderingAnnotationModule.h" // For export macro
51 
52 class vtkAlgorithmOutput;
53 class vtkAxisActor2D;
54 class vtkDataObject;
55 class vtkPolyData;
57 class vtkTextMapper;
58 class vtkTextProperty;
59 class vtkLegendBoxActor;
60 class vtkGlyphSource2D;
61 class vtkPieChartActorConnection;
62 class vtkPieceLabelArray;
63 
64 class VTKRENDERINGANNOTATION_EXPORT vtkPieChartActor : public vtkActor2D
65 {
66 public:
68 
71  vtkTypeMacro(vtkPieChartActor, vtkActor2D);
72  void PrintSelf(ostream& os, vtkIndent indent) override;
74 
78  static vtkPieChartActor* New();
79 
81 
86  virtual void SetInputData(vtkDataObject*);
89 
93  virtual vtkDataObject* GetInput();
94 
96 
99  vtkSetMacro(TitleVisibility, vtkTypeBool);
100  vtkGetMacro(TitleVisibility, vtkTypeBool);
101  vtkBooleanMacro(TitleVisibility, vtkTypeBool);
103 
105 
108  vtkSetStringMacro(Title);
109  vtkGetStringMacro(Title);
111 
113 
118  vtkGetObjectMacro(TitleTextProperty, vtkTextProperty);
120 
122 
125  vtkSetMacro(LabelVisibility, vtkTypeBool);
126  vtkGetMacro(LabelVisibility, vtkTypeBool);
127  vtkBooleanMacro(LabelVisibility, vtkTypeBool);
129 
131 
136  vtkGetObjectMacro(LabelTextProperty, vtkTextProperty);
138 
140 
144  void SetPieceColor(int i, double r, double g, double b);
145  void SetPieceColor(int i, const double color[3])
146  {
147  this->SetPieceColor(i, color[0], color[1], color[2]);
148  }
149  double* GetPieceColor(int i);
151 
153 
157  void SetPieceLabel(const int i, const char*);
158  const char* GetPieceLabel(int i);
160 
162 
167  vtkSetMacro(LegendVisibility, vtkTypeBool);
168  vtkGetMacro(LegendVisibility, vtkTypeBool);
169  vtkBooleanMacro(LegendVisibility, vtkTypeBool);
171 
173 
177  vtkGetObjectMacro(LegendActor, vtkLegendBoxActor);
179 
181 
184  int RenderOverlay(vtkViewport*) override;
186  int RenderTranslucentPolygonalGeometry(vtkViewport*) override { return 0; }
188 
193 
200 
201 protected:
203  ~vtkPieChartActor() override;
204 
205 private:
206  vtkPieChartActorConnection* ConnectionHolder;
207 
208  vtkIdType ArrayNumber;
209  vtkIdType ComponentNumber;
210  vtkTypeBool TitleVisibility; // Should I see the title?
211  char* Title; // The title string
212  vtkTextProperty* TitleTextProperty;
213  vtkTypeBool LabelVisibility;
214  vtkTextProperty* LabelTextProperty;
215  vtkPieceLabelArray* Labels;
216  vtkTypeBool LegendVisibility;
217  vtkLegendBoxActor* LegendActor;
218  vtkGlyphSource2D* GlyphSource;
219 
220  // Local variables needed to plot
221  vtkIdType N; // The number of values
222  double Total; // The total of all values in the data array
223  double* Fractions; // The fraction of the pie
224 
225  vtkTextMapper** PieceMappers; // a label for each radial spoke
226  vtkActor2D** PieceActors;
227 
228  vtkTextMapper* TitleMapper;
229  vtkActor2D* TitleActor;
230 
231  vtkPolyData* WebData; // The web of the spider plot
232  vtkPolyDataMapper2D* WebMapper;
233  vtkActor2D* WebActor;
234 
235  vtkPolyData* PlotData; // The lines drawn within the axes
236  vtkPolyDataMapper2D* PlotMapper;
237  vtkActor2D* PlotActor;
238 
239  vtkTimeStamp BuildTime;
240 
241  double Center[3];
242  double Radius;
243 
244  int LastPosition[2];
245  int LastPosition2[2];
246  double P1[3];
247  double P2[3];
248 
249  void Initialize();
250  int PlaceAxes(vtkViewport* viewport, const int* size);
251  int BuildPlot(vtkViewport*);
252 
253 private:
254  vtkPieChartActor(const vtkPieChartActor&) = delete;
255  void operator=(const vtkPieChartActor&) = delete;
256 };
257 
258 #endif
a actor that draws 2D data
Definition: vtkActor2D.h:55
Proxy object to connect input/output ports.
Create an axis with tick marks and labels.
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
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: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