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 =========================================================================*/
37 #ifndef vtkPieChartActor_h
38 #define vtkPieChartActor_h
39 
40 #include "vtkActor2D.h"
41 #include "vtkRenderingAnnotationModule.h" // For export macro
42 
43 class vtkAlgorithmOutput;
44 class vtkAxisActor2D;
45 class vtkDataObject;
46 class vtkPolyData;
48 class vtkTextMapper;
49 class vtkTextProperty;
50 class vtkLegendBoxActor;
51 class vtkGlyphSource2D;
52 class vtkPieChartActorConnection;
53 class vtkPieceLabelArray;
54 
55 class VTKRENDERINGANNOTATION_EXPORT vtkPieChartActor : public vtkActor2D
56 {
57 public:
59 
62  vtkTypeMacro(vtkPieChartActor, vtkActor2D);
63  void PrintSelf(ostream& os, vtkIndent indent) override;
65 
69  static vtkPieChartActor* New();
70 
72 
77  virtual void SetInputData(vtkDataObject*);
78  virtual void SetInputConnection(vtkAlgorithmOutput*);
80 
84  virtual vtkDataObject* GetInput();
85 
87 
90  vtkSetMacro(TitleVisibility, vtkTypeBool);
91  vtkGetMacro(TitleVisibility, vtkTypeBool);
92  vtkBooleanMacro(TitleVisibility, vtkTypeBool);
94 
96 
99  vtkSetStringMacro(Title);
100  vtkGetStringMacro(Title);
102 
104 
108  virtual void SetTitleTextProperty(vtkTextProperty* p);
109  vtkGetObjectMacro(TitleTextProperty, vtkTextProperty);
111 
113 
116  vtkSetMacro(LabelVisibility, vtkTypeBool);
117  vtkGetMacro(LabelVisibility, vtkTypeBool);
118  vtkBooleanMacro(LabelVisibility, vtkTypeBool);
120 
122 
126  virtual void SetLabelTextProperty(vtkTextProperty* p);
127  vtkGetObjectMacro(LabelTextProperty, vtkTextProperty);
129 
131 
135  void SetPieceColor(int i, double r, double g, double b);
136  void SetPieceColor(int i, const double color[3])
137  {
138  this->SetPieceColor(i, color[0], color[1], color[2]);
139  }
140  double* GetPieceColor(int i);
142 
144 
148  void SetPieceLabel(const int i, const char*);
149  const char* GetPieceLabel(int i);
151 
153 
158  vtkSetMacro(LegendVisibility, vtkTypeBool);
159  vtkGetMacro(LegendVisibility, vtkTypeBool);
160  vtkBooleanMacro(LegendVisibility, vtkTypeBool);
162 
164 
168  vtkGetObjectMacro(LegendActor, vtkLegendBoxActor);
170 
172 
175  int RenderOverlay(vtkViewport*) override;
176  int RenderOpaqueGeometry(vtkViewport*) override;
177  int RenderTranslucentPolygonalGeometry(vtkViewport*) override { return 0; }
179 
184 
190  void ReleaseGraphicsResources(vtkWindow*) override;
191 
192 protected:
194  ~vtkPieChartActor() override;
195 
196 private:
197  vtkPieChartActorConnection* ConnectionHolder;
198 
199  vtkIdType ArrayNumber;
200  vtkIdType ComponentNumber;
201  vtkTypeBool TitleVisibility; // Should I see the title?
202  char* Title; // The title string
203  vtkTextProperty* TitleTextProperty;
204  vtkTypeBool LabelVisibility;
205  vtkTextProperty* LabelTextProperty;
206  vtkPieceLabelArray* Labels;
207  vtkTypeBool LegendVisibility;
208  vtkLegendBoxActor* LegendActor;
209  vtkGlyphSource2D* GlyphSource;
210 
211  // Local variables needed to plot
212  vtkIdType N; // The number of values
213  double Total; // The total of all values in the data array
214  double* Fractions; // The fraction of the pie
215 
216  vtkTextMapper** PieceMappers; // a label for each radial spoke
217  vtkActor2D** PieceActors;
218 
219  vtkTextMapper* TitleMapper;
220  vtkActor2D* TitleActor;
221 
222  vtkPolyData* WebData; // The web of the spider plot
223  vtkPolyDataMapper2D* WebMapper;
224  vtkActor2D* WebActor;
225 
226  vtkPolyData* PlotData; // The lines drawn within the axes
227  vtkPolyDataMapper2D* PlotMapper;
228  vtkActor2D* PlotActor;
229 
230  vtkTimeStamp BuildTime;
231 
232  double Center[3];
233  double Radius;
234 
235  int LastPosition[2];
236  int LastPosition2[2];
237  double P1[3];
238  double P2[3];
239 
240  void Initialize();
241  int PlaceAxes(vtkViewport* viewport, const int* size);
242  int BuildPlot(vtkViewport*);
243 
244 private:
245  vtkPieChartActor(const vtkPieChartActor&) = delete;
246  void operator=(const vtkPieChartActor&) = delete;
247 };
248 
249 #endif
draw symbols with text
int RenderOverlay(vtkViewport *viewport) override
Support the standard render methods.
abstract specification for Viewports
Definition: vtkViewport.h:55
a actor that draws 2D data
Definition: vtkActor2D.h:45
record modification and/or execution time
Definition: vtkTimeStamp.h:35
Create an axis with tick marks and labels.
int vtkIdType
Definition: vtkType.h:332
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:90
create a pie chart from an array
2D text annotation
Definition: vtkTextMapper.h:50
Proxy object to connect input/output ports.
int vtkTypeBool
Definition: vtkABI.h:69
window superclass for vtkRenderWindow
Definition: vtkWindow.h:38
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:39
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:65
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.