Incorrect work with curves. Closes #170

This commit is contained in:
Roman Telezhynskyi 2022-03-16 17:43:09 +02:00
parent e013ce234a
commit 8b0b5c89aa
7 changed files with 22 additions and 15 deletions

View File

@ -3,6 +3,7 @@
- Fix issue with Custom template.
- Fix issue with tile font size.
- [smart-pattern/valentina#171] System identifies two of the same curve.
- [smart-pattern/valentina#170] Incorrect work with curves.
# Valentina 0.7.50 February 14, 2022
- Fix regression. Minimal seam allowance width is less than the point accuracy values.

View File

@ -204,7 +204,8 @@ VSplineData::~VSplineData()
qreal VSplineData::GetL(const QPointF &p1, const QPointF &p4, qreal kCurve)
{
static const qreal angle = 90;
const qreal radius = QLineF(p1, p4).length()/M_SQRT2;
qreal length = VFuzzyComparePoints(p1, p4) ? accuracyPointOnLine*2 : QLineF(p1, p4).length();
const qreal radius = length/M_SQRT2;
return kCurve * radius * 4 / 3 * qTan( angle * M_PI_4 / 180.0 );
}

View File

@ -207,11 +207,6 @@ VSplinePath::~VSplinePath()
*/
void VSplinePath::append(const VSplinePoint &point)
{
if (d->path.size() > 0 && static_cast<QPointF>(ConstLast(d->path).P()) == static_cast<QPointF>(point.P())) //-V807
{
return;
}
d->path.append(point);
CreateName();
}

View File

@ -234,6 +234,7 @@ void VToolEndLine::SetVisualization()
visual->SetAngle(VAbstractApplication::VApp()->TrVars()
->FormulaToUser(formulaAngle, VAbstractApplication::VApp()->Settings()->GetOsSeparator()));
visual->setLineStyle(LineStyleToPenStyle(m_lineType));
visual->SetMode(Mode::Show);
visual->RefreshGeometry();
}
}

View File

@ -75,9 +75,11 @@ VToolLinePoint::VToolLinePoint(VAbstractPattern *doc, VContainer *data, const qu
Q_ASSERT_X(basePointId != 0, Q_FUNC_INFO, "basePointId == 0"); //-V654 //-V712
QPointF point1 = static_cast<QPointF>(*data->GeometricObject<VPointF>(basePointId));
QPointF point2 = static_cast<QPointF>(*data->GeometricObject<VPointF>(id));
mainLine = new VScaledLine(QLineF(point1 - point2, QPointF()), this);
QLineF line(point1 - point2, QPointF());
mainLine = new VScaledLine(line, this);
mainLine->SetBoldLine(false);
mainLine->setFlag(QGraphicsItem::ItemStacksBehindParent, true);
mainLine->setVisible(not line.isNull());
}
//---------------------------------------------------------------------------------------------------------------------
@ -107,7 +109,9 @@ void VToolLinePoint::RefreshGeometry()
VToolSinglePoint::RefreshPointGeometry(*VDrawTool::data.GeometricObject<VPointF>(m_id));
QPointF point = static_cast<QPointF>(*VDrawTool::data.GeometricObject<VPointF>(m_id));
QPointF basePoint = static_cast<QPointF>(*VDrawTool::data.GeometricObject<VPointF>(basePointId));
mainLine->setLine(QLineF(basePoint - point, QPointF()));
QLineF line(basePoint - point, QPointF());
mainLine->setLine(line);
mainLine->setVisible(not line.isNull());
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -62,6 +62,8 @@ void VisToolEndLine::RefreshGeometry()
const QSharedPointer<VPointF> first = Visualization::data->GeometricObject<VPointF>(object1Id);
QLineF line;
if (qFuzzyIsNull(length))
{
if (mode == Mode::Creation)
{
if (QGuiApplication::keyboardModifiers() == Qt::ShiftModifier)
{
@ -74,6 +76,11 @@ void VisToolEndLine::RefreshGeometry()
}
}
else
{
DrawPoint(point, static_cast<QPointF>(*first), mainColor);
}
}
else
{
line = VGObject::BuildLine(static_cast<QPointF>(*first), length, angle);
DrawPoint(point, line.p2(), mainColor);

View File

@ -251,15 +251,13 @@ void Visualization::DrawLine(VScaledLine *lineItem, const QLineF &line, const QC
QPen visPen = lineItem->pen();
visPen.setColor(color);
visPen.setStyle(style);
visPen.setStyle(not line.isNull() ? style : Qt::NoPen);
lineItem->setPen(visPen);
if (not line.isNull())
{
lineItem->setLine(line);
}
lineItem->setVisible(not line.isNull());
}
//---------------------------------------------------------------------------------------------------------------------