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 
27 #ifndef vtkPlot_h
28 #define vtkPlot_h
29 
30 #include "vtkChartsCoreModule.h" // For export macro
31 #include "vtkContextItem.h"
32 #include "vtkStdString.h" // Needed to hold TooltipLabelFormat ivar
33 #include "vtkSmartPointer.h" // Needed to hold SP ivars
34 #include "vtkContextPolygon.h" // For vtkContextPolygon
35 #include "vtkRect.h" // For vtkRectd ivar
36 
37 class vtkVariant;
38 class vtkTable;
39 class vtkIdTypeArray;
40 class vtkContextMapper2D;
41 class vtkPen;
42 class vtkBrush;
43 class vtkAxis;
44 class vtkStringArray;
45 
46 class VTKCHARTSCORE_EXPORT vtkPlot : public vtkContextItem
47 {
48 public:
49  vtkTypeMacro(vtkPlot, vtkContextItem);
50  void PrintSelf(ostream &os, vtkIndent indent) override;
51 
53 
58  vtkSetMacro(LegendVisibility, bool);
59  vtkGetMacro(LegendVisibility, bool);
60  vtkBooleanMacro(LegendVisibility, bool);
62 
70  virtual bool PaintLegend(vtkContext2D *painter, const vtkRectf& rect,
71  int legendIndex);
72 
74 
86  virtual void SetTooltipLabelFormat(const vtkStdString &label);
87  virtual vtkStdString GetTooltipLabelFormat();
89 
91 
94  virtual void SetTooltipNotation(int notation);
95  virtual int GetTooltipNotation();
97 
99 
102  virtual void SetTooltipPrecision(int precision);
103  virtual int GetTooltipPrecision();
105 
110  virtual vtkStdString GetTooltipLabel(const vtkVector2d &plotPos,
111  vtkIdType seriesIndex,
112  vtkIdType segmentIndex);
113 
119  virtual vtkIdType GetNearestPoint(const vtkVector2f& point,
120  const vtkVector2f& tolerance,
122 
126  virtual bool SelectPoints(const vtkVector2f& min, const vtkVector2f& max);
127 
131  virtual bool SelectPointsInPolygon(const vtkContextPolygon &polygon);
132 
134 
137  virtual void SetColor(unsigned char r, unsigned char g, unsigned char b,
138  unsigned char a);
139  virtual void SetColor(double r, double g, double b);
140  virtual void GetColor(double rgb[3]);
141  void GetColor(unsigned char rgb[3]);
143 
147  virtual void SetWidth(float width);
148 
152  virtual float GetWidth();
153 
155 
158  void SetPen(vtkPen *pen);
159  vtkPen* GetPen();
161 
163 
166  void SetBrush(vtkBrush *brush);
167  vtkBrush* GetBrush();
169 
171 
175  void SetSelectionPen(vtkPen *pen);
176  vtkPen* GetSelectionPen();
178 
180 
184  void SetSelectionBrush(vtkBrush *brush);
185  vtkBrush* GetSelectionBrush();
187 
191  virtual void SetLabel(const vtkStdString &label);
192 
196  virtual vtkStdString GetLabel();
197 
202  virtual void SetLabels(vtkStringArray *labels);
203 
208  virtual vtkStringArray *GetLabels();
209 
213  virtual int GetNumberOfLabels();
214 
218  vtkStdString GetLabel(vtkIdType index);
219 
225  void SetIndexedLabels(vtkStringArray *labels);
226 
230  virtual vtkStringArray *GetIndexedLabels();
231 
235  vtkContextMapper2D* GetData();
236 
238 
242  vtkGetMacro(UseIndexForXSeries, bool);
244 
246 
250  vtkSetMacro(UseIndexForXSeries, bool);
252 
254 
258  virtual void SetInputData(vtkTable *table);
259  virtual void SetInputData(vtkTable *table, const vtkStdString &xColumn,
260  const vtkStdString &yColumn);
261  void SetInputData(vtkTable *table, vtkIdType xColumn, vtkIdType yColumn);
263 
267  virtual vtkTable* GetInput();
268 
274  virtual void SetInputArray(int index, const vtkStdString &name);
275 
277 
283  vtkSetMacro(Selectable,bool);
284  vtkGetMacro(Selectable,bool);
285  vtkBooleanMacro(Selectable,bool);
287 
289 
294  virtual void SetSelection(vtkIdTypeArray *id);
295  vtkGetObjectMacro(Selection, vtkIdTypeArray);
297 
299 
302  vtkGetObjectMacro(XAxis, vtkAxis);
303  virtual void SetXAxis(vtkAxis* axis);
305 
307 
310  vtkGetObjectMacro(YAxis, vtkAxis);
311  virtual void SetYAxis(vtkAxis* axis);
313 
315 
321  void SetShiftScale(const vtkRectd &scaling);
322  vtkRectd GetShiftScale();
324 
330  virtual void GetBounds(double bounds[4])
331  { bounds[0] = bounds[1] = bounds[2] = bounds[3] = 0.0; }
332 
357  virtual void GetUnscaledInputBounds(double bounds[4])
358  {
359  // Implemented here by calling GetBounds() to support plot
360  // subclasses that do no log-scaling or plot orientation.
361  return this->GetBounds(bounds);
362  }
363 
370  virtual void UpdateCache() {}
371 
373 
377  virtual void SetProperty(const vtkStdString &property, const vtkVariant &var);
378  virtual vtkVariant GetProperty(const vtkStdString &property);
380 
381 protected:
382  vtkPlot();
383  ~vtkPlot() override;
384 
388  vtkStdString GetNumber(double position, vtkAxis *axis);
389 
394 
399 
405 
411 
416 
421 
426 
432 
438 
443 
448 
453 
458 
464 
470 
473 
478 
480 
481 private:
482  vtkPlot(const vtkPlot &) = delete;
483  void operator=(const vtkPlot &) = delete;
484 
485 };
486 
487 #endif //vtkPlot_h
vtkAxis * XAxis
The X axis associated with this plot.
Definition: vtkPlot.h:452
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:34
virtual void UpdateCache()
Subclasses that build data caches to speed up painting should override this method to update such cac...
Definition: vtkPlot.h:370
vtkRectd ShiftScale
The current shift in origin and scaling factor applied to the plot.
Definition: vtkPlot.h:477
base class for items that are part of a vtkContextScene.
vtkSmartPointer< vtkStringArray > IndexedLabels
Holds Labels when they&#39;re auto-created.
Definition: vtkPlot.h:425
vtkSmartPointer< vtkBrush > Brush
This object stores the vtkBrush that controls how the plot is drawn.
Definition: vtkPlot.h:398
int TooltipNotation
Definition: vtkPlot.h:471
virtual void GetBounds(double bounds[4])
Get the bounds for this plot as (Xmin, Xmax, Ymin, Ymax).
Definition: vtkPlot.h:330
a vtkAbstractArray subclass for strings
dynamic, self-adjusting array of vtkIdType
int vtkIdType
Definition: vtkType.h:345
bool Selectable
Whether plot points can be selected or not.
Definition: vtkPlot.h:442
int TooltipPrecision
Definition: vtkPlot.h:472
Abstract class for 2D context mappers.
vtkSmartPointer< vtkPen > SelectionPen
This object stores the vtkPen that controls how the selected elements of the plot are drawn...
Definition: vtkPlot.h:404
A atomic type representing the union of many types.
Definition: vtkVariant.h:65
vtkStdString TooltipDefaultLabelFormat
The default printf-style string to build custom tooltip labels from.
Definition: vtkPlot.h:469
vtkIdTypeArray * Selection
Selected indices for the table the plot is rendering.
Definition: vtkPlot.h:447
Class for drawing 2D primitives to a graphical context.
Definition: vtkContext2D.h:52
provides a brush that fills shapes drawn by vtkContext2D.
Definition: vtkBrush.h:37
takes care of drawing 2D axes
Definition: vtkAxis.h:68
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkSmartPointer< vtkBrush > SelectionBrush
This object stores the vtkBrush that controls how the selected elements of the plot are drawn...
Definition: vtkPlot.h:410
vtkSmartPointer< vtkContextMapper2D > Data
This data member contains the data that will be plotted, it inherits from vtkAlgorithm.
Definition: vtkPlot.h:437
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
provides a pen that draws the outlines of shapes drawn by vtkContext2D.
Definition: vtkPen.h:36
Abstract class for 2D plots.
Definition: vtkPlot.h:46
vtkSmartPointer< vtkStringArray > Labels
Plot labels, used by legend.
Definition: vtkPlot.h:415
vtkSmartPointer< vtkStringArray > AutoLabels
Holds Labels when they&#39;re auto-created.
Definition: vtkPlot.h:420
A table, which contains similar-typed columns of data.
Definition: vtkTable.h:62
virtual void GetUnscaledInputBounds(double bounds[4])
Provide un-log-scaled bounds for the plot inputs.
Definition: vtkPlot.h:357
vtkAxis * YAxis
The X axis associated with this plot.
Definition: vtkPlot.h:457
bool LegendVisibility
Definition: vtkPlot.h:479
vtkStdString TooltipLabelFormat
A printf-style string to build custom tooltip labels from.
Definition: vtkPlot.h:463
vtkSmartPointer< vtkPen > Pen
This object stores the vtkPen that controls how the plot is drawn.
Definition: vtkPlot.h:393
#define max(a, b)
bool UseIndexForXSeries
Use the Y array index for the X value.
Definition: vtkPlot.h:431