QWT API (English) 7.3.0
Qt Widget Library for Technical Applications - English API Documentation
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.
 
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 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.
 
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
 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.
 
T atX (size_type ix) const
 Value at x-axis index.
 
T atY (size_type iy) const
 Value at y-axis index.
 
T atValue (size_type ix, size_type iy) const
 Value at matrix index.
 
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
 

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.
 
T nearestNeighbour (T x, T y) const
 Nearest neighbor interpolation.
 
T bilinearInterpolation (T x, T y) const
 Bilinear interpolation.
 
T 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.

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

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.

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.

Parameters
xAxisThe x-axis values.
yAxisThe y-axis values.
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 at matrix index.

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

Value at x-axis index.

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

Value at y-axis index.

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

Parameters
xThe x-coordinate.
yThe y-coordinate.
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 ( T  x,
T  y 
) const
inlineprotected

Bilinear interpolation.

Parameters
xThe x-coordinate.
yThe y-coordinate.
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,
T  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,
T  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 ( T  x,
T  y 
) const
inlineprotected

Nearest neighbor interpolation.

Parameters
xThe x-coordinate.
yThe y-coordinate.
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() ( T  x,
T  y 
) const
inline

Operator to query value at (x, y).

Parameters
xThe x-coordinate.
yThe y-coordinate.
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 []

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

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] 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

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

Returns
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 ( T  x,
T  y 
) const
inline

Query value at (x, y).

Parameters
xThe x-coordinate.
yThe y-coordinate.
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

Size of the value matrix.

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.

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

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.

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

Returns

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