Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages

vtkXYPlotActor.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: vtkXYPlotActor.h,v $
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 =========================================================================*/
00087 #ifndef __vtkXYPlotActor_h
00088 #define __vtkXYPlotActor_h
00089 
00090 #define VTK_XYPLOT_INDEX                 0
00091 #define VTK_XYPLOT_ARC_LENGTH            1
00092 #define VTK_XYPLOT_NORMALIZED_ARC_LENGTH 2
00093 #define VTK_XYPLOT_VALUE                 3
00094 
00095 #define VTK_XYPLOT_ROW 0
00096 #define VTK_XYPLOT_COLUMN 1
00097 
00098 #include "vtkActor2D.h"
00099 
00100 class vtkAppendPolyData;
00101 class vtkAxisActor2D;
00102 class vtkDataObject;
00103 class vtkDataObjectCollection;
00104 class vtkDataSet;
00105 class vtkDataSetCollection;
00106 class vtkGlyph2D;
00107 class vtkGlyphSource2D;
00108 class vtkIntArray;
00109 class vtkLegendBoxActor;
00110 class vtkPlanes;
00111 class vtkPolyData;
00112 class vtkPolyDataMapper2D;
00113 class vtkTextMapper;
00114 class vtkTextProperty;
00115 
00116 class VTK_HYBRID_EXPORT vtkXYPlotActor : public vtkActor2D
00117 {
00118 public:
00119   vtkTypeRevisionMacro(vtkXYPlotActor,vtkActor2D);
00120   void PrintSelf(ostream& os, vtkIndent indent);
00121 
00126   static vtkXYPlotActor *New();
00127 
00128   //---Data Set Input----------------------------------------------------------
00129   // The following methods are used to plot input datasets. Datasets
00130   // will be plotted if set as input; otherwise the input data objects
00131   // will be plotted (if defined).
00132   
00134 
00138   void AddInput(vtkDataSet *in, const char* arrayName, int component);
00139   void AddInput(vtkDataSet *in) {this->AddInput(in, NULL, 0);}
00141 
00143 
00144   void RemoveInput(vtkDataSet *in, const char* arrayName, int component);
00145   void RemoveInput(vtkDataSet *in) {this->RemoveInput(in, NULL, 0);}
00147 
00150   void RemoveAllInputs();
00151 
00153   vtkDataSetCollection *GetInputList() {return this->InputList;}
00154 
00156 
00159   void SetPointComponent(int i, int comp);
00160   int GetPointComponent(int i);
00161   //---end Data Set Input-----------------------------------------------------
00163 
00165 
00173   vtkSetClampMacro(XValues,int,VTK_XYPLOT_INDEX,VTK_XYPLOT_VALUE);
00174   vtkGetMacro(XValues,int);
00175   void SetXValuesToIndex(){this->SetXValues(VTK_XYPLOT_INDEX);};
00176   void SetXValuesToArcLength() {this->SetXValues(VTK_XYPLOT_ARC_LENGTH);};
00177   void SetXValuesToNormalizedArcLength()
00178     {this->SetXValues(VTK_XYPLOT_NORMALIZED_ARC_LENGTH);};
00179   void SetXValuesToValue() {this->SetXValues(VTK_XYPLOT_VALUE);};
00180   const char *GetXValuesAsString();
00182 
00183   //---Data Object Input------------------------------------------------------
00184   // The following methods are used to plot input data objects. Datasets will
00185   // be plotted in preference to data objects if set as input; otherwise the
00186   // input data objects will be plotted (if defined).
00187   
00189   void AddDataObjectInput(vtkDataObject *in);
00190 
00192   void RemoveDataObjectInput(vtkDataObject *in);
00193 
00195 
00196   vtkDataObjectCollection *GetDataObjectInputList() 
00197     {return this->DataObjectInputList;}
00199 
00201 
00203   vtkSetClampMacro(DataObjectPlotMode,int,VTK_XYPLOT_ROW,VTK_XYPLOT_COLUMN);
00204   vtkGetMacro(DataObjectPlotMode,int);
00205   void SetDataObjectPlotModeToRows()
00206     {this->SetDataObjectPlotMode(VTK_XYPLOT_ROW);}
00207   void SetDataObjectPlotModeToColumns()
00208     {this->SetDataObjectPlotMode(VTK_XYPLOT_COLUMN);}
00209   const char *GetDataObjectPlotModeAsString();
00211 
00213 
00219   void SetDataObjectXComponent(int i, int comp);
00220   int GetDataObjectXComponent(int i);
00222 
00224 
00230   void SetDataObjectYComponent(int i, int comp);
00231   int GetDataObjectYComponent(int i);
00232   //---end Data Object Input--------------------------------------------------
00234 
00235   //---Per Curve Properties---------------------------------------------------
00236   // The following methods are used to set properties on each curve that is
00237   // plotted. Each input dataset (or data object) results in one curve. The
00238   // methods that follow have an index i that corresponds to the input dataset
00239   // or data object. 
00240   void SetPlotColor(int i, double r, double g, double b);
00241   void SetPlotColor(int i, const double color[3]) {
00242     this->SetPlotColor(i, color[0], color[1], color[2]); };
00243   double *GetPlotColor(int i);
00244   void SetPlotSymbol(int i,vtkPolyData *input);
00245   vtkPolyData *GetPlotSymbol(int i);
00246   void SetPlotLabel(int i, const char *label);
00247   const char *GetPlotLabel(int i);
00248 
00249   // Allow per-curve specification of line and point rendering.  These override
00250   // global settings PlotPoints and PlotLines.  If not on, the default behavior
00251   // is governed by PlotPoints and PlotLines ivars.
00252   vtkGetMacro(PlotCurvePoints, int);
00253   vtkSetMacro(PlotCurvePoints, int);
00254   vtkBooleanMacro(PlotCurvePoints, int);
00255 
00256   vtkGetMacro(PlotCurveLines, int);
00257   vtkSetMacro(PlotCurveLines, int);
00258   vtkBooleanMacro(PlotCurveLines, int);
00259 
00260   void SetPlotLines(int i, int);
00261   int GetPlotLines(int i);
00262 
00263   void SetPlotPoints(int i, int);
00264   int GetPlotPoints(int i);
00265   //---end Per Curve Properties-----------------------------------------------
00266 
00268 
00270   vtkSetMacro(ExchangeAxes, int);
00271   vtkGetMacro(ExchangeAxes, int);
00272   vtkBooleanMacro(ExchangeAxes, int);
00274 
00276 
00280   vtkSetMacro(ReverseXAxis, int);
00281   vtkGetMacro(ReverseXAxis, int);
00282   vtkBooleanMacro(ReverseXAxis, int);
00284 
00286 
00290   vtkSetMacro(ReverseYAxis, int);
00291   vtkGetMacro(ReverseYAxis, int);
00292   vtkBooleanMacro(ReverseYAxis, int);
00294 
00296 
00300   vtkGetObjectMacro(LegendActor,vtkLegendBoxActor);
00301   vtkGetObjectMacro(GlyphSource,vtkGlyphSource2D);
00303 
00305 
00307   vtkSetStringMacro(Title);
00308   vtkGetStringMacro(Title);
00309   vtkSetStringMacro(XTitle);
00310   vtkGetStringMacro(XTitle);
00311   vtkSetStringMacro(YTitle);
00312   vtkGetStringMacro(YTitle);
00314 
00316 
00318   vtkAxisActor2D *GetXAxisActor2D()
00319     {return this->XAxis;}
00320   vtkAxisActor2D *GetYAxisActor2D()
00321     {return this->YAxis;}
00323 
00325 
00331   vtkSetVector2Macro(XRange,double);
00332   vtkGetVectorMacro(XRange,double,2);
00333   vtkSetVector2Macro(YRange,double);
00334   vtkGetVectorMacro(YRange,double,2);
00335   void SetPlotRange(double xmin, double ymin, double xmax, double ymax)
00336     {this->SetXRange(xmin,xmax); this->SetYRange(ymin,ymax);}
00338   
00340 
00345   vtkSetClampMacro(NumberOfXLabels, int, 0, 50);
00346   vtkGetMacro(NumberOfXLabels, int);
00347   vtkSetClampMacro(NumberOfYLabels, int, 0, 50);
00348   vtkGetMacro(NumberOfYLabels, int);
00349   void SetNumberOfLabels(int num)
00350     {this->SetNumberOfXLabels(num); this->SetNumberOfYLabels(num);}
00352   
00354 
00357   vtkSetMacro(Legend, int);
00358   vtkGetMacro(Legend, int);
00359   vtkBooleanMacro(Legend, int);
00361 
00363 
00369   vtkSetVector2Macro(LegendPosition,double);
00370   vtkGetVector2Macro(LegendPosition,double);
00371   vtkSetVector2Macro(LegendPosition2,double);
00372   vtkGetVector2Macro(LegendPosition2,double);
00374   
00376 
00377   virtual void SetTitleTextProperty(vtkTextProperty *p);
00378   vtkGetObjectMacro(TitleTextProperty,vtkTextProperty);
00380   
00382 
00384   virtual void SetAxisTitleTextProperty(vtkTextProperty *p);
00385   vtkGetObjectMacro(AxisTitleTextProperty,vtkTextProperty);
00387   
00389 
00391   virtual void SetAxisLabelTextProperty(vtkTextProperty *p);
00392   vtkGetObjectMacro(AxisLabelTextProperty,vtkTextProperty);
00394       
00396 
00397   vtkSetMacro(Logx, int);
00398   vtkGetMacro(Logx, int);
00399   vtkBooleanMacro(Logx, int);
00401 
00403 
00404   virtual void SetLabelFormat (const char* _arg);
00405   vtkGetStringMacro(LabelFormat);
00407 
00409 
00411   vtkSetClampMacro(Border, int, 0, 50);
00412   vtkGetMacro(Border, int);
00414 
00416 
00419   vtkGetMacro(PlotPoints, int);
00420   vtkSetMacro(PlotPoints, int);
00421   vtkBooleanMacro(PlotPoints, int);
00423 
00425 
00427   vtkGetMacro(PlotLines, int);
00428   vtkSetMacro(PlotLines, int);
00429   vtkBooleanMacro(PlotLines, int);
00431   
00433 
00436   vtkSetClampMacro(GlyphSize, double, 0.0, 0.2);
00437   vtkGetMacro(GlyphSize, double);
00439 
00442   void ViewportToPlotCoordinate(vtkViewport *viewport, double &u, double &v);
00443 
00445 
00448   void ViewportToPlotCoordinate(vtkViewport *viewport);
00449   vtkSetVector2Macro(PlotCoordinate,double);
00450   vtkGetVector2Macro(PlotCoordinate,double);
00452 
00454   void PlotToViewportCoordinate(vtkViewport *viewport, double &u, double &v);
00455 
00457 
00461   void PlotToViewportCoordinate(vtkViewport *viewport);
00462   vtkSetVector2Macro(ViewportCoordinate,double);
00463   vtkGetVector2Macro(ViewportCoordinate,double);
00465 
00468   int IsInPlot(vtkViewport *viewport, double u, double v);
00469   
00471   unsigned long GetMTime();
00472   
00475   void PrintAsCSV(ostream &os);
00476 
00477 //BTX  
00479 
00481   int RenderOpaqueGeometry(vtkViewport*);
00482   int RenderOverlay(vtkViewport*);
00483   int RenderTranslucentGeometry(vtkViewport *) {return 0;}
00485 
00489   void ReleaseGraphicsResources(vtkWindow *);
00490 //ETX  
00491 
00492 protected:
00493   vtkXYPlotActor();
00494   ~vtkXYPlotActor();
00495 
00496   vtkDataSetCollection *InputList; //list of data sets to plot
00497   char** SelectedInputScalars; // list of data set arrays to plot
00498   vtkIntArray* SelectedInputScalarsComponent; // list of componenents
00499   vtkDataObjectCollection *DataObjectInputList; //list of data objects to plot
00500   char  *Title;
00501   char  *XTitle;
00502   char  *YTitle;
00503   int   XValues;
00504   int   NumberOfXLabels;
00505   int   NumberOfYLabels;
00506   int   Logx;
00507   char  *LabelFormat;
00508   double XRange[2];
00509   double YRange[2];
00510   double XComputedRange[2];  //range actually used by plot
00511   double YComputedRange[2];  //range actually used by plot
00512   int Border;
00513   int PlotLines;
00514   int PlotPoints;
00515   int PlotCurveLines;
00516   int PlotCurvePoints;
00517   int ExchangeAxes;
00518   int ReverseXAxis;
00519   int ReverseYAxis;
00520   
00521   vtkTextMapper   *TitleMapper;
00522   vtkActor2D      *TitleActor;
00523   vtkTextProperty *TitleTextProperty;
00524 
00525   vtkAxisActor2D      *XAxis;
00526   vtkAxisActor2D      *YAxis;
00527 
00528   vtkTextProperty *AxisTitleTextProperty;
00529   vtkTextProperty *AxisLabelTextProperty;
00530 
00531   double ViewportCoordinate[2];
00532   double PlotCoordinate[2];
00533   
00534   //Handle data objects and datasets
00535   int DataObjectPlotMode;
00536   vtkIntArray *XComponent;
00537   vtkIntArray *YComponent;
00538   vtkIntArray *LinesOn;
00539   vtkIntArray *PointsOn;
00540 
00541   //The data drawn within the axes. Each curve is one polydata.
00542   //color is controlled by scalar data. The curves are appended
00543   //together, possibly glyphed with point symbols.
00544   int NumberOfInputs;
00545   vtkPolyData             **PlotData; 
00546   vtkGlyph2D              **PlotGlyph;
00547   vtkAppendPolyData       **PlotAppend;
00548   vtkPolyDataMapper2D     **PlotMapper;
00549   vtkActor2D              **PlotActor;
00550   void                    InitializeEntries();
00551   
00552   // Legends and plot symbols. The legend also keeps track of
00553   // the symbols and such.
00554   int Legend;
00555   double LegendPosition[2];
00556   double LegendPosition2[2];
00557   vtkLegendBoxActor *LegendActor;
00558   vtkGlyphSource2D *GlyphSource;
00559   vtkPlanes *ClipPlanes;
00560   double GlyphSize;
00561 
00562   // Keep track of changes.
00563   int CachedSize[2];
00564   vtkTimeStamp  BuildTime;
00565 
00566   void ComputeXRange(double range[2], double *lengths);
00567   void ComputeYRange(double range[2]);
00568   void ComputeDORange(double xrange[2], double yrange[2], double *lengths);
00569 
00570   virtual void CreatePlotData(int *pos, int *pos2, double xRange[2], 
00571                               double yRange[2], double *norms, 
00572                               int numDS, int numDO);
00573   void PlaceAxes(vtkViewport *viewport, int *size, int pos[2], int pos2[2]);
00574   void GenerateClipPlanes(int *pos, int *pos2);
00575   double ComputeGlyphScale(int i, int *pos, int *pos2);
00576   void ClipPlotData(int *pos, int *pos2, vtkPolyData *pd);
00577   double *TransformPoint(int pos[2], int pos2[2], double x[3], double xNew[3]);
00578   
00579 private:
00580   vtkXYPlotActor(const vtkXYPlotActor&);  // Not implemented.
00581   void operator=(const vtkXYPlotActor&);  // Not implemented.
00582 };
00583 
00584 
00585 #endif
00586 

Generated on Mon Jan 21 23:07:28 2008 for VTK by  doxygen 1.4.3-20050530