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
takes care of drawing 2D axes
Definition: vtkAxis.h:178
provides a brush that fills shapes drawn by vtkContext2D.
Definition: vtkBrush.h:97
Class for drawing 2D primitives to a graphical context.
Definition: vtkContext2D.h:73
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:113
provides a pen that draws the outlines of shapes drawn by vtkContext2D.
Definition: vtkPen.h:136
Abstract class for 2D plots.
Definition: vtkPlot.h:157
bool UseIndexForXSeries
Use the Y array index for the X value.
Definition: vtkPlot.h:574
virtual void UpdateCache()
Subclasses that build data caches to speed up painting should override this method to update such cac...
Definition: vtkPlot.h:486
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:620
virtual int GetTooltipNotation()
Sets/gets the tooltip notation style.
int TooltipPrecision
Definition: vtkPlot.h:615
vtkSmartPointer< vtkStringArray > IndexedLabels
Holds Labels when they're auto-created.
Definition: vtkPlot.h:568
vtkAxis * XAxis
The X axis associated with this plot.
Definition: vtkPlot.h:595
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:622
virtual void GetUnscaledInputBounds(double bounds[4])
Provide un-log-scaled bounds for the plot inputs.
Definition: vtkPlot.h:473
vtkIdTypeArray * Selection
Selected indices for the table the plot is rendering.
Definition: vtkPlot.h:590
vtkSmartPointer< vtkBrush > SelectionBrush
This object stores the vtkBrush that controls how the selected elements of the plot are drawn.
Definition: vtkPlot.h:553
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:600
vtkStdString TooltipDefaultLabelFormat
The default printf-style string to build custom tooltip labels from.
Definition: vtkPlot.h:612
vtkSmartPointer< vtkPen > SelectionPen
This object stores the vtkPen that controls how the selected elements of the plot are drawn.
Definition: vtkPlot.h:547
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:606
bool Selectable
Whether plot points can be selected or not.
Definition: vtkPlot.h:585
int TooltipNotation
Definition: vtkPlot.h:614
vtkSmartPointer< vtkContextMapper2D > Data
This data member contains the data that will be plotted, it inherits from vtkAlgorithm.
Definition: vtkPlot.h:580
vtkSmartPointer< vtkStringArray > Labels
Plot labels, used by legend.
Definition: vtkPlot.h:558
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:563
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:541
vtkSmartPointer< vtkPen > Pen
This object stores the vtkPen that controls how the plot is drawn.
Definition: vtkPlot.h:536
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:105
a vtkAbstractArray subclass for strings
A table, which contains similar-typed columns of data.
Definition: vtkTable.h:172
A atomic type representing the union of many types.
Definition: vtkVariant.h:155
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)