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

View file

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