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