version 2.28.0
piqt conversion PI2QMathMatrixT(), Q2PIMathMatrixT() and many Q2PIMathVectorT()
This commit is contained in:
@@ -27,8 +27,11 @@
|
||||
|
||||
#include <QColor>
|
||||
#include <QDateTime>
|
||||
#include <QGenericMatrix>
|
||||
#include <QImage>
|
||||
#include <QMatrix4x4>
|
||||
#include <QPolygonF>
|
||||
#include <QVector2D>
|
||||
#include <QVector3D>
|
||||
#if QT_VERSION_MAJOR == 5
|
||||
# if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)
|
||||
@@ -105,6 +108,60 @@ inline PIMathVectorT3d Q2PIVector3(const QVector3D & v) {
|
||||
return PIMathVectorT3d({double(v.x()), double(v.y()), double(v.z())});
|
||||
}
|
||||
|
||||
template<uint Rows, uint Cols = Rows, typename Type = double>
|
||||
inline QGenericMatrix<Cols, Rows, Type> PI2QMathMatrixT(const PIMathMatrixT<Rows, Cols, Type> & v) {
|
||||
QGenericMatrix<Cols, Rows, Type> ret;
|
||||
for (int r = 0; r < Rows; ++r)
|
||||
for (int c = 0; c < Cols; ++c)
|
||||
ret(r, c) = v[r][c];
|
||||
return ret;
|
||||
}
|
||||
|
||||
template<int Rows, int Cols = Rows, typename Type = double>
|
||||
inline PIMathMatrixT<Rows, Cols, Type> Q2PIMathMatrixT(const QGenericMatrix<Cols, Rows, Type> & v) {
|
||||
PIMathMatrixT<Rows, Cols, Type> ret;
|
||||
for (int r = 0; r < Rows; ++r)
|
||||
for (int c = 0; c < Cols; ++c)
|
||||
ret[r][c] = v(r, c);
|
||||
return ret;
|
||||
}
|
||||
inline PIMathMatrixT<4, 4, float> Q2PIMathMatrixT(const QMatrix4x4 & v) {
|
||||
PIMathMatrixT<4, 4, float> ret;
|
||||
for (int r = 0; r < 4; ++r)
|
||||
for (int c = 0; c < 4; ++c)
|
||||
ret[r][c] = v(r, c);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
inline PIMathVectorT2d Q2PIMathVectorT(const QVector2D & v) {
|
||||
return PIMathVectorT2d({v[0], v[1]});
|
||||
}
|
||||
inline PIMathVectorT2d Q2PIMathVectorT(const QPointF & v) {
|
||||
return PIMathVectorT2d({v.x(), v.y()});
|
||||
}
|
||||
inline PIMathVectorT3d Q2PIMathVectorT(const QVector3D & v) {
|
||||
return PIMathVectorT3d({v[0], v[1], v[2]});
|
||||
}
|
||||
inline PIMathVectorT4d Q2PIMathVectorT(const QVector4D & v) {
|
||||
return PIMathVectorT4d({v[0], v[1], v[2], v[3]});
|
||||
}
|
||||
template<int Size, typename Type = double>
|
||||
inline PIMathVectorT<Size, double> Q2PIMathVectorT(const QGenericMatrix<1, Size, Type> & v) {
|
||||
PIMathVectorT<Size, double> ret;
|
||||
for (int i = 0; i < Size; ++i)
|
||||
ret[i] = v(i, 0);
|
||||
return ret;
|
||||
}
|
||||
template<int Size, typename Type = double>
|
||||
inline PIMathVectorT<Size, double> Q2PIMathVectorT(const QGenericMatrix<Size, 1, Type> & v) {
|
||||
PIMathVectorT<Size, double> ret;
|
||||
for (int i = 0; i < Size; ++i)
|
||||
ret[i] = v(0, i);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
inline QPointF PI2QPoint(const PIPointd & v) {
|
||||
return QPointF(v.x, v.y);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user