VTK  9.3.20240328
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
44 #ifndef vtkPieChartActor_h
45 #define vtkPieChartActor_h
46 
47 #include "vtkActor2D.h"
48 #include "vtkRenderingAnnotationModule.h" // For export macro
49 
50 VTK_ABI_NAMESPACE_BEGIN
51 class vtkAlgorithmOutput;
52 class vtkAxisActor2D;
53 class vtkDataObject;
54 class vtkPolyData;
56 class vtkTextMapper;
57 class vtkTextProperty;
58 class vtkLegendBoxActor;
59 class vtkGlyphSource2D;
60 class vtkPieChartActorConnection;
61 class vtkPieceLabelArray;
62 
63 class VTKRENDERINGANNOTATION_EXPORT vtkPieChartActor : public vtkActor2D
64 {
65 public:
67 
70  vtkTypeMacro(vtkPieChartActor, vtkActor2D);
71  void PrintSelf(ostream& os, vtkIndent indent) override;
73 
77  static vtkPieChartActor* New();
78 
80 
85  virtual void SetInputData(vtkDataObject*);
88 
92  virtual vtkDataObject* GetInput();
93 
95 
98  vtkSetMacro(TitleVisibility, vtkTypeBool);
99  vtkGetMacro(TitleVisibility, vtkTypeBool);
100  vtkBooleanMacro(TitleVisibility, vtkTypeBool);
102 
104 
107  vtkSetStringMacro(Title);
108  vtkGetStringMacro(Title);
110 
112 
117  vtkGetObjectMacro(TitleTextProperty, vtkTextProperty);
119 
121 
124  vtkSetMacro(LabelVisibility, vtkTypeBool);
125  vtkGetMacro(LabelVisibility, vtkTypeBool);
126  vtkBooleanMacro(LabelVisibility, vtkTypeBool);
128 
130 
135  vtkGetObjectMacro(LabelTextProperty, vtkTextProperty);
137 
139 
143  void SetPieceColor(int i, double r, double g, double b);
144  void SetPieceColor(int i, const double color[3])
145  {
146  this->SetPieceColor(i, color[0], color[1], color[2]);
147  }
148  double* GetPieceColor(int i);
150 
152 
156  void SetPieceLabel(int i, const char*);
157  const char* GetPieceLabel(int i);
159 
161 
166  vtkSetMacro(LegendVisibility, vtkTypeBool);
167  vtkGetMacro(LegendVisibility, vtkTypeBool);
168  vtkBooleanMacro(LegendVisibility, vtkTypeBool);
170 
172 
176  vtkGetObjectMacro(LegendActor, vtkLegendBoxActor);
178 
180 
183  int RenderOverlay(vtkViewport*) override;
185  int RenderTranslucentPolygonalGeometry(vtkViewport*) override { return 0; }
187 
192 
199 
200 protected:
202  ~vtkPieChartActor() override;
203 
204 private:
205  vtkPieChartActorConnection* ConnectionHolder;
206 
207  vtkIdType ArrayNumber;
208  vtkIdType ComponentNumber;
209  vtkTypeBool TitleVisibility; // Should I see the title?
210  char* Title; // The title string
211  vtkTextProperty* TitleTextProperty;
212  vtkTypeBool LabelVisibility;
213  vtkTextProperty* LabelTextProperty;
214  vtkPieceLabelArray* Labels;
215  vtkTypeBool LegendVisibility;
216  vtkLegendBoxActor* LegendActor;
217  vtkGlyphSource2D* GlyphSource;
218 
219  // Local variables needed to plot
220  vtkIdType N; // The number of values
221  double Total; // The total of all values in the data array
222  double* Fractions; // The fraction of the pie
223 
224  vtkTextMapper** PieceMappers; // a label for each radial spoke
225  vtkActor2D** PieceActors;
226 
227  vtkTextMapper* TitleMapper;
228  vtkActor2D* TitleActor;
229 
230  vtkPolyData* WebData; // The web of the spider plot
231  vtkPolyDataMapper2D* WebMapper;
232  vtkActor2D* WebActor;
233 
234  vtkPolyData* PlotData; // The lines drawn within the axes
235  vtkPolyDataMapper2D* PlotMapper;
236  vtkActor2D* PlotActor;
237 
238  vtkTimeStamp BuildTime;
239 
240  double Center[3];
241  double Radius;
242 
243  int LastPosition[2];
244  int LastPosition2[2];
245  double P1[3];
246  double P2[3];
247 
248  void Initialize();
249  int PlaceAxes(vtkViewport* viewport, const int* size);
250  int BuildPlot(vtkViewport*);
251 
252  vtkPieChartActor(const vtkPieChartActor&) = delete;
253  void operator=(const vtkPieChartActor&) = delete;
254 };
255 
256 VTK_ABI_NAMESPACE_END
257 #endif
a actor that draws 2D data
Definition: vtkActor2D.h:144
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:108
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:180
2D text annotation
represent text properties.
record modification and/or execution time
Definition: vtkTimeStamp.h:44
abstract specification for Viewports
Definition: vtkViewport.h:64
window superclass for vtkRenderWindow
Definition: vtkWindow.h:47
@ color
Definition: vtkX3D.h:221
@ size
Definition: vtkX3D.h:253
int vtkTypeBool
Definition: vtkABI.h:64
int vtkIdType
Definition: vtkType.h:315