QWT API (中文) 7.3.0
Qt绘图库 - 中文API文档
载入中...
搜索中...
未找到
Public 类型 | Public 成员函数 | 静态 Public 成员函数 | Protected 成员函数 | 所有成员列表
QwtGridData< T, XContainer, YContainer, DataColumn, DataContainer > 模板类 参考

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

#include <qwt_grid_data.hpp>

Public 类型

enum  ResampleMode { NearestNeighbour , BilinearInterpolation , BicubicInterpolation }
 Enumeration for resampling methods. 更多...
 
using value_type = T
 Type of the stored values
 
using x_container_type = XContainer
 Type of the x-axis container
 
using y_container_type = YContainer
 Type of the y-axis container
 
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 成员函数

 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
 Size of x-axis
 
size_type ySize () const
 Size of y-axis
 
std::pair< size_type, size_type > valueSize () const
 Size of the value matrix
 
atX (size_type ix) const
 Value at x-axis index
 
atY (size_type iy) const
 Value at y-axis index
 
atValue (size_type ix, size_type iy) const
 Value at matrix index
 
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
 

静态 Public 成员函数

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 成员函数

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.
 

详细描述

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.

Y-axis direction (down), X-axis direction (right): n rows, m columns

|column[0]|column[1]| ... |column[m]| +------—+------—+--—+------—+ | [x0,yn] | [x1,yn] | ... | [xm,yn] | -> yAxis[n] corresponding row +------—+------—+--—+------—+ | ... | ... | ... | ... | +------—+------—+--—+------—+ | [x0,y1] | [x1,y1] | ... | [xm,y1] | -> yAxis[1] corresponding row +------—+------—+--—+------—+ | [x0,y0] | [x1,y0] | ... | [xm,y0] | -> yAxis[0] corresponding row +------—+------—+--—+------—+ ↑ ↑ ↑ ↑ 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:94
T value(T x, T y) const
Query value at (x, y).
Definition qwt_grid_data.hpp:219
const y_container_type & yAxis() const
Get the y-axis values.
Definition qwt_grid_data.hpp:325
const data_container_type & data() const
Get the data matrix.
Definition qwt_grid_data.hpp:335
const x_container_type & xAxis() const
Get the x-axis values.
Definition qwt_grid_data.hpp:315

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:41
模板参数
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).

成员枚举类型说明

◆ 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.

构造及析构函数说明

◆ 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.

Initializes an empty QwtGridData object.

◆ 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.

参数
xAxisThe x-axis values.
yAxisThe y-axis values.
dataThe 2D data matrix.
modeThe resampling mode to use.

成员函数说明

◆ 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 at matrix index

参数
ix
返回

◆ 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

Value at x-axis index

参数
ix
返回

◆ 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

Value at y-axis index

参数
ix
返回

◆ 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.

参数
xThe x-coordinate.
yThe y-coordinate.
返回
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.

参数
xThe x-coordinate.
yThe y-coordinate.
返回
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.

返回
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.

参数
arrThe sorted array.
valThe target value.
返回
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.

参数
arrThe sorted array.
valThe target value.
返回
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.

返回
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.

参数
xThe x-coordinate.
yThe y-coordinate.
返回
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).

参数
xThe x-coordinate.
yThe y-coordinate.
返回
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 []

Queries value at the given (x, y) coordinates.

参数
xy,std::pair<x,y>
返回
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.

返回
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.

参数
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] corresponding row +------—+------—+--—+------—+ | ... | ... | ... | ... | +------—+------—+--—+------—+ | [x0,y1] | [x1,y1] | ... | [xm,y1] | -> yAxis[1] corresponding row +------—+------—+--—+------—+ | [x0,y0] | [x1,y0] | ... | [xm,y0] | -> yAxis[0] corresponding row +------—+------—+--—+------—+ ↑ ↑ ↑ ↑ xAxis[0] xAxis[1] ... xAxis[m]

so (data matrix).size = xAxis.size,(data matrix).at(n).size = yAxis.size

参数
xAxisThe x-axis values.
yAxisThe y-axis values.
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.

返回
True if valid, false otherwise.

◆ 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).

参数
xThe x-coordinate.
yThe y-coordinate.
返回
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

Size of the value matrix

返回
<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.

返回
The x-axis values.

◆ 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

Size of x-axis

返回

◆ 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.

返回
The y-axis values.

◆ 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

Size of y-axis

返回

该类的文档由以下文件生成: