-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
Copy pathvtkPlotHistogram2D.h
178 lines (151 loc) · 5.57 KB
/
vtkPlotHistogram2D.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
// SPDX-License-Identifier: BSD-3-Clause
/**
* @class vtk2DHistogramItem
* @brief 2D histogram item.
*
*
*
*/
#ifndef vtkPlotHistogram2D_h
#define vtkPlotHistogram2D_h
#include "vtkChartsCoreModule.h" // For export macro
#include "vtkNew.h" // For vtkNew
#include "vtkPlot.h"
#include "vtkRect.h" // Needed for vtkRectf
#include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
#include <string> // Needed for std::string
VTK_ABI_NAMESPACE_BEGIN
class vtkDoubleArray;
class vtkImageData;
class vtkScalarsToColors;
class VTKCHARTSCORE_EXPORT VTK_MARSHALAUTO vtkPlotHistogram2D : public vtkPlot
{
public:
vtkTypeMacro(vtkPlotHistogram2D, vtkPlot);
void PrintSelf(ostream& os, vtkIndent indent) override;
/**
* Creates a new object.
*/
static vtkPlotHistogram2D* New();
/**
* Perform any updates to the item that may be necessary before rendering.
* The scene should take care of calling this on all items before their
* Paint function is invoked.
*/
void Update() override;
/**
* Paint event for the item, called whenever it needs to be drawn.
*/
bool Paint(vtkContext2D* painter) override;
/**
* Set the input. The image data is supposed to have scalars attribute set,
* if no array name is set.
*/
virtual void SetInputData(vtkImageData* data, vtkIdType z = 0);
void SetInputData(vtkTable*) override {}
void SetInputData(vtkTable*, const vtkStdString&, const vtkStdString&) override {}
/**
* Get the input table used by the plot.
*/
vtkImageData* GetInputImageData();
/**
* Set the color transfer function that will be used to generate the 2D
* histogram.
*/
void SetTransferFunction(vtkScalarsToColors* transfer);
/**
* Get the color transfer function that is used to generate the histogram.
*/
vtkScalarsToColors* GetTransferFunction();
void GetBounds(double bounds[4]) override;
virtual void SetPosition(const vtkRectf& pos);
virtual vtkRectf GetPosition();
///@{
/**
* Set/get the selected array name.
* When empty, plot using SCALARS attribute.
* Default: empty string (use SCALARS).
*/
vtkSetMacro(ArrayName, std::string);
vtkGetMacro(ArrayName, std::string);
///@}
/**
* Generate and return the tooltip label string for this plot
* The segmentIndex parameter is ignored.
* The member variable TooltipLabelFormat can be set as a
* printf-style string to build custom tooltip labels from,
* and may contain:
* An empty string generates the default tooltip labels.
* The following case-sensitive format tags (without quotes) are recognized:
* '%x' The X position of the histogram cell
* '%y' The Y position of the histogram cell
* '%v' The scalar value of the histogram cell
* '%i' The X axis tick label for the histogram cell
* '%j' The Y axis tick label for the histogram cell
* Any other characters or unrecognized format tags are printed in the
* tooltip label verbatim.
*/
vtkStdString GetTooltipLabel(
const vtkVector2d& plotPos, vtkIdType seriesIndex, vtkIdType segmentIndex) override;
/**
* Function to query a plot for the nearest point to the specified coordinate.
* Returns an index between 0 and (number of histogram cells - 1), or -1.
* The index 0 is at cell x=0, y=0 of the histogram, and the index increases
* in a minor fashion with x and in a major fashion with y.
* The referent of "location" is set to the x and y integer indices of the
* histogram cell.
*/
vtkIdType GetNearestPoint(const vtkVector2f& point, const vtkVector2f& tolerance,
vtkVector2f* location, vtkIdType* segmentId) override;
using vtkPlot::GetNearestPoint;
/**
* Update the internal cache. Returns true if cache was successfully updated. Default does
* nothing.
* This method is called by Update() when either the plot's data has changed or
* CacheRequiresUpdate() returns true. It is not necessary to call this method explicitly.
*/
bool UpdateCache() override;
protected:
vtkPlotHistogram2D();
~vtkPlotHistogram2D() override;
vtkSmartPointer<vtkImageData> Input;
vtkSmartPointer<vtkImageData> Output;
vtkSmartPointer<vtkScalarsToColors> TransferFunction;
vtkRectf Position;
private:
vtkPlotHistogram2D(const vtkPlotHistogram2D&) = delete;
void operator=(const vtkPlotHistogram2D&) = delete;
/**
* Returns the index of the label of an axis, depending on a
* position on the axis.
*/
static vtkIdType GetLabelIndexFromValue(double value, vtkAxis* axis);
/**
* Returns whether an array is compatible with magnitude computation,
* ie. its number of component is 2 or 3.
*/
static inline bool CanComputeMagnitude(vtkDataArray* array);
/**
* Returns the selected data array. Does not return magnitude
* array, but the associated array of the input.
*/
inline vtkDataArray* GetSelectedArray();
/**
* Returns the void pointer to the selected array. If the transfer
* function is set to magnitude mode, it will return the cached
* magnitude array. Also set the vtkDataArray pointer in parameter.
*/
void* GetInputArrayPointer(vtkDataArray*& inputArray);
/**
* Returns the value of the selected array at the coordinates given
* in parameters. The value is casted to double. It takes magnitude
* array into account, so as component, for n-components arrays.
* Returns NaN when something goes wrong.
*/
double GetInputArrayValue(int x, int y, int z);
std::string ArrayName;
vtkNew<vtkDoubleArray> MagnitudeArray;
};
VTK_ABI_NAMESPACE_END
#endif // vtkPlotHistogram2D_h