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) VTK_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() VTK_OVERRIDE;
384 
388  vtkStdString GetNumber(double position, vtkAxis *axis);
389 
394 
399 
404  vtkSmartPointer<vtkPen> SelectionPen;
405 
410  vtkSmartPointer<vtkBrush> SelectionBrush;
411 
416 
421 
426 
431  bool UseIndexForXSeries;
432 
438 
442  bool Selectable;
443 
447  vtkIdTypeArray *Selection;
448 
452  vtkAxis* XAxis;
453 
457  vtkAxis* YAxis;
458 
463  vtkStdString TooltipLabelFormat;
464 
469  vtkStdString TooltipDefaultLabelFormat;
470 
471  int TooltipNotation;
472  int TooltipPrecision;
473 
477  vtkRectd ShiftScale;
478 
479  bool LegendVisibility;
480 
481 private:
482  vtkPlot(const vtkPlot &) VTK_DELETE_FUNCTION;
483  void operator=(const vtkPlot &) VTK_DELETE_FUNCTION;
484 
485 };
486 
487 #endif //vtkPlot_h
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:41
virtual void UpdateCache()
Subclasses that build data caches to speed up painting should override this method to update such cac...
Definition: vtkPlot.h:370
base class for items that are part of a vtkContextScene.
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
Hold a reference to a vtkObjectBase instance.
int vtkIdType
Definition: vtkType.h:345
Abstract class for 2D context mappers.
A atomic type representing the union of many types.
Definition: vtkVariant.h:69
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
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
vtkSetMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
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
vtkBooleanMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
#define max(a, b)