Count mirror line as part of shape.

This commit is contained in:
Roman Telezhynskyi 2024-07-18 19:42:06 +03:00
parent 1a2ba7233d
commit b4f7f6378f
2 changed files with 50 additions and 46 deletions

View file

@ -182,6 +182,7 @@ auto VPGraphicsPiece::boundingRect() const -> QRectF
shape.addPath(m_stickyPath); shape.addPath(m_stickyPath);
shape.addPath(m_foldLineMarkPath); shape.addPath(m_foldLineMarkPath);
shape.addPath(m_foldLineLabelPath); shape.addPath(m_foldLineLabelPath);
shape.addPath(m_mirrorLinePath);
VPSettings *settings = VPApplication::VApp()->PuzzleSettings(); VPSettings *settings = VPApplication::VApp()->PuzzleSettings();
const qreal halfPenWidth = settings->GetLayoutLineWidth() / 2.; const qreal halfPenWidth = settings->GetLayoutLineWidth() / 2.;
@ -598,6 +599,7 @@ void VPGraphicsPiece::PaintPiece(QPainter *painter)
m_stickyPath = QPainterPath(); m_stickyPath = QPainterPath();
m_foldLineMarkPath = QPainterPath(); m_foldLineMarkPath = QPainterPath();
m_foldLineLabelPath = QPainterPath(); m_foldLineLabelPath = QPainterPath();
m_mirrorLinePath = QPainterPath();
VPPiecePtr const piece = m_piece.toStrongRef(); VPPiecePtr const piece = m_piece.toStrongRef();
if (piece.isNull()) if (piece.isNull())
@ -907,12 +909,14 @@ void VPGraphicsPiece::PaintStickyPath(QPainter *painter)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPGraphicsPiece::PaintMirrorLine(QPainter *painter, const VPPiecePtr &piece) const void VPGraphicsPiece::PaintMirrorLine(QPainter *painter, const VPPiecePtr &piece)
{ {
if (piece->IsShowFullPiece()) if (!piece->IsShowFullPiece())
{ {
return;
}
bool mirrorFlag = false; bool mirrorFlag = false;
QPainterPath mirrorLinePath;
if (not piece->IsSeamAllowance() || piece->IsSeamAllowanceBuiltIn()) if (not piece->IsSeamAllowance() || piece->IsSeamAllowanceBuiltIn())
{ {
QLineF const seamMirrorLine = piece->GetMappedSeamMirrorLine(); QLineF const seamMirrorLine = piece->GetMappedSeamMirrorLine();
@ -921,7 +925,7 @@ void VPGraphicsPiece::PaintMirrorLine(QPainter *painter, const VPPiecePtr &piece
QPainterPath mirrorPath; QPainterPath mirrorPath;
mirrorPath.moveTo(seamMirrorLine.p1()); mirrorPath.moveTo(seamMirrorLine.p1());
mirrorPath.lineTo(seamMirrorLine.p2()); mirrorPath.lineTo(seamMirrorLine.p2());
mirrorLinePath.addPath(mirrorPath); m_mirrorLinePath.addPath(mirrorPath);
mirrorFlag = true; mirrorFlag = true;
} }
} }
@ -945,7 +949,7 @@ void VPGraphicsPiece::PaintMirrorLine(QPainter *painter, const VPPiecePtr &piece
QPainterPath mirrorPath; QPainterPath mirrorPath;
mirrorPath.moveTo(seamAllowanceMirrorLine.p1()); mirrorPath.moveTo(seamAllowanceMirrorLine.p1());
mirrorPath.lineTo(seamAllowanceMirrorLine.p2()); mirrorPath.lineTo(seamAllowanceMirrorLine.p2());
mirrorLinePath.addPath(mirrorPath); m_mirrorLinePath.addPath(mirrorPath);
mirrorFlag = true; mirrorFlag = true;
} }
} }
@ -956,11 +960,10 @@ void VPGraphicsPiece::PaintMirrorLine(QPainter *painter, const VPPiecePtr &piece
QPen pen = painter->pen(); QPen pen = painter->pen();
pen.setStyle(Qt::DashDotLine); pen.setStyle(Qt::DashDotLine);
painter->setPen(pen); painter->setPen(pen);
painter->drawPath(mirrorLinePath); painter->drawPath(m_mirrorLinePath);
painter->restore(); painter->restore();
} }
} }
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPGraphicsPiece::PaintFoldLine(QPainter *painter, const VPPiecePtr &piece) void VPGraphicsPiece::PaintFoldLine(QPainter *painter, const VPPiecePtr &piece)

View file

@ -96,6 +96,7 @@ private:
QPainterPath m_internalPaths{}; QPainterPath m_internalPaths{};
QPainterPath m_passmarks{}; QPainterPath m_passmarks{};
QPainterPath m_placeLabels{}; QPainterPath m_placeLabels{};
QPainterPath m_mirrorLinePath{};
QPointF m_moveStartPoint{}; QPointF m_moveStartPoint{};
QPointF m_rotationStartPoint{}; QPointF m_rotationStartPoint{};
@ -133,7 +134,7 @@ private:
void PaintPassmarks(QPainter *painter, const VPPiecePtr &piece); void PaintPassmarks(QPainter *painter, const VPPiecePtr &piece);
void PaintPlaceLabels(QPainter *painter, const VPPiecePtr &piece); void PaintPlaceLabels(QPainter *painter, const VPPiecePtr &piece);
void PaintStickyPath(QPainter *painter); void PaintStickyPath(QPainter *painter);
void PaintMirrorLine(QPainter *painter, const VPPiecePtr &piece) const; void PaintMirrorLine(QPainter *painter, const VPPiecePtr &piece);
void PaintFoldLine(QPainter *painter, const VPPiecePtr &piece); void PaintFoldLine(QPainter *painter, const VPPiecePtr &piece);
void GroupMove(const QPointF &pos); void GroupMove(const QPointF &pos);