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 
136 #ifndef vtkPlot_h
137 #define vtkPlot_h
138 
139 #include "vtkChartsCoreModule.h" // For export macro
140 #include "vtkContextItem.h"
141 #include "vtkContextPolygon.h" // For vtkContextPolygon
142 #include "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_0_0
143 #include "vtkRect.h" // For vtkRectd ivar
144 #include "vtkSmartPointer.h" // Needed to hold SP ivars
145 #include "vtkStdString.h" // Needed to hold TooltipLabelFormat ivar
146 
147 class vtkVariant;
148 class vtkTable;
149 class vtkIdTypeArray;
150 class vtkContextMapper2D;
151 class vtkPen;
152 class vtkBrush;
153 class vtkAxis;
154 class vtkStringArray;
155 
156 class VTKCHARTSCORE_EXPORT vtkPlot : public vtkContextItem
157 {
158 public:
159  vtkTypeMacro(vtkPlot, vtkContextItem);
160  void PrintSelf(ostream& os, vtkIndent indent) override;
161 
163 
168  vtkSetMacro(LegendVisibility, bool);
169  vtkGetMacro(LegendVisibility, bool);
170  vtkBooleanMacro(LegendVisibility, bool);
172 
180  virtual bool PaintLegend(vtkContext2D* painter, const vtkRectf& rect, int legendIndex);
181 
183 
195  virtual void SetTooltipLabelFormat(const vtkStdString& label);
198 
200 
203  virtual void SetTooltipNotation(int notation);
204  virtual int GetTooltipNotation();
206 
208 
211  virtual void SetTooltipPrecision(int precision);
212  virtual int GetTooltipPrecision();
214 
220  const vtkVector2d& plotPos, vtkIdType seriesIndex, vtkIdType segmentIndex);
221 
227  virtual vtkIdType GetNearestPoint(const vtkVector2f& point, const vtkVector2f& tolerance,
228  vtkVector2f* location, vtkIdType* segmentId);
229 
237  VTK_DEPRECATED_IN_9_0_0("Use the vtkPlot::GetNearestPoint() overload with a segmentId argument")
238  virtual vtkIdType GetNearestPoint(
239  const vtkVector2f& point, const vtkVector2f& tolerance, vtkVector2f* location);
240 
244  virtual bool SelectPoints(const vtkVector2f& min, const vtkVector2f& max);
245 
249  virtual bool SelectPointsInPolygon(const vtkContextPolygon& polygon);
250 
252 
255  virtual void SetColor(unsigned char r, unsigned char g, unsigned char b, unsigned char a);
256  virtual void SetColor(double r, double g, double b);
257  virtual void GetColor(double rgb[3]);
258  void GetColor(unsigned char rgb[3]);
260 
264  virtual void SetWidth(float width);
265 
269  virtual float GetWidth();
270 
272 
275  void SetPen(vtkPen* pen);
276  vtkPen* GetPen();
278 
280 
283  void SetBrush(vtkBrush* brush);
284  vtkBrush* GetBrush();
286 
288 
292  void SetSelectionPen(vtkPen* pen);
293  vtkPen* GetSelectionPen();
295 
297 
301  void SetSelectionBrush(vtkBrush* brush);
302  vtkBrush* GetSelectionBrush();
304 
308  virtual void SetLabel(const vtkStdString& label);
309 
313  virtual vtkStdString GetLabel();
314 
319  virtual void SetLabels(vtkStringArray* labels);
320 
325  virtual vtkStringArray* GetLabels();
326 
330  virtual int GetNumberOfLabels();
331 
336 
342  void SetIndexedLabels(vtkStringArray* labels);
343 
347  virtual vtkStringArray* GetIndexedLabels();
348 
353 
355 
359  vtkGetMacro(UseIndexForXSeries, bool);
361 
363 
367  vtkSetMacro(UseIndexForXSeries, bool);
369 
371 
375  virtual void SetInputData(vtkTable* table);
376  virtual void SetInputData(
377  vtkTable* table, const vtkStdString& xColumn, const vtkStdString& yColumn);
378  void SetInputData(vtkTable* table, vtkIdType xColumn, vtkIdType yColumn);
380 
384  virtual vtkTable* GetInput();
385 
391  virtual void SetInputArray(int index, const vtkStdString& name);
392 
394 
400  vtkSetMacro(Selectable, bool);
401  vtkGetMacro(Selectable, bool);
402  vtkBooleanMacro(Selectable, bool);
404 
406 
411  virtual void SetSelection(vtkIdTypeArray* id);
412  vtkGetObjectMacro(Selection, vtkIdTypeArray);
414 
416 
419  vtkGetObjectMacro(XAxis, vtkAxis);
420  virtual void SetXAxis(vtkAxis* axis);
422 
424 
427  vtkGetObjectMacro(YAxis, vtkAxis);
428  virtual void SetYAxis(vtkAxis* axis);
430 
432 
438  void SetShiftScale(const vtkRectd& shiftScale);
439  vtkRectd GetShiftScale();
441 
447  virtual void GetBounds(double bounds[4]) { bounds[0] = bounds[1] = bounds[2] = bounds[3] = 0.0; }
448 
473  virtual void GetUnscaledInputBounds(double bounds[4])
474  {
475  // Implemented here by calling GetBounds() to support plot
476  // subclasses that do no log-scaling or plot orientation.
477  return this->GetBounds(bounds);
478  }
479 
486  virtual void UpdateCache() {}
487 
489 
493  virtual void SetProperty(const vtkStdString& property, const vtkVariant& var);
494  virtual vtkVariant GetProperty(const vtkStdString& property);
496 
498 
502  static bool ClampPos(double pos[2], double bounds[4]);
503  virtual bool ClampPos(double pos[2]);
505 
509  bool Hit(const vtkContextMouseEvent& mouse) override;
510 
511 protected:
513  ~vtkPlot() override;
514 
519 
521 
525  virtual void TransformScreenToData(const vtkVector2f& in, vtkVector2f& out);
526  virtual void TransformDataToScreen(const vtkVector2f& in, vtkVector2f& out);
527  virtual void TransformScreenToData(
528  const double inX, const double inY, double& outX, double& outY);
529  virtual void TransformDataToScreen(
530  const double inX, const double inY, double& outX, double& outY);
532 
537 
542 
548 
554 
559 
564 
569 
575 
581 
586 
591 
596 
601 
607 
613 
616 
621 
623 
628  // VTK_DEPRECATED_IN_9_0_0("used to track deprecation integration logic")
629  bool LegacyRecursionFlag = false;
630 
631 private:
632  vtkPlot(const vtkPlot&) = delete;
633  void operator=(const vtkPlot&) = delete;
634 };
635 
636 #endif // vtkPlot_h
vtkBrush
provides a brush that fills shapes drawn by vtkContext2D.
Definition: vtkBrush.h:97
vtkPlot::AutoLabels
vtkSmartPointer< vtkStringArray > AutoLabels
Holds Labels when they're auto-created.
Definition: vtkPlot.h:563
vtkPlot::GetTooltipLabel
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::GetTooltipPrecision
virtual int GetTooltipPrecision()
Sets/gets the tooltip precision.
vtkStdString.h
vtkPlot::TooltipLabelFormat
vtkStdString TooltipLabelFormat
A printf-style string to build custom tooltip labels from.
Definition: vtkPlot.h:606
vtkPlot::IndexedLabels
vtkSmartPointer< vtkStringArray > IndexedLabels
Holds Labels when they're auto-created.
Definition: vtkPlot.h:568
vtkContextPolygon.h
vtkPlot::Brush
vtkSmartPointer< vtkBrush > Brush
This object stores the vtkBrush that controls how the plot is drawn.
Definition: vtkPlot.h:541
vtkContextMouseEvent
data structure to represent mouse events.
Definition: vtkContextMouseEvent.h:54
vtkPlot::TooltipNotation
int TooltipNotation
Definition: vtkPlot.h:614
vtkContextMapper2D
Abstract class for 2D context mappers.
Definition: vtkContextMapper2D.h:38
vtkIdType
int vtkIdType
Definition: vtkType.h:332
vtkTable
A table, which contains similar-typed columns of data.
Definition: vtkTable.h:172
vtkPlot::LegendVisibility
bool LegendVisibility
Definition: vtkPlot.h:622
vtkPlot::Data
vtkSmartPointer< vtkContextMapper2D > Data
This data member contains the data that will be plotted, it inherits from vtkAlgorithm.
Definition: vtkPlot.h:580
vtkPlot::TooltipPrecision
int TooltipPrecision
Definition: vtkPlot.h:615
vtkSmartPointer< vtkPen >
vtkPlot::Selectable
bool Selectable
Whether plot points can be selected or not.
Definition: vtkPlot.h:585
vtkContext2D
Class for drawing 2D primitives to a graphical context.
Definition: vtkContext2D.h:73
vtkContextItem.h
vtkPlot::GetTooltipNotation
virtual int GetTooltipNotation()
Sets/gets the tooltip notation style.
vtkPlot
Abstract class for 2D plots.
Definition: vtkPlot.h:157
vtkPlot::Labels
vtkSmartPointer< vtkStringArray > Labels
Plot labels, used by legend.
Definition: vtkPlot.h:558
vtkRectd
Definition: vtkRect.h:350
max
#define max(a, b)
Definition: vtkX3DExporterFIWriterHelper.h:31
vtkVector2d
Definition: vtkVector.h:503
vtkX3D::position
@ position
Definition: vtkX3D.h:267
vtkX3D::point
@ point
Definition: vtkX3D.h:242
vtkPlot::ClampPos
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,...
vtkPlot::UpdateCache
virtual void UpdateCache()
Subclasses that build data caches to speed up painting should override this method to update such cac...
Definition: vtkPlot.h:486
vtkPlot::UseIndexForXSeries
bool UseIndexForXSeries
Use the Y array index for the X value.
Definition: vtkPlot.h:574
vtkBlockSortHelper::GetBounds
void GetBounds(T a, double bds[6])
Definition: vtkBlockSortHelper.h:37
vtkPlot::vtkPlot
vtkPlot()
vtkRect.h
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:113
vtkPlot::SelectionBrush
vtkSmartPointer< vtkBrush > SelectionBrush
This object stores the vtkBrush that controls how the selected elements of the plot are drawn.
Definition: vtkPlot.h:553
vtkPlot::TooltipDefaultLabelFormat
vtkStdString TooltipDefaultLabelFormat
The default printf-style string to build custom tooltip labels from.
Definition: vtkPlot.h:612
VTK_DEPRECATED_IN_9_0_0
#define VTK_DEPRECATED_IN_9_0_0(reason)
Definition: vtkDeprecation.h:126
vtkSmartPointer.h
vtkVariant
A atomic type representing the union of many types.
Definition: vtkVariant.h:155
vtkPlot::GetProperty
virtual vtkVariant GetProperty(const vtkStdString &property)
A General setter/getter that should be overridden.
vtkPlot::Pen
vtkSmartPointer< vtkPen > Pen
This object stores the vtkPen that controls how the plot is drawn.
Definition: vtkPlot.h:536
vtkContextPolygon
Definition: vtkContextPolygon.h:27
vtkPlot::PaintLegend
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...
vtkPlot::SelectionPen
vtkSmartPointer< vtkPen > SelectionPen
This object stores the vtkPen that controls how the selected elements of the plot are drawn.
Definition: vtkPlot.h:547
vtkX3D::name
@ name
Definition: vtkX3D.h:225
vtkPlot::Selection
vtkIdTypeArray * Selection
Selected indices for the table the plot is rendering.
Definition: vtkPlot.h:590
vtkPlot::SetTooltipNotation
virtual void SetTooltipNotation(int notation)
Sets/gets the tooltip notation style.
vtkPlot::XAxis
vtkAxis * XAxis
The X axis associated with this plot.
Definition: vtkPlot.h:595
vtkContextItem
base class for items that are part of a vtkContextScene.
Definition: vtkContextItem.h:53
vtkPlot::~vtkPlot
~vtkPlot() override
vtkPlot::SetProperty
virtual void SetProperty(const vtkStdString &property, const vtkVariant &var)
A General setter/getter that should be overridden.
vtkIdTypeArray
dynamic, self-adjusting array of vtkIdType
Definition: vtkIdTypeArray.h:145
vtkDeprecation.h
vtkPlot::GetUnscaledInputBounds
virtual void GetUnscaledInputBounds(double bounds[4])
Provide un-log-scaled bounds for the plot inputs.
Definition: vtkPlot.h:473
vtkAxis
takes care of drawing 2D axes
Definition: vtkAxis.h:178
vtkPlot::SetTooltipLabelFormat
virtual void SetTooltipLabelFormat(const vtkStdString &label)
Sets/gets a printf-style string to build custom tooltip labels from.
vtkStringArray
a vtkAbstractArray subclass for strings
Definition: vtkStringArray.h:146
vtkX3D::location
@ location
Definition: vtkX3D.h:412
vtkPlot::ShiftScale
vtkRectd ShiftScale
The current shift in origin and scaling factor applied to the plot.
Definition: vtkPlot.h:620
vtkPen
provides a pen that draws the outlines of shapes drawn by vtkContext2D.
Definition: vtkPen.h:136
vtkStdString
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:105
vtkIOSSUtilities::GetData
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.
vtkX3D::index
@ index
Definition: vtkX3D.h:252
vtkPlot::ClampPos
virtual bool ClampPos(double pos[2])
Clamp the given 2D pos into the provided bounds Return true if the pos has been clamped,...
vtkPlot::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkRectf
Definition: vtkRect.h:336
vtkPlot::SetTooltipPrecision
virtual void SetTooltipPrecision(int precision)
Sets/gets the tooltip precision.
vtkVector2f
Definition: vtkVector.h:491
vtkPlot::YAxis
vtkAxis * YAxis
The X axis associated with this plot.
Definition: vtkPlot.h:600
vtkPlot::GetTooltipLabelFormat
virtual vtkStdString GetTooltipLabelFormat()
Sets/gets a printf-style string to build custom tooltip labels from.
vtkPlot::GetNumber
vtkStdString GetNumber(double position, vtkAxis *axis)
Get the properly formatted number for the supplied position and axis.
vtkPlot::Hit
bool Hit(const vtkContextMouseEvent &mouse) override
Returns true if the supplied x, y coordinate is inside the item.