VTK  9.3.0
vtkPieChartActor.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
34 #ifndef vtkPieChartActor_h
35 #define vtkPieChartActor_h
36 
37 #include "vtkActor2D.h"
38 #include "vtkRenderingAnnotationModule.h" // For export macro
39 
40 VTK_ABI_NAMESPACE_BEGIN
41 class vtkAlgorithmOutput;
42 class vtkAxisActor2D;
43 class vtkDataObject;
44 class vtkPolyData;
46 class vtkTextMapper;
47 class vtkTextProperty;
48 class vtkLegendBoxActor;
49 class vtkGlyphSource2D;
50 class vtkPieChartActorConnection;
51 class vtkPieceLabelArray;
52 
53 class VTKRENDERINGANNOTATION_EXPORT vtkPieChartActor : public vtkActor2D
54 {
55 public:
57 
60  vtkTypeMacro(vtkPieChartActor, vtkActor2D);
61  void PrintSelf(ostream& os, vtkIndent indent) override;
63 
67  static vtkPieChartActor* New();
68 
70 
75  virtual void SetInputData(vtkDataObject*);
78 
82  virtual vtkDataObject* GetInput();
83 
85 
88  vtkSetMacro(TitleVisibility, vtkTypeBool);
89  vtkGetMacro(TitleVisibility, vtkTypeBool);
90  vtkBooleanMacro(TitleVisibility, vtkTypeBool);
92 
94 
97  vtkSetStringMacro(Title);
98  vtkGetStringMacro(Title);
100 
102 
107  vtkGetObjectMacro(TitleTextProperty, vtkTextProperty);
109 
111 
114  vtkSetMacro(LabelVisibility, vtkTypeBool);
115  vtkGetMacro(LabelVisibility, vtkTypeBool);
116  vtkBooleanMacro(LabelVisibility, vtkTypeBool);
118 
120 
125  vtkGetObjectMacro(LabelTextProperty, vtkTextProperty);
127 
129 
133  void SetPieceColor(int i, double r, double g, double b);
134  void SetPieceColor(int i, const double color[3])
135  {
136  this->SetPieceColor(i, color[0], color[1], color[2]);
137  }
138  double* GetPieceColor(int i);
140 
142 
146  void SetPieceLabel(int i, const char*);
147  const char* GetPieceLabel(int i);
149 
151 
156  vtkSetMacro(LegendVisibility, vtkTypeBool);
157  vtkGetMacro(LegendVisibility, vtkTypeBool);
158  vtkBooleanMacro(LegendVisibility, vtkTypeBool);
160 
162 
166  vtkGetObjectMacro(LegendActor, vtkLegendBoxActor);
168 
170 
173  int RenderOverlay(vtkViewport*) override;
175  int RenderTranslucentPolygonalGeometry(vtkViewport*) override { return 0; }
177 
182 
189 
190 protected:
192  ~vtkPieChartActor() override;
193 
194 private:
195  vtkPieChartActorConnection* ConnectionHolder;
196 
197  vtkIdType ArrayNumber;
198  vtkIdType ComponentNumber;
199  vtkTypeBool TitleVisibility; // Should I see the title?
200  char* Title; // The title string
201  vtkTextProperty* TitleTextProperty;
202  vtkTypeBool LabelVisibility;
203  vtkTextProperty* LabelTextProperty;
204  vtkPieceLabelArray* Labels;
205  vtkTypeBool LegendVisibility;
206  vtkLegendBoxActor* LegendActor;
207  vtkGlyphSource2D* GlyphSource;
208 
209  // Local variables needed to plot
210  vtkIdType N; // The number of values
211  double Total; // The total of all values in the data array
212  double* Fractions; // The fraction of the pie
213 
214  vtkTextMapper** PieceMappers; // a label for each radial spoke
215  vtkActor2D** PieceActors;
216 
217  vtkTextMapper* TitleMapper;
218  vtkActor2D* TitleActor;
219 
220  vtkPolyData* WebData; // The web of the spider plot
221  vtkPolyDataMapper2D* WebMapper;
222  vtkActor2D* WebActor;
223 
224  vtkPolyData* PlotData; // The lines drawn within the axes
225  vtkPolyDataMapper2D* PlotMapper;
226  vtkActor2D* PlotActor;
227 
228  vtkTimeStamp BuildTime;
229 
230  double Center[3];
231  double Radius;
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  vtkPieChartActor(const vtkPieChartActor&) = delete;
243  void operator=(const vtkPieChartActor&) = delete;
244 };
245 
246 VTK_ABI_NAMESPACE_END
247 #endif
a actor that draws 2D data
Definition: vtkActor2D.h:44
Proxy object to connect input/output ports.
Create an axis with tick marks and labels.
general representation of visualization data
Definition: vtkDataObject.h:64
create 2D glyphs represented by vtkPolyData
a simple class to control print indentation
Definition: vtkIndent.h:38
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 SetPieceColor(int i, double r, double g, double b)
Specify colors for each piece of pie.
void SetPieceLabel(int i, const char *)
Specify the names for each piece of pie.
draw vtkPolyData onto the image plane
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:89
2D text annotation
Definition: vtkTextMapper.h:49
represent text properties.
record modification and/or execution time
Definition: vtkTimeStamp.h:34
abstract specification for Viewports
Definition: vtkViewport.h:54
window superclass for vtkRenderWindow
Definition: vtkWindow.h:37
@ color
Definition: vtkX3D.h:221
@ size
Definition: vtkX3D.h:253
int vtkTypeBool
Definition: vtkABI.h:64
int vtkIdType
Definition: vtkType.h:315