A generic container class for storing 2D grid data and providing resampling methods.
More...
|
| enum | ResampleMode { NearestNeighbour
, BilinearInterpolation
, BicubicInterpolation
} |
| | Enumeration for resampling methods. More...
|
| |
|
using | value_type = T |
| | Type of the stored values / 存储值的类型
|
| |
|
using | x_container_type = XContainer |
| | Type of the x-axis container / x 轴容器的类型
|
| |
|
using | y_container_type = YContainer |
| | Type of the y-axis container / y 轴容器的类型
|
| |
|
using | data_column_type = DataColumn |
| | Type of a single column in the data matrix / 数据矩阵中单列的类型
|
| |
|
using | data_container_type = DataContainer |
| | Type of the data matrix / 数据矩阵的类型
|
| |
|
using | size_type = typename DataColumn::size_type |
| |
|
| | QwtGridData () |
| | Default constructor.
|
| |
| | QwtGridData (const x_container_type &xAxis, const y_container_type &yAxis, const data_container_type &data, ResampleMode mode=NearestNeighbour) |
| | Constructor with initial data.
|
| |
| void | setValue (const x_container_type &xAxis, const y_container_type &yAxis, const data_container_type &data) |
| | Set new x-axis, y-axis, and data matrix.
|
| |
| T | operator() (T x, T y) const |
| | Operator to query value at (x, y).
|
| |
| T | operator[] (const std::pair< T, T > &xy) const |
| | operator []
|
| |
| T | value (T x, T y) const |
| | Query value at (x, y).
|
| |
| void | setResampleMode (ResampleMode mode) |
| | Set the resampling mode.
|
| |
| ResampleMode | resampleMode () const |
| | Get the current resampling mode.
|
| |
| size_type | xSize () const |
| | x的尺寸
|
| |
| size_type | ySize () const |
| | y的尺寸
|
| |
| std::pair< size_type, size_type > | valueSize () const |
| | value矩阵的尺寸
|
| |
| T | atX (size_type ix) const |
| | x 值对应的内容
|
| |
| T | atY (size_type iy) const |
| | y值对应的内容
|
| |
| T | atValue (size_type ix, size_type iy) const |
| | value值对应的内容
|
| |
| const x_container_type & | xAxis () const |
| | Get the x-axis values.
|
| |
| const y_container_type & | yAxis () const |
| | Get the y-axis values.
|
| |
| const data_container_type & | data () const |
| | Get the data matrix.
|
| |
| bool | valid () const |
| | Check if the object is valid.
|
| |
| void | validate () |
| | Validate the data.
|
| |
|
T | xMin () const |
| |
|
T | xMax () const |
| |
|
T | yMin () const |
| |
|
T | yMax () const |
| |
|
T | dataMin () const |
| |
|
T | dataMax () const |
| |
template<typename T, typename XContainer = std::vector< T >, typename YContainer = std::vector< T >, typename DataColumn = std::vector< T >, typename DataContainer = std::vector< DataColumn >>
class QwtGridData< T, XContainer, YContainer, DataColumn, DataContainer >
A generic container class for storing 2D grid data and providing resampling methods.
This template class encapsulates a 2D table with x-axis and y-axis data. It supports three resampling methods: Nearest Neighbor, Bilinear Interpolation, and Bicubic Interpolation. The container types for the axes and data are templated to allow flexibility.
此模板类封装了一个二维表格以及对应的 x 轴和 y 轴数据。 它支持三种插值方法:最近邻插值、双线性插值和双三次插值。 轴和数据的容器类型被模板化以提供灵活性。
↓Y轴方向 →X轴方向 n行 m列
|column[0]|column[1]| ... |column[m]| +------—+------—+--—+------—+ | [x0,yn] | [x1,yn] | ... | [xm,yn] | → yAxis[n] 对应行 +------—+------—+--—+------—+ | ... | ... | ... | ... | +------—+------—+--—+------—+ | [x0,y1] | [x1,y1] | ... | [xm,y1] | → yAxis[1] 对应行 +------—+------—+--—+------—+ | [x0,y0] | [x1,y0] | ... | [xm,y0] | → yAxis[0] 对应行 +------—+------—+--—+------—+ ↑ ↑ ↑ ↑ xAxis[0] xAxis[1] ... xAxis[m]
Example Usage:
Example using std::vector:
std::vector<double>
xAxis = {0, 1, 2, 3};
std::vector<double>
yAxis = {0, 1, 2};
std::vector<std::vector<double>>
data = {
{1, 2, 3},
{4, 5, 6},
{7, 8, 9},
{10, 11, 12}
};
double value = gridData(1.5, 1.5);
std::cout <<
"Value at (1.5, 1.5): " <<
value << std::endl;
A generic container class for storing 2D grid data and providing resampling methods.
Definition qwt_grid_data.hpp:95
T value(T x, T y) const
Query value at (x, y).
Definition qwt_grid_data.hpp:234
const y_container_type & yAxis() const
Get the y-axis values.
Definition qwt_grid_data.hpp:348
const data_container_type & data() const
Get the data matrix.
Definition qwt_grid_data.hpp:360
const x_container_type & xAxis() const
Get the x-axis values.
Definition qwt_grid_data.hpp:336
Example using QVector:
{1, 2, 3},
{4, 5, 6},
{7, 8, 9},
{10, 11, 12}
};
double value = gridData(1.5, 1.5);
qDebug() <<
"Value at (1.5, 1.5):" <<
value;
Definition qwt_clipper.h:40
- Template Parameters
-
| T | The type of the values stored in the grid. |
| XContainer | The container type for the x-axis values (default: std::vector). |
| YContainer | The container type for the y-axis values (default: same as XContainer). |
| DataColumn | The container type for a single column in the data matrix (default: same as XContainer). |
| DataContainer | The container type for the entire data matrix (default: same as XContainer). |
template<typename T , typename XContainer = std::vector< T >, typename YContainer = std::vector< T >, typename DataColumn = std::vector< T >, typename DataContainer = std::vector< DataColumn >>
| T QwtGridData< T, XContainer, YContainer, DataColumn, DataContainer >::bicubicInterpolation |
( |
T |
x, |
|
|
T |
y |
|
) |
| const |
|
inlineprotected |
Perform bicubic interpolation.
Returns the bicubically interpolated value at the specified (x, y) position. This implementation uses the Hermite bicubic interpolation method.
返回指定 (x, y) 位置的双三次插值结果。 此实现使用 Hermite 双三次插值方法。
- Parameters
-
| x | The x-coordinate / x 坐标 |
| y | The y-coordinate / y 坐标 |
- Returns
- The bicubically interpolated value / 双三次插值结果
template<typename T , typename XContainer = std::vector< T >, typename YContainer = std::vector< T >, typename DataColumn = std::vector< T >, typename DataContainer = std::vector< DataColumn >>
Set new x-axis, y-axis, and data matrix.
data matrix is look like that:
|column[0]|column[1]| ... |column[m]| +------—+------—+--—+------—+ | [x0,yn] | [x1,yn] | ... | [xm,yn] | → yAxis[n] 对应行 +------—+------—+--—+------—+ | ... | ... | ... | ... | +------—+------—+--—+------—+ | [x0,y1] | [x1,y1] | ... | [xm,y1] | → yAxis[1] 对应行 +------—+------—+--—+------—+ | [x0,y0] | [x1,y0] | ... | [xm,y0] | → yAxis[0] 对应行 +------—+------—+--—+------—+ ↑ ↑ ↑ ↑ xAxis[0] xAxis[1] ... xAxis[m]
so (data matrix).size = xAxis.size,(data matrix).at(n).size = yAxis.szie
设置新的 x 轴、y 轴和数据矩阵。 数据矩阵是一个vector<vector> ,数据矩阵.size = xAxis.size,数据矩阵.at(n).size = yAxis.size
- Parameters
-
| xAxis | The x-axis values. / x 轴值。 |
| yAxis | The y-axis values. / y 轴值。 |
| data | The 2D data matrix. / 二维数据矩阵。 |