QWT 7.0.1
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
QwtGridData< T, XContainer, YContainer, DataColumn, DataContainer > Class Template Reference

A generic container class for storing 2D grid data and providing resampling methods. More...

#include <qwt_grid_data.hpp>

Public Types

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
 

Public Member Functions

 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.
 
operator() (T x, T y) const
 Operator to query value at (x, y).
 
operator[] (const std::pair< T, T > &xy) const
 operator []
 
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矩阵的尺寸
 
atX (size_type ix) const
 x 值对应的内容
 
atY (size_type iy) const
 y值对应的内容
 
atValue (size_type ix, size_type iy) const
 value值对应的内容
 
const x_container_typexAxis () const
 Get the x-axis values.
 
const y_container_typeyAxis () const
 Get the y-axis values.
 
const data_container_typedata () const
 Get the data matrix.
 
bool valid () const
 Check if the object is valid.
 
void validate ()
 Validate the data.
 
xMin () const
 
xMax () const
 
yMin () const
 
yMax () const
 
dataMin () const
 
dataMax () const
 

Static Public Member Functions

template<typename Container >
static size_type findClosestIndex (const Container &arr, T val)
 Find the closest index in a sorted array.
 
template<typename Container >
static size_type findLowerIndex (const Container &arr, T val)
 Find the lower bound index in a sorted array.
 
template<typename V >
static const V & clamp (const V &value, const V &lo, const V &hi)
 

Protected Member Functions

void findValueRange ()
 Get the minimum & maximum value in the data matrix.
 
nearestNeighbour (T x, T y) const
 Nearest neighbor interpolation.
 
bilinearInterpolation (T x, T y) const
 Bilinear interpolation.
 
bicubicInterpolation (T x, T y) const
 Perform bicubic interpolation.
 

Detailed Description

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}
};
// Create an instance with bilinear interpolation
// Query the value at (1.5, 1.5)
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:

QVector<double> xAxis = {0, 1, 2, 3};
QVector<double> yAxis = {0, 1, 2};
{1, 2, 3},
{4, 5, 6},
{7, 8, 9},
{10, 11, 12}
};
// Create an instance with bicubic interpolation
QVector< double > > >; QwtQVectorGridData gridData(xAxis, yAxis, data, QwtQVectorGridData::BicubicInterpolation);
// Query the value at (1.5, 1.5)
double value = gridData(1.5, 1.5);
qDebug() << "Value at (1.5, 1.5):" << value;
Definition qwt_clipper.h:40
Template Parameters
TThe type of the values stored in the grid.
XContainerThe container type for the x-axis values (default: std::vector).
YContainerThe container type for the y-axis values (default: same as XContainer).
DataColumnThe container type for a single column in the data matrix (default: same as XContainer).
DataContainerThe container type for the entire data matrix (default: same as XContainer).

Member Enumeration Documentation

◆ ResampleMode

template<typename T , typename XContainer = std::vector< T >, typename YContainer = std::vector< T >, typename DataColumn = std::vector< T >, typename DataContainer = std::vector< DataColumn >>
enum QwtGridData::ResampleMode

Enumeration for resampling methods.

Defines the available resampling methods:

  • NearestNeighbour: Nearest neighbor interpolation.
  • BilinearInterpolation: Bilinear interpolation.
  • BicubicInterpolation: Hermite bicubic interpolation.

定义可用的抽样方法:

  • NearestNeighbour: 最近邻插值。
  • BilinearInterpolation: 双线性插值。
  • BicubicInterpolation: Hermite 双三次插值。

Constructor & Destructor Documentation

◆ QwtGridData() [1/2]

template<typename T , typename XContainer = std::vector< T >, typename YContainer = std::vector< T >, typename DataColumn = std::vector< T >, typename DataContainer = std::vector< DataColumn >>
QwtGridData< T, XContainer, YContainer, DataColumn, DataContainer >::QwtGridData ( )
inline

Default constructor.

初始化一个空的 QwtGridData 对象。

◆ QwtGridData() [2/2]

template<typename T , typename XContainer = std::vector< T >, typename YContainer = std::vector< T >, typename DataColumn = std::vector< T >, typename DataContainer = std::vector< DataColumn >>
QwtGridData< T, XContainer, YContainer, DataColumn, DataContainer >::QwtGridData ( const x_container_type xAxis,
const y_container_type yAxis,
const data_container_type data,
ResampleMode  mode = NearestNeighbour 
)
inline

Constructor with initial data.

Initializes the object with x-axis, y-axis, and data matrix.

