VTK
dox/Hybrid/vtkBarChartActor.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    vtkBarChartActor.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 __vtkBarChartActor_h
00037 #define __vtkBarChartActor_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 vtkBarLabelArray;
00050 
00051 class VTK_HYBRID_EXPORT vtkBarChartActor : public vtkActor2D
00052 {
00053 public:
00055 
00056   vtkTypeMacro(vtkBarChartActor,vtkActor2D);
00057   void PrintSelf(ostream& os, vtkIndent indent);
00059 
00061   static vtkBarChartActor *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 SetBarColor(int i, double r, double g, double b);
00109   void SetBarColor(int i, const double color[3]) 
00110     { this->SetBarColor(i, color[0], color[1], color[2]); }
00111   double *GetBarColor(int i);
00113 
00115 
00117   void SetBarLabel(const int i, const char *);
00118   const char* GetBarLabel(int i);
00120 
00122 
00123   vtkSetStringMacro(YTitle);
00124   vtkGetStringMacro(YTitle);
00126 
00128 
00131   vtkSetMacro(LegendVisibility, int);
00132   vtkGetMacro(LegendVisibility, int);
00133   vtkBooleanMacro(LegendVisibility, int);
00135 
00137 
00139   vtkGetObjectMacro(LegendActor,vtkLegendBoxActor);
00141 
00143 
00144   int RenderOverlay(vtkViewport*);
00145   int RenderOpaqueGeometry(vtkViewport*);
00146   virtual int RenderTranslucentPolygonalGeometry(vtkViewport* ) {return 0;}
00148 
00150   virtual int HasTranslucentPolygonalGeometry();
00151   
00155   void ReleaseGraphicsResources(vtkWindow *);
00156 
00157 protected:
00158   vtkBarChartActor();
00159   ~vtkBarChartActor();
00160 
00161 private:
00162   vtkDataObject *Input;        // List of data sets to plot
00163   vtkIdType ArrayNumber;
00164   vtkIdType ComponentNumber;
00165   int TitleVisibility;         // Should I see the title?
00166   char *Title;                 // The title string
00167   vtkTextProperty *TitleTextProperty; 
00168   int LabelVisibility;
00169   vtkTextProperty *LabelTextProperty;
00170   vtkBarLabelArray *Labels;
00171   int LegendVisibility;
00172   vtkLegendBoxActor *LegendActor;
00173   vtkGlyphSource2D *GlyphSource;
00174 
00175   // Local variables needed to plot
00176   vtkIdType N;        // The number of values
00177   double   *Heights;  // The heights of each bar
00178   double    MinHeight; //The maximum and minimum height
00179   double    MaxHeight;
00180   double    LowerLeft[2];
00181   double    UpperRight[2];
00182 
00183   vtkTextMapper    **BarMappers; //a label for each bar
00184   vtkActor2D       **BarActors;
00185 
00186   vtkTextMapper    *TitleMapper;
00187   vtkActor2D       *TitleActor;
00188 
00189   vtkPolyData         *PlotData;    // The actual bars plus the x-axis
00190   vtkPolyDataMapper2D *PlotMapper;
00191   vtkActor2D          *PlotActor;
00192   
00193   vtkAxisActor2D *YAxis;  //The y-axis 
00194   char           *YTitle;
00195 
00196   vtkTimeStamp  BuildTime;
00197 
00198   int    LastPosition[2];
00199   int    LastPosition2[2];
00200   double P1[3];
00201   double P2[3];
00202 
00203   void Initialize();
00204   int PlaceAxes(vtkViewport *viewport, int *size);
00205   int BuildPlot(vtkViewport*);
00206 
00207 private:
00208   vtkBarChartActor(const vtkBarChartActor&);  // Not implemented.
00209   void operator=(const vtkBarChartActor&);  // Not implemented.
00210 };
00211 
00212 
00213 #endif
00214