VTK
|
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 "vtkRenderingAnnotationModule.h" // For export macro 00040 #include "vtkActor2D.h" 00041 00042 class vtkAxisActor2D; 00043 class vtkDataObject; 00044 class vtkPolyData; 00045 class vtkPolyDataMapper2D; 00046 class vtkTextMapper; 00047 class vtkTextProperty; 00048 class vtkLegendBoxActor; 00049 class vtkGlyphSource2D; 00050 class vtkBarLabelArray; 00051 00052 class VTKRENDERINGANNOTATION_EXPORT vtkBarChartActor : public vtkActor2D 00053 { 00054 public: 00056 00057 vtkTypeMacro(vtkBarChartActor,vtkActor2D); 00058 void PrintSelf(ostream& os, vtkIndent indent); 00060 00062 static vtkBarChartActor *New(); 00063 00065 virtual void SetInput(vtkDataObject*); 00066 00068 00069 vtkGetObjectMacro(Input,vtkDataObject); 00071 00073 00074 vtkSetMacro(TitleVisibility, int); 00075 vtkGetMacro(TitleVisibility, int); 00076 vtkBooleanMacro(TitleVisibility, int); 00078 00080 00081 vtkSetStringMacro(Title); 00082 vtkGetStringMacro(Title); 00084 00086 00088 virtual void SetTitleTextProperty(vtkTextProperty *p); 00089 vtkGetObjectMacro(TitleTextProperty,vtkTextProperty); 00091 00093 00094 vtkSetMacro(LabelVisibility, int); 00095 vtkGetMacro(LabelVisibility, int); 00096 vtkBooleanMacro(LabelVisibility, int); 00098 00100 00102 virtual void SetLabelTextProperty(vtkTextProperty *p); 00103 vtkGetObjectMacro(LabelTextProperty,vtkTextProperty); 00105 00107 00109 void SetBarColor(int i, double r, double g, double b); 00110 void SetBarColor(int i, const double color[3]) 00111 { this->SetBarColor(i, color[0], color[1], color[2]); } 00112 double *GetBarColor(int i); 00114 00116 00118 void SetBarLabel(const int i, const char *); 00119 const char* GetBarLabel(int i); 00121 00123 00124 vtkSetStringMacro(YTitle); 00125 vtkGetStringMacro(YTitle); 00127 00129 00132 vtkSetMacro(LegendVisibility, int); 00133 vtkGetMacro(LegendVisibility, int); 00134 vtkBooleanMacro(LegendVisibility, int); 00136 00138 00140 vtkGetObjectMacro(LegendActor,vtkLegendBoxActor); 00142 00144 00145 int RenderOverlay(vtkViewport*); 00146 int RenderOpaqueGeometry(vtkViewport*); 00147 virtual int RenderTranslucentPolygonalGeometry(vtkViewport* ) {return 0;} 00149 00151 virtual int HasTranslucentPolygonalGeometry(); 00152 00156 void ReleaseGraphicsResources(vtkWindow *); 00157 00158 protected: 00159 vtkBarChartActor(); 00160 ~vtkBarChartActor(); 00161 00162 private: 00163 vtkDataObject *Input; // List of data sets to plot 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 vtkBarLabelArray *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 *Heights; // The heights of each bar 00179 double MinHeight; //The maximum and minimum height 00180 double MaxHeight; 00181 double LowerLeft[2]; 00182 double UpperRight[2]; 00183 00184 vtkTextMapper **BarMappers; //a label for each bar 00185 vtkActor2D **BarActors; 00186 00187 vtkTextMapper *TitleMapper; 00188 vtkActor2D *TitleActor; 00189 00190 vtkPolyData *PlotData; // The actual bars plus the x-axis 00191 vtkPolyDataMapper2D *PlotMapper; 00192 vtkActor2D *PlotActor; 00193 00194 vtkAxisActor2D *YAxis; //The y-axis 00195 char *YTitle; 00196 00197 vtkTimeStamp BuildTime; 00198 00199 int LastPosition[2]; 00200 int LastPosition2[2]; 00201 double P1[3]; 00202 double P2[3]; 00203 00204 void Initialize(); 00205 int PlaceAxes(vtkViewport *viewport, int *size); 00206 int BuildPlot(vtkViewport*); 00207 00208 private: 00209 vtkBarChartActor(const vtkBarChartActor&); // Not implemented. 00210 void operator=(const vtkBarChartActor&); // Not implemented. 00211 }; 00212 00213 00214 #endif 00215