Improve validation grainline position.
This commit is contained in:
parent
ec672a8811
commit
bd50428b56
|
@ -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.
|
||||
|
|
|
@ -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);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
Loading…
Reference in New Issue
Block a user