00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
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
00145
00146
00147
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
00179
00181
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
00200
00201
00202
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
00250
00251
00252
00253
00254
00255
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
00266
00267
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
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
00540
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
00552
00553 protected:
00554 vtkXYPlotActor();
00555 ~vtkXYPlotActor();
00556
00557 vtkDataSetCollection *InputList;
00558 char** SelectedInputScalars;
00559 vtkIntArray* SelectedInputScalarsComponent;
00560 vtkDataObjectCollection *DataObjectInputList;
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];
00572 float YComputedRange[2];
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
00596 int DataObjectPlotMode;
00597 vtkIntArray *XComponent;
00598 vtkIntArray *YComponent;
00599 vtkIntArray *LinesOn;
00600 vtkIntArray *PointsOn;
00601
00602
00603
00604
00605 int NumberOfInputs;
00606 vtkPolyData **PlotData;
00607 vtkGlyph2D **PlotGlyph;
00608 vtkAppendPolyData **PlotAppend;
00609 vtkPolyDataMapper2D **PlotMapper;
00610 vtkActor2D **PlotActor;
00611 void InitializeEntries();
00612
00613
00614
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
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&);
00642 void operator=(const vtkXYPlotActor&);
00643 };
00644
00645
00646 #endif
00647