Hybrid/vtkXYPlotActor.h Source File

Main Page Class Hierarchy Alphabetical List Compound List File List Compound 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   Language:  C++
    00006
    00007   Copyright (c) 1993-2002 Ken Martin, Will Schroeder, Bill Lorensen
    00008   All rights reserved.
    00009   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
    00010
    00011      This software is distributed WITHOUT ANY WARRANTY; without even
    00012      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
    00013      PURPOSE.  See the above copyright notice for more information.
    00014
    00015 =========================================================================*/
    00103 #ifndef __vtkXYPlotActor_h
    00104 #define __vtkXYPlotActor_h
    00105
    00106 #define VTK_XYPLOT_INDEX                 0
    00107 #define VTK_XYPLOT_ARC_LENGTH            1
    00108 #define VTK_XYPLOT_NORMALIZED_ARC_LENGTH 2
    00109 #define VTK_XYPLOT_VALUE                 3
    00110
    00111 #define VTK_XYPLOT_ROW 0
    00112 #define VTK_XYPLOT_COLUMN 1
    00113
    00114 #include "vtkActor2D.h"
    00115
    00116 class vtkAppendPolyData;
    00117 class vtkAxisActor2D;
    00118 class vtkDataObject;
    00119 class vtkDataObjectCollection;
    00120 class vtkDataSet;
    00121 class vtkDataSetCollection;
    00122 class vtkGlyph2D;
    00123 class vtkGlyphSource2D;
    00124 class vtkIntArray;
    00125 class vtkLegendBoxActor;
    00126 class vtkPlanes;
    00127 class vtkPolyData;
    00128 class vtkPolyDataMapper2D;
    00129 class vtkTextMapper;
    00130 class vtkTextProperty;
    00131
    00132 class VTK_HYBRID_EXPORT vtkXYPlotActor : public vtkActor2D
    00133 {
    00134 public:
    00135   vtkTypeRevisionMacro(vtkXYPlotActor,vtkActor2D);
    00136   void PrintSelf(ostream& os, vtkIndent indent);
    00137
    00142   static vtkXYPlotActor *New();
    00143
    00144   //---Data Set Input----------------------------------------------------------
    00145   // The following methods are used to plot input datasets. Datasets
    00146   // will be plotted if set as input; otherwise the input data objects
    00147   // will be plotted (if defined).
    00148
    00150
    00154   void AddInput(vtkDataSet *in, const char* arrayName, int component);
    00155   void AddInput(vtkDataSet *in) {this->AddInput(in, NULL, 0);}
    00157
    00159
    00160   void RemoveInput(vtkDataSet *in, const char* arrayName, int component);
    00161   void RemoveInput(vtkDataSet *in) {this->RemoveInput(in, NULL, 0);}
    00163
    00166   void RemoveAllInputs();
    00167
    00169   vtkDataSetCollection *GetInputList() {return this->InputList;}
    00170
    00172
    00175   void SetPointComponent(int i, int comp);
    00176   int GetPointComponent(int i);
    00177   //---end Data Set Input-----------------------------------------------------
    00179
    00181   /*! Specify how the independent (x) variable is computed from the points.
    00182       The independent variable can be the scalar/point index (i.e., point
    00183       id), the accumulated arc length along the points, the normalized arc
    00184       length, or by component value. If plotting datasets (e.g., points),
    00185       the value that is used is specified by the PointComponent ivar.
    00186       (Note: these methods also control how field data is plotted. Field
    00187       data is usually plotted by value or index, if plotting length
    00188       1-dimensional length measures are used.) */
    00189   vtkSetClampMacro(XValues,int,VTK_XYPLOT_INDEX,VTK_XYPLOT_VALUE);
    00190   vtkGetMacro(XValues,int);
    00191   void SetXValuesToIndex(){this->SetXValues(VTK_XYPLOT_INDEX);};
    00192   void SetXValuesToArcLength() {this->SetXValues(VTK_XYPLOT_ARC_LENGTH);};
    00193   void SetXValuesToNormalizedArcLength()
    00194     {this->SetXValues(VTK_XYPLOT_NORMALIZED_ARC_LENGTH);};
    00195   void SetXValuesToValue() {this->SetXValues(VTK_XYPLOT_VALUE);};
    00196   const char *GetXValuesAsString();
    00198
    00199   //---Data Object Input------------------------------------------------------
    00200   // The following methods are used to plot input data objects. Datasets will
    00201   // be plotted in preference to data objects if set as input; otherwise the
    00202   // input data objects will be plotted (if defined).
    00203
    00205   void AddDataObjectInput(vtkDataObject *in);
    00206
    00208   void RemoveDataObjectInput(vtkDataObject *in);
    00209
    00211
    00212   vtkDataObjectCollection *GetDataObjectInputList()
    00213     {return this->DataObjectInputList;}
    00215
    00217
    00219   vtkSetClampMacro(DataObjectPlotMode,int,VTK_XYPLOT_COLUMN,VTK_XYPLOT_ROW);
    00220   vtkGetMacro(DataObjectPlotMode,int);
    00221   void SetDataObjectPlotModeToRows()
    00222     {this->SetDataObjectPlotMode(VTK_XYPLOT_ROW);}
    00223   void SetDataObjectPlotModeToColumns()
    00224     {this->SetDataObjectPlotMode(VTK_XYPLOT_COLUMN);}
    00225   const char *GetDataObjectPlotModeAsString();
    00227
    00229
    00235   void SetDataObjectXComponent(int i, int comp);
    00236   int GetDataObjectXComponent(int i);
    00238
    00240
    00246   void SetDataObjectYComponent(int i, int comp);
    00247   int GetDataObjectYComponent(int i);
    00248   //---end Data Object Input--------------------------------------------------
    00250
    00251   //---Per Curve Properties---------------------------------------------------
    00252   // The following methods are used to set properties on each curve that is
    00253   // plotted. Each input dataset (or data object) results in one curve. The
    00254   // methods that follow have an index i that corresponds to the input dataset
    00255   // or data object.
    00256   void SetPlotColor(int i, float r, float g, float b);
    00257   void SetPlotColor(int i, const float color[3]) {
    00258     this->SetPlotColor(i, color[0], color[1], color[2]); };
    00259   float *GetPlotColor(int i);
    00260   void SetPlotSymbol(int i,vtkPolyData *input);
    00261   vtkPolyData *GetPlotSymbol(int i);
    00262   void SetPlotLabel(int i, const char *label);
    00263   const char *GetPlotLabel(int i);
    00264
    00265   // Allow per-curve specification of line and point rendering.  These override
    00266   // global settings PlotPoints and PlotLines.  If not on, the default behavior
    00267   // is governed by PlotPoints and PlotLines ivars.
    00268   vtkGetMacro(PlotCurvePoints, int);
    00269   vtkSetMacro(PlotCurvePoints, int);
    00270   vtkBooleanMacro(PlotCurvePoints, int);
    00271
    00272   vtkGetMacro(PlotCurveLines, int);
    00273   vtkSetMacro(PlotCurveLines, int);
    00274   vtkBooleanMacro(PlotCurveLines, int);
    00275
    00276   void SetPlotLines(int i, int);
    00277   int GetPlotLines(int i);
    00278
    00279   void SetPlotPoints(int i, int);
    00280   int GetPlotPoints(int i);
    00281   //---end Per Curve Properties-----------------------------------------------
    00282
    00284
    00286   vtkSetMacro(ExchangeAxes, int);
    00287   vtkGetMacro(ExchangeAxes, int);
    00288   vtkBooleanMacro(ExchangeAxes, int);
    00290
    00292
    00296   vtkSetMacro(ReverseXAxis, int);
    00297   vtkGetMacro(ReverseXAxis, int);
    00298   vtkBooleanMacro(ReverseXAxis, int);
    00300
    00302
    00306   vtkSetMacro(ReverseYAxis, int);
    00307   vtkGetMacro(ReverseYAxis, int);
    00308   vtkBooleanMacro(ReverseYAxis, int);
    00310
    00312
    00316   vtkLegendBoxActor *GetLegendBoxActor()
    00317     {return this->LegendActor;}
    00318   vtkGlyphSource2D *GetGlyphSource()
    00319     {return this->GlyphSource;}
    00321
    00323
    00325   vtkSetStringMacro(Title);
    00326   vtkGetStringMacro(Title);
    00327   vtkSetStringMacro(XTitle);
    00328   vtkGetStringMacro(XTitle);
    00329   vtkSetStringMacro(YTitle);
    00330   vtkGetStringMacro(YTitle);
    00332
    00334
    00336   vtkAxisActor2D *GetXAxisActor2D()
    00337     {return this->XAxis;}
    00338   vtkAxisActor2D *GetYAxisActor2D()
    00339     {return this->YAxis;}
    00341
    00343
    00349   vtkSetVector2Macro(XRange,float);
    00350   vtkGetVectorMacro(XRange,float,2);
    00351   vtkSetVector2Macro(YRange,float);
    00352   vtkGetVectorMacro(YRange,float,2);
    00353   void SetPlotRange(float xmin, float ymin, float xmax, float ymax)
    00354     {this->SetXRange(xmin,xmax); this->SetYRange(ymin,ymax);}
    00356
    00358
    00363   vtkSetClampMacro(NumberOfXLabels, int, 0, 50);
    00364   vtkGetMacro(NumberOfXLabels, int);
    00365   vtkSetClampMacro(NumberOfYLabels, int, 0, 50);
    00366   vtkGetMacro(NumberOfYLabels, int);
    00367   void SetNumberOfLabels(int num)
    00368     {this->SetNumberOfXLabels(num); this->SetNumberOfYLabels(num);}
    00370
    00372
    00375   vtkSetMacro(Legend, int);
    00376   vtkGetMacro(Legend, int);
    00377   vtkBooleanMacro(Legend, int);
    00379
    00381
    00387   vtkSetVector2Macro(LegendPosition,float);
    00388   vtkGetVector2Macro(LegendPosition,float);
    00389   vtkSetVector2Macro(LegendPosition2,float);
    00390   vtkGetVector2Macro(LegendPosition2,float);
    00392
    00394
    00395   virtual void SetTitleTextProperty(vtkTextProperty *p);
    00396   vtkGetObjectMacro(TitleTextProperty,vtkTextProperty);
    00398
    00400
    00402   virtual void SetAxisTitleTextProperty(vtkTextProperty *p);
    00403   vtkGetObjectMacro(AxisTitleTextProperty,vtkTextProperty);
    00405
    00407
    00409   virtual void SetAxisLabelTextProperty(vtkTextProperty *p);
    00410   vtkGetObjectMacro(AxisLabelTextProperty,vtkTextProperty);
    00412
    00413 #ifndef VTK_REMOVE_LEGACY_CODE
    00414
    00415
    00419   virtual void SetFontFamily(int val);
    00420   virtual int GetFontFamily();
    00421   void SetFontFamilyToArial()   { this->SetFontFamily(VTK_ARIAL);  };
    00422   void SetFontFamilyToCourier() { this->SetFontFamily(VTK_COURIER);};
    00423   void SetFontFamilyToTimes()   { this->SetFontFamily(VTK_TIMES);  };
    00425 #endif
    00426
    00427 #ifndef VTK_REMOVE_LEGACY_CODE
    00428
    00429
    00432   virtual void SetBold(int val);
    00433   virtual int GetBold();
    00434   vtkBooleanMacro(Bold, int);
    00436 #endif
    00437
    00438 #ifndef VTK_REMOVE_LEGACY_CODE
    00439
    00440
    00443   virtual void SetItalic(int val);
    00444   virtual int GetItalic();
    00445   vtkBooleanMacro(Italic, int);
    00447 #endif
    00448
    00449 #ifndef VTK_REMOVE_LEGACY_CODE
    00450
    00451
    00454   virtual void SetShadow(int val);
    00455   virtual int GetShadow();
    00456   vtkBooleanMacro(Shadow, int);
    00458 #endif
    00459
    00461
    00462   vtkSetMacro(Logx, int);
    00463   vtkGetMacro(Logx, int);
    00464   vtkBooleanMacro(Logx, int);
    00466
    00468
    00469   virtual void SetLabelFormat (const char* _arg);
    00470   vtkGetStringMacro(LabelFormat);
    00472
    00474
    00476   vtkSetClampMacro(Border, int, 0, 50);
    00477   vtkGetMacro(Border, int);
    00479
    00481
    00484   vtkGetMacro(PlotPoints, int);
    00485   vtkSetMacro(PlotPoints, int);
    00486   vtkBooleanMacro(PlotPoints, int);
    00488
    00490
    00492   vtkGetMacro(PlotLines, int);
    00493   vtkSetMacro(PlotLines, int);
    00494   vtkBooleanMacro(PlotLines, int);
    00496
    00498
    00501   vtkSetClampMacro(GlyphSize, float, 0.0, 0.2);
    00502   vtkGetMacro(GlyphSize, float);
    00504
    00507   void ViewportToPlotCoordinate(vtkViewport *viewport, float &u, float &v);
    00508
    00510
    00513   void ViewportToPlotCoordinate(vtkViewport *viewport);
    00514   vtkSetVector2Macro(PlotCoordinate,float);
    00515   vtkGetVector2Macro(PlotCoordinate,float);
    00517
    00519   void PlotToViewportCoordinate(vtkViewport *viewport, float &u, float &v);
    00520
    00522
    00526   void PlotToViewportCoordinate(vtkViewport *viewport);
    00527   vtkSetVector2Macro(ViewportCoordinate,float);
    00528   vtkGetVector2Macro(ViewportCoordinate,float);
    00530
    00533   int IsInPlot(vtkViewport *viewport, float u, float v);
    00534
    00536   unsigned long GetMTime();
    00537
    00538 //BTX
    00540   /*! WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE DO NOT USE
    00541       THIS METHOD OUTSIDE OF THE RENDERING PROCESS. Draw the x-y plot. */
    00542   int RenderOpaqueGeometry(vtkViewport*);
    00543   int RenderOverlay(vtkViewport*);
    00544   int RenderTranslucentGeometry(vtkViewport *) {return 0;}
    00546
    00550   void ReleaseGraphicsResources(vtkWindow *);
    00551 //ETX
    00552
    00553 protected:
    00554   vtkXYPlotActor();
    00555   ~vtkXYPlotActor();
    00556
    00557   vtkDataSetCollection *InputList; //list of data sets to plot
    00558   char** SelectedInputScalars; // list of data set arrays to plot
    00559   vtkIntArray* SelectedInputScalarsComponent; // list of componenents
    00560   vtkDataObjectCollection *DataObjectInputList; //list of data objects to plot
    00561   char  *Title;
    00562   char  *XTitle;
    00563   char  *YTitle;
    00564   int   XValues;
    00565   int   NumberOfXLabels;
    00566   int   NumberOfYLabels;
    00567   int   Logx;
    00568   char  *LabelFormat;
    00569   float XRange[2];
    00570   float YRange[2];
    00571   float XComputedRange[2];  //range actually used by plot
    00572   float YComputedRange[2];  //range actually used by plot
    00573   int Border;
    00574   int PlotLines;
    00575   int PlotPoints;
    00576   int PlotCurveLines;
    00577   int PlotCurvePoints;
    00578   int ExchangeAxes;
    00579   int ReverseXAxis;
    00580   int ReverseYAxis;
    00581
    00582   vtkTextMapper   *TitleMapper;
    00583   vtkActor2D      *TitleActor;
    00584   vtkTextProperty *TitleTextProperty;
    00585
    00586   vtkAxisActor2D      *XAxis;
    00587   vtkAxisActor2D      *YAxis;
    00588
    00589   vtkTextProperty *AxisTitleTextProperty;
    00590   vtkTextProperty *AxisLabelTextProperty;
    00591
    00592   float ViewportCoordinate[2];
    00593   float PlotCoordinate[2];
    00594
    00595   //Handle data objects and datasets
    00596   int DataObjectPlotMode;
    00597   vtkIntArray *XComponent;
    00598   vtkIntArray *YComponent;
    00599   vtkIntArray *LinesOn;
    00600   vtkIntArray *PointsOn;
    00601
    00602   //The data drawn within the axes. Each curve is one polydata.
    00603   //color is controlled by scalar data. The curves are appended
    00604   //together, possibly glyphed with point symbols.
    00605   int NumberOfInputs;
    00606   vtkPolyData             **PlotData;
    00607   vtkGlyph2D              **PlotGlyph;
    00608   vtkAppendPolyData       **PlotAppend;
    00609   vtkPolyDataMapper2D     **PlotMapper;
    00610   vtkActor2D              **PlotActor;
    00611   void                    InitializeEntries();
    00612
    00613   // Legends and plot symbols. The legend also keeps track of
    00614   // the symbols and such.
    00615   int Legend;
    00616   float LegendPosition[2];
    00617   float LegendPosition2[2];
    00618   vtkLegendBoxActor *LegendActor;
    00619   vtkGlyphSource2D *GlyphSource;
    00620   vtkPlanes *ClipPlanes;
    00621   float GlyphSize;
    00622
    00623   // Keep track of changes.
    00624   int CachedSize[2];
    00625   vtkTimeStamp  BuildTime;
    00626
    00627   void ComputeXRange(float range[2], float *lengths);
    00628   void ComputeYRange(float range[2]);
    00629   void ComputeDORange(float xrange[2], float yrange[2], float *lengths);
    00630
    00631   virtual void CreatePlotData(int *pos, int *pos2, float xRange[2],
    00632                               float yRange[2], float *norms,
    00633                               int numDS, int numDO);
    00634   void PlaceAxes(vtkViewport *viewport, int *size, int pos[2], int pos2[2]);
    00635   void GenerateClipPlanes(int *pos, int *pos2);
    00636   float ComputeGlyphScale(int i, int *pos, int *pos2);
    00637   void ClipPlotData(int *pos, int *pos2, vtkPolyData *pd);
    00638   float *TransformPoint(int pos[2], int pos2[2], float x[3], float xNew[3]);
    00639
    00640 private:
    00641   vtkXYPlotActor(const vtkXYPlotActor&);  // Not implemented.
    00642   void operator=(const vtkXYPlotActor&);  // Not implemented.
    00643 };
    00644
    00645
    00646 #endif
    00647