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 =========================================================================*/
34 #ifndef vtkPieChartActor_h
35 #define vtkPieChartActor_h
36 
37 #include "vtkRenderingAnnotationModule.h" // For export macro
38 #include "vtkActor2D.h"
39 
40 class vtkAlgorithmOutput;
41 class vtkAxisActor2D;
42 class vtkDataObject;
43 class vtkPolyData;
45 class vtkTextMapper;
46 class vtkTextProperty;
47 class vtkLegendBoxActor;
48 class vtkGlyphSource2D;
49 class vtkPieChartActorConnection;
50 class vtkPieceLabelArray;
51 
52 class VTKRENDERINGANNOTATION_EXPORT vtkPieChartActor : public vtkActor2D
53 {
54 public:
56 
60  void PrintSelf(ostream& os, vtkIndent indent) override;
62 
66  static vtkPieChartActor *New();
67 
69 
74  virtual void SetInputData(vtkDataObject*);
75  virtual void SetInputConnection(vtkAlgorithmOutput*);
77 
81  virtual vtkDataObject* GetInput();
82 
84 
87  vtkSetMacro(TitleVisibility, vtkTypeBool);
88  vtkGetMacro(TitleVisibility, vtkTypeBool);
89  vtkBooleanMacro(TitleVisibility, vtkTypeBool);
91 
93 
96  vtkSetStringMacro(Title);
97  vtkGetStringMacro(Title);
99 
101 
105  virtual void SetTitleTextProperty(vtkTextProperty *p);
106  vtkGetObjectMacro(TitleTextProperty,vtkTextProperty);
108 
110 
113  vtkSetMacro(LabelVisibility, vtkTypeBool);
114  vtkGetMacro(LabelVisibility, vtkTypeBool);
115  vtkBooleanMacro(LabelVisibility, vtkTypeBool);
117 
119 
123  virtual void SetLabelTextProperty(vtkTextProperty *p);
124  vtkGetObjectMacro(LabelTextProperty,vtkTextProperty);
126 
128 
132  void SetPieceColor(int i, double r, double g, double b);
133  void SetPieceColor(int i, const double color[3])
134  { this->SetPieceColor(i, color[0], color[1], color[2]); }
135  double *GetPieceColor(int i);
137 
139 
143  void SetPieceLabel(const int i, const char *);
144  const char* GetPieceLabel(int i);
146 
148 
153  vtkSetMacro(LegendVisibility, vtkTypeBool);
154  vtkGetMacro(LegendVisibility, vtkTypeBool);
155  vtkBooleanMacro(LegendVisibility, vtkTypeBool);
157 
159 
163  vtkGetObjectMacro(LegendActor,vtkLegendBoxActor);
165 
167 
170  int RenderOverlay(vtkViewport*) override;
171  int RenderOpaqueGeometry(vtkViewport*) override;
174 
178  int HasTranslucentPolygonalGeometry() override;
179 
185  void ReleaseGraphicsResources(vtkWindow *) override;
186 
187 protected:
189  ~vtkPieChartActor() override;
190 
191 private:
192 
193  vtkPieChartActorConnection* ConnectionHolder;
194 
195  vtkIdType ArrayNumber;
196  vtkIdType ComponentNumber;
197  vtkTypeBool TitleVisibility; // Should I see the title?
198  char *Title; // The title string
199  vtkTextProperty *TitleTextProperty;
200  vtkTypeBool LabelVisibility;
201  vtkTextProperty *LabelTextProperty;
202  vtkPieceLabelArray *Labels;
203  vtkTypeBool LegendVisibility;
204  vtkLegendBoxActor *LegendActor;
205  vtkGlyphSource2D *GlyphSource;
206 
207  // Local variables needed to plot
208  vtkIdType N; // The number of values
209  double Total; // The total of all values in the data array
210  double *Fractions; // The fraction of the pie
211 
212  vtkTextMapper **PieceMappers; //a label for each radial spoke
213  vtkActor2D **PieceActors;
214 
215  vtkTextMapper *TitleMapper;
216  vtkActor2D *TitleActor;
217 
218  vtkPolyData *WebData; // The web of the spider plot
219  vtkPolyDataMapper2D *WebMapper;
220  vtkActor2D *WebActor;
221 
222  vtkPolyData *PlotData; // The lines drawn within the axes
223  vtkPolyDataMapper2D *PlotMapper;
224  vtkActor2D *PlotActor;
225 
226  vtkTimeStamp BuildTime;
227 
228  double Center[3];
229  double Radius;
230 
231  int LastPosition[2];
232  int LastPosition2[2];
233  double P1[3];
234  double P2[3];
235 
236  void Initialize();
237  int PlaceAxes(vtkViewport *viewport, int *size);
238  int BuildPlot(vtkViewport*);
239 
240 private:
241  vtkPieChartActor(const vtkPieChartActor&) = delete;
242  void operator=(const vtkPieChartActor&) = delete;
243 };
244 
245 
246 #endif
247 
vtkActor2D::RenderOpaqueGeometry
int RenderOpaqueGeometry(vtkViewport *viewport) override
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE DO NOT USE THESE METHODS OUTSIDE OF THE RENDE...
vtkGlyphSource2D
create 2D glyphs represented by vtkPolyData
Definition: vtkGlyphSource2D.h:56
vtkPolyDataMapper2D
draw vtkPolyData onto the image plane
Definition: vtkPolyDataMapper2D.h:45
vtkIdType
int vtkIdType
Definition: vtkType.h:347
vtkLegendBoxActor
draw symbols with text
Definition: vtkLegendBoxActor.h:58
vtkPieChartActor
create a pie chart from an array
Definition: vtkPieChartActor.h:52
vtkTimeStamp
record modification and/or execution time
Definition: vtkTimeStamp.h:32
vtkActor2D::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkPieChartActor::SetPieceColor
void SetPieceColor(int i, const double color[3])
Definition: vtkPieChartActor.h:133
vtkWindow
window superclass for vtkRenderWindow
Definition: vtkWindow.h:34
vtkX3D::color
Definition: vtkX3D.h:221
vtkActor2D::ReleaseGraphicsResources
void ReleaseGraphicsResources(vtkWindow *) override
Release any graphics resources that are being consumed by this actor.
vtkTextMapper
2D text annotation
Definition: vtkTextMapper.h:47
vtkActor2D::RenderOverlay
int RenderOverlay(vtkViewport *viewport) override
Support the standard render methods.
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkActor2D::HasTranslucentPolygonalGeometry
int HasTranslucentPolygonalGeometry() override
Does this prop have some translucent polygonal geometry?
vtkX3D::size
Definition: vtkX3D.h:253
vtkViewport
abstract specification for Viewports
Definition: vtkViewport.h:44
P1
#define P1
Definition: vtkTableBasedClipCases.h:851
vtkTextProperty
represent text properties.
Definition: vtkTextProperty.h:33
vtkActor2D
a actor that draws 2D data
Definition: vtkActor2D.h:39
vtkActor2D.h
vtkActor2D::New
static vtkActor2D * New()
Creates an actor2D with the following defaults: position (0,0) (coordinate system is viewport); at la...
vtkAlgorithmOutput
Proxy object to connect input/output ports.
Definition: vtkAlgorithmOutput.h:36
vtkPolyData
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:79
vtkAxisActor2D
Create an axis with tick marks and labels.
Definition: vtkAxisActor2D.h:69
vtkPieChartActor::RenderTranslucentPolygonalGeometry
int RenderTranslucentPolygonalGeometry(vtkViewport *) override
Definition: vtkPieChartActor.h:172
P2
#define P2
Definition: vtkTableBasedClipCases.h:852
vtkDataObject
general representation of visualization data
Definition: vtkDataObject.h:58
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69