Main Page | Directories | Class Hierarchy | Alphabetical List | Class List | 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 =========================================================================*/
00099 #ifndef __vtkXYPlotActor_h
00100 #define __vtkXYPlotActor_h
00101 
00102 #define VTK_XYPLOT_INDEX                 0
00103 #define VTK_XYPLOT_ARC_LENGTH            1
00104 #define VTK_XYPLOT_NORMALIZED_ARC_LENGTH 2
00105 #define VTK_XYPLOT_VALUE                 3
00106 
00107 #define VTK_XYPLOT_ROW 0
00108 #define VTK_XYPLOT_COLUMN 1
00109 
00110 #include "vtkActor2D.h"
00111 
00112 class vtkAppendPolyData;
00113 class vtkAxisActor2D;
00114 class vtkDataObject;
00115 class vtkDataObjectCollection;
00116 class vtkDataSet;
00117 class vtkDataSetCollection;
00118 class vtkGlyph2D;
00119 class vtkGlyphSource2D;
00120 class vtkIntArray;
00121 class vtkLegendBoxActor;
00122 class vtkPlanes;
00123 class vtkPolyData;
00124 class vtkPolyDataMapper2D;
00125 class vtkTextMapper;
00126 class vtkTextProperty;
00127 
00128 class VTK_HYBRID_EXPORT vtkXYPlotActor : public vtkActor2D
00129 {
00130 public:
00131   vtkTypeRevisionMacro(vtkXYPlotActor,vtkActor2D);
00132   void PrintSelf(ostream& os, vtkIndent indent);
00133 
00138   static vtkXYPlotActor *New();
00139 
00140   //---Data Set Input----------------------------------------------------------
00141   // The following methods are used to plot input datasets. Datasets
00142   // will be plotted if set as input; otherwise the input data objects
00143   // will be plotted (if defined).
00144   
00146 
00150   void AddInput(vtkDataSet *in, const char* arrayName, int component);
00151   void AddInput(vtkDataSet *in) {this->AddInput(in, NULL, 0);}
00153 
00155 
00156   void RemoveInput(vtkDataSet *in, const char* arrayName, int component);
00157   void RemoveInput(vtkDataSet *in) {this->RemoveInput(in, NULL, 0);}
00159 
00162   void RemoveAllInputs();
00163 
00165   vtkDataSetCollection *GetInputList() {return this->InputList;}
00166 
00168 
00171   void SetPointComponent(int i, int comp);
00172   int GetPointComponent(int i);
00173   //---end Data Set Input-----------------------------------------------------
00175 
00177 
00185   vtkSetClampMacro(XValues,int,VTK_XYPLOT_INDEX,VTK_XYPLOT_VALUE);
00186   vtkGetMacro(XValues,int);
00187   void SetXValuesToIndex(){this->SetXValues(VTK_XYPLOT_INDEX);};
00188   void SetXValuesToArcLength() {this->SetXValues(VTK_XYPLOT_ARC_LENGTH);};
00189   void SetXValuesToNormalizedArcLength()
00190     {this->SetXValues(VTK_XYPLOT_NORMALIZED_ARC_LENGTH);};
00191   void SetXValuesToValue() {this->SetXValues(VTK_XYPLOT_VALUE);};
00192   const char *GetXValuesAsString();
00194 
00195   //---Data Object Input------------------------------------------------------
00196   // The following methods are used to plot input data objects. Datasets will
00197   // be plotted in preference to data objects if set as input; otherwise the
00198   // input data objects will be plotted (if defined).
00199   
00201   void AddDataObjectInput(vtkDataObject *in);
00202 
00204   void RemoveDataObjectInput(vtkDataObject *in);
00205 
00207 
00208   vtkDataObjectCollection *GetDataObjectInputList() 
00209     {return this->DataObjectInputList;}
00211 
00213 
00215   vtkSetClampMacro(DataObjectPlotMode,int,VTK_XYPLOT_COLUMN,VTK_XYPLOT_ROW);
00216   vtkGetMacro(DataObjectPlotMode,int);
00217   void SetDataObjectPlotModeToRows()
00218     {this->SetDataObjectPlotMode(VTK_XYPLOT_ROW);}
00219   void SetDataObjectPlotModeToColumns()
00220     {this->SetDataObjectPlotMode(VTK_XYPLOT_COLUMN);}
00221   const char *GetDataObjectPlotModeAsString();
00223 
00225 
00231   void SetDataObjectXComponent(int i, int comp);
00232   int GetDataObjectXComponent(int i);
00234 
00236 
00242   void SetDataObjectYComponent(int i, int comp);
00243   int GetDataObjectYComponent(int i);
00244   //---end Data Object Input--------------------------------------------------
00246 
00247   //---Per Curve Properties---------------------------------------------------
00248   // The following methods are used to set properties on each curve that is
00249   // plotted. Each input dataset (or data object) results in one curve. The
00250   // methods that follow have an index i that corresponds to the input dataset
00251   // or data object. 
00252   void SetPlotColor(int i, double r, double g, double b);
00253   void SetPlotColor(int i, const double color[3]) {
00254     this->SetPlotColor(i, color[0], color[1], color[2]); };
00255   double *GetPlotColor(int i);
00256   void SetPlotSymbol(int i,vtkPolyData *input);
00257   vtkPolyData *GetPlotSymbol(int i);
00258   void SetPlotLabel(int i, const char *label);
00259   const char *GetPlotLabel(int i);
00260 
00261   // Allow per-curve specification of line and point rendering.  These override
00262   // global settings PlotPoints and PlotLines.  If not on, the default behavior
00263   // is governed by PlotPoints and PlotLines ivars.
00264   vtkGetMacro(PlotCurvePoints, int);
00265   vtkSetMacro(PlotCurvePoints, int);
00266   vtkBooleanMacro(PlotCurvePoints, int);
00267 
00268   vtkGetMacro(PlotCurveLines, int);
00269   vtkSetMacro(PlotCurveLines, int);
00270   vtkBooleanMacro(PlotCurveLines, int);
00271 
00272   void SetPlotLines(int i, int);
00273   int GetPlotLines(int i);
00274 
00275   void SetPlotPoints(int i, int);
00276   int GetPlotPoints(int i);
00277   //---end Per Curve Properties-----------------------------------------------
00278 
00280 
00282   vtkSetMacro(ExchangeAxes, int);
00283   vtkGetMacro(ExchangeAxes, int);
00284   vtkBooleanMacro(ExchangeAxes, int);
00286 
00288 
00292   vtkSetMacro(ReverseXAxis, int);
00293   vtkGetMacro(ReverseXAxis, int);
00294   vtkBooleanMacro(ReverseXAxis, int);
00296 
00298 
00302   vtkSetMacro(ReverseYAxis, int);
00303   vtkGetMacro(ReverseYAxis, int);
00304   vtkBooleanMacro(ReverseYAxis, int);
00306 
00308 
00312   vtkLegendBoxActor *GetLegendBoxActor()
00313     {return this->LegendActor;}
00314   vtkGlyphSource2D *GetGlyphSource()
00315     {return this->GlyphSource;}
00317 
00319 
00321   vtkSetStringMacro(Title);
00322   vtkGetStringMacro(Title);
00323   vtkSetStringMacro(XTitle);
00324   vtkGetStringMacro(XTitle);
00325   vtkSetStringMacro(YTitle);
00326   vtkGetStringMacro(YTitle);
00328 
00330 
00332   vtkAxisActor2D *GetXAxisActor2D()
00333     {return this->XAxis;}
00334   vtkAxisActor2D *GetYAxisActor2D()
00335     {return this->YAxis;}
00337 
00339 
00345   vtkSetVector2Macro(XRange,double);
00346   vtkGetVectorMacro(XRange,double,2);
00347   vtkSetVector2Macro(YRange,double);
00348   vtkGetVectorMacro(YRange,double,2);
00349   void SetPlotRange(double xmin, double ymin, double xmax, double ymax)
00350     {this->SetXRange(xmin,xmax); this->SetYRange(ymin,ymax);}
00352   
00354 
00359   vtkSetClampMacro(NumberOfXLabels, int, 0, 50);
00360   vtkGetMacro(NumberOfXLabels, int);
00361   vtkSetClampMacro(NumberOfYLabels, int, 0, 50);
00362   vtkGetMacro(NumberOfYLabels, int);
00363   void SetNumberOfLabels(int num)
00364     {this->SetNumberOfXLabels(num); this->SetNumberOfYLabels(num);}
00366   
00368 
00371   vtkSetMacro(Legend, int);
00372   vtkGetMacro(Legend, int);
00373   vtkBooleanMacro(Legend, int);
00375 
00377 
00383   vtkSetVector2Macro(LegendPosition,double);
00384   vtkGetVector2Macro(LegendPosition,double);
00385   vtkSetVector2Macro(LegendPosition2,double);
00386   vtkGetVector2Macro(LegendPosition2,double);
00388   
00390 
00391   virtual void SetTitleTextProperty(vtkTextProperty *p);
00392   vtkGetObjectMacro(TitleTextProperty,vtkTextProperty);
00394   
00396 
00398   virtual void SetAxisTitleTextProperty(vtkTextProperty *p);
00399   vtkGetObjectMacro(AxisTitleTextProperty,vtkTextProperty);
00401   
00403 
00405   virtual void SetAxisLabelTextProperty(vtkTextProperty *p);
00406   vtkGetObjectMacro(AxisLabelTextProperty,vtkTextProperty);
00408       
00410 
00411   vtkSetMacro(Logx, int);
00412   vtkGetMacro(Logx, int);
00413   vtkBooleanMacro(Logx, int);
00415 
00417 
00418   virtual void SetLabelFormat (const char* _arg);
00419   vtkGetStringMacro(LabelFormat);
00421 
00423 
00425   vtkSetClampMacro(Border, int, 0, 50);
00426   vtkGetMacro(Border, int);
00428 
00430 
00433   vtkGetMacro(PlotPoints, int);
00434   vtkSetMacro(PlotPoints, int);
00435   vtkBooleanMacro(PlotPoints, int);
00437 
00439 
00441   vtkGetMacro(PlotLines, int);
00442   vtkSetMacro(PlotLines, int);
00443   vtkBooleanMacro(PlotLines, int);
00445   
00447 
00450   vtkSetClampMacro(GlyphSize, double, 0.0, 0.2);
00451   vtkGetMacro(GlyphSize, double);
00453 
00456   void ViewportToPlotCoordinate(vtkViewport *viewport, double &u, double &v);
00457 
00459 
00462   void ViewportToPlotCoordinate(vtkViewport *viewport);
00463   vtkSetVector2Macro(PlotCoordinate,double);
00464   vtkGetVector2Macro(PlotCoordinate,double);
00466 
00468   void PlotToViewportCoordinate(vtkViewport *viewport, double &u, double &v);
00469 
00471 
00475   void PlotToViewportCoordinate(vtkViewport *viewport);
00476   vtkSetVector2Macro(ViewportCoordinate,double);
00477   vtkGetVector2Macro(ViewportCoordinate,double);
00479 
00482   int IsInPlot(vtkViewport *viewport, double u, double v);
00483   
00485   unsigned long GetMTime();
00486   
00487 //BTX  
00489 
00491   int RenderOpaqueGeometry(vtkViewport*);
00492   int RenderOverlay(vtkViewport*);
00493   int RenderTranslucentGeometry(vtkViewport *) {return 0;}
00495 
00499   void ReleaseGraphicsResources(vtkWindow *);
00500 //ETX  
00501 
00502 protected:
00503   vtkXYPlotActor();
00504   ~vtkXYPlotActor();
00505 
00506   vtkDataSetCollection *InputList; //list of data sets to plot
00507   char** SelectedInputScalars; // list of data set arrays to plot
00508   vtkIntArray* SelectedInputScalarsComponent; // list of componenents
00509   vtkDataObjectCollection *DataObjectInputList; //list of data objects to plot
00510   char  *Title;
00511   char  *XTitle;
00512   char  *YTitle;
00513   int   XValues;
00514   int   NumberOfXLabels;
00515   int   NumberOfYLabels;
00516   int   Logx;
00517   char  *LabelFormat;
00518   double XRange[2];
00519   double YRange[2];
00520   double XComputedRange[2];  //range actually used by plot
00521   double YComputedRange[2];  //range actually used by plot
00522   int Border;
00523   int PlotLines;
00524   int PlotPoints;
00525   int PlotCurveLines;
00526   int PlotCurvePoints;
00527   int ExchangeAxes;
00528   int ReverseXAxis;
00529   int ReverseYAxis;
00530   
00531   vtkTextMapper   *TitleMapper;
00532   vtkActor2D      *TitleActor;
00533   vtkTextProperty *TitleTextProperty;
00534 
00535   vtkAxisActor2D      *XAxis;
00536   vtkAxisActor2D      *YAxis;
00537 
00538   vtkTextProperty *AxisTitleTextProperty;
00539   vtkTextProperty *AxisLabelTextProperty;
00540 
00541   double ViewportCoordinate[2];
00542   double PlotCoordinate[2];
00543   
00544   //Handle data objects and datasets
00545   int DataObjectPlotMode;
00546   vtkIntArray *XComponent;
00547   vtkIntArray *YComponent;
00548   vtkIntArray *LinesOn;
00549   vtkIntArray *PointsOn;
00550 
00551   //The data drawn within the axes. Each curve is one polydata.
00552   //color is controlled by scalar data. The curves are appended
00553   //together, possibly glyphed with point symbols.
00554   int NumberOfInputs;
00555   vtkPolyData             **PlotData; 
00556   vtkGlyph2D              **PlotGlyph;
00557   vtkAppendPolyData       **PlotAppend;
00558   vtkPolyDataMapper2D     **PlotMapper;
00559   vtkActor2D              **PlotActor;
00560   void                    InitializeEntries();
00561   
00562   // Legends and plot symbols. The legend also keeps track of
00563   // the symbols and such.
00564   int Legend;
00565   double LegendPosition[2];
00566   double LegendPosition2[2];
00567   vtkLegendBoxActor *LegendActor;
00568   vtkGlyphSource2D *GlyphSource;
00569   vtkPlanes *ClipPlanes;
00570   double GlyphSize;
00571 
00572   // Keep track of changes.
00573   int CachedSize[2];
00574   vtkTimeStamp  BuildTime;
00575 
00576   void ComputeXRange(double range[2], double *lengths);
00577   void ComputeYRange(double range[2]);
00578   void ComputeDORange(double xrange[2], double yrange[2], double *lengths);
00579 
00580   virtual void CreatePlotData(int *pos, int *pos2, double xRange[2], 
00581                               double yRange[2], double *norms, 
00582                               int numDS, int numDO);
00583   void PlaceAxes(vtkViewport *viewport, int *size, int pos[2], int pos2[2]);
00584   void GenerateClipPlanes(int *pos, int *pos2);
00585   double ComputeGlyphScale(int i, int *pos, int *pos2);
00586   void ClipPlotData(int *pos, int *pos2, vtkPolyData *pd);
00587   double *TransformPoint(int pos[2], int pos2[2], double x[3], double xNew[3]);
00588   
00589 private:
00590   vtkXYPlotActor(const vtkXYPlotActor&);  // Not implemented.
00591   void operator=(const vtkXYPlotActor&);  // Not implemented.
00592 };
00593 
00594 
00595 #endif
00596