Fix grainline position on layout.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2017-07-11 13:53:36 +03:00
parent 9475da34b8
commit 3b00e4ad0e
2 changed files with 36 additions and 18 deletions

View File

@ -489,7 +489,7 @@ void VLayoutPiece::SetDetail(const QString& qsName, const VPieceLabelData& data,
v[i] = RotatePoint(ptCenter, v.at(i), dAng);
}
QScopedPointer<QGraphicsItem> item(GetMainItem());
QScopedPointer<QGraphicsItem> 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<QGraphicsItem> item(GetMainItem());
QScopedPointer<QGraphicsItem> 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<QGraphicsItem> item(GetMainItem());
QScopedPointer<QGraphicsItem> item(GetMainPathItem());
d->grainlinePoints = CorrectPosition(item->boundingRect(), RoundPoints(v));
}
@ -843,20 +843,7 @@ QVector<T> VLayoutPiece::Map(const QVector<T> &points) const
//---------------------------------------------------------------------------------------------------------------------
QPainterPath VLayoutPiece::ContourPath() const
{
QPainterPath path;
// contour
QVector<QPointF> 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();
QVector<QPointF>points = 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<QPointF> 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
{

View File

@ -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<QPointF> 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<QPointF> &labelShape, const VTextManager &tm,