VTK
vtkXYPlotActor.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkXYPlotActor.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
87 #ifndef __vtkXYPlotActor_h
88 #define __vtkXYPlotActor_h
89 
90 #define VTK_XYPLOT_INDEX 0
91 #define VTK_XYPLOT_ARC_LENGTH 1
92 #define VTK_XYPLOT_NORMALIZED_ARC_LENGTH 2
93 #define VTK_XYPLOT_VALUE 3
94 
95 #define VTK_XYPLOT_ROW 0
96 #define VTK_XYPLOT_COLUMN 1
97 
98 #include "vtkActor2D.h"
99 
100 class vtkAppendPolyData;
101 class vtkAxisActor2D;
102 class vtkDataObject;
104 class vtkDataSet;
106 class vtkGlyph2D;
107 class vtkGlyphSource2D;
108 class vtkIntArray;
109 class vtkLegendBoxActor;
110 class vtkPlanes;
111 class vtkPolyData;
112 class vtkPolyDataMapper2D;
113 class vtkTextMapper;
114 class vtkTextProperty;
115 
117 {
118 public:
119  vtkTypeMacro(vtkXYPlotActor,vtkActor2D);
120  void PrintSelf(ostream& os, vtkIndent indent);
121 
126  static vtkXYPlotActor *New();
127 
128  //---Data Set Input----------------------------------------------------------
129  // The following methods are used to plot input datasets. Datasets
130  // will be plotted if set as input; otherwise the input data objects
131  // will be plotted (if defined).
132 
134 
139  void AddInput(vtkDataSet *in, const char* arrayName, int component);
140  void AddInput(vtkDataSet *in) {this->AddInput(in, NULL, 0);}
142 
144 
145  void RemoveInput(vtkDataSet *in, const char* arrayName, int component);
146  void RemoveInput(vtkDataSet *in) {this->RemoveInput(in, NULL, 0);}
148 
151  void RemoveAllInputs();
152 
154  vtkDataSetCollection *GetInputList() {return this->InputList;}
155 
157 
160  void SetPointComponent(int i, int comp);
161  int GetPointComponent(int i);
162  //---end Data Set Input-----------------------------------------------------
164 
166 
174  vtkSetClampMacro(XValues,int,VTK_XYPLOT_INDEX,VTK_XYPLOT_VALUE);
175  vtkGetMacro(XValues,int);
176  void SetXValuesToIndex(){this->SetXValues(VTK_XYPLOT_INDEX);};
177  void SetXValuesToArcLength() {this->SetXValues(VTK_XYPLOT_ARC_LENGTH);};
179  {this->SetXValues(VTK_XYPLOT_NORMALIZED_ARC_LENGTH);};
180  void SetXValuesToValue() {this->SetXValues(VTK_XYPLOT_VALUE);};
181  const char *GetXValuesAsString();
183 
184  //---Data Object Input------------------------------------------------------
185  // The following methods are used to plot input data objects. Datasets will
186  // be plotted in preference to data objects if set as input; otherwise the
187  // input data objects will be plotted (if defined).
188 
190  void AddDataObjectInput(vtkDataObject *in);
191 
193  void RemoveDataObjectInput(vtkDataObject *in);
194 
196 
198  {return this->DataObjectInputList;}
200 
202 
204  vtkSetClampMacro(DataObjectPlotMode,int,VTK_XYPLOT_ROW,VTK_XYPLOT_COLUMN);
205  vtkGetMacro(DataObjectPlotMode,int);
207  {this->SetDataObjectPlotMode(VTK_XYPLOT_ROW);}
209  {this->SetDataObjectPlotMode(VTK_XYPLOT_COLUMN);}
210  const char *GetDataObjectPlotModeAsString();
212 
214 
220  void SetDataObjectXComponent(int i, int comp);
221  int GetDataObjectXComponent(int i);
223 
225 
231  void SetDataObjectYComponent(int i, int comp);
232  int GetDataObjectYComponent(int i);
233  //---end Data Object Input--------------------------------------------------
235 
236  //---Per Curve Properties---------------------------------------------------
237  // The following methods are used to set properties on each curve that is
238  // plotted. Each input dataset (or data object) results in one curve. The
239  // methods that follow have an index i that corresponds to the input dataset
240  // or data object.
241  void SetPlotColor(int i, double r, double g, double b);
242  void SetPlotColor(int i, const double color[3]) {
243  this->SetPlotColor(i, color[0], color[1], color[2]); };
244  double *GetPlotColor(int i);
245  void SetPlotSymbol(int i,vtkPolyData *input);
246  vtkPolyData *GetPlotSymbol(int i);
247  void SetPlotLabel(int i, const char *label);
248  const char *GetPlotLabel(int i);
249 
250  // Allow per-curve specification of line and point rendering. These override
251  // global settings PlotPoints and PlotLines. If not on, the default behavior
252  // is governed by PlotPoints and PlotLines ivars.
253  vtkGetMacro(PlotCurvePoints, int);
254  vtkSetMacro(PlotCurvePoints, int);
255  vtkBooleanMacro(PlotCurvePoints, int);
256 
257  vtkGetMacro(PlotCurveLines, int);
258  vtkSetMacro(PlotCurveLines, int);
259  vtkBooleanMacro(PlotCurveLines, int);
260 
261  void SetPlotLines(int i, int);
262  int GetPlotLines(int i);
263 
264  void SetPlotPoints(int i, int);
265  int GetPlotPoints(int i);
266  //---end Per Curve Properties-----------------------------------------------
267 
269 
271  vtkSetMacro(ExchangeAxes, int);
272  vtkGetMacro(ExchangeAxes, int);
273  vtkBooleanMacro(ExchangeAxes, int);
275 
277 
281  vtkSetMacro(ReverseXAxis, int);
282  vtkGetMacro(ReverseXAxis, int);
283  vtkBooleanMacro(ReverseXAxis, int);
285 
287 
291  vtkSetMacro(ReverseYAxis, int);
292  vtkGetMacro(ReverseYAxis, int);
293  vtkBooleanMacro(ReverseYAxis, int);
295 
297 
301  vtkGetObjectMacro(LegendActor,vtkLegendBoxActor);
302  vtkGetObjectMacro(GlyphSource,vtkGlyphSource2D);
304 
306 
308  vtkSetStringMacro(Title);
309  vtkGetStringMacro(Title);
310  vtkSetStringMacro(XTitle);
311  vtkGetStringMacro(XTitle);
312  vtkSetStringMacro(YTitle);
313  vtkGetStringMacro(YTitle);
315 
317 
320  {return this->XAxis;}
322  {return this->YAxis;}
324 
326 
332  vtkSetVector2Macro(XRange,double);
333  vtkGetVectorMacro(XRange,double,2);
334  vtkSetVector2Macro(YRange,double);
335  vtkGetVectorMacro(YRange,double,2);
336  void SetPlotRange(double xmin, double ymin, double xmax, double ymax)
337  {this->SetXRange(xmin,xmax); this->SetYRange(ymin,ymax);}
339 
341 
346  vtkSetClampMacro(NumberOfXLabels, int, 0, 50);
347  vtkGetMacro(NumberOfXLabels, int);
348  vtkSetClampMacro(NumberOfYLabels, int, 0, 50);
349  vtkGetMacro(NumberOfYLabels, int);
350  void SetNumberOfLabels(int num)
351  {this->SetNumberOfXLabels(num); this->SetNumberOfYLabels(num);}
353 
355 
360  void SetAdjustXLabels(int adjust);
361  vtkGetMacro( AdjustXLabels, int );
362  void SetAdjustYLabels(int adjust);
363  vtkGetMacro( AdjustYLabels, int );
365 
367 
368  void SetXTitlePosition(double position);
369  double GetXTitlePosition();
370  void SetYTitlePosition(double position);
371  double GetYTitlePosition();
373 
375 
376  void SetNumberOfXMinorTicks(int num);
377  int GetNumberOfXMinorTicks();
378  void SetNumberOfYMinorTicks(int num);
379  int GetNumberOfYMinorTicks();
381 
383 
386  vtkSetMacro(Legend, int);
387  vtkGetMacro(Legend, int);
388  vtkBooleanMacro(Legend, int);
390 
392 
394  vtkSetVector2Macro(TitlePosition,double);
395  vtkGetVector2Macro(TitlePosition,double);
397 
399 
401  vtkSetMacro(AdjustTitlePosition, int);
402  vtkGetMacro(AdjustTitlePosition, int);
403  vtkBooleanMacro(AdjustTitlePosition, int);
405 
406 //BTX
407 enum Alignment {
408  AlignLeft = 0x1,
409  AlignRight = 0x2,
410  AlignHCenter = 0x4,
411  AlignTop = 0x10,
412  AlignBottom = 0x20,
413  AlignVCenter = 0x40,
414  AlignAxisLeft = 0x100,
415  AlignAxisRight = 0x200,
416  AlignAxisHCenter = 0x400,
417  AlignAxisTop = 0x1000,
418  AlignAxisBottom = 0x2000,
419  AlignAxisVCenter = 0x4000,
420 };
421 //ETX
423 
428  vtkSetMacro(AdjustTitlePositionMode, int);
429  vtkGetMacro(AdjustTitlePositionMode, int);
431 
433 
439  vtkSetVector2Macro(LegendPosition,double);
440  vtkGetVector2Macro(LegendPosition,double);
441  vtkSetVector2Macro(LegendPosition2,double);
442  vtkGetVector2Macro(LegendPosition2,double);
444 
446 
447  virtual void SetTitleTextProperty(vtkTextProperty *p);
448  vtkGetObjectMacro(TitleTextProperty,vtkTextProperty);
450 
452 
454  virtual void SetAxisTitleTextProperty(vtkTextProperty *p);
455  vtkGetObjectMacro(AxisTitleTextProperty,vtkTextProperty);
457 
459 
461  virtual void SetAxisLabelTextProperty(vtkTextProperty *p);
462  vtkGetObjectMacro(AxisLabelTextProperty,vtkTextProperty);
464 
466 
467  vtkSetMacro(Logx, int);
468  vtkGetMacro(Logx, int);
469  vtkBooleanMacro(Logx, int);
471 
473 
475  virtual void SetLabelFormat (const char* _arg);
476  const char* GetLabelFormat()
477  {
478  return this->GetXLabelFormat();
479  }
481 
483 
484  virtual void SetXLabelFormat (const char* _arg);
485  vtkGetStringMacro(XLabelFormat);
487 
489 
490  virtual void SetYLabelFormat (const char* _arg);
491  vtkGetStringMacro(YLabelFormat);
493 
495 
497  vtkSetClampMacro(Border, int, 0, 50);
498  vtkGetMacro(Border, int);
500 
502 
505  vtkGetMacro(PlotPoints, int);
506  vtkSetMacro(PlotPoints, int);
507  vtkBooleanMacro(PlotPoints, int);
509 
511 
513  vtkGetMacro(PlotLines, int);
514  vtkSetMacro(PlotLines, int);
515  vtkBooleanMacro(PlotLines, int);
517 
519 
522  vtkSetClampMacro(GlyphSize, double, 0.0, 0.2);
523  vtkGetMacro(GlyphSize, double);
525 
528  void ViewportToPlotCoordinate(vtkViewport *viewport, double &u, double &v);
529 
531 
534  void ViewportToPlotCoordinate(vtkViewport *viewport);
535  vtkSetVector2Macro(PlotCoordinate,double);
536  vtkGetVector2Macro(PlotCoordinate,double);
538 
540  void PlotToViewportCoordinate(vtkViewport *viewport, double &u, double &v);
541 
543 
547  void PlotToViewportCoordinate(vtkViewport *viewport);
548  vtkSetVector2Macro(ViewportCoordinate,double);
549  vtkGetVector2Macro(ViewportCoordinate,double);
551 
554  int IsInPlot(vtkViewport *viewport, double u, double v);
555 
557 
559  vtkSetMacro(ChartBox, int);
560  vtkGetMacro(ChartBox, int);
561  vtkBooleanMacro(ChartBox, int);
563 
565 
567  vtkSetMacro(ChartBorder, int);
568  vtkGetMacro(ChartBorder, int);
569  vtkBooleanMacro(ChartBorder, int);
571 
573  vtkProperty2D* GetChartBoxProperty() { return this->ChartBoxActor->GetProperty(); };
574 
576 
577  vtkSetMacro(ShowReferenceXLine, int);
578  vtkGetMacro(ShowReferenceXLine, int);
579  vtkBooleanMacro(ShowReferenceXLine, int);
581 
583 
584  vtkSetMacro(ReferenceXValue, double);
585  vtkGetMacro(ReferenceXValue, double);
587 
589 
590  vtkSetMacro(ShowReferenceYLine, int);
591  vtkGetMacro(ShowReferenceYLine, int);
592  vtkBooleanMacro(ShowReferenceYLine, int);
594 
596 
597  vtkSetMacro(ReferenceYValue, double);
598  vtkGetMacro(ReferenceYValue, double);
600 
602  unsigned long GetMTime();
603 
606  void PrintAsCSV(ostream &os);
607 
608 //BTX
610 
616 
618  virtual int HasTranslucentPolygonalGeometry();
619 
621 
625 //ETX
627 
628 protected:
629  vtkXYPlotActor();
630  ~vtkXYPlotActor();
631 
632  vtkDataSetCollection *InputList; //list of data sets to plot
633  char** SelectedInputScalars; // list of data set arrays to plot
634  vtkIntArray* SelectedInputScalarsComponent; // list of componenents
635  vtkDataObjectCollection *DataObjectInputList; //list of data objects to plot
636  char *Title;
637  char *XTitle;
638  char *YTitle;
639  int XValues;
642  int Logx;
645  double XRange[2];
646  double YRange[2];
647  double XComputedRange[2]; //range actually used by plot
648  double YComputedRange[2]; //range actually used by plot
649  int Border;
660  double TitlePosition[2];
662 
666 
669 
672 
673  double ViewportCoordinate[2];
674  double PlotCoordinate[2];
675 
676  //Handle data objects and datasets
682 
683  //The data drawn within the axes. Each curve is one polydata.
684  //color is controlled by scalar data. The curves are appended
685  //together, possibly glyphed with point symbols.
692  void InitializeEntries();
693 
694  // Legends and plot symbols. The legend also keeps track of
695  // the symbols and such.
696  int Legend;
697  double LegendPosition[2];
698  double LegendPosition2[2];
702  double GlyphSize;
703 
704  // Background box
705  int ChartBox;
713 
714  // Reference lines
719 
723 
724  // Keep track of changes.
725  int CachedSize[2];
727 
728  void ComputeXRange(double range[2], double *lengths);
729  void ComputeYRange(double range[2]);
730  void ComputeDORange(double xrange[2], double yrange[2], double *lengths);
731 
732  virtual void CreatePlotData(int *pos, int *pos2, double xRange[2],
733  double yRange[2], double *norms,
734  int numDS, int numDO);
735  void PlaceAxes(vtkViewport *viewport, int *size, int pos[2], int pos2[2]);
736  void GenerateClipPlanes(int *pos, int *pos2);
737  double ComputeGlyphScale(int i, int *pos, int *pos2);
738  void ClipPlotData(int *pos, int *pos2, vtkPolyData *pd);
739  double *TransformPoint(int pos[2], int pos2[2], double x[3], double xNew[3]);
740 
741 private:
742  vtkXYPlotActor(const vtkXYPlotActor&); // Not implemented.
743  void operator=(const vtkXYPlotActor&); // Not implemented.
744 };
745 
746 
747 #endif
vtkPolyDataMapper2D * ChartBorderMapper
const char * GetLabelFormat()
draw symbols with text
generate an x-y plot from input dataset(s) or field data
vtkLegendBoxActor * LegendActor
maintain an unordered list of dataset objects
copy oriented and scaled glyph geometry to every input point (2D specialization)
Definition: vtkGlyph2D.h:37
virtual int RenderTranslucentPolygonalGeometry(vtkViewport *)
double ReferenceXValue
virtual void ReleaseGraphicsResources(vtkWindow *)
abstract specification for Viewports
Definition: vtkViewport.h:45
vtkPolyData ** PlotData
vtkPolyDataMapper2D * ReferenceLinesMapper
abstract class to specify dataset behavior
Definition: vtkDataSet.h:58
vtkActor2D ** PlotActor
void AddInput(vtkDataSet *in)
maintain an unordered list of data objects
a actor that draws 2D data
Definition: vtkActor2D.h:43
vtkAxisActor2D * GetXAxisActor2D()
record modification and/or execution time
Definition: vtkTimeStamp.h:33
vtkDataSetCollection * GetInputList()
vtkTextProperty * AxisTitleTextProperty
implicit function for convex set of planes
Definition: vtkPlanes.h:52
Create an axis with tick marks and labels.
vtkIntArray * PointsOn
void SetPlotRange(double xmin, double ymin, double xmax, double ymax)
vtkDataSetCollection * InputList
char ** SelectedInputScalars
#define VTK_XYPLOT_VALUE
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:81
#define VTK_XYPLOT_INDEX
vtkAxisActor2D * XAxis
vtkProperty2D * GetChartBoxProperty()
void RemoveInput(vtkDataSet *in)
2D text annotation
Definition: vtkTextMapper.h:43
vtkPolyData * ChartBorderPolyData
vtkTimeStamp BuildTime
window superclass for vtkRenderWindow
Definition: vtkWindow.h:35
vtkAxisActor2D * GetYAxisActor2D()
#define VTK_XYPLOT_ARC_LENGTH
dynamic, self-adjusting array of int
Definition: vtkIntArray.h:42
vtkPolyDataMapper2D ** PlotMapper
vtkActor2D * ChartBoxActor
vtkIntArray * LinesOn
virtual unsigned long GetMTime()
virtual int HasTranslucentPolygonalGeometry()
virtual int RenderOpaqueGeometry(vtkViewport *viewport)
a simple class to control print indentation
Definition: vtkIndent.h:37
void PrintSelf(ostream &os, vtkIndent indent)
static vtkActor2D * New()
vtkAppendPolyData ** PlotAppend
vtkIntArray * XComponent
void SetPlotColor(int i, const double color[3])
appends one or more polygonal datasets together
vtkGlyphSource2D * GlyphSource
vtkActor2D * TitleActor
vtkTextMapper * TitleMapper
vtkTextProperty * AxisLabelTextProperty
vtkGlyph2D ** PlotGlyph
represent text properties.
vtkAxisActor2D * YAxis
void SetNumberOfLabels(int num)
void SetXValuesToArcLength()
void SetXValuesToValue()
vtkDataObjectCollection * GetDataObjectInputList()
vtkTextProperty * TitleTextProperty
#define VTK_XYPLOT_ROW
vtkActor2D * ChartBorderActor
#define VTK_XYPLOT_NORMALIZED_ARC_LENGTH
#define VTK_XYPLOT_COLUMN
void SetXValuesToNormalizedArcLength()
vtkIntArray * YComponent
void SetDataObjectPlotModeToRows()
vtkPlanes * ClipPlanes
virtual int RenderOverlay(vtkViewport *viewport)
represent surface properties of a 2D image
Definition: vtkProperty2D.h:38
create 2D glyphs represented by vtkPolyData
vtkPolyDataMapper2D * ChartBoxMapper
void SetXValuesToIndex()
vtkIntArray * SelectedInputScalarsComponent
#define VTK_HYBRID_EXPORT
vtkPolyData * ReferenceLinesPolyData
vtkActor2D * ReferenceLinesActor
vtkDataObjectCollection * DataObjectInputList
general representation of visualization data
Definition: vtkDataObject.h:70
double ReferenceYValue
draw vtkPolyData onto the image plane
vtkPolyData * ChartBoxPolyData
void SetDataObjectPlotModeToColumns()