VTK
vtkPlot.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: Visualization Toolkit
4 Module: vtkPlot.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
33#ifndef vtkPlot_h
34#define vtkPlot_h
35
36#include "vtkChartsCoreModule.h" // For export macro
37#include "vtkContextItem.h"
38#include "vtkStdString.h" // Needed to hold TooltipLabelFormat ivar
39#include "vtkSmartPointer.h" // Needed to hold SP ivars
40#include "vtkContextPolygon.h" // For vtkContextPolygon
41#include "vtkRect.h" // For vtkRectd ivar
42
43class vtkVariant;
44class vtkTable;
45class vtkIdTypeArray;
47class vtkPen;
48class vtkBrush;
49class vtkAxis;
50class vtkStringArray;
51
52class VTKCHARTSCORE_EXPORT vtkPlot : public vtkContextItem
53{
54public:
55 vtkTypeMacro(vtkPlot, vtkContextItem);
56 virtual void PrintSelf(ostream &os, vtkIndent indent);
57
59
64 vtkSetMacro(LegendVisibility, bool);
65 vtkGetMacro(LegendVisibility, bool);
66 vtkBooleanMacro(LegendVisibility, bool);
68
76 virtual bool PaintLegend(vtkContext2D *painter, const vtkRectf& rect,
77 int legendIndex);
78
80
92 virtual void SetTooltipLabelFormat(const vtkStdString &label);
95
97
100 virtual void SetTooltipNotation(int notation);
101 virtual int GetTooltipNotation();
103
105
108 virtual void SetTooltipPrecision(int precision);
109 virtual int GetTooltipPrecision();
111
117 vtkIdType seriesIndex,
118 vtkIdType segmentIndex);
119
126 const vtkVector2f& tolerance,
128
132 virtual bool SelectPoints(const vtkVector2f& min, const vtkVector2f& max);
133
137 virtual bool SelectPointsInPolygon(const vtkContextPolygon &polygon);
138
140
143 virtual void SetColor(unsigned char r, unsigned char g, unsigned char b,
144 unsigned char a);
145 virtual void SetColor(double r, double g, double b);
146 virtual void GetColor(double rgb[3]);
147 void GetColor(unsigned char rgb[3]);
149
153 virtual void SetWidth(float width);
154
158 virtual float GetWidth();
159
161
164 void SetPen(vtkPen *pen);
167
169
172 void SetBrush(vtkBrush *brush);
175
177
184
186
193
197 virtual void SetLabel(const vtkStdString &label);
198
203
208 virtual void SetLabels(vtkStringArray *labels);
209
215
219 virtual int GetNumberOfLabels();
220
225
232
237
242
244
248 vtkGetMacro(UseIndexForXSeries, bool);
250
252
256 vtkSetMacro(UseIndexForXSeries, bool);
258
260
264 virtual void SetInputData(vtkTable *table);
265 virtual void SetInputData(vtkTable *table, const vtkStdString &xColumn,
266 const vtkStdString &yColumn);
267 void SetInputData(vtkTable *table, vtkIdType xColumn, vtkIdType yColumn);
269
273 virtual vtkTable* GetInput();
274
280 virtual void SetInputArray(int index, const vtkStdString &name);
281
283
289 vtkSetMacro(Selectable,bool);
290 vtkGetMacro(Selectable,bool);
291 vtkBooleanMacro(Selectable,bool);
293
295
300 virtual void SetSelection(vtkIdTypeArray *id);
301 vtkGetObjectMacro(Selection, vtkIdTypeArray);
303
305
308 vtkGetObjectMacro(XAxis, vtkAxis);
309 virtual void SetXAxis(vtkAxis* axis);
311
313
316 vtkGetObjectMacro(YAxis, vtkAxis);
317 virtual void SetYAxis(vtkAxis* axis);
319
321
327 void SetShiftScale(const vtkRectd &scaling);
330
336 virtual void GetBounds(double bounds[4])
337 { bounds[0] = bounds[1] = bounds[2] = bounds[3] = 0.0; }
338
363 virtual void GetUnscaledInputBounds(double bounds[4])
364 {
365 // Implemented here by calling GetBounds() to support plot
366 // subclasses that do no log-scaling or plot orientation.
367 return this->GetBounds(bounds);
368 }
369
376 virtual void UpdateCache() {}
377
379
383 virtual void SetProperty(const vtkStdString &property, const vtkVariant &var);
384 virtual vtkVariant GetProperty(const vtkStdString &property);
386
387protected:
390
395
400
405
411
417
422
427
432
438
444
449
454
459
464
470
476
479
484
486
487private:
488 vtkPlot(const vtkPlot &) VTK_DELETE_FUNCTION;
489 void operator=(const vtkPlot &) VTK_DELETE_FUNCTION;
490
491};
492
493#endif //vtkPlot_h
takes care of drawing 2D axes
Definition: vtkAxis.h:72
provides a brush that fills shapes drawn by vtkContext2D.
Definition: vtkBrush.h:38
Class for drawing 2D primitives to a graphical context.
Definition: vtkContext2D.h:58
base class for items that are part of a vtkContextScene.
Abstract class for 2D context mappers.
dynamic, self-adjusting array of vtkIdType
a simple class to control print indentation
Definition: vtkIndent.h:40
provides a pen that draws the outlines of shapes drawn by vtkContext2D.
Definition: vtkPen.h:40
Abstract class for 2D plots.
Definition: vtkPlot.h:53
bool UseIndexForXSeries
Use the Y array index for the X value.
Definition: vtkPlot.h:437
virtual vtkStdString GetLabel()
Get the label of this plot.
virtual void UpdateCache()
Subclasses that build data caches to speed up painting should override this method to update such cac...
Definition: vtkPlot.h:376
virtual int GetTooltipPrecision()
virtual void GetColor(double rgb[3])
vtkContextMapper2D * GetData()
Get the data object that the plot will draw.
vtkRectd ShiftScale
The current shift in origin and scaling factor applied to the plot.
Definition: vtkPlot.h:483
virtual int GetTooltipNotation()
virtual vtkTable * GetInput()
Get the input table used by the plot.
void SetSelectionPen(vtkPen *pen)
Set/get the vtkBrush object that controls how this plot fills selected shapes.
int TooltipPrecision
Definition: vtkPlot.h:478
vtkSmartPointer< vtkStringArray > IndexedLabels
Holds Labels when they're auto-created.
Definition: vtkPlot.h:431
void SetIndexedLabels(vtkStringArray *labels)
Set indexed labels for the plot.
virtual void SetInputData(vtkTable *table, const vtkStdString &xColumn, const vtkStdString &yColumn)
virtual bool SelectPoints(const vtkVector2f &min, const vtkVector2f &max)
Select all points in the specified rectangle.
vtkAxis * XAxis
The X axis associated with this plot.
Definition: vtkPlot.h:458
virtual void PrintSelf(ostream &os, vtkIndent indent)
Methods invoked by print to print information about the object including superclasses.
virtual vtkStdString GetTooltipLabel(const vtkVector2d &plotPos, vtkIdType seriesIndex, vtkIdType segmentIndex)
Generate and return the tooltip label string for this plot The segmentIndex parameter is ignored,...
vtkPen * GetPen()
virtual void SetWidth(float width)
Set the width of the line.
virtual int GetNumberOfLabels()
Get the number of labels associated with this plot.
virtual vtkStdString GetTooltipLabelFormat()
virtual vtkVariant GetProperty(const vtkStdString &property)
virtual void SetInputData(vtkTable *table)
This is a convenience function to set the input table and the x, y column for the plot.
virtual void SetColor(unsigned char r, unsigned char g, unsigned char b, unsigned char a)
Set the plot color.
vtkStdString GetLabel(vtkIdType index)
Get the label at the specified index.
bool LegendVisibility
Definition: vtkPlot.h:485
virtual void SetInputArray(int index, const vtkStdString &name)
Convenience function to set the input arrays.
virtual void GetUnscaledInputBounds(double bounds[4])
Provide un-log-scaled bounds for the plot inputs.
Definition: vtkPlot.h:363
vtkPen * GetSelectionPen()
virtual vtkIdType GetNearestPoint(const vtkVector2f &point, const vtkVector2f &tolerance, vtkVector2f *location)
Function to query a plot for the nearest point to the specified coordinate.
void SetBrush(vtkBrush *brush)
Set/get the vtkBrush object that controls how this plot fills shapes.
vtkIdTypeArray * Selection
Selected indices for the table the plot is rendering.
Definition: vtkPlot.h:453
virtual vtkStringArray * GetLabels()
Get the plot labels.
virtual void SetLabel(const vtkStdString &label)
Set the label of this plot.
vtkSmartPointer< vtkBrush > SelectionBrush
This object stores the vtkBrush that controls how the selected elements of the plot are drawn.
Definition: vtkPlot.h:416
virtual void GetBounds(double bounds[4])
Get the bounds for this plot as (Xmin, Xmax, Ymin, Ymax).
Definition: vtkPlot.h:336
virtual void SetTooltipLabelFormat(const vtkStdString &label)
Sets/gets a printf-style string to build custom tooltip labels from.
virtual void SetXAxis(vtkAxis *axis)
vtkAxis * YAxis
The X axis associated with this plot.
Definition: vtkPlot.h:463
vtkStdString TooltipDefaultLabelFormat
The default printf-style string to build custom tooltip labels from.
Definition: vtkPlot.h:475
virtual void SetColor(double r, double g, double b)
vtkSmartPointer< vtkPen > SelectionPen
This object stores the vtkPen that controls how the selected elements of the plot are drawn.
Definition: vtkPlot.h:410
virtual bool PaintLegend(vtkContext2D *painter, const vtkRectf &rect, int legendIndex)
Paint legend event for the plot, called whenever the legend needs the plot items symbol/mark/line dra...
void SetSelectionBrush(vtkBrush *brush)
Set/get the vtkBrush object that controls how this plot fills selected shapes.
virtual void SetProperty(const vtkStdString &property, const vtkVariant &var)
A General setter/getter that should be overridden.
void GetColor(unsigned char rgb[3])
void SetPen(vtkPen *pen)
Set/get the vtkPen object that controls how this plot draws (out)lines.
vtkStdString TooltipLabelFormat
A printf-style string to build custom tooltip labels from.
Definition: vtkPlot.h:469
bool Selectable
Whether plot points can be selected or not.
Definition: vtkPlot.h:448
int TooltipNotation
Definition: vtkPlot.h:477
vtkRectd GetShiftScale()
virtual vtkStringArray * GetIndexedLabels()
Get the indexed labels array.
vtkSmartPointer< vtkContextMapper2D > Data
This data member contains the data that will be plotted, it inherits from vtkAlgorithm.
Definition: vtkPlot.h:443
void SetShiftScale(const vtkRectd &scaling)
Get/set the origin shift and scaling factor used by the plot, this is normally 0.0 offset and 1....
vtkSmartPointer< vtkStringArray > Labels
Plot labels, used by legend.
Definition: vtkPlot.h:421
void SetInputData(vtkTable *table, vtkIdType xColumn, vtkIdType yColumn)
virtual void SetTooltipPrecision(int precision)
Sets/gets the tooltip precision.
virtual void SetYAxis(vtkAxis *axis)
vtkBrush * GetSelectionBrush()
vtkSmartPointer< vtkStringArray > AutoLabels
Holds Labels when they're auto-created.
Definition: vtkPlot.h:426
vtkStdString GetNumber(double position, vtkAxis *axis)
Get the properly formatted number for the supplied position and axis.
vtkSmartPointer< vtkBrush > Brush
This object stores the vtkBrush that controls how the plot is drawn.
Definition: vtkPlot.h:404
virtual bool SelectPointsInPolygon(const vtkContextPolygon &polygon)
Select all points in the specified polygon.
vtkBrush * GetBrush()
virtual void SetSelection(vtkIdTypeArray *id)
Sets the list of points that must be selected.
vtkSmartPointer< vtkPen > Pen
This object stores the vtkPen that controls how the plot is drawn.
Definition: vtkPlot.h:399
virtual float GetWidth()
Get the width of the line.
virtual void SetLabels(vtkStringArray *labels)
Set the plot labels, these are used for stacked chart variants, with the index referring to the stack...
virtual void SetTooltipNotation(int notation)
Sets/gets the tooltip notation style.
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:49
a vtkAbstractArray subclass for strings
A table, which contains similar-typed columns of data.
Definition: vtkTable.h:69
A atomic type representing the union of many types.
Definition: vtkVariant.h:76
@ point
Definition: vtkX3D.h:236
@ location
Definition: vtkX3D.h:406
@ name
Definition: vtkX3D.h:219
@ position
Definition: vtkX3D.h:261
@ index
Definition: vtkX3D.h:246
vtkSetMacro(IgnoreDriverBugs, bool)
Updates the extensions string.
vtkBooleanMacro(IgnoreDriverBugs, bool)
Updates the extensions string.
int vtkIdType
Definition: vtkType.h:287
#define max(a, b)