VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkXYPlotActor.h 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 vtkTypeMacro(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 00139 void AddInput(vtkDataSet *in, const char* arrayName, int component); 00140 void AddInput(vtkDataSet *in) {this->AddInput(in, NULL, 0);} 00142 00144 00145 void RemoveInput(vtkDataSet *in, const char* arrayName, int component); 00146 void RemoveInput(vtkDataSet *in) {this->RemoveInput(in, NULL, 0);} 00148 00151 void RemoveAllInputs(); 00152 00154 vtkDataSetCollection *GetInputList() {return this->InputList;} 00155 00157 00160 void SetPointComponent(int i, int comp); 00161 int GetPointComponent(int i); 00162 //---end Data Set Input----------------------------------------------------- 00164 00166 00174 vtkSetClampMacro(XValues,int,VTK_XYPLOT_INDEX,VTK_XYPLOT_VALUE); 00175 vtkGetMacro(XValues,int); 00176 void SetXValuesToIndex(){this->SetXValues(VTK_XYPLOT_INDEX);}; 00177 void SetXValuesToArcLength() {this->SetXValues(VTK_XYPLOT_ARC_LENGTH);}; 00178 void SetXValuesToNormalizedArcLength() 00179 {this->SetXValues(VTK_XYPLOT_NORMALIZED_ARC_LENGTH);}; 00180 void SetXValuesToValue() {this->SetXValues(VTK_XYPLOT_VALUE);}; 00181 const char *GetXValuesAsString(); 00183 00184 //---Data Object Input------------------------------------------------------ 00185 // The following methods are used to plot input data objects. Datasets will 00186 // be plotted in preference to data objects if set as input; otherwise the 00187 // input data objects will be plotted (if defined). 00188 00190 void AddDataObjectInput(vtkDataObject *in); 00191 00193 void RemoveDataObjectInput(vtkDataObject *in); 00194 00196 00197 vtkDataObjectCollection *GetDataObjectInputList() 00198 {return this->DataObjectInputList;} 00200 00202 00204 vtkSetClampMacro(DataObjectPlotMode,int,VTK_XYPLOT_ROW,VTK_XYPLOT_COLUMN); 00205 vtkGetMacro(DataObjectPlotMode,int); 00206 void SetDataObjectPlotModeToRows() 00207 {this->SetDataObjectPlotMode(VTK_XYPLOT_ROW);} 00208 void SetDataObjectPlotModeToColumns() 00209 {this->SetDataObjectPlotMode(VTK_XYPLOT_COLUMN);} 00210 const char *GetDataObjectPlotModeAsString(); 00212 00214 00220 void SetDataObjectXComponent(int i, int comp); 00221 int GetDataObjectXComponent(int i); 00223 00225 00231 void SetDataObjectYComponent(int i, int comp); 00232 int GetDataObjectYComponent(int i); 00233 //---end Data Object Input-------------------------------------------------- 00235 00236 //---Per Curve Properties--------------------------------------------------- 00237 // The following methods are used to set properties on each curve that is 00238 // plotted. Each input dataset (or data object) results in one curve. The 00239 // methods that follow have an index i that corresponds to the input dataset 00240 // or data object. 00241 void SetPlotColor(int i, double r, double g, double b); 00242 void SetPlotColor(int i, const double color[3]) { 00243 this->SetPlotColor(i, color[0], color[1], color[2]); }; 00244 double *GetPlotColor(int i); 00245 void SetPlotSymbol(int i,vtkPolyData *input); 00246 vtkPolyData *GetPlotSymbol(int i); 00247 void SetPlotLabel(int i, const char *label); 00248 const char *GetPlotLabel(int i); 00249 00250 // Allow per-curve specification of line and point rendering. These override 00251 // global settings PlotPoints and PlotLines. If not on, the default behavior 00252 // is governed by PlotPoints and PlotLines ivars. 00253 vtkGetMacro(PlotCurvePoints, int); 00254 vtkSetMacro(PlotCurvePoints, int); 00255 vtkBooleanMacro(PlotCurvePoints, int); 00256 00257 vtkGetMacro(PlotCurveLines, int); 00258 vtkSetMacro(PlotCurveLines, int); 00259 vtkBooleanMacro(PlotCurveLines, int); 00260 00261 void SetPlotLines(int i, int); 00262 int GetPlotLines(int i); 00263 00264 void SetPlotPoints(int i, int); 00265 int GetPlotPoints(int i); 00266 //---end Per Curve Properties----------------------------------------------- 00267 00269 00271 vtkSetMacro(ExchangeAxes, int); 00272 vtkGetMacro(ExchangeAxes, int); 00273 vtkBooleanMacro(ExchangeAxes, int); 00275 00277 00281 vtkSetMacro(ReverseXAxis, int); 00282 vtkGetMacro(ReverseXAxis, int); 00283 vtkBooleanMacro(ReverseXAxis, int); 00285 00287 00291 vtkSetMacro(ReverseYAxis, int); 00292 vtkGetMacro(ReverseYAxis, int); 00293 vtkBooleanMacro(ReverseYAxis, int); 00295 00297 00301 vtkGetObjectMacro(LegendActor,vtkLegendBoxActor); 00302 vtkGetObjectMacro(GlyphSource,vtkGlyphSource2D); 00304 00306 00308 vtkSetStringMacro(Title); 00309 vtkGetStringMacro(Title); 00310 vtkSetStringMacro(XTitle); 00311 vtkGetStringMacro(XTitle); 00312 vtkSetStringMacro(YTitle); 00313 vtkGetStringMacro(YTitle); 00315 00317 00319 vtkAxisActor2D *GetXAxisActor2D() 00320 {return this->XAxis;} 00321 vtkAxisActor2D *GetYAxisActor2D() 00322 {return this->YAxis;} 00324 00326 00332 vtkSetVector2Macro(XRange,double); 00333 vtkGetVectorMacro(XRange,double,2); 00334 vtkSetVector2Macro(YRange,double); 00335 vtkGetVectorMacro(YRange,double,2); 00336 void SetPlotRange(double xmin, double ymin, double xmax, double ymax) 00337 {this->SetXRange(xmin,xmax); this->SetYRange(ymin,ymax);} 00339 00341 00346 vtkSetClampMacro(NumberOfXLabels, int, 0, 50); 00347 vtkGetMacro(NumberOfXLabels, int); 00348 vtkSetClampMacro(NumberOfYLabels, int, 0, 50); 00349 vtkGetMacro(NumberOfYLabels, int); 00350 void SetNumberOfLabels(int num) 00351 {this->SetNumberOfXLabels(num); this->SetNumberOfYLabels(num);} 00353 00355 00360 void SetAdjustXLabels(int adjust); 00361 vtkGetMacro( AdjustXLabels, int ); 00362 void SetAdjustYLabels(int adjust); 00363 vtkGetMacro( AdjustYLabels, int ); 00365 00367 00368 void SetXTitlePosition(double position); 00369 double GetXTitlePosition(); 00370 void SetYTitlePosition(double position); 00371 double GetYTitlePosition(); 00373 00375 00376 void SetNumberOfXMinorTicks(int num); 00377 int GetNumberOfXMinorTicks(); 00378 void SetNumberOfYMinorTicks(int num); 00379 int GetNumberOfYMinorTicks(); 00381 00383 00386 vtkSetMacro(Legend, int); 00387 vtkGetMacro(Legend, int); 00388 vtkBooleanMacro(Legend, int); 00390 00392 00394 vtkSetVector2Macro(TitlePosition,double); 00395 vtkGetVector2Macro(TitlePosition,double); 00397 00399 00401 vtkSetMacro(AdjustTitlePosition, int); 00402 vtkGetMacro(AdjustTitlePosition, int); 00403 vtkBooleanMacro(AdjustTitlePosition, int); 00405 00406 //BTX 00407 enum Alignment { 00408 AlignLeft = 0x1, 00409 AlignRight = 0x2, 00410 AlignHCenter = 0x4, 00411 AlignTop = 0x10, 00412 AlignBottom = 0x20, 00413 AlignVCenter = 0x40, 00414 AlignAxisLeft = 0x100, 00415 AlignAxisRight = 0x200, 00416 AlignAxisHCenter = 0x400, 00417 AlignAxisTop = 0x1000, 00418 AlignAxisBottom = 0x2000, 00419 AlignAxisVCenter = 0x4000, 00420 }; 00421 //ETX 00423 00428 vtkSetMacro(AdjustTitlePositionMode, int); 00429 vtkGetMacro(AdjustTitlePositionMode, int); 00431 00433 00439 vtkSetVector2Macro(LegendPosition,double); 00440 vtkGetVector2Macro(LegendPosition,double); 00441 vtkSetVector2Macro(LegendPosition2,double); 00442 vtkGetVector2Macro(LegendPosition2,double); 00444 00446 00447 virtual void SetTitleTextProperty(vtkTextProperty *p); 00448 vtkGetObjectMacro(TitleTextProperty,vtkTextProperty); 00450 00452 00454 virtual void SetAxisTitleTextProperty(vtkTextProperty *p); 00455 vtkGetObjectMacro(AxisTitleTextProperty,vtkTextProperty); 00457 00459 00461 virtual void SetAxisLabelTextProperty(vtkTextProperty *p); 00462 vtkGetObjectMacro(AxisLabelTextProperty,vtkTextProperty); 00464 00466 00467 vtkSetMacro(Logx, int); 00468 vtkGetMacro(Logx, int); 00469 vtkBooleanMacro(Logx, int); 00471 00473 00475 virtual void SetLabelFormat (const char* _arg); 00476 const char* GetLabelFormat() 00477 { 00478 return this->GetXLabelFormat(); 00479 } 00481 00483 00484 virtual void SetXLabelFormat (const char* _arg); 00485 vtkGetStringMacro(XLabelFormat); 00487 00489 00490 virtual void SetYLabelFormat (const char* _arg); 00491 vtkGetStringMacro(YLabelFormat); 00493 00495 00497 vtkSetClampMacro(Border, int, 0, 50); 00498 vtkGetMacro(Border, int); 00500 00502 00505 vtkGetMacro(PlotPoints, int); 00506 vtkSetMacro(PlotPoints, int); 00507 vtkBooleanMacro(PlotPoints, int); 00509 00511 00513 vtkGetMacro(PlotLines, int); 00514 vtkSetMacro(PlotLines, int); 00515 vtkBooleanMacro(PlotLines, int); 00517 00519 00522 vtkSetClampMacro(GlyphSize, double, 0.0, 0.2); 00523 vtkGetMacro(GlyphSize, double); 00525 00528 void ViewportToPlotCoordinate(vtkViewport *viewport, double &u, double &v); 00529 00531 00534 void ViewportToPlotCoordinate(vtkViewport *viewport); 00535 vtkSetVector2Macro(PlotCoordinate,double); 00536 vtkGetVector2Macro(PlotCoordinate,double); 00538 00540 void PlotToViewportCoordinate(vtkViewport *viewport, double &u, double &v); 00541 00543 00547 void PlotToViewportCoordinate(vtkViewport *viewport); 00548 vtkSetVector2Macro(ViewportCoordinate,double); 00549 vtkGetVector2Macro(ViewportCoordinate,double); 00551 00554 int IsInPlot(vtkViewport *viewport, double u, double v); 00555 00557 00559 vtkSetMacro(ChartBox, int); 00560 vtkGetMacro(ChartBox, int); 00561 vtkBooleanMacro(ChartBox, int); 00563 00565 00567 vtkSetMacro(ChartBorder, int); 00568 vtkGetMacro(ChartBorder, int); 00569 vtkBooleanMacro(ChartBorder, int); 00571 00573 vtkProperty2D* GetChartBoxProperty() { return this->ChartBoxActor->GetProperty(); }; 00574 00576 00577 vtkSetMacro(ShowReferenceXLine, int); 00578 vtkGetMacro(ShowReferenceXLine, int); 00579 vtkBooleanMacro(ShowReferenceXLine, int); 00581 00583 00584 vtkSetMacro(ReferenceXValue, double); 00585 vtkGetMacro(ReferenceXValue, double); 00587 00589 00590 vtkSetMacro(ShowReferenceYLine, int); 00591 vtkGetMacro(ShowReferenceYLine, int); 00592 vtkBooleanMacro(ShowReferenceYLine, int); 00594 00596 00597 vtkSetMacro(ReferenceYValue, double); 00598 vtkGetMacro(ReferenceYValue, double); 00600 00602 unsigned long GetMTime(); 00603 00606 void PrintAsCSV(ostream &os); 00607 00608 //BTX 00610 00612 int RenderOpaqueGeometry(vtkViewport*); 00613 int RenderOverlay(vtkViewport*); 00614 virtual int RenderTranslucentPolygonalGeometry(vtkViewport *) {return 0;} 00616 00618 virtual int HasTranslucentPolygonalGeometry(); 00619 00621 00624 void ReleaseGraphicsResources(vtkWindow *); 00625 //ETX 00627 00628 protected: 00629 vtkXYPlotActor(); 00630 ~vtkXYPlotActor(); 00631 00632 vtkDataSetCollection *InputList; //list of data sets to plot 00633 char** SelectedInputScalars; // list of data set arrays to plot 00634 vtkIntArray* SelectedInputScalarsComponent; // list of componenents 00635 vtkDataObjectCollection *DataObjectInputList; //list of data objects to plot 00636 char *Title; 00637 char *XTitle; 00638 char *YTitle; 00639 int XValues; 00640 int NumberOfXLabels; 00641 int NumberOfYLabels; 00642 int Logx; 00643 char *XLabelFormat; 00644 char *YLabelFormat; 00645 double XRange[2]; 00646 double YRange[2]; 00647 double XComputedRange[2]; //range actually used by plot 00648 double YComputedRange[2]; //range actually used by plot 00649 int Border; 00650 int PlotLines; 00651 int PlotPoints; 00652 int PlotCurveLines; 00653 int PlotCurvePoints; 00654 int ExchangeAxes; 00655 int ReverseXAxis; 00656 int ReverseYAxis; 00657 int AdjustXLabels; 00658 int AdjustYLabels; 00659 int AdjustTitlePosition; 00660 double TitlePosition[2]; 00661 int AdjustTitlePositionMode; 00662 00663 vtkTextMapper *TitleMapper; 00664 vtkActor2D *TitleActor; 00665 vtkTextProperty *TitleTextProperty; 00666 00667 vtkAxisActor2D *XAxis; 00668 vtkAxisActor2D *YAxis; 00669 00670 vtkTextProperty *AxisTitleTextProperty; 00671 vtkTextProperty *AxisLabelTextProperty; 00672 00673 double ViewportCoordinate[2]; 00674 double PlotCoordinate[2]; 00675 00676 //Handle data objects and datasets 00677 int DataObjectPlotMode; 00678 vtkIntArray *XComponent; 00679 vtkIntArray *YComponent; 00680 vtkIntArray *LinesOn; 00681 vtkIntArray *PointsOn; 00682 00683 //The data drawn within the axes. Each curve is one polydata. 00684 //color is controlled by scalar data. The curves are appended 00685 //together, possibly glyphed with point symbols. 00686 int NumberOfInputs; 00687 vtkPolyData **PlotData; 00688 vtkGlyph2D **PlotGlyph; 00689 vtkAppendPolyData **PlotAppend; 00690 vtkPolyDataMapper2D **PlotMapper; 00691 vtkActor2D **PlotActor; 00692 void InitializeEntries(); 00693 00694 // Legends and plot symbols. The legend also keeps track of 00695 // the symbols and such. 00696 int Legend; 00697 double LegendPosition[2]; 00698 double LegendPosition2[2]; 00699 vtkLegendBoxActor *LegendActor; 00700 vtkGlyphSource2D *GlyphSource; 00701 vtkPlanes *ClipPlanes; 00702 double GlyphSize; 00703 00704 // Background box 00705 int ChartBox; 00706 vtkPolyData *ChartBoxPolyData; 00707 vtkPolyDataMapper2D *ChartBoxMapper; 00708 vtkActor2D *ChartBoxActor; 00709 int ChartBorder; 00710 vtkPolyData *ChartBorderPolyData; 00711 vtkPolyDataMapper2D *ChartBorderMapper; 00712 vtkActor2D *ChartBorderActor; 00713 00714 // Reference lines 00715 int ShowReferenceXLine; 00716 int ShowReferenceYLine; 00717 double ReferenceXValue; 00718 double ReferenceYValue; 00719 00720 vtkPolyData *ReferenceLinesPolyData; 00721 vtkPolyDataMapper2D *ReferenceLinesMapper; 00722 vtkActor2D *ReferenceLinesActor; 00723 00724 // Keep track of changes. 00725 int CachedSize[2]; 00726 vtkTimeStamp BuildTime; 00727 00728 void ComputeXRange(double range[2], double *lengths); 00729 void ComputeYRange(double range[2]); 00730 void ComputeDORange(double xrange[2], double yrange[2], double *lengths); 00731 00732 virtual void CreatePlotData(int *pos, int *pos2, double xRange[2], 00733 double yRange[2], double *norms, 00734 int numDS, int numDO); 00735 void PlaceAxes(vtkViewport *viewport, int *size, int pos[2], int pos2[2]); 00736 void GenerateClipPlanes(int *pos, int *pos2); 00737 double ComputeGlyphScale(int i, int *pos, int *pos2); 00738 void ClipPlotData(int *pos, int *pos2, vtkPolyData *pd); 00739 double *TransformPoint(int pos[2], int pos2[2], double x[3], double xNew[3]); 00740 00741 private: 00742 vtkXYPlotActor(const vtkXYPlotActor&); // Not implemented. 00743 void operator=(const vtkXYPlotActor&); // Not implemented. 00744 }; 00745 00746 00747 #endif