New warnings. Warn a user about incorrect cut curve segment length.
This commit is contained in:
parent
95ba17aee3
commit
a6d9194051
|
@ -4,6 +4,7 @@
|
||||||
- Warn about stale layout only in GUI mode.
|
- Warn about stale layout only in GUI mode.
|
||||||
- Fix regression. Set default value for detail labels size and grainline length to 10 cm.
|
- Fix regression. Set default value for detail labels size and grainline length to 10 cm.
|
||||||
- [smart-pattern/valentina#136] 2 decimals for entering values in multi measurements tables.
|
- [smart-pattern/valentina#136] 2 decimals for entering values in multi measurements tables.
|
||||||
|
- New warnings. Warn a user about incorrect cut curve segment length.
|
||||||
|
|
||||||
# Valentina 0.7.49 July 1, 2021
|
# Valentina 0.7.49 July 1, 2021
|
||||||
- Fix crash.
|
- Fix crash.
|
||||||
|
|
|
@ -39,6 +39,7 @@
|
||||||
#include "../vmisc/vmath.h"
|
#include "../vmisc/vmath.h"
|
||||||
#include "../vgeometry/vpointf.h"
|
#include "../vgeometry/vpointf.h"
|
||||||
#include "../vmisc/vabstractapplication.h"
|
#include "../vmisc/vabstractapplication.h"
|
||||||
|
#include "../ifc/exception/vexception.h"
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
@ -420,6 +421,11 @@ QPointF VAbstractCubicBezier::CutSpline(qreal length, QPointF &spl1p2, QPointF &
|
||||||
if (fullLength <= minLength)
|
if (fullLength <= minLength)
|
||||||
{
|
{
|
||||||
spl1p2 = spl1p3 = spl2p2 = spl2p3 = QPointF();
|
spl1p2 = spl1p3 = spl2p2 = spl2p3 = QPointF();
|
||||||
|
|
||||||
|
const QString errorMsg = QObject::tr("Unable to cut curve '%1'. The curve is too short.").arg(name());
|
||||||
|
VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) :
|
||||||
|
qWarning() << VAbstractApplication::warningMessageSignature + errorMsg;
|
||||||
|
|
||||||
return QPointF();
|
return QPointF();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -428,10 +434,20 @@ QPointF VAbstractCubicBezier::CutSpline(qreal length, QPointF &spl1p2, QPointF &
|
||||||
if (length < minLength)
|
if (length < minLength)
|
||||||
{
|
{
|
||||||
length = minLength;
|
length = minLength;
|
||||||
|
|
||||||
|
const QString errorMsg = QObject::tr("Curve '%1'. Length of a cut segment is too small. Optimize it to minimal "
|
||||||
|
"value.").arg(name());
|
||||||
|
VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) :
|
||||||
|
qWarning() << VAbstractApplication::warningMessageSignature + errorMsg;
|
||||||
}
|
}
|
||||||
else if (length > maxLength)
|
else if (length > maxLength)
|
||||||
{
|
{
|
||||||
length = maxLength;
|
length = maxLength;
|
||||||
|
|
||||||
|
const QString errorMsg = QObject::tr("Curve '%1'. Length of a cut segment is too big. Optimize it to maximal "
|
||||||
|
"value.").arg(name());
|
||||||
|
VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) :
|
||||||
|
qWarning() << VAbstractApplication::warningMessageSignature + errorMsg;
|
||||||
}
|
}
|
||||||
|
|
||||||
const qreal parT = GetParmT(length);
|
const qreal parT = GetParmT(length);
|
||||||
|
|
|
@ -30,12 +30,14 @@
|
||||||
#include "vsplinepoint.h"
|
#include "vsplinepoint.h"
|
||||||
|
|
||||||
#include <QPainterPath>
|
#include <QPainterPath>
|
||||||
|
#include <QtDebug>
|
||||||
|
|
||||||
#include "../vmisc/def.h"
|
#include "../vmisc/def.h"
|
||||||
#include "../ifc/ifcdef.h"
|
#include "../ifc/ifcdef.h"
|
||||||
#include "../ifc/exception/vexception.h"
|
#include "../ifc/exception/vexception.h"
|
||||||
#include "vpointf.h"
|
#include "vpointf.h"
|
||||||
#include "vspline.h"
|
#include "vspline.h"
|
||||||
|
#include "vabstractapplication.h"
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VAbstractCubicBezierPath::VAbstractCubicBezierPath(const GOType &type, const quint32 &idObject, const Draw &mode)
|
VAbstractCubicBezierPath::VAbstractCubicBezierPath(const GOType &type, const quint32 &idObject, const Draw &mode)
|
||||||
|
@ -180,6 +182,11 @@ QPointF VAbstractCubicBezierPath::CutSplinePath(qreal length, qint32 &p1, qint32
|
||||||
{
|
{
|
||||||
p1 = p2 = -1;
|
p1 = p2 = -1;
|
||||||
spl1p2 = spl1p3 = spl2p2 = spl2p3 = QPointF();
|
spl1p2 = spl1p3 = spl2p2 = spl2p3 = QPointF();
|
||||||
|
|
||||||
|
const QString errorMsg = QObject::tr("Unable to cut curve '%1'. The curve is too short.").arg(name());
|
||||||
|
VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) :
|
||||||
|
qWarning() << VAbstractApplication::warningMessageSignature + errorMsg;
|
||||||
|
|
||||||
return QPointF();
|
return QPointF();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -188,10 +195,20 @@ QPointF VAbstractCubicBezierPath::CutSplinePath(qreal length, qint32 &p1, qint32
|
||||||
if (length < minLength)
|
if (length < minLength)
|
||||||
{
|
{
|
||||||
length = minLength;
|
length = minLength;
|
||||||
|
|
||||||
|
const QString errorMsg = QObject::tr("Curve '%1'. Length of a cut segment is too small. Optimize it to minimal "
|
||||||
|
"value.").arg(name());
|
||||||
|
VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) :
|
||||||
|
qWarning() << VAbstractApplication::warningMessageSignature + errorMsg;
|
||||||
}
|
}
|
||||||
else if (length > maxLength)
|
else if (length > maxLength)
|
||||||
{
|
{
|
||||||
length = maxLength;
|
length = maxLength;
|
||||||
|
|
||||||
|
const QString errorMsg = QObject::tr("Curve '%1'. Length of a cut segment is too big. Optimize it to maximal "
|
||||||
|
"value.").arg(name());
|
||||||
|
VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) :
|
||||||
|
qWarning() << VAbstractApplication::warningMessageSignature + errorMsg;
|
||||||
}
|
}
|
||||||
|
|
||||||
fullLength = 0;
|
fullLength = 0;
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
|
|
||||||
#include <QLineF>
|
#include <QLineF>
|
||||||
#include <QPointF>
|
#include <QPointF>
|
||||||
|
#include <QtDebug>
|
||||||
|
|
||||||
#include "../vmisc/def.h"
|
#include "../vmisc/def.h"
|
||||||
#include "../vmisc/vmath.h"
|
#include "../vmisc/vmath.h"
|
||||||
|
@ -38,6 +39,7 @@
|
||||||
#include "vabstractcurve.h"
|
#include "vabstractcurve.h"
|
||||||
#include "varc_p.h"
|
#include "varc_p.h"
|
||||||
#include "vspline.h"
|
#include "vspline.h"
|
||||||
|
#include "../ifc/exception/vexception.h"
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
|
@ -351,10 +353,17 @@ QPointF VArc::CutArc(qreal length, VArc &arc1, VArc &arc2) const
|
||||||
{
|
{
|
||||||
arc1 = VArc();
|
arc1 = VArc();
|
||||||
arc2 = VArc();
|
arc2 = VArc();
|
||||||
|
|
||||||
|
const QString errorMsg = QObject::tr("Unable to cut curve '%1'. The curve is too short.").arg(name());
|
||||||
|
VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) :
|
||||||
|
qWarning() << VAbstractApplication::warningMessageSignature + errorMsg;
|
||||||
|
|
||||||
return QPointF();
|
return QPointF();
|
||||||
}
|
}
|
||||||
|
|
||||||
QLineF line(static_cast<QPointF>(GetCenter()), GetP1());
|
QLineF line(static_cast<QPointF>(GetCenter()), GetP1());
|
||||||
|
const qreal minLength = ToPixel(1, Unit::Mm);
|
||||||
|
const qreal maxLength = fullLength - ToPixel(1, Unit::Mm);
|
||||||
|
|
||||||
if (not IsFlipped())
|
if (not IsFlipped())
|
||||||
{
|
{
|
||||||
|
@ -362,7 +371,26 @@ QPointF VArc::CutArc(qreal length, VArc &arc1, VArc &arc2) const
|
||||||
{
|
{
|
||||||
length = fullLength + length;
|
length = fullLength + length;
|
||||||
}
|
}
|
||||||
length = qBound(ToPixel(1, Unit::Mm), length, fullLength - ToPixel(1, Unit::Mm));
|
|
||||||
|
const qreal minLength = ToPixel(1, Unit::Mm);
|
||||||
|
const qreal maxLength = fullLength - ToPixel(1, Unit::Mm);
|
||||||
|
|
||||||
|
if (length < minLength)
|
||||||
|
{
|
||||||
|
const QString errorMsg = QObject::tr("Curve '%1'. Length of a cut segment is too small. Optimize it to "
|
||||||
|
"minimal value.").arg(name());
|
||||||
|
VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) :
|
||||||
|
qWarning() << VAbstractApplication::warningMessageSignature + errorMsg;
|
||||||
|
}
|
||||||
|
else if (length > maxLength)
|
||||||
|
{
|
||||||
|
const QString errorMsg = QObject::tr("Curve '%1'. Length of a cut segment is too big. Optimize it to "
|
||||||
|
"maximal value.").arg(name());
|
||||||
|
VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) :
|
||||||
|
qWarning() << VAbstractApplication::warningMessageSignature + errorMsg;
|
||||||
|
}
|
||||||
|
|
||||||
|
length = qBound(minLength, length, maxLength);
|
||||||
|
|
||||||
line.setAngle(line.angle() + qRadiansToDegrees(length/d->radius));
|
line.setAngle(line.angle() + qRadiansToDegrees(length/d->radius));
|
||||||
}
|
}
|
||||||
|
@ -372,7 +400,26 @@ QPointF VArc::CutArc(qreal length, VArc &arc1, VArc &arc2) const
|
||||||
{
|
{
|
||||||
length = fullLength + length;
|
length = fullLength + length;
|
||||||
}
|
}
|
||||||
length = qBound(fullLength + ToPixel(1, Unit::Mm), length, ToPixel(-1, Unit::Mm));
|
|
||||||
|
const qreal minLength = fullLength + ToPixel(1, Unit::Mm);
|
||||||
|
const qreal maxLength = ToPixel(-1, Unit::Mm);
|
||||||
|
|
||||||
|
if (length > minLength)
|
||||||
|
{
|
||||||
|
const QString errorMsg = QObject::tr("Curve '%1'. Length of a cut segment is too small. Optimize it to "
|
||||||
|
"minimal value.").arg(name());
|
||||||
|
VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) :
|
||||||
|
qWarning() << VAbstractApplication::warningMessageSignature + errorMsg;
|
||||||
|
}
|
||||||
|
else if (length < maxLength)
|
||||||
|
{
|
||||||
|
const QString errorMsg = QObject::tr("Curve '%1'. Length of a cut segment is too big. Optimize it to "
|
||||||
|
"maximal value.").arg(name());
|
||||||
|
VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) :
|
||||||
|
qWarning() << VAbstractApplication::warningMessageSignature + errorMsg;
|
||||||
|
}
|
||||||
|
|
||||||
|
length = qBound(minLength, length, maxLength);
|
||||||
|
|
||||||
line.setAngle(line.angle() - qRadiansToDegrees(qAbs(length)/d->radius));
|
line.setAngle(line.angle() - qRadiansToDegrees(qAbs(length)/d->radius));
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,10 +31,12 @@
|
||||||
#include <QLineF>
|
#include <QLineF>
|
||||||
#include <QPoint>
|
#include <QPoint>
|
||||||
#include <QPainterPath>
|
#include <QPainterPath>
|
||||||
|
#include <QtDebug>
|
||||||
|
|
||||||
#include "../vmisc/def.h"
|
#include "../vmisc/def.h"
|
||||||
#include "../vmisc/vmath.h"
|
#include "../vmisc/vmath.h"
|
||||||
#include "../ifc/ifcdef.h"
|
#include "../ifc/ifcdef.h"
|
||||||
|
#include "../ifc/exception/vexception.h"
|
||||||
#include "../vmisc/vabstractapplication.h"
|
#include "../vmisc/vabstractapplication.h"
|
||||||
#include "../vmisc/compatibility.h"
|
#include "../vmisc/compatibility.h"
|
||||||
#include "vabstractcurve.h"
|
#include "vabstractcurve.h"
|
||||||
|
@ -356,6 +358,11 @@ QPointF VEllipticalArc::CutArc(const qreal &length, VEllipticalArc &arc1, VEllip
|
||||||
{
|
{
|
||||||
arc1 = VEllipticalArc();
|
arc1 = VEllipticalArc();
|
||||||
arc2 = VEllipticalArc();
|
arc2 = VEllipticalArc();
|
||||||
|
|
||||||
|
const QString errorMsg = QObject::tr("Unable to cut curve '%1'. The curve is too short.").arg(name());
|
||||||
|
VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) :
|
||||||
|
qWarning() << VAbstractApplication::warningMessageSignature + errorMsg;
|
||||||
|
|
||||||
return QPointF();
|
return QPointF();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -364,10 +371,20 @@ QPointF VEllipticalArc::CutArc(const qreal &length, VEllipticalArc &arc1, VEllip
|
||||||
if (length < minLength)
|
if (length < minLength)
|
||||||
{
|
{
|
||||||
len = minLength;
|
len = minLength;
|
||||||
|
|
||||||
|
const QString errorMsg = QObject::tr("Curve '%1'. Length of a cut segment is too small. Optimize it to minimal "
|
||||||
|
"value.").arg(name());
|
||||||
|
VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) :
|
||||||
|
qWarning() << VAbstractApplication::warningMessageSignature + errorMsg;
|
||||||
}
|
}
|
||||||
else if (length > maxLength)
|
else if (length > maxLength)
|
||||||
{
|
{
|
||||||
len = maxLength;
|
len = maxLength;
|
||||||
|
|
||||||
|
const QString errorMsg = QObject::tr("Curve '%1'. Length of a cut segment is too big. Optimize it to maximal "
|
||||||
|
"value.").arg(name());
|
||||||
|
VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) :
|
||||||
|
qWarning() << VAbstractApplication::warningMessageSignature + errorMsg;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue
Block a user