VTK  9.7.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 "vtkNew.h" // For vtkNew
30 #include "vtkRenderingAnnotationModule.h" // For export macro
31 #include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
32 
33 VTK_ABI_NAMESPACE_BEGIN
34 class vtkAlgorithmOutput;
35 class vtkAxisActor2D;
36 class vtkDataObject;
37 class vtkPolyData;
39 class vtkTextMapper;
40 class vtkTextProperty;
41 class vtkLegendBoxActor;
42 class vtkGlyphSource2D;
43 class vtkPieChartActorConnection;
44 class vtkPieceLabelArray;
45 
46 class VTKRENDERINGANNOTATION_EXPORT VTK_MARSHALAUTO vtkPieChartActor : public vtkActor2D
47 {
48 public:
50 
53  vtkTypeMacro(vtkPieChartActor, vtkActor2D);
54  void PrintSelf(ostream& os, vtkIndent indent) override;
56 
60  static vtkPieChartActor* New();
61 
63 
68  VTK_MARSHALSETTER(Input)
69  virtual void SetInputData(vtkDataObject*);
70  virtual void SetInputConnection(vtkAlgorithmOutput*);
72 
76  VTK_MARSHALGETTER(Input)
77  virtual vtkDataObject* GetInput();
78 
80 
83  vtkSetMacro(TitleVisibility, vtkTypeBool);
84  vtkGetMacro(TitleVisibility, vtkTypeBool);
85  vtkBooleanMacro(TitleVisibility, vtkTypeBool);
87 
89 
92  vtkSetStringMacro(Title);
93  vtkGetStringMacro(Title);
95 
97 
101  virtual void SetTitleTextProperty(vtkTextProperty* p);
102  vtkGetObjectMacro(TitleTextProperty, vtkTextProperty);
104 
106 
109  vtkSetMacro(LabelVisibility, vtkTypeBool);
110  vtkGetMacro(LabelVisibility, vtkTypeBool);
111  vtkBooleanMacro(LabelVisibility, vtkTypeBool);
113 
115 
119  virtual void SetLabelTextProperty(vtkTextProperty* p);
120  vtkGetObjectMacro(LabelTextProperty, vtkTextProperty);
122 
124 
128  void SetPieceColor(int i, double r, double g, double b);
129  void SetPieceColor(int i, const double color[3])
130  {
131  this->SetPieceColor(i, color[0], color[1], color[2]);
132  }
133  double* GetPieceColor(int i);
135 
137 
141  void SetPieceLabel(int i, const char*);
142  const char* GetPieceLabel(int i);
143  int GetNumberOfPieceLabels();
145 
147 
152  vtkSetMacro(LegendVisibility, vtkTypeBool);
153  vtkGetMacro(LegendVisibility, vtkTypeBool);
154  vtkBooleanMacro(LegendVisibility, vtkTypeBool);
156 
158 
162  vtkGetObjectMacro(LegendActor, vtkLegendBoxActor);
164 
166 
169  int RenderOverlay(vtkViewport*) override;
170  int RenderOpaqueGeometry(vtkViewport*) override;
171  int RenderTranslucentPolygonalGeometry(vtkViewport*) override { return 0; }
173 
178 
184  void ReleaseGraphicsResources(vtkWindow*) override;
185 
186 protected:
188  ~vtkPieChartActor() override;
189 
190 private:
191  vtkPieChartActorConnection* ConnectionHolder;
192 
193  vtkIdType ArrayNumber;
194  vtkIdType ComponentNumber;
195  vtkTypeBool TitleVisibility; // Should I see the title?
196  char* Title; // The title string
197  vtkTextProperty* TitleTextProperty;
198  vtkTypeBool LabelVisibility;
199  vtkTextProperty* LabelTextProperty;
200  vtkPieceLabelArray* Labels;
201  vtkTypeBool LegendVisibility;
202  vtkNew<vtkLegendBoxActor> LegendActor;
203  vtkGlyphSource2D* GlyphSource;
204 
205  // Local variables needed to plot
206  vtkIdType N; // The number of values
207  double Total; // The total of all values in the data array
208  double* Fractions; // The fraction of the pie
209 
210  vtkTextMapper** PieceMappers; // a label for each radial spoke
211  vtkActor2D** PieceActors;
212 
213  vtkTextMapper* TitleMapper;
214  vtkActor2D* TitleActor;
215 
216  vtkPolyData* WebData; // The web of the spider plot
217  vtkPolyDataMapper2D* WebMapper;
218  vtkActor2D* WebActor;
219 
220  vtkPolyData* PlotData; // The lines drawn within the axes
221  vtkPolyDataMapper2D* PlotMapper;
222  vtkActor2D* PlotActor;
223 
224  vtkTimeStamp BuildTime;
225 
226  double Center[3];
227  double Radius;
228 
229  int LastPosition[2];
230  int LastPosition2[2];
231  double P1[3];
232  double P2[3];
233 
234  void Initialize();
235  int PlaceAxes(vtkViewport* viewport, const int* size);
236  int BuildPlot(vtkViewport*);
237 
238  vtkPieChartActor(const vtkPieChartActor&) = delete;
239  void operator=(const vtkPieChartActor&) = delete;
240 };
241 
242 VTK_ABI_NAMESPACE_END
243 #endif
draw symbols with text
int RenderOverlay(vtkViewport *viewport) override
Support the standard render methods.
abstract specification for Viewports
Definition: vtkViewport.h:46
a actor that draws 2D data
Definition: vtkActor2D.h:35
record modification and/or execution time
Definition: vtkTimeStamp.h:24
Create an axis with tick marks and labels.
int vtkIdType
Definition: vtkType.h:363
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:71
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:41
int RenderTranslucentPolygonalGeometry(vtkViewport *) override
Draw the pie plot.
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
#define VTK_MARSHALGETTER(property)
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.
#define VTK_MARSHALAUTO
create 2D glyphs represented by vtkPolyData
general representation of visualization data
Definition: vtkDataObject.h:55
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.
#define VTK_MARSHALSETTER(property)