version 2.28.0
piqt conversion PI2QMathMatrixT(), Q2PIMathMatrixT() and many Q2PIMathVectorT()
This commit is contained in:
@@ -3,7 +3,7 @@ cmake_policy(SET CMP0017 NEW) # need include() with .cmake
|
|||||||
cmake_policy(SET CMP0072 NEW) # FindOpenGL prefers GLVND by default
|
cmake_policy(SET CMP0072 NEW) # FindOpenGL prefers GLVND by default
|
||||||
project(QAD)
|
project(QAD)
|
||||||
set(QAD_MAJOR 2)
|
set(QAD_MAJOR 2)
|
||||||
set(QAD_MINOR 27)
|
set(QAD_MINOR 28)
|
||||||
set(QAD_REVISION 0)
|
set(QAD_REVISION 0)
|
||||||
set(QAD_SUFFIX )
|
set(QAD_SUFFIX )
|
||||||
set(QAD_COMPANY SHS)
|
set(QAD_COMPANY SHS)
|
||||||
|
|||||||
@@ -27,8 +27,11 @@
|
|||||||
|
|
||||||
#include <QColor>
|
#include <QColor>
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
|
#include <QGenericMatrix>
|
||||||
#include <QImage>
|
#include <QImage>
|
||||||
|
#include <QMatrix4x4>
|
||||||
#include <QPolygonF>
|
#include <QPolygonF>
|
||||||
|
#include <QVector2D>
|
||||||
#include <QVector3D>
|
#include <QVector3D>
|
||||||
#if QT_VERSION_MAJOR == 5
|
#if QT_VERSION_MAJOR == 5
|
||||||
# if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)
|
# 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())});
|
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) {
|
inline QPointF PI2QPoint(const PIPointd & v) {
|
||||||
return QPointF(v.x, v.y);
|
return QPointF(v.x, v.y);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user