VTK
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 "vtkRenderingAnnotationModule.h" // For export macro
41 #include "vtkActor2D.h"
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 
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  { this->SetPieceColor(i, color[0], color[1], color[2]); }
138  double *GetPieceColor(int i);
140 
142 
146  void SetPieceLabel(const 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;
174  int RenderOpaqueGeometry(vtkViewport*) override;
177 
182 
188  void ReleaseGraphicsResources(vtkWindow *) override;
189 
190 protected:
192  ~vtkPieChartActor() override;
193 
194 private:
195 
196  vtkPieChartActorConnection* ConnectionHolder;
197 
198  vtkIdType ArrayNumber;
199  vtkIdType ComponentNumber;
200  vtkTypeBool TitleVisibility; // Should I see the title?
201  char *Title; // The title string
202  vtkTextProperty *TitleTextProperty;
203  vtkTypeBool LabelVisibility;
204  vtkTextProperty *LabelTextProperty;
205  vtkPieceLabelArray *Labels;
206  vtkTypeBool LegendVisibility;
207  vtkLegendBoxActor *LegendActor;
208  vtkGlyphSource2D *GlyphSource;
209 
210  // Local variables needed to plot
211  vtkIdType N; // The number of values
212  double Total; // The total of all values in the data array
213  double *Fractions; // The fraction of the pie
214 
215  vtkTextMapper **PieceMappers; //a label for each radial spoke
216  vtkActor2D **PieceActors;
217 
218  vtkTextMapper *TitleMapper;
219  vtkActor2D *TitleActor;
220 
221  vtkPolyData *WebData; // The web of the spider plot
222  vtkPolyDataMapper2D *WebMapper;
223  vtkActor2D *WebActor;
224 
225  vtkPolyData *PlotData; // The lines drawn within the axes
226  vtkPolyDataMapper2D *PlotMapper;
227  vtkActor2D *PlotActor;
228 
229  vtkTimeStamp BuildTime;
230 
231  double Center[3];
232  double Radius;
233 
234  int LastPosition[2];
235  int LastPosition2[2];
236  double P1[3];
237  double P2[3];
238 
239  void Initialize();
240  int PlaceAxes(vtkViewport *viewport, int *size);
241  int BuildPlot(vtkViewport*);
242 
243 private:
244  vtkPieChartActor(const vtkPieChartActor&) = delete;
245  void operator=(const vtkPieChartActor&) = delete;
246 };
247 
248 
249 #endif
250 
draw symbols with text
int RenderOverlay(vtkViewport *viewport) override
Support the standard render methods.
abstract specification for Viewports
Definition: vtkViewport.h:47
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:347
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:85
create a pie chart from an array
2D text annotation
Definition: vtkTextMapper.h:53
Proxy object to connect input/output ports.
int vtkTypeBool
Definition: vtkABI.h:69
window superclass for vtkRenderWindow
Definition: vtkWindow.h:37
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
#define P1
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?
#define P2
int RenderOpaqueGeometry(vtkViewport *viewport) override
Support the standard render methods.
create 2D glyphs represented by vtkPolyData
general representation of visualization data
Definition: vtkDataObject.h:64
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.