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-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 =========================================================================*/
00107 #ifndef __vtkXYPlotActor_h
00108 #define __vtkXYPlotActor_h
00109 
00110 #define VTK_XYPLOT_INDEX                 0
00111 #define VTK_XYPLOT_ARC_LENGTH            1
00112 #define VTK_XYPLOT_NORMALIZED_ARC_LENGTH 2
00113 #define VTK_XYPLOT_VALUE                 3
00114 
00115 #define VTK_XYPLOT_ROW 0
00116 #define VTK_XYPLOT_COLUMN 1
00117 
00118 #include "vtkAxisActor2D.h"
00119 class vtkDataSetCollection;
00120 class vtkDataObjectCollection;
00121 class vtkGlyphSource2D;
00122 class vtkGlyph2D;
00123 class vtkLegendBoxActor;
00124 class vtkAppendPolyData;
00125 class vtkPlanes;
00126 class vtkIntArray;
00127 
00128 class VTK_HYBRID_EXPORT vtkXYPlotActor : public vtkActor2D
00129 {
00130 public:
00131   vtkTypeMacro(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   void AddInput(vtkDataSet *in);
00147 
00149   void RemoveInput(vtkDataSet *in);
00150 
00152   vtkDataSetCollection *GetInputList() {return this->InputList;}
00153 
00155 
00158   void SetPointComponent(int i, int comp);
00159   int GetPointComponent(int i);
00160   //---end Data Set Input-----------------------------------------------------
00162 
00164   /*! Specify how the independent (x) variable is computed from the points.
00165       The independent variable can be the scalar/point index (i.e., point
00166       id), the accumulated arc length along the points, the normalized arc
00167       length, or by component value. If plotting datasets (e.g., points),
00168       the value that is used is specified by the PointComponent ivar. 
00169       (Note: these methods also control how field data is plotted. Field
00170       data is usually plotted by value or index, if plotting length
00171       1-dimensional length measures are used.) */
00172   vtkSetClampMacro(XValues,int,VTK_XYPLOT_INDEX,VTK_XYPLOT_VALUE);
00173   vtkGetMacro(XValues,int);
00174   void SetXValuesToIndex(){this->SetXValues(VTK_XYPLOT_INDEX);};
00175   void SetXValuesToArcLength() {this->SetXValues(VTK_XYPLOT_ARC_LENGTH);};
00176   void SetXValuesToNormalizedArcLength()
00177     {this->SetXValues(VTK_XYPLOT_NORMALIZED_ARC_LENGTH);};
00178   void SetXValuesToValue() {this->SetXValues(VTK_XYPLOT_VALUE);};
00179   const char *GetXValuesAsString();
00181 
00182   //---Data Object Input------------------------------------------------------
00183   // The following methods are used to plot input data objects. Datasets will
00184   // be plotted in preference to data objects if set as input; otherwise the
00185   // input data objects will be plotted (if defined).
00186   
00188   void AddDataObjectInput(vtkDataObject *in);
00189 
00191   void RemoveDataObjectInput(vtkDataObject *in);
00192 
00194 
00195   vtkDataObjectCollection *GetDataObjectInputList() 
00196     {return this->DataObjectInputList;}
00198 
00200 
00202   vtkSetClampMacro(DataObjectPlotMode,int,VTK_XYPLOT_COLUMN,VTK_XYPLOT_ROW);
00203   vtkGetMacro(DataObjectPlotMode,int);
00204   void SetDataObjectPlotModeToRows()
00205     {this->SetDataObjectPlotMode(VTK_XYPLOT_ROW);}
00206   void SetDataObjectPlotModeToColumns()
00207     {this->SetDataObjectPlotMode(VTK_XYPLOT_COLUMN);}
00208   const char *GetDataObjectPlotModeAsString();
00210 
00212 
00218   void SetDataObjectXComponent(int i, int comp);
00219   int GetDataObjectXComponent(int i);
00221 
00223 
00229   void SetDataObjectYComponent(int i, int comp);
00230   int GetDataObjectYComponent(int i);
00231   //---end Data Object Input--------------------------------------------------
00233 
00234   //---Per Curve Properties---------------------------------------------------
00235   // The following methods are used to set properties on each curve that is
00236   // plotted. Each input dataset (or data object) results in one curve. The
00237   // methods that follow have an index i that corresponds to the input dataset
00238   // or data object. 
00239   void SetPlotColor(int i, float r, float g, float b);
00240   void SetPlotColor(int i, const float color[3]) {
00241     this->SetPlotColor(i, color[0], color[1], color[2]); };
00242   float *GetPlotColor(int i);
00243   void SetPlotSymbol(int i,vtkPolyData *input);
00244   vtkPolyData *GetPlotSymbol(int i);
00245   void SetPlotLabel(int i, const char *label);
00246   const char *GetPlotLabel(int i);
00247 
00248   // Allow per-curve specification of line and point rendering.  These override
00249   // global settings PlotPoints and PlotLines.  If not on, the default behavior
00250   // is governed by PlotPoints and PlotLines ivars.
00251   vtkGetMacro(PlotCurvePoints, int);
00252   vtkSetMacro(PlotCurvePoints, int);
00253   vtkBooleanMacro(PlotCurvePoints, int);
00254 
00255   vtkGetMacro(PlotCurveLines, int);
00256   vtkSetMacro(PlotCurveLines, int);
00257   vtkBooleanMacro(PlotCurveLines, int);
00258 
00259   void SetPlotLines(int i, int);
00260   int GetPlotLines(int i);
00261 
00262   void SetPlotPoints(int i, int);
00263   int GetPlotPoints(int i);
00264   //---end Per Curve Properties-----------------------------------------------
00265 
00267 
00269   vtkSetMacro(ExchangeAxes, int);
00270   vtkGetMacro(ExchangeAxes, int);
00271   vtkBooleanMacro(ExchangeAxes, int);
00273 
00275 
00279   vtkSetMacro(ReverseXAxis, int);
00280   vtkGetMacro(ReverseXAxis, int);
00281   vtkBooleanMacro(ReverseXAxis, int);
00283 
00285 
00289   vtkSetMacro(ReverseYAxis, int);
00290   vtkGetMacro(ReverseYAxis, int);
00291   vtkBooleanMacro(ReverseYAxis, int);
00293 
00295 
00299   vtkLegendBoxActor *GetLegendBoxActor()
00300     {return this->LegendActor;}
00301   vtkGlyphSource2D *GetGlyphSource()
00302     {return this->GlyphSource;}
00304 
00306 
00308   vtkSetStringMacro(Title);
00309   vtkGetStringMacro(Title);
00310   vtkSetStringMacro(XTitle);
00311   vtkGetStringMacro(XTitle);
00312   vtkSetStringMacro(YTitle);
00313   vtkGetStringMacro(YTitle);
00315 
00317 
00323   vtkSetVector2Macro(XRange,float);
00324   vtkGetVectorMacro(XRange,float,2);
00325   vtkSetVector2Macro(YRange,float);
00326   vtkGetVectorMacro(YRange,float,2);
00327   void SetPlotRange(float xmin, float ymin, float xmax, float ymax)
00328     {this->SetXRange(xmin,xmax); this->SetYRange(ymin,ymax);}
00330   
00332 
00337   vtkSetClampMacro(NumberOfXLabels, int, 0, 50);
00338   vtkGetMacro(NumberOfXLabels, int);
00339   vtkSetClampMacro(NumberOfYLabels, int, 0, 50);
00340   vtkGetMacro(NumberOfYLabels, int);
00341   void SetNumberOfLabels(int num)
00342     {this->SetNumberOfXLabels(num); this->SetNumberOfYLabels(num);}
00344   
00346 
00349   vtkSetMacro(Legend, int);
00350   vtkGetMacro(Legend, int);
00351   vtkBooleanMacro(Legend, int);
00353 
00355 
00361   vtkSetVector2Macro(LegendPosition,float);
00362   vtkGetVector2Macro(LegendPosition,float);
00363   vtkSetVector2Macro(LegendPosition2,float);
00364   vtkGetVector2Macro(LegendPosition2,float);
00366   
00368 
00369   vtkSetMacro(Bold, int);
00370   vtkGetMacro(Bold, int);
00371   vtkBooleanMacro(Bold, int);
00373 
00375 
00376   vtkSetMacro(Italic, int);
00377   vtkGetMacro(Italic, int);
00378   vtkBooleanMacro(Italic, int);
00380 
00382 
00384   vtkSetMacro(Shadow, int);
00385   vtkGetMacro(Shadow, int);
00386   vtkBooleanMacro(Shadow, int);
00388 
00390 
00391   vtkSetMacro(Logx, int);
00392   vtkGetMacro(Logx, int);
00393   vtkBooleanMacro(Logx, int);
00395 
00397 
00400   vtkSetMacro(FontFamily, int);
00401   vtkGetMacro(FontFamily, int);
00402   void SetFontFamilyToArial() {this->SetFontFamily(VTK_ARIAL);};
00403   void SetFontFamilyToCourier() {this->SetFontFamily(VTK_COURIER);};
00404   void SetFontFamilyToTimes() {this->SetFontFamily(VTK_TIMES);};
00406 
00408 
00409   vtkSetStringMacro(LabelFormat);
00410   vtkGetStringMacro(LabelFormat);
00412 
00414 
00416   vtkSetClampMacro(Border, int, 0, 50);
00417   vtkGetMacro(Border, int);
00419 
00421 
00424   vtkGetMacro(PlotPoints, int);
00425   vtkSetMacro(PlotPoints, int);
00426   vtkBooleanMacro(PlotPoints, int);
00428 
00430 
00432   vtkGetMacro(PlotLines, int);
00433   vtkSetMacro(PlotLines, int);
00434   vtkBooleanMacro(PlotLines, int);
00436   
00438 
00441   vtkSetClampMacro(GlyphSize, float, 0.0, 0.2);
00442   vtkGetMacro(GlyphSize, float);
00444 
00447   void ViewportToPlotCoordinate(vtkViewport *viewport, float &u, float &v);
00448 
00450 
00453   void ViewportToPlotCoordinate(vtkViewport *viewport);
00454   vtkSetVector2Macro(PlotCoordinate,float);
00455   vtkGetVector2Macro(PlotCoordinate,float);
00457 
00459   void PlotToViewportCoordinate(vtkViewport *viewport, float &u, float &v);
00460 
00462 
00466   void PlotToViewportCoordinate(vtkViewport *viewport);
00467   vtkSetVector2Macro(ViewportCoordinate,float);
00468   vtkGetVector2Macro(ViewportCoordinate,float);
00470 
00473   int IsInPlot(vtkViewport *viewport, float u, float v);
00474   
00476   unsigned long GetMTime();
00477   
00478 //BTX  
00480   /*! WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE DO NOT USE
00481       THIS METHOD OUTSIDE OF THE RENDERING PROCESS. Draw the x-y plot. */
00482   int RenderOpaqueGeometry(vtkViewport*);
00483   int RenderOverlay(vtkViewport*);
00484   int RenderTranslucentGeometry(vtkViewport *) {return 0;}
00486 
00490   void ReleaseGraphicsResources(vtkWindow *);
00491 //ETX  
00492 
00493 protected:
00494   vtkXYPlotActor();
00495   ~vtkXYPlotActor();
00496 
00497   vtkDataSetCollection *InputList; //list of data sets to plot
00498   vtkDataObjectCollection *DataObjectInputList; //list of data objects to plot
00499   char  *Title;
00500   char  *XTitle;
00501   char  *YTitle;
00502   int   XValues;
00503   int   NumberOfXLabels;
00504   int   NumberOfYLabels;
00505   int   Bold;
00506   int   Italic;
00507   int   Shadow;
00508   int   FontFamily;
00509   int   Logx;
00510   char  *LabelFormat;
00511   float XRange[2];
00512   float YRange[2];
00513   float XComputedRange[2];  //range actually used by plot
00514   float YComputedRange[2];  //range actually used by plot
00515   int Border;
00516   int PlotLines;
00517   int PlotPoints;
00518   int PlotCurveLines;
00519   int PlotCurvePoints;
00520   int ExchangeAxes;
00521   int ReverseXAxis;
00522   int ReverseYAxis;
00523   
00524   vtkTextMapper *TitleMapper;
00525   vtkActor2D    *TitleActor;
00526 
00527   vtkAxisActor2D      *XAxis;
00528   vtkAxisActor2D      *YAxis;
00529 
00530   float ViewportCoordinate[2];
00531   float PlotCoordinate[2];
00532   
00533   //Handle data objects and datasets
00534   int DataObjectPlotMode;
00535   vtkIntArray *XComponent;
00536   vtkIntArray *YComponent;
00537   vtkIntArray *LinesOn;
00538   vtkIntArray *PointsOn;
00539 
00540   //The data drawn within the axes. Each curve is one polydata.
00541   //color is controlled by scalar data. The curves are appended
00542   //together, possibly glyphed with point symbols.
00543   int NumberOfInputs;
00544   vtkPolyData             **PlotData; 
00545   vtkGlyph2D              **PlotGlyph;
00546   vtkAppendPolyData       **PlotAppend;
00547   vtkPolyDataMapper2D     **PlotMapper;
00548   vtkActor2D              **PlotActor;
00549   void                    InitializeEntries();
00550   
00551   // Legends and plot symbols. The legend also keeps track of
00552   // the symbols and such.
00553   int Legend;
00554   float LegendPosition[2];
00555   float LegendPosition2[2];
00556   vtkLegendBoxActor *LegendActor;
00557   vtkGlyphSource2D *GlyphSource;
00558   vtkPlanes *ClipPlanes;
00559   float GlyphSize;
00560 
00561   // Keep track of changes.
00562   int CachedSize[2];
00563   vtkTimeStamp  BuildTime;
00564 
00565   void ComputeXRange(float range[2], float *lengths);
00566   void ComputeYRange(float range[2]);
00567   void ComputeDORange(float xrange[2], float yrange[2], float *lengths);
00568 
00569   virtual void CreatePlotData(int *pos, int *pos2, float xRange[2], 
00570                               float yRange[2], float *norms, 
00571                               int numDS, int numDO);
00572   void PlaceAxes(vtkViewport *viewport, int *size, int pos[2], int pos2[2]);
00573   void GenerateClipPlanes(int *pos, int *pos2);
00574   float ComputeGlyphScale(int i, int *pos, int *pos2);
00575   void ClipPlotData(int *pos, int *pos2, vtkPolyData *pd);
00576   float *TransformPoint(int pos[2], int pos2[2], float x[3], float xNew[3]);
00577   
00578 private:
00579   vtkXYPlotActor(const vtkXYPlotActor&);  // Not implemented.
00580   void operator=(const vtkXYPlotActor&);  // Not implemented.
00581 };
00582 
00583 
00584 #endif
00585 

Generated on Thu Mar 28 14:19:24 2002 for VTK by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001