Improve validation grainline position.

This commit is contained in:
Roman Telezhynskyi 2021-11-16 18:33:20 +02:00
parent ec672a8811
commit bd50428b56
2 changed files with 20 additions and 4 deletions

View File

@ -16,6 +16,7 @@
- Fix handling numeric values passed in console mode.
- Add Don't ask again for Stale layout question dialog.
- Help user to select default GUI language.
- Improve validation grainline position.
# Valentina 0.7.49 July 1, 2021
- Fix crash.

View File

@ -2050,14 +2050,29 @@ QList<VToolSeamAllowance *> VToolSeamAllowance::SelectedTools() const
auto VToolSeamAllowance::IsGrainlinePositionValid() const -> bool
{
QLineF grainLine = m_grainLine->Grainline();
QPainterPath grainLinePath = VAbstractPiece::PainterPath(QVector<QPointF>{grainLine.p1(), grainLine.p2()});
const VPiece detail = VAbstractTool::data.GetPiece(m_id);
const QVector<QPointF> contourPoints = detail.IsSeamAllowance() && not detail.IsSeamAllowanceBuiltIn() ?
detail.SeamAllowancePoints(getData()) : detail.MainPathPoints(getData());
const QPainterPath contourPath = VAbstractPiece::PainterPath(contourPoints);
return contourPath.contains(grainLinePath);
QVector<QPointF> points = VAbstractCurve::CurveIntersectLine(contourPoints, grainLine);
if (not points.isEmpty())
{
for (auto &point : points)
{
if (not VFuzzyComparePoints(grainLine.p1(), point) && not VFuzzyComparePoints(grainLine.p2(), point))
{
return false;
}
}
}
else
{
QPainterPath grainLinePath = VAbstractPiece::PainterPath(QVector<QPointF>{grainLine.p1(), grainLine.p2()});
const QPainterPath contourPath = VAbstractPiece::PainterPath(contourPoints);
return contourPath.contains(grainLinePath);
}
return true;
}
//---------------------------------------------------------------------------------------------------------------------