VTK  9.1.0
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
36#ifndef vtkPlot_h
37#define vtkPlot_h
38
39#include "vtkChartsCoreModule.h" // For export macro
40#include "vtkContextItem.h"
41#include "vtkContextPolygon.h" // For vtkContextPolygon
42#include "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_0_0
43#include "vtkRect.h" // For vtkRectd ivar
44#include "vtkSmartPointer.h" // Needed to hold SP ivars
45#include "vtkStdString.h" // Needed to hold TooltipLabelFormat ivar
46
47class vtkVariant;
48class vtkTable;
49class vtkIdTypeArray;
51class vtkPen;
52class vtkBrush;
53class vtkAxis;
54class vtkStringArray;
55
56class VTKCHARTSCORE_EXPORT vtkPlot : public vtkContextItem
57{
58public:
59 vtkTypeMacro(vtkPlot, vtkContextItem);
60 void PrintSelf(ostream& os, vtkIndent indent) override;
61
63
68 vtkSetMacro(LegendVisibility, bool);
69 vtkGetMacro(LegendVisibility, bool);
70 vtkBooleanMacro(LegendVisibility, bool);
72
80 virtual bool PaintLegend(vtkContext2D* painter, const vtkRectf& rect, int legendIndex);
81
83
95 virtual void SetTooltipLabelFormat(const vtkStdString& label);
98
100
103 virtual void SetTooltipNotation(int notation);
104 virtual int GetTooltipNotation();
106
108
111 virtual void SetTooltipPrecision(int precision);
112 virtual int GetTooltipPrecision();
114
120 const vtkVector2d& plotPos, vtkIdType seriesIndex, vtkIdType segmentIndex);
121
127 virtual vtkIdType GetNearestPoint(const vtkVector2f& point, const vtkVector2f& tolerance,
128 vtkVector2f* location, vtkIdType* segmentId);
129
137 VTK_DEPRECATED_IN_9_0_0("Use the vtkPlot::GetNearestPoint() overload with a segmentId argument")
138 virtual vtkIdType GetNearestPoint(
139 const vtkVector2f& point, const vtkVector2f& tolerance, vtkVector2f* location);
140
144 virtual bool SelectPoints(const vtkVector2f& min, const vtkVector2f& max);
145
149 virtual bool SelectPointsInPolygon(const vtkContextPolygon& polygon);
150
152
155 virtual void SetColor(unsigned char r, unsigned char g, unsigned char b, unsigned char a);
156 virtual void SetColor(double r, double g, double b);
157 virtual void GetColor(double rgb[3]);
158 void GetColor(unsigned char rgb[3]);
160
164 virtual void SetWidth(float width);
165
169 virtual float GetWidth();
170
172
175 void SetPen(vtkPen* pen);
176 vtkPen* GetPen();
178
180
183 void SetBrush(vtkBrush* brush);
184 vtkBrush* GetBrush();
186
188
192 void SetSelectionPen(vtkPen* pen);
193 vtkPen* GetSelectionPen();
195
197
201 void SetSelectionBrush(vtkBrush* brush);
202 vtkBrush* GetSelectionBrush();
204
208 virtual void SetLabel(const vtkStdString& label);
209
213 virtual vtkStdString GetLabel();
214
219 virtual void SetLabels(vtkStringArray* labels);
220
225 virtual vtkStringArray* GetLabels();
226
230 virtual int GetNumberOfLabels();
231
236
242 void SetIndexedLabels(vtkStringArray* labels);
243
247 virtual vtkStringArray* GetIndexedLabels();
248
253
255
259 vtkGetMacro(UseIndexForXSeries, bool);
261
263
267 vtkSetMacro(UseIndexForXSeries, bool);
269
271
275 virtual void SetInputData(vtkTable* table);
276 virtual void SetInputData(
277 vtkTable* table, const vtkStdString& xColumn, const vtkStdString& yColumn);
278 void SetInputData(vtkTable* table, vtkIdType xColumn, vtkIdType yColumn);
280
284 virtual vtkTable* GetInput();
285
291 virtual void SetInputArray(int index, const vtkStdString& name);
292
294
300 vtkSetMacro(Selectable, bool);
301 vtkGetMacro(Selectable, bool);
302 vtkBooleanMacro(Selectable, bool);
304
306
311 virtual void SetSelection(vtkIdTypeArray* id);
312 vtkGetObjectMacro(Selection, vtkIdTypeArray);
314
316
319 vtkGetObjectMacro(XAxis, vtkAxis);
320 virtual void SetXAxis(vtkAxis* axis);
322
324
327 vtkGetObjectMacro(YAxis, vtkAxis);
328 virtual void SetYAxis(vtkAxis* axis);
330
332
338 void SetShiftScale(const vtkRectd& shiftScale);
339 vtkRectd GetShiftScale();
341
347 virtual void GetBounds(double bounds[4]) { bounds[0] = bounds[1] = bounds[2] = bounds[3] = 0.0; }
348
373 virtual void GetUnscaledInputBounds(double bounds[4])
374 {
375 // Implemented here by calling GetBounds() to support plot
376 // subclasses that do no log-scaling or plot orientation.
377 return this->GetBounds(bounds);
378 }
379
386 virtual void UpdateCache() {}
387
389
393 virtual void SetProperty(const vtkStdString& property, const vtkVariant& var);
394 virtual vtkVariant GetProperty(const vtkStdString& property);
396
398
402 static bool ClampPos(double pos[2], double bounds[4]);
403 virtual bool ClampPos(double pos[2]);
405
409 bool Hit(const vtkContextMouseEvent& mouse) override;
410
411protected:
413 ~vtkPlot() override;
414
419
421
425 virtual void TransformScreenToData(const vtkVector2f& in, vtkVector2f& out);
426 virtual void TransformDataToScreen(const vtkVector2f& in, vtkVector2f& out);
428 const double inX, const double inY, double& outX, double& outY);
430 const double inX, const double inY, double& outX, double& outY);
432
437
442
448
454
459
464
469
475
481
486
491
496
501
507
513
516
521
523
528 // VTK_DEPRECATED_IN_9_0_0("used to track deprecation integration logic")
529 bool LegacyRecursionFlag = false;
530
531private:
532 vtkPlot(const vtkPlot&) = delete;
533 void operator=(const vtkPlot&) = delete;
534};
535
536#endif // vtkPlot_h
takes care of drawing 2D axes
Definition: vtkAxis.h:78
provides a brush that fills shapes drawn by vtkContext2D.
Definition: vtkBrush.h:47
Class for drawing 2D primitives to a graphical context.
Definition: vtkContext2D.h:63
base class for items that are part of a vtkContextScene.
Abstract class for 2D context mappers.
data structure to represent mouse events.
dynamic, self-adjusting array of vtkIdType
a simple class to control print indentation
Definition: vtkIndent.h:43
provides a pen that draws the outlines of shapes drawn by vtkContext2D.
Definition: vtkPen.h:46
Abstract class for 2D plots.
Definition: vtkPlot.h:57
bool UseIndexForXSeries
Use the Y array index for the X value.
Definition: vtkPlot.h:474
virtual void UpdateCache()
Subclasses that build data caches to speed up painting should override this method to update such cac...
Definition: vtkPlot.h:386
virtual int GetTooltipPrecision()
Sets/gets the tooltip precision.
vtkRectd ShiftScale
The current shift in origin and scaling factor applied to the plot.
Definition: vtkPlot.h:520
virtual int GetTooltipNotation()
Sets/gets the tooltip notation style.
int TooltipPrecision
Definition: vtkPlot.h:515
vtkSmartPointer< vtkStringArray > IndexedLabels
Holds Labels when they're auto-created.
Definition: vtkPlot.h:468
vtkAxis * XAxis
The X axis associated with this plot.
Definition: vtkPlot.h:495
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,...
~vtkPlot() override
virtual vtkStdString GetTooltipLabelFormat()
Sets/gets a printf-style string to build custom tooltip labels from.
virtual vtkVariant GetProperty(const vtkStdString &property)
A General setter/getter that should be overridden.
bool LegendVisibility
Definition: vtkPlot.h:522
virtual void GetUnscaledInputBounds(double bounds[4])
Provide un-log-scaled bounds for the plot inputs.
Definition: vtkPlot.h:373
vtkIdTypeArray * Selection
Selected indices for the table the plot is rendering.
Definition: vtkPlot.h:490
vtkSmartPointer< vtkBrush > SelectionBrush
This object stores the vtkBrush that controls how the selected elements of the plot are drawn.
Definition: vtkPlot.h:453
virtual void SetTooltipLabelFormat(const vtkStdString &label)
Sets/gets a printf-style string to build custom tooltip labels from.
vtkAxis * YAxis
The X axis associated with this plot.
Definition: vtkPlot.h:500
vtkStdString TooltipDefaultLabelFormat
The default printf-style string to build custom tooltip labels from.
Definition: vtkPlot.h:512
vtkSmartPointer< vtkPen > SelectionPen
This object stores the vtkPen that controls how the selected elements of the plot are drawn.
Definition: vtkPlot.h:447
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...
virtual void SetProperty(const vtkStdString &property, const vtkVariant &var)
A General setter/getter that should be overridden.
vtkStdString TooltipLabelFormat
A printf-style string to build custom tooltip labels from.
Definition: vtkPlot.h:506
bool Selectable
Whether plot points can be selected or not.
Definition: vtkPlot.h:485
int TooltipNotation
Definition: vtkPlot.h:514
vtkSmartPointer< vtkContextMapper2D > Data
This data member contains the data that will be plotted, it inherits from vtkAlgorithm.
Definition: vtkPlot.h:480
vtkSmartPointer< vtkStringArray > Labels
Plot labels, used by legend.
Definition: vtkPlot.h:458
virtual void SetTooltipPrecision(int precision)
Sets/gets the tooltip precision.
static bool ClampPos(double pos[2], double bounds[4])
Clamp the given 2D pos into the provided bounds Return true if the pos has been clamped,...
virtual void TransformScreenToData(const vtkVector2f &in, vtkVector2f &out)
Transform the mouse event in the control-points space.
bool Hit(const vtkContextMouseEvent &mouse) override
Returns true if the supplied x, y coordinate is inside the item.
virtual void TransformDataToScreen(const double inX, const double inY, double &outX, double &outY)
Transform the mouse event in the control-points space.
virtual vtkIdType GetNearestPoint(const vtkVector2f &point, const vtkVector2f &tolerance, vtkVector2f *location, vtkIdType *segmentId)
Function to query a plot for the nearest point to the specified coordinate.
vtkSmartPointer< vtkStringArray > AutoLabels
Holds Labels when they're auto-created.
Definition: vtkPlot.h:463
virtual void TransformDataToScreen(const vtkVector2f &in, vtkVector2f &out)
Transform the mouse event in the control-points space.
virtual bool ClampPos(double pos[2])
Clamp the given 2D pos into the provided bounds Return true if the pos has been clamped,...
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:441
vtkSmartPointer< vtkPen > Pen
This object stores the vtkPen that controls how the plot is drawn.
Definition: vtkPlot.h:436
virtual void TransformScreenToData(const double inX, const double inY, double &outX, double &outY)
Transform the mouse event in the control-points space.
virtual void SetTooltipNotation(int notation)
Sets/gets the tooltip notation style.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:45
a vtkAbstractArray subclass for strings
A table, which contains similar-typed columns of data.
Definition: vtkTable.h:72
A atomic type representing the union of many types.
Definition: vtkVariant.h:75
void GetBounds(T a, double bds[6])
vtkSmartPointer< vtkDataArray > GetData(const Ioss::GroupingEntity *entity, const std::string &fieldname, Ioss::Transform *transform=nullptr, Cache *cache=nullptr, const std::string &cachekey=std::string())
Returns a VTK array for a given field (fieldname) on the chosen block (or set) entity.
@ point
Definition: vtkX3D.h:242
@ location
Definition: vtkX3D.h:412
@ name
Definition: vtkX3D.h:225
@ position
Definition: vtkX3D.h:267
@ index
Definition: vtkX3D.h:252
#define VTK_DEPRECATED_IN_9_0_0(reason)
int vtkIdType
Definition: vtkType.h:332
#define max(a, b)