diff --git a/src/app/valentina/mainwindowsnogui.cpp b/src/app/valentina/mainwindowsnogui.cpp index b3e6b9e72..b0471a14f 100644 --- a/src/app/valentina/mainwindowsnogui.cpp +++ b/src/app/valentina/mainwindowsnogui.cpp @@ -37,6 +37,8 @@ #include "dialogs/dialoglayoutprogress.h" #include "dialogs/dialogsavelayout.h" #include "../vlayout/vposter.h" +#include "../vpatterndb/vpatternpiecedata.h" +#include "../vpatterndb/vpatterninfogeometry.h" #include #include @@ -472,6 +474,16 @@ void MainWindowsNoGUI::PrepareDetailsForLayout(const QHash *de det.SetCountourPoints(d.ContourPoints(pattern)); det.SetSeamAllowencePoints(d.SeamAllowancePoints(pattern), d.getSeamAllowance(), d.getClosed()); det.setName(d.getName()); + const VPatternPieceData& data = d.GetPatternPieceData(); + if (data.IsVisible() == true) + { + det.SetDetailLabelPoints(data.GetPos(), data.GetLabelWidth(), data.GetLabelHeight(), data.GetRotation()); + } + const VPatternInfoGeometry& geom = d.GetPatternInfo(); + if (geom.IsVisible() == true) + { + det.SetPatternInfoPoints(geom.GetPos(), geom.GetLabelWidth(), geom.GetLabelHeight(), geom.GetRotation()); + } det.setWidth(qApp->toPixel(d.getWidth())); listDetails.append(det); diff --git a/src/libs/vlayout/vlayoutdetail.cpp b/src/libs/vlayout/vlayoutdetail.cpp index 7cf91035a..a5fc4971b 100644 --- a/src/libs/vlayout/vlayoutdetail.cpp +++ b/src/libs/vlayout/vlayoutdetail.cpp @@ -112,6 +112,44 @@ QVector VLayoutDetail::GetLayoutAllowencePoints() const return Map(d->layoutAllowence); } +//--------------------------------------------------------------------------------------------------------------------- +QVector VLayoutDetail::GetDetailLabelPoints() const +{ + return d->detailLabel; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VLayoutDetail::SetDetailLabelPoints(const QPointF& ptPos, qreal dWidth, qreal dHeight, qreal dRot) +{ + qreal dAng = qDegreesToRadians(dRot); + QPointF ptCenter(ptPos.x() + dWidth/2, ptPos.y() + dHeight/2); + QVector v; + v << ptPos << QPointF(ptPos.x() + dWidth, ptPos.y()) << QPointF(ptPos.x() + dWidth, ptPos.y() + dHeight) + << QPointF(ptPos.x(), ptPos.y() + dHeight) << ptPos; + for (int i = 0; i < v.count(); ++i) + v[i] = RotatePoint(ptCenter, v[i], dAng); + d->detailLabel = RoundPoints(v); +} + +//--------------------------------------------------------------------------------------------------------------------- +QVector VLayoutDetail::GetPatternInfoPoints() const +{ + return d->patternInfo; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VLayoutDetail::SetPatternInfoPoints(const QPointF& ptPos, qreal dWidth, qreal dHeight, qreal dRot) +{ + qreal dAng = qDegreesToRadians(dRot); + QPointF ptCenter(ptPos.x() + dWidth/2, ptPos.y() + dHeight/2); + QVector v; + v << ptPos << QPointF(ptPos.x() + dWidth, ptPos.y()) << QPointF(ptPos.x() + dWidth, ptPos.y() + dHeight) + << QPointF(ptPos.x(), ptPos.y() + dHeight) << ptPos; + for (int i = 0; i < v.count(); ++i) + v[i] = RotatePoint(ptCenter, v[i], dAng); + d->patternInfo = RoundPoints(v); +} + //--------------------------------------------------------------------------------------------------------------------- QTransform VLayoutDetail::GetMatrix() const { @@ -420,6 +458,34 @@ QPainterPath VLayoutDetail::ContourPath() const path.setFillRule(Qt::WindingFill); } + if (d->detailLabel.count() > 0) + { + points = Map(d->detailLabel); + + QPainterPath pathDet; + pathDet.moveTo(points.at(0)); + for (qint32 i = 1; i < points.count(); ++i) + { + pathDet.lineTo(points.at(i)); + } + + path.addPath(pathDet); + } + + if (d->patternInfo.count() > 0) + { + points = Map(d->patternInfo); + + QPainterPath pathDet; + pathDet.moveTo(points.at(0)); + for (qint32 i = 1; i < points.count(); ++i) + { + pathDet.lineTo(points.at(i)); + } + + path.addPath(pathDet); + } + return path; } @@ -459,3 +525,14 @@ void VLayoutDetail::SetMirror(bool value) { d->mirror = value; } + +//--------------------------------------------------------------------------------------------------------------------- +QPointF VLayoutDetail::RotatePoint(const QPointF &ptCenter, const QPointF& pt, qreal dAng) +{ + QPointF ptDest; + QPointF ptRel = pt - ptCenter; + ptDest.setX(cos(dAng)*ptRel.x() - sin(dAng)*ptRel.y()); + ptDest.setY(sin(dAng)*ptRel.x() + cos(dAng)*ptRel.y()); + + return ptDest + ptCenter; +} diff --git a/src/libs/vlayout/vlayoutdetail.h b/src/libs/vlayout/vlayoutdetail.h index 2e75159ad..8358dbbf4 100644 --- a/src/libs/vlayout/vlayoutdetail.h +++ b/src/libs/vlayout/vlayoutdetail.h @@ -54,6 +54,12 @@ public: QVector GetLayoutAllowencePoints() const; void SetLayoutAllowencePoints(); + QVector GetDetailLabelPoints() const; + void SetDetailLabelPoints(const QPointF& ptPos, qreal dWidth, qreal dHeight, qreal dRot); + + QVector GetPatternInfoPoints() const; + void SetPatternInfoPoints(const QPointF& ptPos, qreal dWidth, qreal dHeight, qreal dRot); + QTransform GetMatrix() const; void SetMatrix(const QTransform &matrix); @@ -86,6 +92,8 @@ private: QVector Map(const QVector &points) const; static QVector RoundPoints(const QVector &points); + + QPointF RotatePoint(const QPointF& ptCenter, const QPointF& pt, qreal dAng); }; Q_DECLARE_TYPEINFO(VLayoutDetail, Q_MOVABLE_TYPE); diff --git a/src/libs/vlayout/vlayoutdetail_p.h b/src/libs/vlayout/vlayoutdetail_p.h index 8a008ac80..1a2e00147 100644 --- a/src/libs/vlayout/vlayoutdetail_p.h +++ b/src/libs/vlayout/vlayoutdetail_p.h @@ -44,13 +44,14 @@ class VLayoutDetailData : public QSharedData public: VLayoutDetailData() :contour(QVector()), seamAllowence(QVector()), layoutAllowence(QVector()), - matrix(QMatrix()), layoutWidth(0), mirror(false) + matrix(QMatrix()), layoutWidth(0), mirror(false), detailLabel(QVector()), + patternInfo(QVector()) {} VLayoutDetailData(const VLayoutDetailData &detail) :QSharedData(detail), contour(detail.contour), seamAllowence(detail.seamAllowence), layoutAllowence(detail.layoutAllowence), matrix(detail.matrix), layoutWidth(detail.layoutWidth), - mirror(detail.mirror) + mirror(detail.mirror), detailLabel(detail.detailLabel), patternInfo(detail.patternInfo) {} ~VLayoutDetailData() {} @@ -72,6 +73,11 @@ public: bool mirror; + /** @brief detail label rectangle */ + QVector detailLabel; + /** @brief pattern info rectangle */ + QVector patternInfo; + private: VLayoutDetailData &operator=(const VLayoutDetailData &) Q_DECL_EQ_DELETE; };