VTK
|
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 =========================================================================*/ 00084 #ifndef __vtkXYPlotActor_h 00085 #define __vtkXYPlotActor_h 00086 00087 #define VTK_XYPLOT_INDEX 0 00088 #define VTK_XYPLOT_ARC_LENGTH 1 00089 #define VTK_XYPLOT_NORMALIZED_ARC_LENGTH 2 00090 #define VTK_XYPLOT_VALUE 3 00091 00092 #define VTK_XYPLOT_ROW 0 00093 #define VTK_XYPLOT_COLUMN 1 00094 00095 #include "vtkActor2D.h" 00096 00097 class vtkAppendPolyData; 00098 class vtkAxisActor2D; 00099 class vtkDataObject; 00100 class vtkDataObjectCollection; 00101 class vtkDataSet; 00102 class vtkDataSetCollection; 00103 class vtkGlyph2D; 00104 class vtkGlyphSource2D; 00105 class vtkIntArray; 00106 class vtkLegendBoxActor; 00107 class vtkPlanes; 00108 class vtkPolyData; 00109 class vtkPolyDataMapper2D; 00110 class vtkTextMapper; 00111 class vtkTextProperty; 00112 00113 class VTK_HYBRID_EXPORT vtkXYPlotActor : public vtkActor2D 00114 { 00115 public: 00116 vtkTypeRevisionMacro(vtkXYPlotActor,vtkActor2D); 00117 void PrintSelf(ostream& os, vtkIndent indent); 00118 00123 static vtkXYPlotActor *New(); 00124 00125 //---Data Set Input---------------------------------------------------------- 00126 // The following methods are used to plot input datasets. Datasets 00127 // will be plotted if set as input; otherwise the input data objects 00128 // will be plotted (if defined). 00129 00131 00136 void AddInput(vtkDataSet *in, const char* arrayName, int component); 00137 void AddInput(vtkDataSet *in) {this->AddInput(in, NULL, 0);} 00139 00141 00142 void RemoveInput(vtkDataSet *in, const char* arrayName, int component); 00143 void RemoveInput(vtkDataSet *in) {this->RemoveInput(in, NULL, 0);} 00145 00148 void RemoveAllInputs(); 00149 00151 vtkDataSetCollection *GetInputList() {return this->InputList;} 00152 00154 00157 void SetPointComponent(int i, int comp); 00158 int GetPointComponent(int i); 00159 //---end Data Set Input----------------------------------------------------- 00161 00163 00171 vtkSetClampMacro(XValues,int,VTK_XYPLOT_INDEX,VTK_XYPLOT_VALUE); 00172 vtkGetMacro(XValues,int); 00173 void SetXValuesToIndex(){this->SetXValues(VTK_XYPLOT_INDEX);}; 00174 void SetXValuesToArcLength() {this->SetXValues(VTK_XYPLOT_ARC_LENGTH);}; 00175 void SetXValuesToNormalizedArcLength() 00176 {this->SetXValues(VTK_XYPLOT_NORMALIZED_ARC_LENGTH);}; 00177 void SetXValuesToValue() {this->SetXValues(VTK_XYPLOT_VALUE);}; 00178 const char *GetXValuesAsString(); 00180 00181 //---Data Object Input------------------------------------------------------ 00182 // The following methods are used to plot input data objects. Datasets will 00183 // be plotted in preference to data objects if set as input; otherwise the 00184 // input data objects will be plotted (if defined). 00185 00187 void AddDataObjectInput(vtkDataObject *in); 00188 00190 void RemoveDataObjectInput(vtkDataObject *in); 00191 00193 00194 vtkDataObjectCollection *GetDataObjectInputList() 00195 {return this->DataObjectInputList;} 00197 00199 00201 vtkSetClampMacro(DataObjectPlotMode,int,VTK_XYPLOT_ROW,VTK_XYPLOT_COLUMN); 00202 vtkGetMacro(DataObjectPlotMode,int); 00203 void SetDataObjectPlotModeToRows() 00204 {this->SetDataObjectPlotMode(VTK_XYPLOT_ROW);} 00205 void SetDataObjectPlotModeToColumns() 00206 {this->SetDataObjectPlotMode(VTK_XYPLOT_COLUMN);} 00207 const char *GetDataObjectPlotModeAsString(); 00209 00211 00217 void SetDataObjectXComponent(int i, int comp); 00218 int GetDataObjectXComponent(int i); 00220 00222 00228 void SetDataObjectYComponent(int i, int comp); 00229 int GetDataObjectYComponent(int i); 00230 //---end Data Object Input-------------------------------------------------- 00232 00233 //---Per Curve Properties--------------------------------------------------- 00234 // The following methods are used to set properties on each curve that is 00235 // plotted. Each input dataset (or data object) results in one curve. The 00236 // methods that follow have an index i that corresponds to the input dataset 00237 // or data object. 00238 void SetPlotColor(int i, double r, double g, double b); 00239 void SetPlotColor(int i, const double color[3]) { 00240 this->SetPlotColor(i, color[0], color[1], color[2]); }; 00241 double *GetPlotColor(int i); 00242 void SetPlotSymbol(int i,vtkPolyData *input); 00243 vtkPolyData *GetPlotSymbol(int i); 00244 void SetPlotLabel(int i, const char *label); 00245 const char *GetPlotLabel(int i); 00246 00247 // Allow per-curve specification of line and point rendering. These override 00248 // global settings PlotPoints and PlotLines. If not on, the default behavior 00249 // is governed by PlotPoints and PlotLines ivars. 00250 vtkGetMacro(PlotCurvePoints, int); 00251 vtkSetMacro(PlotCurvePoints, int); 00252 vtkBooleanMacro(PlotCurvePoints, int); 00253 00254 vtkGetMacro(PlotCurveLines, int); 00255 vtkSetMacro(PlotCurveLines, int); 00256 vtkBooleanMacro(PlotCurveLines, int); 00257 00258 void SetPlotLines(int i, int); 00259 int GetPlotLines(int i); 00260 00261 void SetPlotPoints(int i, int); 00262 int GetPlotPoints(int i); 00263 //---end Per Curve Properties----------------------------------------------- 00264 00266 00268 vtkSetMacro(ExchangeAxes, int); 00269 vtkGetMacro(ExchangeAxes, int); 00270 vtkBooleanMacro(ExchangeAxes, int); 00272 00274 00278 vtkSetMacro(ReverseXAxis, int); 00279 vtkGetMacro(ReverseXAxis, int); 00280 vtkBooleanMacro(ReverseXAxis, int); 00282 00284 00288 vtkSetMacro(ReverseYAxis, int); 00289 vtkGetMacro(ReverseYAxis, int); 00290 vtkBooleanMacro(ReverseYAxis, int); 00292 00294 00298 vtkGetObjectMacro(LegendActor,vtkLegendBoxActor); 00299 vtkGetObjectMacro(GlyphSource,vtkGlyphSource2D); 00301 00303 00305 vtkSetStringMacro(Title); 00306 vtkGetStringMacro(Title); 00307 vtkSetStringMacro(XTitle); 00308 vtkGetStringMacro(XTitle); 00309 vtkSetStringMacro(YTitle); 00310 vtkGetStringMacro(YTitle); 00312 00314 00316 vtkAxisActor2D *GetXAxisActor2D() 00317 {return this->XAxis;} 00318 vtkAxisActor2D *GetYAxisActor2D() 00319 {return this->YAxis;} 00321 00323 00329 vtkSetVector2Macro(XRange,double); 00330 vtkGetVectorMacro(XRange,double,2); 00331 vtkSetVector2Macro(YRange,double); 00332 vtkGetVectorMacro(YRange,double,2); 00333 void SetPlotRange(double xmin, double ymin, double xmax, double ymax) 00334 {this->SetXRange(xmin,xmax); this->SetYRange(ymin,ymax);} 00336 00338 00343 vtkSetClampMacro(NumberOfXLabels, int, 0, 50); 00344 vtkGetMacro(NumberOfXLabels, int); 00345 vtkSetClampMacro(NumberOfYLabels, int, 0, 50); 00346 vtkGetMacro(NumberOfYLabels, int); 00347 void SetNumberOfLabels(int num) 00348 {this->SetNumberOfXLabels(num); this->SetNumberOfYLabels(num);} 00350 00352 00357 void SetAdjustXLabels(int adjust); 00358 vtkGetMacro( AdjustXLabels, int ); 00359 void SetAdjustYLabels(int adjust); 00360 vtkGetMacro( AdjustYLabels, int ); 00362 00364 00365 void SetXTitlePosition(double position); 00366 double GetXTitlePosition(); 00367 void SetYTitlePosition(double position); 00368 double GetYTitlePosition(); 00370 00372 00373 void SetNumberOfXMinorTicks(int num); 00374 int GetNumberOfXMinorTicks(); 00375 void SetNumberOfYMinorTicks(int num); 00376 int GetNumberOfYMinorTicks(); 00378 00380 00383 vtkSetMacro(Legend, int); 00384 vtkGetMacro(Legend, int); 00385 vtkBooleanMacro(Legend, int); 00387 00389 00391 vtkSetVector2Macro(TitlePosition,double); 00392 vtkGetVector2Macro(TitlePosition,double); 00394 00396 00398 vtkSetMacro(AdjustTitlePosition, int); 00399 vtkGetMacro(AdjustTitlePosition, int); 00400 vtkBooleanMacro(AdjustTitlePosition, int); 00402 00404 00410 vtkSetVector2Macro(LegendPosition,double); 00411 vtkGetVector2Macro(LegendPosition,double); 00412 vtkSetVector2Macro(LegendPosition2,double); 00413 vtkGetVector2Macro(LegendPosition2,double); 00415 00417 00418 virtual void SetTitleTextProperty(vtkTextProperty *p); 00419 vtkGetObjectMacro(TitleTextProperty,vtkTextProperty); 00421 00423 00425 virtual void SetAxisTitleTextProperty(vtkTextProperty *p); 00426 vtkGetObjectMacro(AxisTitleTextProperty,vtkTextProperty); 00428 00430 00432 virtual void SetAxisLabelTextProperty(vtkTextProperty *p); 00433 vtkGetObjectMacro(AxisLabelTextProperty,vtkTextProperty); 00435 00437 00438 vtkSetMacro(Logx, int); 00439 vtkGetMacro(Logx, int); 00440 vtkBooleanMacro(Logx, int); 00442 00444 00446 virtual void SetLabelFormat (const char* _arg); 00447 const char* GetLabelFormat() 00448 { 00449 return this->GetXLabelFormat(); 00450 } 00452 00454 00455 virtual void SetXLabelFormat (const char* _arg); 00456 vtkGetStringMacro(XLabelFormat); 00458 00460 00461 virtual void SetYLabelFormat (const char* _arg); 00462 vtkGetStringMacro(YLabelFormat); 00464 00466 00468 vtkSetClampMacro(Border, int, 0, 50); 00469 vtkGetMacro(Border, int); 00471 00473 00476 vtkGetMacro(PlotPoints, int); 00477 vtkSetMacro(PlotPoints, int); 00478 vtkBooleanMacro(PlotPoints, int); 00480 00482 00484 vtkGetMacro(PlotLines, int); 00485 vtkSetMacro(PlotLines, int); 00486 vtkBooleanMacro(PlotLines, int); 00488 00490 00493 vtkSetClampMacro(GlyphSize, double, 0.0, 0.2); 00494 vtkGetMacro(GlyphSize, double); 00496 00499 void ViewportToPlotCoordinate(vtkViewport *viewport, double &u, double &v); 00500 00502 00505 void ViewportToPlotCoordinate(vtkViewport *viewport); 00506 vtkSetVector2Macro(PlotCoordinate,double); 00507 vtkGetVector2Macro(PlotCoordinate,double); 00509 00511 void PlotToViewportCoordinate(vtkViewport *viewport, double &u, double &v); 00512 00514 00518 void PlotToViewportCoordinate(vtkViewport *viewport); 00519 vtkSetVector2Macro(ViewportCoordinate,double); 00520 vtkGetVector2Macro(ViewportCoordinate,double); 00522 00525 int IsInPlot(vtkViewport *viewport, double u, double v); 00526 00528 unsigned long GetMTime(); 00529 00532 void PrintAsCSV(ostream &os); 00533 00534 //BTX 00536 00538 int RenderOpaqueGeometry(vtkViewport*); 00539 int RenderOverlay(vtkViewport*); 00540 virtual int RenderTranslucentPolygonalGeometry(vtkViewport *) {return 0;} 00542 00544 virtual int HasTranslucentPolygonalGeometry(); 00545 00549 void ReleaseGraphicsResources(vtkWindow *); 00550 //ETX 00551 00552 protected: 00553 vtkXYPlotActor(); 00554 ~vtkXYPlotActor(); 00555 00556 vtkDataSetCollection *InputList; //list of data sets to plot 00557 char** SelectedInputScalars; // list of data set arrays to plot 00558 vtkIntArray* SelectedInputScalarsComponent; // list of componenents 00559 vtkDataObjectCollection *DataObjectInputList; //list of data objects to plot 00560 char *Title; 00561 char *XTitle; 00562 char *YTitle; 00563 int XValues; 00564 int NumberOfXLabels; 00565 int NumberOfYLabels; 00566 int Logx; 00567 char *XLabelFormat; 00568 char *YLabelFormat; 00569 double XRange[2]; 00570 double YRange[2]; 00571 double XComputedRange[2]; //range actually used by plot 00572 double 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 int AdjustXLabels; 00582 int AdjustYLabels; 00583 int AdjustTitlePosition; 00584 double TitlePosition[2]; 00585 00586 vtkTextMapper *TitleMapper; 00587 vtkActor2D *TitleActor; 00588 vtkTextProperty *TitleTextProperty; 00589 00590 vtkAxisActor2D *XAxis; 00591 vtkAxisActor2D *YAxis; 00592 00593 vtkTextProperty *AxisTitleTextProperty; 00594 vtkTextProperty *AxisLabelTextProperty; 00595 00596 double ViewportCoordinate[2]; 00597 double PlotCoordinate[2]; 00598 00599 //Handle data objects and datasets 00600 int DataObjectPlotMode; 00601 vtkIntArray *XComponent; 00602 vtkIntArray *YComponent; 00603 vtkIntArray *LinesOn; 00604 vtkIntArray *PointsOn; 00605 00606 //The data drawn within the axes. Each curve is one polydata. 00607 //color is controlled by scalar data. The curves are appended 00608 //together, possibly glyphed with point symbols. 00609 int NumberOfInputs; 00610 vtkPolyData **PlotData; 00611 vtkGlyph2D **PlotGlyph; 00612 vtkAppendPolyData **PlotAppend; 00613 vtkPolyDataMapper2D **PlotMapper; 00614 vtkActor2D **PlotActor; 00615 void InitializeEntries(); 00616 00617 // Legends and plot symbols. The legend also keeps track of 00618 // the symbols and such. 00619 int Legend; 00620 double LegendPosition[2]; 00621 double LegendPosition2[2]; 00622 vtkLegendBoxActor *LegendActor; 00623 vtkGlyphSource2D *GlyphSource; 00624 vtkPlanes *ClipPlanes; 00625 double GlyphSize; 00626 00627 // Keep track of changes. 00628 int CachedSize[2]; 00629 vtkTimeStamp BuildTime; 00630 00631 void ComputeXRange(double range[2], double *lengths); 00632 void ComputeYRange(double range[2]); 00633 void ComputeDORange(double xrange[2], double yrange[2], double *lengths); 00634 00635 virtual void CreatePlotData(int *pos, int *pos2, double xRange[2], 00636 double yRange[2], double *norms, 00637 int numDS, int numDO); 00638 void PlaceAxes(vtkViewport *viewport, int *size, int pos[2], int pos2[2]); 00639 void GenerateClipPlanes(int *pos, int *pos2); 00640 double ComputeGlyphScale(int i, int *pos, int *pos2); 00641 void ClipPlotData(int *pos, int *pos2, vtkPolyData *pd); 00642 double *TransformPoint(int pos[2], int pos2[2], double x[3], double xNew[3]); 00643 00644 private: 00645 vtkXYPlotActor(const vtkXYPlotActor&); // Not implemented. 00646 void operator=(const vtkXYPlotActor&); // Not implemented. 00647 }; 00648 00649 00650 #endif