VTK  9.7.1
vtkPlotHistogram2D.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
3 
12 #ifndef vtkPlotHistogram2D_h
13 #define vtkPlotHistogram2D_h
14 
15 #include "vtkChartsCoreModule.h" // For export macro
16 #include "vtkNew.h" // For vtkNew
17 #include "vtkPlot.h"
18 #include "vtkRect.h" // Needed for vtkRectf
19 #include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
20 
21 #include <string> // Needed for std::string
22 
23 VTK_ABI_NAMESPACE_BEGIN
24 
25 class vtkDoubleArray;
26 class vtkImageData;
27 class vtkScalarsToColors;
28 
29 class VTKCHARTSCORE_EXPORT VTK_MARSHALAUTO vtkPlotHistogram2D : public vtkPlot
30 {
31 public:
32  vtkTypeMacro(vtkPlotHistogram2D, vtkPlot);
33  void PrintSelf(ostream& os, vtkIndent indent) override;
34 
38  static vtkPlotHistogram2D* New();
39 
45  void Update() override;
46 
50  bool Paint(vtkContext2D* painter) override;
51 
56  virtual void SetInputData(vtkImageData* data, vtkIdType z = 0);
57  void SetInputData(vtkTable*) override {}
58  void SetInputData(vtkTable*, const vtkStdString&, const vtkStdString&) override {}
59 
63  vtkImageData* GetInputImageData();
64 
69  void SetTransferFunction(vtkScalarsToColors* transfer);
70 
74  vtkScalarsToColors* GetTransferFunction();
75 
76  void GetBounds(double bounds[4]) override;
77 
78  virtual void SetPosition(const vtkRectf& pos);
79  virtual vtkRectf GetPosition();
80 
82 
87  vtkSetMacro(ArrayName, std::string);
88  vtkGetMacro(ArrayName, std::string);
90 
108  const vtkVector2d& plotPos, vtkIdType seriesIndex, vtkIdType segmentIndex) override;
109 
118  vtkIdType GetNearestPoint(const vtkVector2f& point, const vtkVector2f& tolerance,
119  vtkVector2f* location, vtkIdType* segmentId) override;
121 
128  bool UpdateCache() override;
129 
130 protected:
132  ~vtkPlotHistogram2D() override;
133 
138 
139 private:
140  vtkPlotHistogram2D(const vtkPlotHistogram2D&) = delete;
141  void operator=(const vtkPlotHistogram2D&) = delete;
142 
147  static vtkIdType GetLabelIndexFromValue(double value, vtkAxis* axis);
152  static inline bool CanComputeMagnitude(vtkDataArray* array);
153 
158  inline vtkDataArray* GetSelectedArray();
165  double GetInputArrayValue(int x, int y, int z);
166 
167  std::string ArrayName;
168  vtkNew<vtkDoubleArray> MagnitudeArray;
169 };
170 
171 VTK_ABI_NAMESPACE_END
172 #endif // vtkPlotHistogram2D_h
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:27
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
virtual bool Paint(vtkContext2D *painter)
Paint event for the item, called whenever the item needs to be drawn.
void Update() override
Perform any updates to the item that may be necessary before rendering.
virtual void GetBounds(double bounds[4])
Get the bounds for this plot as (Xmin, Xmax, Ymin, Ymax).
Definition: vtkPlot.h:393
void SetInputData(vtkTable *) override
This is a convenience function to set the input table and the x, y column for the plot...
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.
int vtkIdType
Definition: vtkType.h:363
dynamic, self-adjusting array of double
Superclass for mapping scalar values to colors.
void SetInputData(vtkTable *, const vtkStdString &, const vtkStdString &) override
This is a convenience function to set the input table and the x, y column for the plot...
Class for drawing 2D primitives to a graphical context.
Definition: vtkContext2D.h:49
takes care of drawing 2D axes
Definition: vtkAxis.h:61
a simple class to control print indentation
Definition: vtkIndent.h:28
topologically and geometrically regular array of data
Definition: vtkImageData.h:45
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:44
virtual bool UpdateCache()
Update the internal cache.
Definition: vtkPlot.h:455
vtkSmartPointer< vtkScalarsToColors > TransferFunction
Abstract class for 2D plots.
Definition: vtkPlot.h:43
A table, which contains similar-typed columns of data.
Definition: vtkTable.h:59
virtual void SetInputData(vtkTable *table)
This is a convenience function to set the input table and the x, y column for the plot...
#define VTK_MARSHALAUTO
vtkSmartPointer< vtkImageData > Input
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
vtkSmartPointer< vtkImageData > Output
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...