Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

contrib/vtkXYPlotActor.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: vtkXYPlotActor.h,v $
00005   Language:  C++
00006 
00007 Copyright (c) 1993-2001 Ken Martin, Will Schroeder, Bill Lorensen 
00008 All rights reserved.
00009 
00010 Redistribution and use in source and binary forms, with or without
00011 modification, are permitted provided that the following conditions are met:
00012 
00013  * Redistributions of source code must retain the above copyright notice,
00014    this list of conditions and the following disclaimer.
00015 
00016  * Redistributions in binary form must reproduce the above copyright notice,
00017    this list of conditions and the following disclaimer in the documentation
00018    and/or other materials provided with the distribution.
00019 
00020  * Neither name of Ken Martin, Will Schroeder, or Bill Lorensen nor the names
00021    of any contributors may be used to endorse or promote products derived
00022    from this software without specific prior written permission.
00023 
00024  * Modified source versions must be plainly marked as such, and must not be
00025    misrepresented as being the original software.
00026 
00027 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
00028 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00029 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00030 ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
00031 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00032 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00033 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00034 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00035 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00036 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00037 
00038 =========================================================================*/
00096 #ifndef __vtkXYPlotActor_h
00097 #define __vtkXYPlotActor_h
00098 
00099 #define VTK_XYPLOT_INDEX                 0
00100 #define VTK_XYPLOT_ARC_LENGTH            1
00101 #define VTK_XYPLOT_NORMALIZED_ARC_LENGTH 2
00102 #define VTK_XYPLOT_VALUE                 3
00103 
00104 #define VTK_XYPLOT_ROW 0
00105 #define VTK_XYPLOT_COLUMN 1
00106 
00107 #include "vtkAxisActor2D.h"
00108 class vtkDataSetCollection;
00109 class vtkDataObjectCollection;
00110 class vtkGlyphSource2D;
00111 class vtkGlyph2D;
00112 class vtkLegendBoxActor;
00113 class vtkAppendPolyData;
00114 class vtkPlanes;
00115 class vtkIntArray;
00116 
00117 class VTK_EXPORT vtkXYPlotActor : public vtkActor2D
00118 {
00119 public:
00120   vtkTypeMacro(vtkXYPlotActor,vtkActor2D);
00121   void PrintSelf(ostream& os, vtkIndent indent);
00122 
00127   static vtkXYPlotActor *New();
00128 
00129   //---Data Set Input----------------------------------------------------------
00130   // The following methods are used to plot input datasets. Datasets
00131   // will be plotted if set as input; otherwise the input data objects
00132   // will be plotted (if defined).
00133   
00135   void AddInput(vtkDataSet *in);
00136 
00138   void RemoveInput(vtkDataSet *in);
00139 
00141   vtkDataSetCollection *GetInputList() {return this->InputList;}
00142 
00146   void SetPointComponent(int i, int comp);
00147   int GetPointComponent(int i);
00148   //---end Data Set Input-----------------------------------------------------
00149 
00158   vtkSetClampMacro(XValues,int,VTK_XYPLOT_INDEX,VTK_XYPLOT_VALUE);
00159   vtkGetMacro(XValues,int);
00160   void SetXValuesToIndex(){this->SetXValues(VTK_XYPLOT_INDEX);};
00161   void SetXValuesToArcLength() {this->SetXValues(VTK_XYPLOT_ARC_LENGTH);};
00162   void SetXValuesToNormalizedArcLength()
00163     {this->SetXValues(VTK_XYPLOT_NORMALIZED_ARC_LENGTH);};
00164   void SetXValuesToValue() {this->SetXValues(VTK_XYPLOT_VALUE);};
00165   const char *GetXValuesAsString();
00166 
00167   //---Data Object Input------------------------------------------------------
00168   // The following methods are used to plot input data objects. Datasets will
00169   // be plotted in preference to data objects if set as input; otherwise the
00170   // input data objects will be plotted (if defined).
00171   
00173   void AddDataObjectInput(vtkDataObject *in);
00174 
00176   void RemoveDataObjectInput(vtkDataObject *in);
00177 
00179   vtkDataObjectCollection *GetDataObjectInputList() 
00180     {return this->DataObjectInputList;}
00181 
00184   vtkSetClampMacro(DataObjectPlotMode,int,VTK_XYPLOT_COLUMN,VTK_XYPLOT_ROW);
00185   vtkGetMacro(DataObjectPlotMode,int);
00186   void SetDataObjectPlotModeToRows()
00187     {this->SetDataObjectPlotMode(VTK_XYPLOT_ROW);}
00188   void SetDataObjectPlotModeToColumns()
00189     {this->SetDataObjectPlotMode(VTK_XYPLOT_COLUMN);}
00190   const char *GetDataObjectPlotModeAsString();
00191 
00198   void SetDataObjectXComponent(int i, int comp);
00199   int GetDataObjectXComponent(int i);
00200 
00207   void SetDataObjectYComponent(int i, int comp);
00208   int GetDataObjectYComponent(int i);
00209   //---end Data Object Input--------------------------------------------------
00210 
00211   //---Per Curve Properties---------------------------------------------------
00212   // The following methods are used to set properties on each curve that is
00213   // plotted. Each input dataset (or data object) results in one curve. The
00214   // methods that follow have an index i that corresponds to the input dataset
00215   // or data object. 
00216   void SetPlotColor(int i, float r, float g, float b);
00217   void SetPlotColor(int i, float color[3]);
00218   float *GetPlotColor(int i);
00219   void SetPlotSymbol(int i,vtkPolyData *input);
00220   vtkPolyData *GetPlotSymbol(int i);
00221   void SetPlotLabel(int i, const char *label);
00222   const char *GetPlotLabel(int i);
00223   //---end Per Curve Properties-----------------------------------------------
00224 
00229   vtkLegendBoxActor *GetLegendBoxActor()
00230     {return this->LegendActor;}
00231   vtkGlyphSource2D *GetGlyphSource()
00232     {return this->GlyphSource;}
00233 
00236   vtkSetStringMacro(Title);
00237   vtkGetStringMacro(Title);
00238   vtkSetStringMacro(XTitle);
00239   vtkGetStringMacro(XTitle);
00240   vtkSetStringMacro(YTitle);
00241   vtkGetStringMacro(YTitle);
00242 
00249   vtkSetVector2Macro(XRange,float);
00250   vtkGetVectorMacro(XRange,float,2);
00251   vtkSetVector2Macro(YRange,float);
00252   vtkGetVectorMacro(YRange,float,2);
00253   void SetPlotRange(float xmin, float ymin, float xmax, float ymax)
00254     {this->SetXRange(xmin,xmax); this->SetYRange(ymin,ymax);}
00255   
00261   vtkSetClampMacro(NumberOfXLabels, int, 0, 50);
00262   vtkGetMacro(NumberOfXLabels, int);
00263   vtkSetClampMacro(NumberOfYLabels, int, 0, 50);
00264   vtkGetMacro(NumberOfYLabels, int);
00265   void SetNumberOfLabels(int num)
00266     {this->SetNumberOfXLabels(num); this->SetNumberOfYLabels(num);}
00267   
00271   vtkSetMacro(Legend, int);
00272   vtkGetMacro(Legend, int);
00273   vtkBooleanMacro(Legend, int);
00274 
00281   vtkSetVector2Macro(LegendPosition,float);
00282   vtkGetVector2Macro(LegendPosition,float);
00283   vtkSetVector2Macro(LegendPosition2,float);
00284   vtkGetVector2Macro(LegendPosition2,float);
00285   
00287   vtkSetMacro(Bold, int);
00288   vtkGetMacro(Bold, int);
00289   vtkBooleanMacro(Bold, int);
00290 
00292   vtkSetMacro(Italic, int);
00293   vtkGetMacro(Italic, int);
00294   vtkBooleanMacro(Italic, int);
00295 
00298   vtkSetMacro(Shadow, int);
00299   vtkGetMacro(Shadow, int);
00300   vtkBooleanMacro(Shadow, int);
00301 
00305   vtkSetMacro(FontFamily, int);
00306   vtkGetMacro(FontFamily, int);
00307   void SetFontFamilyToArial() {this->SetFontFamily(VTK_ARIAL);};
00308   void SetFontFamilyToCourier() {this->SetFontFamily(VTK_COURIER);};
00309   void SetFontFamilyToTimes() {this->SetFontFamily(VTK_TIMES);};
00310 
00312   vtkSetStringMacro(LabelFormat);
00313   vtkGetStringMacro(LabelFormat);
00314 
00317   vtkSetClampMacro(Border, int, 0, 50);
00318   vtkGetMacro(Border, int);
00319 
00323   vtkGetMacro(PlotPoints, int);
00324   vtkSetMacro(PlotPoints, int);
00325   vtkBooleanMacro(PlotPoints, int);
00326 
00329   vtkGetMacro(PlotLines, int);
00330   vtkSetMacro(PlotLines, int);
00331   vtkBooleanMacro(PlotLines, int);
00332   
00336   vtkSetClampMacro(GlyphSize, float, 0.0, 0.2);
00337   vtkGetMacro(GlyphSize, float);
00338 
00341   void ViewportToPlotCoordinate(vtkViewport *viewport, float &u, float &v);
00342 
00346   void ViewportToPlotCoordinate(vtkViewport *viewport);
00347   vtkSetVector2Macro(PlotCoordinate,float);
00348   vtkGetVector2Macro(PlotCoordinate,float);
00349 
00351   void PlotToViewportCoordinate(vtkViewport *viewport, float &u, float &v);
00352 
00357   void PlotToViewportCoordinate(vtkViewport *viewport);
00358   vtkSetVector2Macro(ViewportCoordinate,float);
00359   vtkGetVector2Macro(ViewportCoordinate,float);
00360 
00363   int IsInPlot(vtkViewport *viewport, float u, float v);
00364   
00367   unsigned long GetMTime();
00368   
00369 //BTX  
00372   int RenderOpaqueGeometry(vtkViewport*);
00373   int RenderOverlay(vtkViewport*);
00374   int RenderTranslucentGeometry(vtkViewport *) {return 0;}
00375 
00379   void ReleaseGraphicsResources(vtkWindow *);
00380 //ETX  
00381 
00382 protected:
00383   vtkXYPlotActor();
00384   ~vtkXYPlotActor();
00385   vtkXYPlotActor(const vtkXYPlotActor&) {};
00386   void operator=(const vtkXYPlotActor&) {};
00387 
00388   vtkDataSetCollection *InputList; //list of data sets to plot
00389   vtkDataObjectCollection *DataObjectInputList; //list of data objects to plot
00390   char  *Title;
00391   char  *XTitle;
00392   char  *YTitle;
00393   int   XValues;
00394   int   NumberOfXLabels;
00395   int   NumberOfYLabels;
00396   int   Bold;
00397   int   Italic;
00398   int   Shadow;
00399   int   FontFamily;
00400   char  *LabelFormat;
00401   float XRange[2];
00402   float YRange[2];
00403   float XComputedRange[2];  //range actually used by plot
00404   float YComputedRange[2];  //range actually used by plot
00405   int Border;
00406   int PlotLines;
00407   int PlotPoints;
00408   
00409   vtkTextMapper *TitleMapper;
00410   vtkActor2D    *TitleActor;
00411 
00412   vtkAxisActor2D      *XAxis;
00413   vtkAxisActor2D      *YAxis;
00414 
00415   float ViewportCoordinate[2];
00416   float PlotCoordinate[2];
00417   
00418   //Handle data objects and datasets
00419   int DataObjectPlotMode;
00420   vtkIntArray *XComponent;
00421   vtkIntArray *YComponent;
00422 
00423   //The data drawn within the axes. Each curve is one polydata.
00424   //color is controlled by scalar data. The curves are appended
00425   //together, possibly glyphed with point symbols.
00426   int NumberOfInputs;
00427   vtkPolyData             **PlotData; 
00428   vtkGlyph2D              **PlotGlyph;
00429   vtkAppendPolyData       **PlotAppend;
00430   vtkPolyDataMapper2D     **PlotMapper;
00431   vtkActor2D              **PlotActor;
00432   void                    InitializeEntries();
00433   
00434   // Legends and plot symbols. The legend also keeps track of
00435   // the symbols and such.
00436   int Legend;
00437   float LegendPosition[2];
00438   float LegendPosition2[2];
00439   vtkLegendBoxActor *LegendActor;
00440   vtkGlyphSource2D *GlyphSource;
00441   vtkPlanes *ClipPlanes;
00442   float GlyphSize;
00443 
00444   // Keep track of changes.
00445   int CachedSize[2];
00446   vtkTimeStamp  BuildTime;
00447 
00448   void ComputeXRange(float range[2], float *lengths);
00449   void ComputeYRange(float range[2]);
00450   void ComputeDORange(float xrange[2], float yrange[2], float *lengths);
00451 
00452   virtual void CreatePlotData(int *pos, int *pos2, float xRange[2], 
00453                               float yRange[2], float *norms, 
00454                               int numDS, int numDO);
00455   void PlaceAxes(vtkViewport *viewport, int *size, int pos[2], int pos2[2]);
00456   void GenerateClipPlanes(int *pos, int *pos2);
00457   float ComputeGlyphScale(int i, int *pos, int *pos2);
00458   void ClipPlotData(int *pos, int *pos2, vtkPolyData *pd);
00459   
00460 };
00461 
00462 
00463 #endif
00464 

Generated on Wed Nov 21 12:26:56 2001 for VTK by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001