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 =========================================================================*/
93 #ifndef vtkXYPlotActor_h
94 #define vtkXYPlotActor_h
95 
96 #define VTK_XYPLOT_INDEX 0
97 #define VTK_XYPLOT_ARC_LENGTH 1
98 #define VTK_XYPLOT_NORMALIZED_ARC_LENGTH 2
99 #define VTK_XYPLOT_VALUE 3
100 
101 #define VTK_XYPLOT_ROW 0
102 #define VTK_XYPLOT_COLUMN 1
103 
104 #define VTK_XYPLOT_Y_AXIS_TOP 0
105 #define VTK_XYPLOT_Y_AXIS_HCENTER 1
106 #define VTK_XYPLOT_Y_AXIS_VCENTER 2 // rotate by 90 degrees (y-axis aligned)
107 
108 #include "vtkRenderingAnnotationModule.h" // For export macro
109 #include "vtkActor2D.h"
110 #include "vtkSmartPointer.h" // For SP
111 
112 class vtkXYPlotActorConnections;
113 class vtkAlgorithmOutput;
114 class vtkAppendPolyData;
115 class vtkAxisActor2D;
116 class vtkDataObject;
118 class vtkDataSet;
120 class vtkDoubleArray;
121 class vtkGlyph2D;
122 class vtkGlyphSource2D;
123 class vtkIntArray;
124 class vtkLegendBoxActor;
125 class vtkPlanes;
126 class vtkPolyData;
127 class vtkPolyDataMapper2D;
128 class vtkTextActor;
129 class vtkTextMapper;
130 class vtkTextProperty;
131 
133 {
134 public:
135  vtkTypeMacro(vtkXYPlotActor,vtkActor2D);
136  void PrintSelf(ostream& os, vtkIndent indent);
137 
142  static vtkXYPlotActor *New();
143 
144  //---Data Set Input----------------------------------------------------------
145  // The following methods are used to plot input datasets. Datasets
146  // will be plotted if set as input; otherwise the input data objects
147  // will be plotted (if defined).
148 
150 
156  void AddDataSetInput(vtkDataSet *ds, const char* arrayName, int component);
157  void AddDataSetInput(vtkDataSet *ds) {this->AddDataSetInput(ds, NULL, 0);}
158  void AddDataSetInputConnection(vtkAlgorithmOutput *in, const char* arrayName, int component);
161 
163 
164  void RemoveDataSetInput(vtkDataSet *ds, const char* arrayName, int component);
165  void RemoveDataSetInput(vtkDataSet *ds) {this->RemoveDataSetInput(ds, NULL, 0);}
166  void RemoveDataSetInputConnection(vtkAlgorithmOutput *in, const char* arrayName, int component);
168  {
169  this->RemoveDataSetInputConnection(in, NULL, 0);
170  }
172 
175  void RemoveAllDataSetInputConnections();
176 
178 
181  void SetPointComponent(int i, int comp);
182  int GetPointComponent(int i);
183  //---end Data Set Input-----------------------------------------------------
185 
187 
195  vtkSetClampMacro(XValues,int,VTK_XYPLOT_INDEX,VTK_XYPLOT_VALUE);
196  vtkGetMacro(XValues,int);
197  void SetXValuesToIndex(){this->SetXValues(VTK_XYPLOT_INDEX);};
198  void SetXValuesToArcLength() {this->SetXValues(VTK_XYPLOT_ARC_LENGTH);};
200  {this->SetXValues(VTK_XYPLOT_NORMALIZED_ARC_LENGTH);};
201  void SetXValuesToValue() {this->SetXValues(VTK_XYPLOT_VALUE);};
202  const char *GetXValuesAsString();
204 
205  //---Data Object Input------------------------------------------------------
206  // The following methods are used to plot input data objects. Datasets will
207  // be plotted in preference to data objects if set as input; otherwise the
208  // input data objects will be plotted (if defined).
209 
211 
212  void AddDataObjectInput(vtkDataObject *in);
213  void AddDataObjectInputConnection(vtkAlgorithmOutput *alg);
215 
217 
218  void RemoveDataObjectInputConnection(vtkAlgorithmOutput *aout);
219  void RemoveDataObjectInput(vtkDataObject *in);
221 
223 
225  vtkSetClampMacro(DataObjectPlotMode,int,VTK_XYPLOT_ROW,VTK_XYPLOT_COLUMN);
226  vtkGetMacro(DataObjectPlotMode,int);
228  {this->SetDataObjectPlotMode(VTK_XYPLOT_ROW);}
230  {this->SetDataObjectPlotMode(VTK_XYPLOT_COLUMN);}
231  const char *GetDataObjectPlotModeAsString();
233 
235 
241  void SetDataObjectXComponent(int i, int comp);
242  int GetDataObjectXComponent(int i);
244 
246 
252  void SetDataObjectYComponent(int i, int comp);
253  int GetDataObjectYComponent(int i);
254  //---end Data Object Input--------------------------------------------------
256 
257  //---Per Curve Properties---------------------------------------------------
258  // The following methods are used to set properties on each curve that is
259  // plotted. Each input dataset (or data object) results in one curve. The
260  // methods that follow have an index i that corresponds to the input dataset
261  // or data object.
262  void SetPlotColor(int i, double r, double g, double b);
263  void SetPlotColor(int i, const double color[3]) {
264  this->SetPlotColor(i, color[0], color[1], color[2]); };
265  double *GetPlotColor(int i);
266  void SetPlotSymbol(int i,vtkPolyData *input);
267  vtkPolyData *GetPlotSymbol(int i);
268  void SetPlotLabel(int i, const char *label);
269  const char *GetPlotLabel(int i);
270 
271  // Allow per-curve specification of line and point rendering. These override
272  // global settings PlotPoints and PlotLines. If not on, the default behavior
273  // is governed by PlotPoints and PlotLines ivars.
274  vtkGetMacro(PlotCurvePoints, int);
275  vtkSetMacro(PlotCurvePoints, int);
276  vtkBooleanMacro(PlotCurvePoints, int);
277 
278  vtkGetMacro(PlotCurveLines, int);
279  vtkSetMacro(PlotCurveLines, int);
280  vtkBooleanMacro(PlotCurveLines, int);
281 
282  void SetPlotLines(int i, int);
283  int GetPlotLines(int i);
284 
285  void SetPlotPoints(int i, int);
286  int GetPlotPoints(int i);
287  //---end Per Curve Properties-----------------------------------------------
288 
290 
292  vtkSetMacro(ExchangeAxes, int);
293  vtkGetMacro(ExchangeAxes, int);
294  vtkBooleanMacro(ExchangeAxes, int);
296 
298 
302  vtkSetMacro(ReverseXAxis, int);
303  vtkGetMacro(ReverseXAxis, int);
304  vtkBooleanMacro(ReverseXAxis, int);
306 
308 
312  vtkSetMacro(ReverseYAxis, int);
313  vtkGetMacro(ReverseYAxis, int);
314  vtkBooleanMacro(ReverseYAxis, int);
316 
318 
322  vtkGetObjectMacro(LegendActor,vtkLegendBoxActor);
323  vtkGetObjectMacro(GlyphSource,vtkGlyphSource2D);
325 
327 
328  vtkSetStringMacro(Title);
329  vtkGetStringMacro(Title);
331 
333 
334  vtkSetStringMacro(XTitle);
335  vtkGetStringMacro(XTitle);
337 
339 
340  virtual void SetYTitle( const char* );
341  char* GetYTitle();
343 
345 
348  {
349  return this->XAxis;
350  }
352  {
353  return this->YAxis;
354  }
356 
358 
364  vtkSetVector2Macro(XRange,double);
365  vtkGetVectorMacro(XRange,double,2);
366  vtkSetVector2Macro(YRange,double);
367  vtkGetVectorMacro(YRange,double,2);
368  void SetPlotRange(double xmin, double ymin, double xmax, double ymax)
369  {this->SetXRange(xmin,xmax); this->SetYRange(ymin,ymax);}
371 
373 
378  vtkSetClampMacro(NumberOfXLabels, int, 0, 50);
379  vtkGetMacro(NumberOfXLabels, int);
380  vtkSetClampMacro(NumberOfYLabels, int, 0, 50);
381  vtkGetMacro(NumberOfYLabels, int);
382  void SetNumberOfLabels(int num)
383  {this->SetNumberOfXLabels(num); this->SetNumberOfYLabels(num);}
385 
387 
392  void SetAdjustXLabels(int adjust);
393  vtkGetMacro( AdjustXLabels, int );
394  void SetAdjustYLabels(int adjust);
395  vtkGetMacro( AdjustYLabels, int );
397 
399 
400  void SetNumberOfXMinorTicks(int num);
401  int GetNumberOfXMinorTicks();
402  void SetNumberOfYMinorTicks(int num);
403  int GetNumberOfYMinorTicks();
405 
407 
410  vtkSetMacro(Legend, int);
411  vtkGetMacro(Legend, int);
412  vtkBooleanMacro(Legend, int);
414 
416 
418  vtkSetVector2Macro(TitlePosition,double);
419  vtkGetVector2Macro(TitlePosition,double);
421 
423 
425  vtkSetMacro(AdjustTitlePosition, int);
426  vtkGetMacro(AdjustTitlePosition, int);
427  vtkBooleanMacro(AdjustTitlePosition, int);
429 
430 //BTX
431 enum Alignment {
432  AlignLeft = 0x1,
433  AlignRight = 0x2,
434  AlignHCenter = 0x4,
435  AlignTop = 0x10,
436  AlignBottom = 0x20,
437  AlignVCenter = 0x40,
438  AlignAxisLeft = 0x100,
439  AlignAxisRight = 0x200,
440  AlignAxisHCenter = 0x400,
441  AlignAxisTop = 0x1000,
442  AlignAxisBottom = 0x2000,
443  AlignAxisVCenter = 0x4000
444 };
445 //ETX
447 
452  vtkSetMacro(AdjustTitlePositionMode, int);
453  vtkGetMacro(AdjustTitlePositionMode, int);
455 
457 
463  vtkSetVector2Macro(LegendPosition,double);
464  vtkGetVector2Macro(LegendPosition,double);
465  vtkSetVector2Macro(LegendPosition2,double);
466  vtkGetVector2Macro(LegendPosition2,double);
468 
470 
471  virtual void SetTitleTextProperty(vtkTextProperty *p);
472  vtkGetObjectMacro(TitleTextProperty,vtkTextProperty);
474 
476 
478  virtual void SetAxisTitleTextProperty(vtkTextProperty *p);
479  vtkGetObjectMacro(AxisTitleTextProperty,vtkTextProperty);
481 
483 
485  virtual void SetAxisLabelTextProperty(vtkTextProperty *p);
486  vtkGetObjectMacro(AxisLabelTextProperty,vtkTextProperty);
488 
490 
491  vtkSetMacro(Logx, int);
492  vtkGetMacro(Logx, int);
493  vtkBooleanMacro(Logx, int);
495 
497 
499  virtual void SetLabelFormat ( const char* );
500  const char* GetLabelFormat()
501  {
502  return this->GetXLabelFormat();
503  }
505 
507 
508  virtual void SetXLabelFormat ( const char* );
509  vtkGetStringMacro(XLabelFormat);
511 
513 
514  virtual void SetYLabelFormat ( const char* );
515  vtkGetStringMacro(YLabelFormat);
517 
519 
521  vtkSetClampMacro(Border, int, 0, 50);
522  vtkGetMacro(Border, int);
524 
526 
529  vtkGetMacro(PlotPoints, int);
530  vtkSetMacro(PlotPoints, int);
531  vtkBooleanMacro(PlotPoints, int);
533 
535 
537  vtkGetMacro(PlotLines, int);
538  vtkSetMacro(PlotLines, int);
539  vtkBooleanMacro(PlotLines, int);
541 
543 
546  vtkSetClampMacro(GlyphSize, double, 0.0, 0.2);
547  vtkGetMacro(GlyphSize, double);
549 
552  void ViewportToPlotCoordinate(vtkViewport *viewport, double &u, double &v);
553 
555 
558  void ViewportToPlotCoordinate(vtkViewport *viewport);
559  vtkSetVector2Macro(PlotCoordinate,double);
560  vtkGetVector2Macro(PlotCoordinate,double);
562 
564  void PlotToViewportCoordinate(vtkViewport *viewport, double &u, double &v);
565 
567 
571  void PlotToViewportCoordinate(vtkViewport *viewport);
572  vtkSetVector2Macro(ViewportCoordinate,double);
573  vtkGetVector2Macro(ViewportCoordinate,double);
575 
578  int IsInPlot(vtkViewport *viewport, double u, double v);
579 
581 
583  vtkSetMacro(ChartBox, int);
584  vtkGetMacro(ChartBox, int);
585  vtkBooleanMacro(ChartBox, int);
587 
589 
591  vtkSetMacro(ChartBorder, int);
592  vtkGetMacro(ChartBorder, int);
593  vtkBooleanMacro(ChartBorder, int);
595 
597  vtkProperty2D* GetChartBoxProperty() { return this->ChartBoxActor->GetProperty(); };
598 
600 
601  vtkSetMacro(ShowReferenceXLine, int);
602  vtkGetMacro(ShowReferenceXLine, int);
603  vtkBooleanMacro(ShowReferenceXLine, int);
605 
607 
608  vtkSetMacro(ReferenceXValue, double);
609  vtkGetMacro(ReferenceXValue, double);
611 
613 
614  vtkSetMacro(ShowReferenceYLine, int);
615  vtkGetMacro(ShowReferenceYLine, int);
616  vtkBooleanMacro(ShowReferenceYLine, int);
618 
620 
621  vtkSetMacro(ReferenceYValue, double);
622  vtkGetMacro(ReferenceYValue, double);
624 
626  unsigned long GetMTime();
627 
630  void PrintAsCSV(ostream &os);
631 
632 //BTX
634 
640 
642  virtual int HasTranslucentPolygonalGeometry();
643 
645 
649 //ETX
651 
653 
654  void SetXTitlePosition(double position);
655  double GetXTitlePosition();
657 
659 
660  vtkSetMacro(YTitlePosition,int);
661  vtkGetMacro(YTitlePosition,int);
663  {
664  this->SetYTitlePosition( VTK_XYPLOT_Y_AXIS_TOP );
665  }
667  {
668  this->SetYTitlePosition( VTK_XYPLOT_Y_AXIS_HCENTER );
669  }
671  {
672  this->SetYTitlePosition( VTK_XYPLOT_Y_AXIS_VCENTER );
673  }
675 
677 
678  virtual void SetPlotGlyphType( int, int );
679  virtual void SetLineWidth( double );
680  virtual void AddUserCurvesPoint( double, double, double );
681  virtual void RemoveAllActiveCurves();
683 
685 
686  virtual void SetLegendBorder( int );
687  virtual void SetLegendBox( int );
688  virtual void SetLegendUseBackground( int );
689  virtual void SetLegendBackgroundColor( double, double, double );
691 
693 
694  virtual void SetTitleColor( double, double, double );
695  virtual void SetTitleFontFamily( int );
696  virtual void SetTitleBold( int );
697  virtual void SetTitleItalic( int );
698  virtual void SetTitleShadow( int );
699  virtual void SetTitleFontSize( int );
700  virtual void SetTitleJustification( int );
701  virtual void SetTitleVerticalJustification( int );
703 
705 
706  virtual void SetXAxisColor( double, double, double );
707  virtual void SetYAxisColor( double, double, double );
709 
711 
712  virtual void SetAxisTitleColor( double, double, double );
713  virtual void SetAxisTitleFontFamily( int );
714  virtual void SetAxisTitleBold( int );
715  virtual void SetAxisTitleItalic( int );
716  virtual void SetAxisTitleShadow( int );
717  virtual void SetAxisTitleFontSize( int );
718  virtual void SetAxisTitleJustification( int );
719  virtual void SetAxisTitleVerticalJustification( int );
721 
723 
724  virtual void SetAxisLabelColor( double, double, double );
725  virtual void SetAxisLabelFontFamily( int );
726  virtual void SetAxisLabelBold( int );
727  virtual void SetAxisLabelItalic( int );
728  virtual void SetAxisLabelShadow( int );
729  virtual void SetAxisLabelFontSize( int );
730  virtual void SetAxisLabelJustification( int );
731  virtual void SetAxisLabelVerticalJustification( int );
733 
734 protected:
735  vtkXYPlotActor();
736  ~vtkXYPlotActor();
737 
738  vtkXYPlotActorConnections* InputConnectionHolder;
739  char** SelectedInputScalars; // list of data set arrays to plot
741  vtkXYPlotActorConnections *DataObjectInputConnectionHolder; //list of data objects to plot
742  char* Title;
743  char* XTitle;
745  int XValues;
748  int Logx;
751  double XRange[2];
752  double YRange[2];
753  double XComputedRange[2]; //range actually used by plot
754  double YComputedRange[2]; //range actually used by plot
755  int Border;
766  double TitlePosition[2];
768 
772 
775 
778 
779  double ViewportCoordinate[2];
780  double PlotCoordinate[2];
781 
782  //Handle data objects and datasets
788 
789  //The data drawn within the axes. Each curve is one polydata.
790  //color is controlled by scalar data. The curves are appended
791  //together, possibly glyphed with point symbols.
798  void InitializeEntries();
799 
800  // Legends and plot symbols. The legend also keeps track of
801  // the symbols and such.
802  int Legend;
803  double LegendPosition[2];
804  double LegendPosition2[2];
808  double GlyphSize;
809 
810  // Background box
811  int ChartBox;
819 
820  // Reference lines
825 
829 
830  // Keep track of changes.
831  int CachedSize[2];
833 
834  void ComputeXRange(double range[2], double *lengths);
835  void ComputeYRange(double range[2]);
836  void ComputeDORange(double xrange[2], double yrange[2], double *lengths);
837 
838  virtual void CreatePlotData(int *pos, int *pos2, double xRange[2],
839  double yRange[2], double *norms,
840  int numDS, int numDO);
841  void PlaceAxes(vtkViewport *viewport, int *size, int pos[2], int pos2[2]);
842  void GenerateClipPlanes(int *pos, int *pos2);
843  double ComputeGlyphScale(int i, int *pos, int *pos2);
844  void ClipPlotData(int *pos, int *pos2, vtkPolyData *pd);
845  double *TransformPoint(int pos[2], int pos2[2], double x[3], double xNew[3]);
846 
847 //BTX
849 //ETX
853 
854 private:
855  vtkXYPlotActor(const vtkXYPlotActor&); // Not implemented.
856  void operator=(const vtkXYPlotActor&); // Not implemented.
857 
858  bool DoesConnectionMatch(int i, vtkAlgorithmOutput* in);
859 
860  int IsInputPresent(vtkAlgorithmOutput* in,
861  const char* arrayName,
862  int component);
863 
865  int YTitleSize[2];
866 
868  int YTitlePosition;
869 
871 
872  int YTitleDelta;
873 };
875 
876 
877 #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:38
virtual int RenderTranslucentPolygonalGeometry(vtkViewport *)
vtkXYPlotActorConnections * InputConnectionHolder
double ReferenceXValue
virtual void ReleaseGraphicsResources(vtkWindow *)
abstract specification for Viewports
Definition: vtkViewport.h:46
vtkPolyData ** PlotData
vtkPolyDataMapper2D * ReferenceLinesMapper
abstract class to specify dataset behavior
Definition: vtkDataSet.h:61
void AddDataSetInputConnection(vtkAlgorithmOutput *in)
vtkActor2D ** PlotActor
maintain an unordered list of data objects
a actor that draws 2D data
Definition: vtkActor2D.h:44
vtkAxisActor2D * GetXAxisActor2D()
record modification and/or execution time
Definition: vtkTimeStamp.h:34
vtkTextProperty * AxisTitleTextProperty
#define VTK_XYPLOT_Y_AXIS_TOP
implicit function for convex set of planes
Definition: vtkPlanes.h:53
Create an axis with tick marks and labels.
vtkIntArray * PointsOn
void SetPlotRange(double xmin, double ymin, double xmax, double ymax)
char ** SelectedInputScalars
#define VTK_XYPLOT_VALUE
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:83
#define VTK_XYPLOT_INDEX
vtkSmartPointer< vtkDoubleArray > ActiveCurve
vtkAxisActor2D * XAxis
vtkProperty2D * GetChartBoxProperty()
2D text annotation
Definition: vtkTextMapper.h:52
#define VTKRENDERINGANNOTATION_EXPORT
Proxy object to connect input/output ports.
vtkPolyData * ChartBorderPolyData
vtkTimeStamp BuildTime
dynamic, self-adjusting array of double
#define VTK_XYPLOT_Y_AXIS_HCENTER
window superclass for vtkRenderWindow
Definition: vtkWindow.h:36
vtkAxisActor2D * GetYAxisActor2D()
An actor that displays text. Scaled or unscaled.
Definition: vtkTextActor.h:54
#define VTK_XYPLOT_ARC_LENGTH
dynamic, self-adjusting array of int
Definition: vtkIntArray.h:49
vtkPolyDataMapper2D ** PlotMapper
vtkActor2D * ChartBoxActor
vtkIntArray * LinesOn
virtual unsigned long GetMTime()
vtkXYPlotActorConnections * DataObjectInputConnectionHolder
virtual int HasTranslucentPolygonalGeometry()
virtual int RenderOpaqueGeometry(vtkViewport *viewport)
a simple class to control print indentation
Definition: vtkIndent.h:38
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 AddDataSetInput(vtkDataSet *ds)
void SetNumberOfLabels(int num)
void SetXValuesToArcLength()
void SetXValuesToValue()
vtkTextProperty * TitleTextProperty
#define VTK_XYPLOT_ROW
vtkActor2D * ChartBorderActor
#define VTK_XYPLOT_NORMALIZED_ARC_LENGTH
void SetYTitlePositionToVCenter()
#define VTK_XYPLOT_COLUMN
void SetXValuesToNormalizedArcLength()
vtkIntArray * YComponent
void SetDataObjectPlotModeToRows()
vtkPlanes * ClipPlanes
vtkTextActor * YTitleActor
virtual int RenderOverlay(vtkViewport *viewport)
void SetYTitlePositionToHCenter()
represent surface properties of a 2D image
Definition: vtkProperty2D.h:39
create 2D glyphs represented by vtkPolyData
vtkPolyDataMapper2D * ChartBoxMapper
void SetXValuesToIndex()
void RemoveDataSetInputConnection(vtkAlgorithmOutput *in)
vtkIntArray * SelectedInputScalarsComponent
vtkPolyData * ReferenceLinesPolyData
vtkActor2D * ReferenceLinesActor
general representation of visualization data
Definition: vtkDataObject.h:64
void RemoveDataSetInput(vtkDataSet *ds)
double ReferenceYValue
draw vtkPolyData onto the image plane
vtkPolyData * ChartBoxPolyData
void SetDataObjectPlotModeToColumns()
#define VTK_XYPLOT_Y_AXIS_VCENTER
void SetYTitlePositionToTop()