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 =========================================================================*/ 15 // .NAME vtkXYPlotActor - generate an x-y plot from input dataset(s) or field data 16 // .SECTION Description 17 // vtkXYPlotActor creates an x-y plot of data from one or more input data 18 // sets or field data. The class plots dataset scalar values (y-axis) against 19 // the points (x-axis). The x-axis values are generated by taking the point 20 // ids, computing a cumulative arc length, or a normalized arc length. More 21 // than one input data set can be specified to generate multiple plots. 22 // Alternatively, if field data is supplied as input, the class plots one 23 // component against another. (The user must specify which component to use 24 // as the x-axis and which for the y-axis.) 25 // 26 // To use this class to plot dataset(s), you must specify one or more 27 // input datasets containing scalar and point data. You'll probably also 28 // want to invoke a method to control how the point coordinates are converted 29 // into x values (by default point ids are used). 30 // 31 // To use this class to plot field data, you must specify one or more input 32 // data objects with its associated field data. You'll also want to specify 33 // which component to use as the x-axis and which to use as the y-axis. 34 // Note that when plotting field data, the x and y values are used directly 35 // (i.e., there are no options to normalize the components). 36 // 37 // Once you've set up the plot, you'll want to position it. The 38 // PositionCoordinate defines the lower-left location of the x-y plot 39 // (specified in normalized viewport coordinates) and the Position2Coordinate 40 // define the upper-right corner. (Note: the Position2Coordinate is relative 41 // to PositionCoordinate, so you can move the vtkXYPlotActor around the 42 // viewport by setting just the PositionCoordinate.) The combination of the 43 // two position coordinates specifies a rectangle in which the plot will lie. 44 // 45 // Optional features include the ability to specify axes labels, label 46 // format and plot title. You can also 47 // manually specify the x and y plot ranges (by default they are computed 48 // automatically). The Border instance variable is used to create space 49 // between the boundary of the plot window (specified by PositionCoordinate 50 // and Position2Coordinate) and the plot itself. 51 // 52 // The font property of the plot title can be modified through the 53 // TitleTextProperty attribute. 54 // The font property of the axes titles and labels can be modified through the 55 // AxisTitleTextProperty and AxisLabelTextProperty attributes. You may also 56 // use the GetXAxisActor2D or GetYAxisActor2D methods 57 // to access each individual axis actor to modify their font properties. 58 // In the same way, the GetLegendBoxActor method can be used to access 59 // the legend box actor to modify its font properties. 60 // 61 // There are several advanced features as well. You can assign per curve 62 // properties (such as color and a plot symbol). (Note that each input 63 // dataset and/or data object creates a single curve.) Another option is to 64 // add a plot legend that graphically indicates the correspondance between 65 // the curve, curve symbols, and the data source. You can also exchange the 66 // x and y axes if you prefer you plot orientation that way. 67 68 // .SECTION Caveats 69 // If you are interested in plotting something other than scalar data, you 70 // can use the vtk data shuffling filters (e.g., 71 // vtkAttributeDataToFieldDataFilter and vtkFieldDataToAttributeDataFilter) 72 // to convert the data into scalar data and/or points. 73 74 // .SECTION Thanks 75 // This class was written by: 76 // Will Schroeder, Jim Miller, Charles Law, Sebastien Barre, Amy Squillacote, 77 // Ken Martin, Mathieu Malaterre, Jeff Lee, Francois Finet, Julien Bertel, 78 // Claire Guilbaud, and Philippe Pebay 79 80 // .SECTION See Also 81 // vtkActor2D vtkTextMapper vtkScalarBarActor vtkAxisActor2D vtkCubeAxesActor2D 82 // vtkAttributeDataToFieldDataFilter vtkFieldDataToAttributeDataFilter 83 // vtkTextProperty 84 85 #ifndef vtkXYPlotActor_h 86 #define vtkXYPlotActor_h 87 88 #define VTK_XYPLOT_INDEX 0 89 #define VTK_XYPLOT_ARC_LENGTH 1 90 #define VTK_XYPLOT_NORMALIZED_ARC_LENGTH 2 91 #define VTK_XYPLOT_VALUE 3 92 93 #define VTK_XYPLOT_ROW 0 94 #define VTK_XYPLOT_COLUMN 1 95 96 #define VTK_XYPLOT_Y_AXIS_TOP 0 97 #define VTK_XYPLOT_Y_AXIS_HCENTER 1 98 #define VTK_XYPLOT_Y_AXIS_VCENTER 2 // rotate by 90 degrees (y-axis aligned) 99 100 #include "vtkRenderingAnnotationModule.h" // For export macro 101 #include "vtkActor2D.h" 102 #include "vtkSmartPointer.h" // For SP 103 104 class vtkXYPlotActorConnections; 105 class vtkAlgorithmOutput; 106 class vtkAppendPolyData; 107 class vtkAxisActor2D; 108 class vtkDataObject; 109 class vtkDataObjectCollection; 110 class vtkDataSet; 111 class vtkDataSetCollection; 112 class vtkDoubleArray; 113 class vtkGlyph2D; 114 class vtkGlyphSource2D; 115 class vtkIntArray; 116 class vtkLegendBoxActor; 117 class vtkPlanes; 118 class vtkPolyData; 119 class vtkPolyDataMapper2D; 120 class vtkTextActor; 121 class vtkTextMapper; 122 class vtkTextProperty; 123 124 class VTKRENDERINGANNOTATION_EXPORT vtkXYPlotActor : public vtkActor2D 125 { 126 public: 127 vtkTypeMacro(vtkXYPlotActor,vtkActor2D); 128 void PrintSelf(ostream& os, vtkIndent indent); 129 130 // Description: 131 // Instantiate object with autorange computation; bold, italic, and shadows 132 // on; arial font family; the number of labels set to 5 for the x and y 133 // axes; a label format of "%-#6.3g"; and x coordinates computed from point 134 // ids. 135 static vtkXYPlotActor *New(); 136 137 //---Data Set Input---------------------------------------------------------- 138 // The following methods are used to plot input datasets. Datasets 139 // will be plotted if set as input; otherwise the input data objects 140 // will be plotted (if defined). 141 142 // Description: 143 // Add a dataset to the list of data to append. The array name specifies 144 // which point array to plot. The array must be a vtkDataArray subclass, i.e. 145 // a numeric array. If the array name is NULL, then the default 146 // scalars are used. The array can have multiple components, but only the 147 // first component is ploted. Note that AddInputDataSet() does not setup 148 // a pipeline connection whereas AddInputConnection() does. 149 void AddDataSetInput(vtkDataSet *ds, const char* arrayName, int component); AddDataSetInput(vtkDataSet * ds)150 void AddDataSetInput(vtkDataSet *ds) {this->AddDataSetInput(ds, NULL, 0);} 151 void AddDataSetInputConnection(vtkAlgorithmOutput *in, const char* arrayName, int component); AddDataSetInputConnection(vtkAlgorithmOutput * in)152 void AddDataSetInputConnection(vtkAlgorithmOutput *in) {this->AddDataSetInputConnection(in, NULL, 0);} 153 154 // Description: 155 // Remove a dataset from the list of data to append. 156 void RemoveDataSetInput(vtkDataSet *ds, const char* arrayName, int component); RemoveDataSetInput(vtkDataSet * ds)157 void RemoveDataSetInput(vtkDataSet *ds) {this->RemoveDataSetInput(ds, NULL, 0);} 158 void RemoveDataSetInputConnection(vtkAlgorithmOutput *in, const char* arrayName, int component); RemoveDataSetInputConnection(vtkAlgorithmOutput * in)159 void RemoveDataSetInputConnection(vtkAlgorithmOutput *in) 160 { 161 this->RemoveDataSetInputConnection(in, NULL, 0); 162 } 163 164 // Description: 165 // This removes all of the data set inputs, 166 // but does not change the data object inputs. 167 void RemoveAllDataSetInputConnections(); 168 169 // Description: 170 // If plotting points by value, which component to use to determine the 171 // value. This sets a value per each input dataset (i.e., the ith dataset). 172 void SetPointComponent(int i, int comp); 173 int GetPointComponent(int i); 174 //---end Data Set Input----------------------------------------------------- 175 176 // Description: 177 // Specify how the independent (x) variable is computed from the points. 178 // The independent variable can be the scalar/point index (i.e., point id), 179 // the accumulated arc length along the points, the normalized arc length, 180 // or by component value. If plotting datasets (e.g., points), the value 181 // that is used is specified by the PointComponent ivar. (Note: these 182 // methods also control how field data is plotted. Field data is usually 183 // plotted by value or index, if plotting length 1-dimensional length 184 // measures are used.) 185 vtkSetClampMacro(XValues,int,VTK_XYPLOT_INDEX,VTK_XYPLOT_VALUE); 186 vtkGetMacro(XValues,int); SetXValuesToIndex()187 void SetXValuesToIndex(){this->SetXValues(VTK_XYPLOT_INDEX);}; SetXValuesToArcLength()188 void SetXValuesToArcLength() {this->SetXValues(VTK_XYPLOT_ARC_LENGTH);}; SetXValuesToNormalizedArcLength()189 void SetXValuesToNormalizedArcLength() 190 {this->SetXValues(VTK_XYPLOT_NORMALIZED_ARC_LENGTH);}; SetXValuesToValue()191 void SetXValuesToValue() {this->SetXValues(VTK_XYPLOT_VALUE);}; 192 const char *GetXValuesAsString(); 193 194 //---Data Object Input------------------------------------------------------ 195 // The following methods are used to plot input data objects. Datasets will 196 // be plotted in preference to data objects if set as input; otherwise the 197 // input data objects will be plotted (if defined). 198 199 // Description: 200 // Add a data object to the list of data to display. 201 void AddDataObjectInput(vtkDataObject *in); 202 void AddDataObjectInputConnection(vtkAlgorithmOutput *alg); 203 204 // Description: 205 // Remove a dataset from the list of data to display. 206 void RemoveDataObjectInputConnection(vtkAlgorithmOutput *aout); 207 void RemoveDataObjectInput(vtkDataObject *in); 208 209 // Description: 210 // Indicate whether to plot rows or columns. If plotting rows, then 211 // the dependent variables is taken from a specified row, 212 // versus rows (y). 213 vtkSetClampMacro(DataObjectPlotMode,int,VTK_XYPLOT_ROW,VTK_XYPLOT_COLUMN); 214 vtkGetMacro(DataObjectPlotMode,int); SetDataObjectPlotModeToRows()215 void SetDataObjectPlotModeToRows() 216 {this->SetDataObjectPlotMode(VTK_XYPLOT_ROW);} SetDataObjectPlotModeToColumns()217 void SetDataObjectPlotModeToColumns() 218 {this->SetDataObjectPlotMode(VTK_XYPLOT_COLUMN);} 219 const char *GetDataObjectPlotModeAsString(); 220 221 // Description: 222 // Specify which component of the input data object to use as the 223 // independent variable for the ith input data object. (This ivar is 224 // ignored if plotting the index.) Note that the value is interpreted 225 // differently depending on DataObjectPlotMode. If the mode is Rows, then 226 // the value of DataObjectXComponent is the row number; otherwise it's the 227 // column number. 228 void SetDataObjectXComponent(int i, int comp); 229 int GetDataObjectXComponent(int i); 230 231 // Description: 232 // Specify which component of the input data object to use as the 233 // dependent variable for the ith input data object. (This ivar is 234 // ignored if plotting the index.) Note that the value is interpreted 235 // differently depending on DataObjectPlotMode. If the mode is Rows, then 236 // the value of DataObjectYComponent is the row number; otherwise it's the 237 // column number. 238 void SetDataObjectYComponent(int i, int comp); 239 int GetDataObjectYComponent(int i); 240 //---end Data Object Input-------------------------------------------------- 241 242 //---Per Curve Properties--------------------------------------------------- 243 // The following methods are used to set properties on each curve that is 244 // plotted. Each input dataset (or data object) results in one curve. The 245 // methods that follow have an index i that corresponds to the input dataset 246 // or data object. 247 void SetPlotColor(int i, double r, double g, double b); SetPlotColor(int i,const double color[3])248 void SetPlotColor(int i, const double color[3]) { 249 this->SetPlotColor(i, color[0], color[1], color[2]); }; 250 double *GetPlotColor(int i); 251 void SetPlotSymbol(int i,vtkPolyData *input); 252 vtkPolyData *GetPlotSymbol(int i); 253 void SetPlotLabel(int i, const char *label); 254 const char *GetPlotLabel(int i); 255 256 // Allow per-curve specification of line and point rendering. These override 257 // global settings PlotPoints and PlotLines. If not on, the default behavior 258 // is governed by PlotPoints and PlotLines ivars. 259 vtkGetMacro(PlotCurvePoints, int); 260 vtkSetMacro(PlotCurvePoints, int); 261 vtkBooleanMacro(PlotCurvePoints, int); 262 263 vtkGetMacro(PlotCurveLines, int); 264 vtkSetMacro(PlotCurveLines, int); 265 vtkBooleanMacro(PlotCurveLines, int); 266 267 void SetPlotLines(int i, int); 268 int GetPlotLines(int i); 269 270 void SetPlotPoints(int i, int); 271 int GetPlotPoints(int i); 272 //---end Per Curve Properties----------------------------------------------- 273 274 // Description: 275 // Enable/Disable exchange of the x-y axes (i.e., what was x becomes y, and 276 // vice-versa). Exchanging axes affects the labeling as well. 277 vtkSetMacro(ExchangeAxes, int); 278 vtkGetMacro(ExchangeAxes, int); 279 vtkBooleanMacro(ExchangeAxes, int); 280 281 // Description: 282 // Normally the x-axis is plotted from minimum to maximum. Setting this instance 283 // variable causes the x-axis to be plotted from maximum to minimum. Note that 284 // boolean always applies to the x-axis even if ExchangeAxes is set. 285 vtkSetMacro(ReverseXAxis, int); 286 vtkGetMacro(ReverseXAxis, int); 287 vtkBooleanMacro(ReverseXAxis, int); 288 289 // Description: 290 // Normally the y-axis is plotted from minimum to maximum. Setting this instance 291 // variable causes the y-axis to be plotted from maximum to minimum. Note that 292 // boolean always applies to the y-axis even if ExchangeAxes is set. 293 vtkSetMacro(ReverseYAxis, int); 294 vtkGetMacro(ReverseYAxis, int); 295 vtkBooleanMacro(ReverseYAxis, int); 296 297 // Description: 298 // Retrieve handles to the legend box and glyph source. This is useful 299 // if you would like to change the default behavior of the legend box 300 // or glyph source. For example, the default glyph can be changed from 301 // a line to a vertex plus line, etc.) 302 vtkGetObjectMacro(LegendActor,vtkLegendBoxActor); 303 vtkGetObjectMacro(GlyphSource,vtkGlyphSource2D); 304 305 // Description: 306 // Set/Get the title of the x-y plot. 307 vtkSetStringMacro(Title); 308 vtkGetStringMacro(Title); 309 310 // Description: 311 // Set/Get the title of the x axis 312 vtkSetStringMacro(XTitle); 313 vtkGetStringMacro(XTitle); 314 315 // Description: 316 // Set/Get the title of the y axis 317 virtual void SetYTitle( const char* ); 318 char* GetYTitle(); 319 320 // Description: 321 // Retrieve handles to the X and Y axis (so that you can set their text 322 // properties for example) GetXAxisActor2D()323 vtkAxisActor2D *GetXAxisActor2D() 324 { 325 return this->XAxis; 326 } GetYAxisActor2D()327 vtkAxisActor2D *GetYAxisActor2D() 328 { 329 return this->YAxis; 330 } 331 332 // Description: 333 // Set the plot range (range of independent and dependent variables) 334 // to plot. Data outside of the range will be clipped. If the plot 335 // range of either the x or y variables is set to (v1,v2), where 336 // v1 == v2, then the range will be computed automatically. Note that 337 // the x-range values should be consistent with the way the independent 338 // variable is created (via INDEX, DISTANCE, or ARC_LENGTH). 339 vtkSetVector2Macro(XRange,double); 340 vtkGetVectorMacro(XRange,double,2); 341 vtkSetVector2Macro(YRange,double); 342 vtkGetVectorMacro(YRange,double,2); SetPlotRange(double xmin,double ymin,double xmax,double ymax)343 void SetPlotRange(double xmin, double ymin, double xmax, double ymax) 344 {this->SetXRange(xmin,xmax); this->SetYRange(ymin,ymax);} 345 346 // Description: 347 // Set/Get the number of annotation labels to show along the x and y axes. 348 // This values is a suggestion: the number of labels may vary depending 349 // on the particulars of the data. The convenience method 350 // SetNumberOfLabels() sets the number of x and y labels to the same value. 351 vtkSetClampMacro(NumberOfXLabels, int, 0, 50); 352 vtkGetMacro(NumberOfXLabels, int); 353 vtkSetClampMacro(NumberOfYLabels, int, 0, 50); 354 vtkGetMacro(NumberOfYLabels, int); SetNumberOfLabels(int num)355 void SetNumberOfLabels(int num) 356 {this->SetNumberOfXLabels(num); this->SetNumberOfYLabels(num);} 357 358 // Description: 359 // Set/Get the flag that controls whether the labels and ticks are 360 // adjusted for "nice" numerical values to make it easier to read 361 // the labels. The adjustment is based in the Range instance variable. 362 // Call GetAdjustedRange and GetAdjustedNumberOfLabels to get the adjusted 363 // range and number of labels. 364 void SetAdjustXLabels(int adjust); 365 vtkGetMacro( AdjustXLabels, int ); 366 void SetAdjustYLabels(int adjust); 367 vtkGetMacro( AdjustYLabels, int ); 368 369 // Description: 370 // Set/Get the number of minor ticks in X or Y. 371 void SetNumberOfXMinorTicks(int num); 372 int GetNumberOfXMinorTicks(); 373 void SetNumberOfYMinorTicks(int num); 374 int GetNumberOfYMinorTicks(); 375 376 // Description: 377 // Enable/Disable the creation of a legend. If on, the legend labels will 378 // be created automatically unless the per plot legend symbol has been 379 // set. 380 vtkSetMacro(Legend, int); 381 vtkGetMacro(Legend, int); 382 vtkBooleanMacro(Legend, int); 383 384 // Description: 385 // Set/Get the position of the title. This has no effect if 386 // AdjustTitlePosition is true. 387 vtkSetVector2Macro(TitlePosition,double); 388 vtkGetVector2Macro(TitlePosition,double); 389 390 // Description: 391 // If true, the xyplot actor will adjust the position of the title 392 // automatically to be upper-middle. Default is true. 393 vtkSetMacro(AdjustTitlePosition, int); 394 vtkGetMacro(AdjustTitlePosition, int); 395 vtkBooleanMacro(AdjustTitlePosition, int); 396 397 //BTX 398 enum Alignment { 399 AlignLeft = 0x1, 400 AlignRight = 0x2, 401 AlignHCenter = 0x4, 402 AlignTop = 0x10, 403 AlignBottom = 0x20, 404 AlignVCenter = 0x40, 405 AlignAxisLeft = 0x100, 406 AlignAxisRight = 0x200, 407 AlignAxisHCenter = 0x400, 408 AlignAxisTop = 0x1000, 409 AlignAxisBottom = 0x2000, 410 AlignAxisVCenter = 0x4000 411 }; 412 //ETX 413 // Description: 414 // If AdjustTitlePosition is true, the xyplot actor will 415 // adjust the position of the title automatically depending on the 416 // given mode, the mode is a combination of the Alignment flags. 417 // by default: vtkXYPlotActor::AlignHCenter | vtkXYPlotActor::Top 418 // | vtkXYPlotActor::AlignAxisVCenter 419 vtkSetMacro(AdjustTitlePositionMode, int); 420 vtkGetMacro(AdjustTitlePositionMode, int); 421 422 // Description: 423 // Use these methods to control the position of the legend. The variables 424 // LegendPosition and LegendPosition2 define the lower-left and upper-right 425 // position of the legend. The coordinates are expressed as normalized 426 // values with respect to the rectangle defined by PositionCoordinate and 427 // Position2Coordinate. Note that LegendPosition2 is relative to 428 // LegendPosition. 429 vtkSetVector2Macro(LegendPosition,double); 430 vtkGetVector2Macro(LegendPosition,double); 431 vtkSetVector2Macro(LegendPosition2,double); 432 vtkGetVector2Macro(LegendPosition2,double); 433 434 // Description: 435 // Set/Get the title text property. 436 virtual void SetTitleTextProperty(vtkTextProperty *p); 437 vtkGetObjectMacro(TitleTextProperty,vtkTextProperty); 438 439 // Description: 440 // Set/Get the title text property of all axes. Note that each axis can 441 // be controlled individually through the GetX/YAxisActor2D() methods. 442 virtual void SetAxisTitleTextProperty(vtkTextProperty *p); 443 vtkGetObjectMacro(AxisTitleTextProperty,vtkTextProperty); 444 445 // Description: 446 // Set/Get the labels text property of all axes. Note that each axis can 447 // be controlled individually through the GetX/YAxisActor2D() methods. 448 virtual void SetAxisLabelTextProperty(vtkTextProperty *p); 449 vtkGetObjectMacro(AxisLabelTextProperty,vtkTextProperty); 450 451 // Description: 452 // Enable/Disable plotting of Log of x-values. 453 vtkSetMacro(Logx, int); 454 vtkGetMacro(Logx, int); 455 vtkBooleanMacro(Logx, int); 456 457 // Description: 458 // Set/Get the format with which to print the labels . This sets both X 459 // and Y label formats. GetLabelFormat() returns X label format. 460 virtual void SetLabelFormat ( const char* ); GetLabelFormat()461 const char* GetLabelFormat() 462 { 463 return this->GetXLabelFormat(); 464 } 465 466 // Description: 467 // Set/Get the format with which to print the X label. 468 virtual void SetXLabelFormat ( const char* ); 469 vtkGetStringMacro(XLabelFormat); 470 471 // Description: 472 // Set/Get the format with which to print the Y label. 473 virtual void SetYLabelFormat ( const char* ); 474 vtkGetStringMacro(YLabelFormat); 475 476 // Description: 477 // Set/Get the spacing between the plot window and the plot. The value 478 // is specified in pixels. 479 vtkSetClampMacro(Border, int, 0, 50); 480 vtkGetMacro(Border, int); 481 482 // Description: 483 // Set/Get whether the points are rendered. The point size can be set in 484 // the property object. This is a global flag which affects the plot only 485 // if per curve symbols are not defined. 486 vtkGetMacro(PlotPoints, int); 487 vtkSetMacro(PlotPoints, int); 488 vtkBooleanMacro(PlotPoints, int); 489 490 // Description: 491 // Set/Get whether the lines are rendered. The line width can be set in 492 // the property object. 493 vtkGetMacro(PlotLines, int); 494 vtkSetMacro(PlotLines, int); 495 vtkBooleanMacro(PlotLines, int); 496 497 // Description: 498 // Set/Get the factor that controls how big glyphs are in the plot. 499 // The number is expressed as a fraction of the length of the diagonal 500 // of the plot bounding box. 501 vtkSetClampMacro(GlyphSize, double, 0.0, 0.2); 502 vtkGetMacro(GlyphSize, double); 503 504 // Description: 505 // Given a position within the viewport used by the plot, return the 506 // the plot coordinates (XAxis value, YAxis value) 507 void ViewportToPlotCoordinate(vtkViewport *viewport, double &u, double &v); 508 509 // Description: 510 // An alternate form of ViewportToPlotCoordinate() above. This method 511 // inputs the viewport coordinate pair (defined by the ivar 512 // ViewportCoordinate)and then stores them in the ivar PlotCoordinate. 513 void ViewportToPlotCoordinate(vtkViewport *viewport); 514 vtkSetVector2Macro(PlotCoordinate,double); 515 vtkGetVector2Macro(PlotCoordinate,double); 516 517 // Description: 518 // Given a plot coordinate, return the viewpoint position 519 void PlotToViewportCoordinate(vtkViewport *viewport, double &u, double &v); 520 521 // Description: 522 // An alternate form of PlotToViewportCoordinate() above. This method 523 // inputs the plot coordinate pair (defined in the ivar PlotCoordinate) 524 // and then stores them in the ivar ViewportCoordinate. (This method 525 // can be wrapped.) 526 void PlotToViewportCoordinate(vtkViewport *viewport); 527 vtkSetVector2Macro(ViewportCoordinate,double); 528 vtkGetVector2Macro(ViewportCoordinate,double); 529 530 // Description: 531 // Is the specified viewport position within the plot area (as opposed to the 532 // region used by the plot plus the labels)? 533 int IsInPlot(vtkViewport *viewport, double u, double v); 534 535 // Description: 536 // Set/Get the flag that controls whether a box will be drawn/filled 537 // corresponding to the chart box. 538 vtkSetMacro(ChartBox, int); 539 vtkGetMacro(ChartBox, int); 540 vtkBooleanMacro(ChartBox, int); 541 542 // Description: 543 // Set/Get the flag that controls whether a box will be drawn/filled 544 // corresponding to the legend box. 545 vtkSetMacro(ChartBorder, int); 546 vtkGetMacro(ChartBorder, int); 547 vtkBooleanMacro(ChartBorder, int); 548 549 // Description: 550 // Get the box vtkProperty2D. GetChartBoxProperty()551 vtkProperty2D* GetChartBoxProperty() { return this->ChartBoxActor->GetProperty(); }; 552 553 // Description: 554 // Set/Get if the X reference line is visible. hidden by default 555 vtkSetMacro(ShowReferenceXLine, int); 556 vtkGetMacro(ShowReferenceXLine, int); 557 vtkBooleanMacro(ShowReferenceXLine, int); 558 559 // Description 560 // Set/Get the value for the X reference line 561 vtkSetMacro(ReferenceXValue, double); 562 vtkGetMacro(ReferenceXValue, double); 563 564 // Description: 565 // Set/Get if the Y reference line is visible. hidden by default 566 vtkSetMacro(ShowReferenceYLine, int); 567 vtkGetMacro(ShowReferenceYLine, int); 568 vtkBooleanMacro(ShowReferenceYLine, int); 569 570 // Description 571 // Set/Get the value for the Y reference line 572 vtkSetMacro(ReferenceYValue, double); 573 vtkGetMacro(ReferenceYValue, double); 574 575 // Description: 576 // Take into account the modified time of internal helper classes. 577 unsigned long GetMTime(); 578 579 // Description: 580 // Write the XY Ploat Actor as a CSV (comma separated value) representation. 581 void PrintAsCSV(ostream &os); 582 583 //BTX 584 // Description: 585 // WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE 586 // DO NOT USE THIS METHOD OUTSIDE OF THE RENDERING PROCESS. 587 // Draw the x-y plot. 588 int RenderOpaqueGeometry(vtkViewport*); 589 int RenderOverlay(vtkViewport*); RenderTranslucentPolygonalGeometry(vtkViewport *)590 virtual int RenderTranslucentPolygonalGeometry(vtkViewport *) {return 0;} 591 592 // Description: 593 // Does this prop have some translucent polygonal geometry? 594 virtual int HasTranslucentPolygonalGeometry(); 595 596 // Description: 597 // Release any graphics resources that are being consumed by this actor. 598 // The parameter window could be used to determine which graphic 599 // resources to release. 600 void ReleaseGraphicsResources(vtkWindow *); 601 //ETX 602 603 // Description: 604 // Set/Get the position of the title of X axis. 605 void SetXTitlePosition(double position); 606 double GetXTitlePosition(); 607 608 // Description: 609 // Set/Get the position of the title of Y axis. 610 vtkSetMacro(YTitlePosition,int); 611 vtkGetMacro(YTitlePosition,int); SetYTitlePositionToTop()612 void SetYTitlePositionToTop() 613 { 614 this->SetYTitlePosition( VTK_XYPLOT_Y_AXIS_TOP ); 615 } SetYTitlePositionToHCenter()616 void SetYTitlePositionToHCenter() 617 { 618 this->SetYTitlePosition( VTK_XYPLOT_Y_AXIS_HCENTER ); 619 } SetYTitlePositionToVCenter()620 void SetYTitlePositionToVCenter() 621 { 622 this->SetYTitlePosition( VTK_XYPLOT_Y_AXIS_VCENTER ); 623 } 624 625 // Description: 626 // Set plot properties 627 virtual void SetPlotGlyphType( int, int ); 628 virtual void SetLineWidth( double ); 629 virtual void AddUserCurvesPoint( double, double, double ); 630 virtual void RemoveAllActiveCurves(); 631 632 // Description: 633 // Set legend properties 634 virtual void SetLegendBorder( int ); 635 virtual void SetLegendBox( int ); 636 virtual void SetLegendUseBackground( int ); 637 virtual void SetLegendBackgroundColor( double, double, double ); 638 639 // Description: 640 // Set title properties 641 virtual void SetTitleColor( double, double, double ); 642 virtual void SetTitleFontFamily( int ); 643 virtual void SetTitleBold( int ); 644 virtual void SetTitleItalic( int ); 645 virtual void SetTitleShadow( int ); 646 virtual void SetTitleFontSize( int ); 647 virtual void SetTitleJustification( int ); 648 virtual void SetTitleVerticalJustification( int ); 649 650 // Description: 651 // Set axes properties 652 virtual void SetXAxisColor( double, double, double ); 653 virtual void SetYAxisColor( double, double, double ); 654 655 // Description: 656 // Set axis title properties 657 virtual void SetAxisTitleColor( double, double, double ); 658 virtual void SetAxisTitleFontFamily( int ); 659 virtual void SetAxisTitleBold( int ); 660 virtual void SetAxisTitleItalic( int ); 661 virtual void SetAxisTitleShadow( int ); 662 virtual void SetAxisTitleFontSize( int ); 663 virtual void SetAxisTitleJustification( int ); 664 virtual void SetAxisTitleVerticalJustification( int ); 665 666 // Description: 667 // Set axis label properties 668 virtual void SetAxisLabelColor( double, double, double ); 669 virtual void SetAxisLabelFontFamily( int ); 670 virtual void SetAxisLabelBold( int ); 671 virtual void SetAxisLabelItalic( int ); 672 virtual void SetAxisLabelShadow( int ); 673 virtual void SetAxisLabelFontSize( int ); 674 virtual void SetAxisLabelJustification( int ); 675 virtual void SetAxisLabelVerticalJustification( int ); 676 677 protected: 678 vtkXYPlotActor(); 679 ~vtkXYPlotActor(); 680 681 vtkXYPlotActorConnections* InputConnectionHolder; 682 char** SelectedInputScalars; // list of data set arrays to plot 683 vtkIntArray* SelectedInputScalarsComponent; // list of components 684 vtkXYPlotActorConnections *DataObjectInputConnectionHolder; //list of data objects to plot 685 char* Title; 686 char* XTitle; 687 vtkTextActor* YTitleActor; 688 int XValues; 689 int NumberOfXLabels; 690 int NumberOfYLabels; 691 int Logx; 692 char* XLabelFormat; 693 char* YLabelFormat; 694 double XRange[2]; 695 double YRange[2]; 696 double XComputedRange[2]; //range actually used by plot 697 double YComputedRange[2]; //range actually used by plot 698 int Border; 699 int PlotLines; 700 int PlotPoints; 701 int PlotCurveLines; 702 int PlotCurvePoints; 703 int ExchangeAxes; 704 int ReverseXAxis; 705 int ReverseYAxis; 706 int AdjustXLabels; 707 int AdjustYLabels; 708 int AdjustTitlePosition; 709 double TitlePosition[2]; 710 int AdjustTitlePositionMode; 711 712 vtkTextMapper* TitleMapper; 713 vtkActor2D* TitleActor; 714 vtkTextProperty* TitleTextProperty; 715 716 vtkAxisActor2D* XAxis; 717 vtkAxisActor2D* YAxis; 718 719 vtkTextProperty* AxisTitleTextProperty; 720 vtkTextProperty* AxisLabelTextProperty; 721 722 double ViewportCoordinate[2]; 723 double PlotCoordinate[2]; 724 725 //Handle data objects and datasets 726 int DataObjectPlotMode; 727 vtkIntArray* XComponent; 728 vtkIntArray* YComponent; 729 vtkIntArray* LinesOn; 730 vtkIntArray* PointsOn; 731 732 //The data drawn within the axes. Each curve is one polydata. 733 //color is controlled by scalar data. The curves are appended 734 //together, possibly glyphed with point symbols. 735 int NumberOfInputs; 736 vtkPolyData **PlotData; 737 vtkGlyph2D **PlotGlyph; 738 vtkAppendPolyData **PlotAppend; 739 vtkPolyDataMapper2D **PlotMapper; 740 vtkActor2D **PlotActor; 741 void InitializeEntries(); 742 743 // Legends and plot symbols. The legend also keeps track of 744 // the symbols and such. 745 int Legend; 746 double LegendPosition[2]; 747 double LegendPosition2[2]; 748 vtkLegendBoxActor *LegendActor; 749 vtkGlyphSource2D *GlyphSource; 750 vtkPlanes *ClipPlanes; 751 double GlyphSize; 752 753 // Background box 754 int ChartBox; 755 vtkPolyData *ChartBoxPolyData; 756 vtkPolyDataMapper2D *ChartBoxMapper; 757 vtkActor2D *ChartBoxActor; 758 int ChartBorder; 759 vtkPolyData *ChartBorderPolyData; 760 vtkPolyDataMapper2D *ChartBorderMapper; 761 vtkActor2D *ChartBorderActor; 762 763 // Reference lines 764 int ShowReferenceXLine; 765 int ShowReferenceYLine; 766 double ReferenceXValue; 767 double ReferenceYValue; 768 769 vtkPolyData *ReferenceLinesPolyData; 770 vtkPolyDataMapper2D *ReferenceLinesMapper; 771 vtkActor2D *ReferenceLinesActor; 772 773 // Keep track of changes. 774 int CachedSize[2]; 775 vtkTimeStamp BuildTime; 776 777 void ComputeXRange(double range[2], double *lengths); 778 void ComputeYRange(double range[2]); 779 void ComputeDORange(double xrange[2], double yrange[2], double *lengths); 780 781 virtual void CreatePlotData(int *pos, int *pos2, double xRange[2], 782 double yRange[2], double *norms, 783 int numDS, int numDO); 784 void PlaceAxes(vtkViewport *viewport, int *size, int pos[2], int pos2[2]); 785 void GenerateClipPlanes(int *pos, int *pos2); 786 double ComputeGlyphScale(int i, int *pos, int *pos2); 787 void ClipPlotData(int *pos, int *pos2, vtkPolyData *pd); 788 double *TransformPoint(int pos[2], int pos2[2], double x[3], double xNew[3]); 789 790 //BTX 791 vtkSmartPointer<vtkDoubleArray> ActiveCurve; 792 //ETX 793 int YAxisTitleSize; 794 int ActiveCurveIndex; 795 int PlotColorIndex; 796 797 private: 798 vtkXYPlotActor(const vtkXYPlotActor&); // Not implemented. 799 void operator=(const vtkXYPlotActor&); // Not implemented. 800 801 bool DoesConnectionMatch(int i, vtkAlgorithmOutput* in); 802 803 int IsInputPresent(vtkAlgorithmOutput* in, 804 const char* arrayName, 805 int component); 806 807 // Description: 808 // Estimated sizes of Y axis title 809 int YTitleSize[2]; 810 811 // Description: 812 // Position and orientation of Y axis title 813 int YTitlePosition; 814 815 // Description: 816 // Estimated size of Y axis spacing 817 int YTitleDelta; 818 }; 819 820 821 #endif 822