VTK  9.3.1
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
25 #ifndef vtkPieChartActor_h
26 #define vtkPieChartActor_h
27 
28 #include "vtkActor2D.h"
29 #include "vtkRenderingAnnotationModule.h" // For export macro
30 
31 VTK_ABI_NAMESPACE_BEGIN
32 class vtkAlgorithmOutput;
33 class vtkAxisActor2D;
34 class vtkDataObject;
35 class vtkPolyData;
37 class vtkTextMapper;
38 class vtkTextProperty;
39 class vtkLegendBoxActor;
40 class vtkGlyphSource2D;
41 class vtkPieChartActorConnection;
42 class vtkPieceLabelArray;
43 
44 class VTKRENDERINGANNOTATION_EXPORT vtkPieChartActor : public vtkActor2D
45 {
46 public:
48 
51  vtkTypeMacro(vtkPieChartActor, vtkActor2D);
52  void PrintSelf(ostream& os, vtkIndent indent) override;
54 
58  static vtkPieChartActor* New();
59 
61 
66  virtual void SetInputData(vtkDataObject*);
67  virtual void SetInputConnection(vtkAlgorithmOutput*);
69 
73  virtual vtkDataObject* GetInput();
74 
76 
79  vtkSetMacro(TitleVisibility, vtkTypeBool);
80  vtkGetMacro(TitleVisibility, vtkTypeBool);
81  vtkBooleanMacro(TitleVisibility, vtkTypeBool);
83 
85 
88  vtkSetStringMacro(Title);
89  vtkGetStringMacro(Title);
91 
93 
97  virtual void SetTitleTextProperty(vtkTextProperty* p);
98  vtkGetObjectMacro(TitleTextProperty, vtkTextProperty);
100 
102 
105  vtkSetMacro(LabelVisibility, vtkTypeBool);
106  vtkGetMacro(LabelVisibility, vtkTypeBool);
107  vtkBooleanMacro(LabelVisibility, vtkTypeBool);
109 
111 
115  virtual void SetLabelTextProperty(vtkTextProperty* p);
116  vtkGetObjectMacro(LabelTextProperty, vtkTextProperty);
118 
120 
124  void SetPieceColor(int i, double r, double g, double b);
125  void SetPieceColor(int i, const double color[3])
126  {
127  this->SetPieceColor(i, color[0], color[1], color[2]);
128  }
129  double* GetPieceColor(int i);
131 
133 
137  void SetPieceLabel(int i, const char*);
138  const char* GetPieceLabel(int i);
140 
142 
147  vtkSetMacro(LegendVisibility, vtkTypeBool);
148  vtkGetMacro(LegendVisibility, vtkTypeBool);
149  vtkBooleanMacro(LegendVisibility, vtkTypeBool);
151 
153 
157  vtkGetObjectMacro(LegendActor, vtkLegendBoxActor);
159 
161 
164  int RenderOverlay(vtkViewport*) override;
165  int RenderOpaqueGeometry(vtkViewport*) override;
166  int RenderTranslucentPolygonalGeometry(vtkViewport*) override { return 0; }
168 
173 
179  void ReleaseGraphicsResources(vtkWindow*) override;
180 
181 protected:
183  ~vtkPieChartActor() override;
184 
185 private:
186  vtkPieChartActorConnection* ConnectionHolder;
187 
188  vtkIdType ArrayNumber;
189  vtkIdType ComponentNumber;
190  vtkTypeBool TitleVisibility; // Should I see the title?
191  char* Title; // The title string
192  vtkTextProperty* TitleTextProperty;
193  vtkTypeBool LabelVisibility;
194  vtkTextProperty* LabelTextProperty;
195  vtkPieceLabelArray* Labels;
196  vtkTypeBool LegendVisibility;
197  vtkLegendBoxActor* LegendActor;
198  vtkGlyphSource2D* GlyphSource;
199 
200  // Local variables needed to plot
201  vtkIdType N; // The number of values
202  double Total; // The total of all values in the data array
203  double* Fractions; // The fraction of the pie
204 
205  vtkTextMapper** PieceMappers; // a label for each radial spoke
206  vtkActor2D** PieceActors;
207 
208  vtkTextMapper* TitleMapper;
209  vtkActor2D* TitleActor;
210 
211  vtkPolyData* WebData; // The web of the spider plot
212  vtkPolyDataMapper2D* WebMapper;
213  vtkActor2D* WebActor;
214 
215  vtkPolyData* PlotData; // The lines drawn within the axes
216  vtkPolyDataMapper2D* PlotMapper;
217  vtkActor2D* PlotActor;
218 
219  vtkTimeStamp BuildTime;
220 
221  double Center[3];
222  double Radius;
223 
224  int LastPosition[2];
225  int LastPosition2[2];
226  double P1[3];
227  double P2[3];
228 
229  void Initialize();
230  int PlaceAxes(vtkViewport* viewport, const int* size);
231  int BuildPlot(vtkViewport*);
232 
233  vtkPieChartActor(const vtkPieChartActor&) = delete;
234  void operator=(const vtkPieChartActor&) = delete;
235 };
236 
237 VTK_ABI_NAMESPACE_END
238 #endif
draw symbols with text
int RenderOverlay(vtkViewport *viewport) override
Support the standard render methods.
abstract specification for Viewports
Definition: vtkViewport.h:44
a actor that draws 2D data
Definition: vtkActor2D.h:34
record modification and/or execution time
Definition: vtkTimeStamp.h:24
Create an axis with tick marks and labels.
int vtkIdType
Definition: vtkType.h:315
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:79
create a pie chart from an array
2D text annotation
Definition: vtkTextMapper.h:39
Proxy object to connect input/output ports.
int vtkTypeBool
Definition: vtkABI.h:64
window superclass for vtkRenderWindow
Definition: vtkWindow.h:27
int RenderTranslucentPolygonalGeometry(vtkViewport *) override
Draw the pie plot.
void SetPieceColor(int i, const double color[3])
Specify colors for each piece of pie.
void ReleaseGraphicsResources(vtkWindow *) override
Release any graphics resources that are being consumed by this actor.
a simple class to control print indentation
Definition: vtkIndent.h:28
static vtkActor2D * New()
Creates an actor2D with the following defaults: position (0,0) (coordinate system is viewport); at la...
represent text properties.
vtkTypeBool HasTranslucentPolygonalGeometry() override
Does this prop have some translucent polygonal geometry?
int RenderOpaqueGeometry(vtkViewport *viewport) override
Support the standard render methods.
create 2D glyphs represented by vtkPolyData
general representation of visualization data
Definition: vtkDataObject.h:54
draw vtkPolyData onto the image plane
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.