From 3b00e4ad0ec7ef3a9e400c779cf47e3e9e4b184e Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Tue, 11 Jul 2017 13:53:36 +0300 Subject: [PATCH] Fix grainline position on layout. --HG-- branch : develop --- src/libs/vlayout/vlayoutpiece.cpp | 52 ++++++++++++++++++++----------- src/libs/vlayout/vlayoutpiece.h | 2 ++ 2 files changed, 36 insertions(+), 18 deletions(-) diff --git a/src/libs/vlayout/vlayoutpiece.cpp b/src/libs/vlayout/vlayoutpiece.cpp index da5721deb..3b08917a0 100644 --- a/src/libs/vlayout/vlayoutpiece.cpp +++ b/src/libs/vlayout/vlayoutpiece.cpp @@ -489,7 +489,7 @@ void VLayoutPiece::SetDetail(const QString& qsName, const VPieceLabelData& data, v[i] = RotatePoint(ptCenter, v.at(i), dAng); } - QScopedPointer item(GetMainItem()); + QScopedPointer item(GetMainPathItem()); d->detailLabel = CorrectPosition(item->boundingRect(), RoundPoints(v)); // generate text @@ -529,7 +529,7 @@ void VLayoutPiece::SetPatternInfo(const VAbstractPattern* pDoc, const VPatternLa { v[i] = RotatePoint(ptCenter, v.at(i), dAng); } - QScopedPointer item(GetMainItem()); + QScopedPointer item(GetMainPathItem()); d->patternInfo = CorrectPosition(item->boundingRect(), RoundPoints(v)); // Generate text @@ -582,7 +582,7 @@ void VLayoutPiece::SetGrainline(const VGrainlineData& geom, const VContainer* pa v << pt2; } - QScopedPointer item(GetMainItem()); + QScopedPointer item(GetMainPathItem()); d->grainlinePoints = CorrectPosition(item->boundingRect(), RoundPoints(v)); } @@ -843,20 +843,7 @@ QVector VLayoutPiece::Map(const QVector &points) const //--------------------------------------------------------------------------------------------------------------------- QPainterPath VLayoutPiece::ContourPath() const { - QPainterPath path; - - // contour - QVector points = GetContourPoints(); - - if (not IsHideMainPath() || not IsSeamAllowance() || IsSeamAllowanceBuiltIn()) - { - path.moveTo(points.at(0)); - for (qint32 i = 1; i < points.count(); ++i) - { - path.lineTo(points.at(i)); - } - path.lineTo(points.at(0)); - } + QPainterPath path = MainPath(); // seam allowance if (IsSeamAllowance()) @@ -864,7 +851,7 @@ QPainterPath VLayoutPiece::ContourPath() const if (not IsSeamAllowanceBuiltIn()) { // Draw seam allowance - points = GetSeamAllowancePoints(); + QVectorpoints = GetSeamAllowancePoints(); if (points.last().toPoint() != points.first().toPoint()) { @@ -897,6 +884,27 @@ QPainterPath VLayoutPiece::ContourPath() const return path; } +//--------------------------------------------------------------------------------------------------------------------- +QPainterPath VLayoutPiece::MainPath() const +{ + QPainterPath path; + + // contour + QVector points = GetContourPoints(); + + if (not IsHideMainPath() || not IsSeamAllowance() || IsSeamAllowanceBuiltIn()) + { + path.moveTo(points.at(0)); + for (qint32 i = 1; i < points.count(); ++i) + { + path.lineTo(points.at(i)); + } + path.lineTo(points.at(0)); + } + + return path; +} + //--------------------------------------------------------------------------------------------------------------------- void VLayoutPiece::CreateInternalPathItem(int i, QGraphicsItem *parent) const { @@ -1081,6 +1089,14 @@ QGraphicsPathItem *VLayoutPiece::GetMainItem() const return item; } +//--------------------------------------------------------------------------------------------------------------------- +QGraphicsPathItem *VLayoutPiece::GetMainPathItem() const +{ + QGraphicsPathItem *item = new QGraphicsPathItem(); + item->setPath(MainPath()); + return item; +} + //--------------------------------------------------------------------------------------------------------------------- bool VLayoutPiece::IsMirror() const { diff --git a/src/libs/vlayout/vlayoutpiece.h b/src/libs/vlayout/vlayoutpiece.h index 358abe18b..be95f8b0c 100644 --- a/src/libs/vlayout/vlayoutpiece.h +++ b/src/libs/vlayout/vlayoutpiece.h @@ -124,6 +124,7 @@ public: bool isNull() const; qint64 Square() const; QPainterPath ContourPath() const; + QPainterPath MainPath() const; QPainterPath LayoutAllowancePath() const; Q_REQUIRED_RESULT QGraphicsItem *GetItem(bool textAsPaths) const; @@ -134,6 +135,7 @@ private: QVector DetailPath() const; Q_REQUIRED_RESULT QGraphicsPathItem *GetMainItem() const; + Q_REQUIRED_RESULT QGraphicsPathItem *GetMainPathItem() const; void CreateInternalPathItem(int i, QGraphicsItem *parent) const; void CreateLabelStrings(QGraphicsItem *parent, const QVector &labelShape, const VTextManager &tm,