VTK
dox/Hybrid/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 "vtkActor2D.h"
00040 
00041 class vtkAxisActor2D;
00042 class vtkDataObject;
00043 class vtkPolyData;
00044 class vtkPolyDataMapper2D;
00045 class vtkTextMapper;
00046 class vtkTextProperty;
00047 class vtkLegendBoxActor;
00048 class vtkGlyphSource2D;
00049 class vtkPieceLabelArray;
00050 
00051 class VTK_HYBRID_EXPORT vtkPieChartActor : public vtkActor2D
00052 {
00053 public:
00055 
00056   vtkTypeMacro(vtkPieChartActor,vtkActor2D);
00057   void PrintSelf(ostream& os, vtkIndent indent);
00059 
00061   static vtkPieChartActor *New();
00062 
00064   virtual void SetInput(vtkDataObject*);
00065 
00067 
00068   vtkGetObjectMacro(Input,vtkDataObject);
00070 
00072 
00073   vtkSetMacro(TitleVisibility, int);
00074   vtkGetMacro(TitleVisibility, int);
00075   vtkBooleanMacro(TitleVisibility, int);
00077 
00079 
00080   vtkSetStringMacro(Title);
00081   vtkGetStringMacro(Title);
00083 
00085 
00087   virtual void SetTitleTextProperty(vtkTextProperty *p);
00088   vtkGetObjectMacro(TitleTextProperty,vtkTextProperty);
00090   
00092 
00093   vtkSetMacro(LabelVisibility, int);
00094   vtkGetMacro(LabelVisibility, int);
00095   vtkBooleanMacro(LabelVisibility, int);
00097 
00099 
00101   virtual void SetLabelTextProperty(vtkTextProperty *p);
00102   vtkGetObjectMacro(LabelTextProperty,vtkTextProperty);
00104       
00106 
00108   void SetPieceColor(int i, double r, double g, double b);
00109   void SetPieceColor(int i, const double color[3]) 
00110     { this->SetPieceColor(i, color[0], color[1], color[2]); }
00111   double *GetPieceColor(int i);
00113 
00115 
00117   void SetPieceLabel(const int i, const char *);
00118   const char* GetPieceLabel(int i);
00120 
00122 
00125   vtkSetMacro(LegendVisibility, int);
00126   vtkGetMacro(LegendVisibility, int);
00127   vtkBooleanMacro(LegendVisibility, int);
00129 
00131 
00133   vtkGetObjectMacro(LegendActor,vtkLegendBoxActor);
00135 
00137 
00138   int RenderOverlay(vtkViewport*);
00139   int RenderOpaqueGeometry(vtkViewport*);
00140   virtual int RenderTranslucentPolygonalGeometry(vtkViewport* ) {return 0;}
00142 
00144   virtual int HasTranslucentPolygonalGeometry();
00145   
00149   void ReleaseGraphicsResources(vtkWindow *);
00150 
00151 protected:
00152   vtkPieChartActor();
00153   ~vtkPieChartActor();
00154 
00155 private:
00156   vtkDataObject *Input;        // List of data sets to plot
00157   vtkIdType ArrayNumber;
00158   vtkIdType ComponentNumber;
00159   int TitleVisibility;         // Should I see the title?
00160   char *Title;                 // The title string
00161   vtkTextProperty *TitleTextProperty; 
00162   int LabelVisibility;
00163   vtkTextProperty *LabelTextProperty;
00164   vtkPieceLabelArray *Labels;
00165   int LegendVisibility;
00166   vtkLegendBoxActor *LegendActor;
00167   vtkGlyphSource2D *GlyphSource;
00168 
00169   // Local variables needed to plot
00170   vtkIdType N;                 // The number of values
00171   double    Total;             // The total of all values in the data array
00172   double   *Fractions;         // The fraction of the pie
00173 
00174   vtkTextMapper    **PieceMappers; //a label for each radial spoke
00175   vtkActor2D       **PieceActors;
00176 
00177   vtkTextMapper    *TitleMapper;
00178   vtkActor2D       *TitleActor;
00179 
00180   vtkPolyData         *WebData;    // The web of the spider plot
00181   vtkPolyDataMapper2D *WebMapper;
00182   vtkActor2D          *WebActor;
00183   
00184   vtkPolyData         *PlotData;    // The lines drawn within the axes
00185   vtkPolyDataMapper2D *PlotMapper;
00186   vtkActor2D          *PlotActor;
00187   
00188   vtkTimeStamp  BuildTime;
00189 
00190   double Center[3];
00191   double Radius;
00192 
00193   int   LastPosition[2];
00194   int   LastPosition2[2];
00195   double P1[3];
00196   double P2[3];
00197 
00198   void Initialize();
00199   int PlaceAxes(vtkViewport *viewport, int *size);
00200   int BuildPlot(vtkViewport*);
00201 
00202 private:
00203   vtkPieChartActor(const vtkPieChartActor&);  // Not implemented.
00204   void operator=(const vtkPieChartActor&);  // Not implemented.
00205 };
00206 
00207 
00208 #endif
00209