diff --git a/src/core/XML/xmlexporthelpers.cpp b/src/core/XML/xmlexporthelpers.cpp index d0a389fed..fd7323b7d 100644 --- a/src/core/XML/xmlexporthelpers.cpp +++ b/src/core/XML/xmlexporthelpers.cpp @@ -25,6 +25,8 @@ #include "xmlexporthelpers.h" +#include + #include "Properties/property.h" #include "Paint/simplebrushwrapper.h" #include "Paint/brushescontext.h" @@ -158,6 +160,39 @@ QString XmlExportHelpers::matrixToString(const QMatrix& m) { arg(m.dx()).arg(m.dy()); } +QMatrix4x4 XmlExportHelpers::stringToMatrix4x4(const QString& str) { + const auto vals = str.split(' ', Qt::SkipEmptyParts); + if(vals.count() != 7) RuntimeThrow("Invalid matrix value '" + str + "'"); + const qreal m11 = stringToDouble(vals[0]); + const qreal m12 = stringToDouble(vals[1]); + const qreal m13 = stringToDouble(vals[1]); + const qreal m14 = stringToDouble(vals[1]); + const qreal m21 = stringToDouble(vals[2]); + const qreal m22 = stringToDouble(vals[3]); + const qreal m23 = stringToDouble(vals[1]); + const qreal m24 = stringToDouble(vals[1]); + const qreal m31 = stringToDouble(vals[1]); + const qreal m32 = stringToDouble(vals[1]); + const qreal m33 = stringToDouble(vals[1]); + const qreal m34 = stringToDouble(vals[1]); + const qreal m41 = stringToDouble(vals[1]); + const qreal m42 = stringToDouble(vals[1]); + const qreal m43 = stringToDouble(vals[1]); + const qreal m44 = stringToDouble(vals[1]); + return QMatrix4x4(m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, m41, m42, m43, m44); +} +// TODO +/*QString XmlExportHelpers::matrix4x4ToString(const QMatrix4x4& m) { + return QString("%1 %2 %3 %4 %5 %6 %7 %8 %9 %10 %11 %12 %13 %14").arg(m.m11()).arg(m.m12()) + .arg(m.m13()).arg(m.m14()) + .arg(m.m21()).arg(m.m22()) + .arg(m.m23()).arg(m.m24()) + .arg(m.m31()).arg(m.m32()) + .arg(m.m33()).arg(m.m34()) + .arg(m.m41()).arg(m.42()) + .arg(m.m43()).arg(m.m44()); + }*/ + void XevExportHelpers::setAbsAndRelFileSrc(const QString& absSrc, QDomElement& ele, const XevExporter& exp) { diff --git a/src/core/XML/xmlexporthelpers.h b/src/core/XML/xmlexporthelpers.h index 34d012711..b255fc8ad 100644 --- a/src/core/XML/xmlexporthelpers.h +++ b/src/core/XML/xmlexporthelpers.h @@ -33,6 +33,7 @@ #include #include +class QMatrix4x4; class SimpleBrushWrapper; class XevExporter; class XevImporter; @@ -76,6 +77,11 @@ namespace XmlExportHelpers { QMatrix stringToMatrix(const QString& str); CORE_EXPORT QString matrixToString(const QMatrix& m); + + CORE_EXPORT + QMatrix4x4 stringToMatrix4x4(const QString& str); + /*CORE_EXPORT TODO + QString matrix4x4ToString(const QMatrix4x4& matrix);*/ }; namespace XevExportHelpers { diff --git a/src/core/skia/skiaincludes.h b/src/core/skia/skiaincludes.h index 0d38de81c..5f0ffebdf 100644 --- a/src/core/skia/skiaincludes.h +++ b/src/core/skia/skiaincludes.h @@ -52,6 +52,8 @@ QT_WARNING_DISABLE_GCC("-Wattributes") #include "include/core/SkMaskFilter.h" #include "include/core/SkColorFilter.h" #include "include/core/SkFontMetrics.h" +#include "include/core/SkMatrix44.h" +#include "include/core/SkPoint3.h" #include "include/pathops/SkPathOps.h" diff --git a/src/core/skia/skqtconversions.h b/src/core/skia/skqtconversions.h index 3569563e5..7a47b2eeb 100644 --- a/src/core/skia/skqtconversions.h +++ b/src/core/skia/skqtconversions.h @@ -28,6 +28,7 @@ #include #include +#include #include #include @@ -77,11 +78,23 @@ extern QMatrix toQMatrix(const SkMatrix &matrix); CORE_EXPORT extern SkMatrix toSkMatrix(const QMatrix &matrix); +CORE_EXPORT +extern QMatrix4x4 toQMatrix4x4(const SkMatrix44 &matrix); + +CORE_EXPORT +extern SkMatrix44 toSkMatrix44(const QMatrix4x4 &matrix); + extern inline QPointF toQPointF(const SkPoint &point) { return QPointF(toQreal(point.x()), toQreal(point.y())); } +extern inline QVector3D toQVector3D(const SkPoint3 &point) { + return QVector3D(toQreal(point.x()), + toQreal(point.y()), + toQreal(point.z())); +} + extern inline SkPoint toSkPoint(const QPointF &point) { return SkPoint::Make(toSkScalar(point.x()), toSkScalar(point.y())); @@ -91,6 +104,20 @@ extern inline SkPoint toSkPoint(const QPoint &point) { return SkPoint::Make(point.x(), point.y()); } +extern inline SkPoint3 toSkPoint3(const QPointF &point) { + return SkPoint3::Make(toSkScalar(point.x()), + toSkScalar(point.y()), + 0); +} + +extern inline SkPoint3 toSkPoint3(const QPoint &point) { + return SkPoint3::Make(point.x(), point.y(), 0); +} + +extern inline SkPoint3 toSkPoint3(const QVector3D &point) { + return SkPoint3::Make(point.x(), point.y(), point.z()); +} + CORE_EXPORT extern SkPaint::Cap QCapToSkCap(const Qt::PenCapStyle &cap);