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

Hybrid/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_COLUMN,VTK_XYPLOT_ROW);
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   vtkLegendBoxActor *GetLegendBoxActor()
00301     {return this->LegendActor;}
00302   vtkGlyphSource2D *GetGlyphSource()
00303     {return this->GlyphSource;}
00305 
00307 
00309   vtkSetStringMacro(Title);
00310   vtkGetStringMacro(Title);
00311   vtkSetStringMacro(XTitle);
00312   vtkGetStringMacro(XTitle);
00313   vtkSetStringMacro(YTitle);
00314   vtkGetStringMacro(YTitle);
00316 
00318 
00320   vtkAxisActor2D *GetXAxisActor2D()
00321     {return this->XAxis;}
00322   vtkAxisActor2D *GetYAxisActor2D()
00323     {return this->YAxis;}
00325 
00327 
00333   vtkSetVector2Macro(XRange,double);
00334   vtkGetVectorMacro(XRange,double,2);
00335   vtkSetVector2Macro(YRange,double);
00336   vtkGetVectorMacro(YRange,double,2);
00337   void SetPlotRange(double xmin, double ymin, double xmax, double ymax)
00338     {this->SetXRange(xmin,xmax); this->SetYRange(ymin,ymax);}
00340   
00342 
00347   vtkSetClampMacro(NumberOfXLabels, int, 0, 50);
00348   vtkGetMacro(NumberOfXLabels, int);
00349   vtkSetClampMacro(NumberOfYLabels, int, 0, 50);
00350   vtkGetMacro(NumberOfYLabels, int);
00351   void SetNumberOfLabels(int num)
00352     {this->SetNumberOfXLabels(num); this->SetNumberOfYLabels(num);}
00354   
00356 
00359   vtkSetMacro(Legend, int);
00360   vtkGetMacro(Legend, int);
00361   vtkBooleanMacro(Legend, int);
00363 
00365 
00371   vtkSetVector2Macro(LegendPosition,double);
00372   vtkGetVector2Macro(LegendPosition,double);
00373   vtkSetVector2Macro(LegendPosition2,double);
00374   vtkGetVector2Macro(LegendPosition2,double);
00376   
00378 
00379   virtual void SetTitleTextProperty(vtkTextProperty *p);
00380   vtkGetObjectMacro(TitleTextProperty,vtkTextProperty);
00382   
00384 
00386   virtual void SetAxisTitleTextProperty(vtkTextProperty *p);
00387   vtkGetObjectMacro(AxisTitleTextProperty,vtkTextProperty);
00389   
00391 
00393   virtual void SetAxisLabelTextProperty(vtkTextProperty *p);
00394   vtkGetObjectMacro(AxisLabelTextProperty,vtkTextProperty);
00396       
00398 
00399   vtkSetMacro(Logx, int);
00400   vtkGetMacro(Logx, int);
00401   vtkBooleanMacro(Logx, int);
00403 
00405 
00406   virtual void SetLabelFormat (const char* _arg);
00407   vtkGetStringMacro(LabelFormat);
00409 
00411 
00413   vtkSetClampMacro(Border, int, 0, 50);
00414   vtkGetMacro(Border, int);
00416 
00418 
00421   vtkGetMacro(PlotPoints, int);
00422   vtkSetMacro(PlotPoints, int);
00423   vtkBooleanMacro(PlotPoints, int);
00425 
00427 
00429   vtkGetMacro(PlotLines, int);
00430   vtkSetMacro(PlotLines, int);
00431   vtkBooleanMacro(PlotLines, int);
00433   
00435 
00438   vtkSetClampMacro(GlyphSize, double, 0.0, 0.2);
00439   vtkGetMacro(GlyphSize, double);
00441 
00444   void ViewportToPlotCoordinate(vtkViewport *viewport, double &u, double &v);
00445 
00447 
00450   void ViewportToPlotCoordinate(vtkViewport *viewport);
00451   vtkSetVector2Macro(PlotCoordinate,double);
00452   vtkGetVector2Macro(PlotCoordinate,double);
00454 
00456   void PlotToViewportCoordinate(vtkViewport *viewport, double &u, double &v);
00457 
00459 
00463   void PlotToViewportCoordinate(vtkViewport *viewport);
00464   vtkSetVector2Macro(ViewportCoordinate,double);
00465   vtkGetVector2Macro(ViewportCoordinate,double);
00467 
00470   int IsInPlot(vtkViewport *viewport, double u, double v);
00471   
00473   unsigned long GetMTime();
00474   
00475 //BTX  
00477 
00479   int RenderOpaqueGeometry(vtkViewport*);
00480   int RenderOverlay(vtkViewport*);
00481   int RenderTranslucentGeometry(vtkViewport *) {return 0;}
00483 
00487   void ReleaseGraphicsResources(vtkWindow *);
00488 //ETX  
00489 
00490 protected:
00491   vtkXYPlotActor();
00492   ~vtkXYPlotActor();
00493 
00494   vtkDataSetCollection *InputList; //list of data sets to plot
00495   char** SelectedInputScalars; // list of data set arrays to plot
00496   vtkIntArray* SelectedInputScalarsComponent; // list of componenents
00497   vtkDataObjectCollection *DataObjectInputList; //list of data objects to plot
00498   char  *Title;
00499   char  *XTitle;
00500   char  *YTitle;
00501   int   XValues;
00502   int   NumberOfXLabels;
00503   int   NumberOfYLabels;
00504   int   Logx;
00505   char  *LabelFormat;
00506   double XRange[2];
00507   double YRange[2];
00508   double XComputedRange[2];  //range actually used by plot
00509   double YComputedRange[2];  //range actually used by plot
00510   int Border;
00511   int PlotLines;
00512   int PlotPoints;
00513   int PlotCurveLines;
00514   int PlotCurvePoints;
00515   int ExchangeAxes;
00516   int ReverseXAxis;
00517   int ReverseYAxis;
00518   
00519   vtkTextMapper   *TitleMapper;
00520   vtkActor2D      *TitleActor;
00521   vtkTextProperty *TitleTextProperty;
00522 
00523   vtkAxisActor2D      *XAxis;
00524   vtkAxisActor2D      *YAxis;
00525 
00526   vtkTextProperty *AxisTitleTextProperty;
00527   vtkTextProperty *AxisLabelTextProperty;
00528 
00529   double ViewportCoordinate[2];
00530   double PlotCoordinate[2];
00531   
00532   //Handle data objects and datasets
00533   int DataObjectPlotMode;
00534   vtkIntArray *XComponent;
00535   vtkIntArray *YComponent;
00536   vtkIntArray *LinesOn;
00537   vtkIntArray *PointsOn;
00538 
00539   //The data drawn within the axes. Each curve is one polydata.
00540   //color is controlled by scalar data. The curves are appended
00541   //together, possibly glyphed with point symbols.
00542   int NumberOfInputs;
00543   vtkPolyData             **PlotData; 
00544   vtkGlyph2D              **PlotGlyph;
00545   vtkAppendPolyData       **PlotAppend;
00546   vtkPolyDataMapper2D     **PlotMapper;
00547   vtkActor2D              **PlotActor;
00548   void                    InitializeEntries();
00549   
00550   // Legends and plot symbols. The legend also keeps track of
00551   // the symbols and such.
00552   int Legend;
00553   double LegendPosition[2];
00554   double LegendPosition2[2];
00555   vtkLegendBoxActor *LegendActor;
00556   vtkGlyphSource2D *GlyphSource;
00557   vtkPlanes *ClipPlanes;
00558   double GlyphSize;
00559 
00560   // Keep track of changes.
00561   int CachedSize[2];
00562   vtkTimeStamp  BuildTime;
00563 
00564   void ComputeXRange(double range[2], double *lengths);
00565   void ComputeYRange(double range[2]);
00566   void ComputeDORange(double xrange[2], double yrange[2], double *lengths);
00567 
00568   virtual void CreatePlotData(int *pos, int *pos2, double xRange[2], 
00569                               double yRange[2], double *norms, 
00570                               int numDS, int numDO);
00571   void PlaceAxes(vtkViewport *viewport, int *size, int pos[2], int pos2[2]);
00572   void GenerateClipPlanes(int *pos, int *pos2);
00573   double ComputeGlyphScale(int i, int *pos, int *pos2);
00574   void ClipPlotData(int *pos, int *pos2, vtkPolyData *pd);
00575   double *TransformPoint(int pos[2], int pos2[2], double x[3], double xNew[3]);
00576   
00577 private:
00578   vtkXYPlotActor(const vtkXYPlotActor&);  // Not implemented.
00579   void operator=(const vtkXYPlotActor&);  // Not implemented.
00580 };
00581 
00582 
00583 #endif
00584