使用 x 轴、y 轴和数据矩阵初始化对象。

Parameters
xAxisThe x-axis values. / x 轴值。
yAxisThe y-axis values. / y 轴值。
dataThe 2D data matrix. / 二维数据矩阵。
modeThe resampling mode to use. / 要使用的抽样方法。

Member Function Documentation

◆ atValue()

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 >::atValue ( size_type  ix,
size_type  iy 
) const
inline

value值对应的内容

Parameters
ix
Returns

◆ atX()

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 >::atX ( size_type  ix) const
inline

x 值对应的内容

Parameters
ix
Returns

◆ atY()

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 >::atY ( size_type  iy) const
inline

y值对应的内容

Parameters
ix
Returns

◆ bicubicInterpolation()

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 ( x,
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
xThe x-coordinate / x 坐标
yThe y-coordinate / y 坐标
Returns
The bicubically interpolated value / 双三次插值结果

◆ bilinearInterpolation()

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 >::bilinearInterpolation ( x,
y 
) const
inlineprotected

Bilinear interpolation.

双线性插值。

Parameters
xThe x-coordinate. / x 坐标。
yThe y-coordinate. / y 坐标。
Returns
The interpolated value. / 插值结果。

◆ data()

template<typename T , typename XContainer = std::vector< T >, typename YContainer = std::vector< T >, typename DataColumn = std::vector< T >, typename DataContainer = std::vector< DataColumn >>
const data_container_type & QwtGridData< T, XContainer, YContainer, DataColumn, DataContainer >::data ( ) const
inline

Get the data matrix.

获取数据矩阵。

Returns
The data matrix. / 数据矩阵。

◆ findClosestIndex()

template<typename T , typename XContainer = std::vector< T >, typename YContainer = std::vector< T >, typename DataColumn = std::vector< T >, typename DataContainer = std::vector< DataColumn >>
template<typename Container >
static size_type QwtGridData< T, XContainer, YContainer, DataColumn, DataContainer >::findClosestIndex ( const Container &  arr,
val 
)
inlinestatic

Find the closest index in a sorted array.

在排序数组中查找最接近的索引。

Parameters
arrThe sorted array. / 排序数组。
valThe target value. / 目标值。
Returns
The index of the closest value. / 最接近值的索引。

◆ findLowerIndex()

template<typename T , typename XContainer = std::vector< T >, typename YContainer = std::vector< T >, typename DataColumn = std::vector< T >, typename DataContainer = std::vector< DataColumn >>
template<typename Container >
static size_type QwtGridData< T, XContainer, YContainer, DataColumn, DataContainer >::findLowerIndex ( const Container &  arr,
val 
)
inlinestatic

Find the lower bound index in a sorted array.

在排序数组中查找下界索引。

Parameters
arrThe sorted array. / 排序数组。
valThe target value. / 目标值。
Returns
The lower bound index. / 下界索引。

◆ findValueRange()

template<typename T , typename XContainer = std::vector< T >, typename YContainer = std::vector< T >, typename DataColumn = std::vector< T >, typename DataContainer = std::vector< DataColumn >>
void QwtGridData< T, XContainer, YContainer, DataColumn, DataContainer >::findValueRange ( )
inlineprotected

Get the minimum & maximum value in the data matrix.

查找并返回二维数据矩阵中的最小和最大值。

Returns
std::pair<The minimum value, The maximum value> in the data matrix. / 数据矩阵中的最小和最大值。

◆ nearestNeighbour()

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 >::nearestNeighbour ( x,
y 
) const
inlineprotected

Nearest neighbor interpolation.

最近邻插值。

Parameters
xThe x-coordinate. / x 坐标。
yThe y-coordinate. / y 坐标。
Returns
The nearest value. / 最近邻值。

◆ operator()()

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 >::operator() ( x,
y 
) const
inline

Operator to query value at (x, y).

根据给定的 x 和 y 坐标查询值。

Parameters
xThe x-coordinate. / x 坐标。
yThe y-coordinate. / y 坐标。
Returns
The interpolated or nearest value. / 插值或最近邻值。

◆ operator[]()

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 >::operator[] ( const std::pair< T, T > &  xy) const
inline

operator []

根据给定的 x 和 y 坐标查询值。

Parameters
xy,std::pair<x,y>
Returns
The interpolated or nearest value. / 插值或最近邻值。

◆ resampleMode()

template<typename T , typename XContainer = std::vector< T >, typename YContainer = std::vector< T >, typename DataColumn = std::vector< T >, typename DataContainer = std::vector< DataColumn >>
ResampleMode QwtGridData< T, XContainer, YContainer, DataColumn, DataContainer >::resampleMode ( ) const
inline

Get the current resampling mode.

返回当前激活的抽样方法。

Returns
The current resampling mode. / 当前抽样方法。

◆ setResampleMode()

template<typename T , typename XContainer = std::vector< T >, typename YContainer = std::vector< T >, typename DataColumn = std::vector< T >, typename DataContainer = std::vector< DataColumn >>
void QwtGridData< T, XContainer, YContainer, DataColumn, DataContainer >::setResampleMode ( ResampleMode  mode)
inline

Set the resampling mode.

设置查询值时使用的抽样方法。

Parameters
modeThe resampling mode to use. / 要使用的抽样方法。

◆ setValue()

template<typename T , typename XContainer = std::vector< T >, typename YContainer = std::vector< T >, typename DataColumn = std::vector< T >, typename DataContainer = std::vector< DataColumn >>
void QwtGridData< T, XContainer, YContainer, DataColumn, DataContainer >::setValue ( const x_container_type xAxis,
const y_container_type yAxis,
const data_container_type data 
)
inline

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
xAxisThe x-axis values. / x 轴值。
yAxisThe y-axis values. / y 轴值。
dataThe 2D data matrix. / 二维数据矩阵。

◆ valid()

template<typename T , typename XContainer = std::vector< T >, typename YContainer = std::vector< T >, typename DataColumn = std::vector< T >, typename DataContainer = std::vector< DataColumn >>
bool QwtGridData< T, XContainer, YContainer, DataColumn, DataContainer >::valid ( ) const
inline

Check if the object is valid.

判断对象是否有效。

Returns
True if valid, false otherwise. / 如果有效则返回 true,否则返回 false。

◆ validate()

template<typename T , typename XContainer = std::vector< T >, typename YContainer = std::vector< T >, typename DataColumn = std::vector< T >, typename DataContainer = std::vector< DataColumn >>
void QwtGridData< T, XContainer, YContainer, DataColumn, DataContainer >::validate ( )
inline

Validate the data.

验证数据的有效性。

◆ value()

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 >::value ( x,
y 
) const
inline

Query value at (x, y).

根据给定的 x 和 y 坐标查询值。

Parameters
xThe x-coordinate. / x 坐标。
yThe y-coordinate. / y 坐标。
Returns
The interpolated or nearest value. / 插值或最近邻值。

◆ valueSize()

template<typename T , typename XContainer = std::vector< T >, typename YContainer = std::vector< T >, typename DataColumn = std::vector< T >, typename DataContainer = std::vector< DataColumn >>
std::pair< size_type, size_type > QwtGridData< T, XContainer, YContainer, DataColumn, DataContainer >::valueSize ( ) const
inline

value矩阵的尺寸

Returns
<xsize,ysize>

◆ xAxis()

template<typename T , typename XContainer = std::vector< T >, typename YContainer = std::vector< T >, typename DataColumn = std::vector< T >, typename DataContainer = std::vector< DataColumn >>
const x_container_type & QwtGridData< T, XContainer, YContainer, DataColumn, DataContainer >::xAxis ( ) const
inline

Get the x-axis values.

获取 x 轴值。

Returns
The x-axis values. / x 轴值。

◆ xSize()

template<typename T , typename XContainer = std::vector< T >, typename YContainer = std::vector< T >, typename DataColumn = std::vector< T >, typename DataContainer = std::vector< DataColumn >>
size_type QwtGridData< T, XContainer, YContainer, DataColumn, DataContainer >::xSize ( ) const
inline

x的尺寸

Returns

◆ yAxis()

template<typename T , typename XContainer = std::vector< T >, typename YContainer = std::vector< T >, typename DataColumn = std::vector< T >, typename DataContainer = std::vector< DataColumn >>
const y_container_type & QwtGridData< T, XContainer, YContainer, DataColumn, DataContainer >::yAxis ( ) const
inline

Get the y-axis values.

获取 y 轴值。

Returns
The y-axis values. / y 轴值。

◆ ySize()

template<typename T , typename XContainer = std::vector< T >, typename YContainer = std::vector< T >, typename DataColumn = std::vector< T >, typename DataContainer = std::vector< DataColumn >>
size_type QwtGridData< T, XContainer, YContainer, DataColumn, DataContainer >::ySize ( ) const
inline

y的尺寸

Returns

The documentation for this class was generated from the following file: