VTK
dox/Rendering/Annotation/vtkPieChartActor.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    vtkPieChartActor.h
00005 
00006   Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
00007   All rights reserved.
00008   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
00009 
00010      This software is distributed WITHOUT ANY WARRANTY; without even
00011      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00012      PURPOSE.  See the above copyright notice for more information.
00013 
00014 =========================================================================*/
00036 #ifndef __vtkPieChartActor_h
00037 #define __vtkPieChartActor_h
00038 
00039 #include "vtkRenderingAnnotationModule.h" // For export macro
00040 #include "vtkActor2D.h"
00041 
00042 class vtkAlgorithmOutput;
00043 class vtkAxisActor2D;
00044 class vtkDataObject;
00045 class vtkPolyData;
00046 class vtkPolyDataMapper2D;
00047 class vtkTextMapper;
00048 class vtkTextProperty;
00049 class vtkLegendBoxActor;
00050 class vtkGlyphSource2D;
00051 class vtkPieChartActorConnection;
00052 class vtkPieceLabelArray;
00053 
00054 class VTKRENDERINGANNOTATION_EXPORT vtkPieChartActor : public vtkActor2D
00055 {
00056 public:
00058 
00059   vtkTypeMacro(vtkPieChartActor,vtkActor2D);
00060   void PrintSelf(ostream& os, vtkIndent indent);
00062 
00064   static vtkPieChartActor *New();
00065 
00067 
00069   virtual void SetInputData(vtkDataObject*);
00070   virtual void SetInputConnection(vtkAlgorithmOutput*);
00072 
00074   virtual vtkDataObject* GetInput();
00075 
00077 
00078   vtkSetMacro(TitleVisibility, int);
00079   vtkGetMacro(TitleVisibility, int);
00080   vtkBooleanMacro(TitleVisibility, int);
00082 
00084 
00085   vtkSetStringMacro(Title);
00086   vtkGetStringMacro(Title);
00088 
00090 
00092   virtual void SetTitleTextProperty(vtkTextProperty *p);
00093   vtkGetObjectMacro(TitleTextProperty,vtkTextProperty);
00095 
00097 
00098   vtkSetMacro(LabelVisibility, int);
00099   vtkGetMacro(LabelVisibility, int);
00100   vtkBooleanMacro(LabelVisibility, int);
00102 
00104 
00106   virtual void SetLabelTextProperty(vtkTextProperty *p);
00107   vtkGetObjectMacro(LabelTextProperty,vtkTextProperty);
00109 
00111 
00113   void SetPieceColor(int i, double r, double g, double b);
00114   void SetPieceColor(int i, const double color[3])
00115     { this->SetPieceColor(i, color[0], color[1], color[2]); }
00116   double *GetPieceColor(int i);
00118 
00120 
00122   void SetPieceLabel(const int i, const char *);
00123   const char* GetPieceLabel(int i);
00125 
00127 
00130   vtkSetMacro(LegendVisibility, int);
00131   vtkGetMacro(LegendVisibility, int);
00132   vtkBooleanMacro(LegendVisibility, int);
00134 
00136 
00138   vtkGetObjectMacro(LegendActor,vtkLegendBoxActor);
00140 
00142 
00143   int RenderOverlay(vtkViewport*);
00144   int RenderOpaqueGeometry(vtkViewport*);
00145   virtual int RenderTranslucentPolygonalGeometry(vtkViewport* ) {return 0;}
00147 
00149   virtual int HasTranslucentPolygonalGeometry();
00150 
00154   void ReleaseGraphicsResources(vtkWindow *);
00155 
00156 protected:
00157   vtkPieChartActor();
00158   ~vtkPieChartActor();
00159 
00160 private:
00161 
00162   vtkPieChartActorConnection* ConnectionHolder;
00163 
00164   vtkIdType ArrayNumber;
00165   vtkIdType ComponentNumber;
00166   int TitleVisibility;         // Should I see the title?
00167   char *Title;                 // The title string
00168   vtkTextProperty *TitleTextProperty;
00169   int LabelVisibility;
00170   vtkTextProperty *LabelTextProperty;
00171   vtkPieceLabelArray *Labels;
00172   int LegendVisibility;
00173   vtkLegendBoxActor *LegendActor;
00174   vtkGlyphSource2D *GlyphSource;
00175 
00176   // Local variables needed to plot
00177   vtkIdType N;                 // The number of values
00178   double    Total;             // The total of all values in the data array
00179   double   *Fractions;         // The fraction of the pie
00180 
00181   vtkTextMapper    **PieceMappers; //a label for each radial spoke
00182   vtkActor2D       **PieceActors;
00183 
00184   vtkTextMapper    *TitleMapper;
00185   vtkActor2D       *TitleActor;
00186 
00187   vtkPolyData         *WebData;    // The web of the spider plot
00188   vtkPolyDataMapper2D *WebMapper;
00189   vtkActor2D          *WebActor;
00190 
00191   vtkPolyData         *PlotData;    // The lines drawn within the axes
00192   vtkPolyDataMapper2D *PlotMapper;
00193   vtkActor2D          *PlotActor;
00194 
00195   vtkTimeStamp  BuildTime;
00196 
00197   double Center[3];
00198   double Radius;
00199 
00200   int   LastPosition[2];
00201   int   LastPosition2[2];
00202   double P1[3];
00203   double P2[3];
00204 
00205   void Initialize();
00206   int PlaceAxes(vtkViewport *viewport, int *size);
00207   int BuildPlot(vtkViewport*);
00208 
00209 private:
00210   vtkPieChartActor(const vtkPieChartActor&);  // Not implemented.
00211   void operator=(const vtkPieChartActor&);  // Not implemented.
00212 };
00213 
00214 
00215 #endif
00216