Improved curve segment warnings.

This commit is contained in:
Roman Telezhynskyi 2022-05-20 15:49:15 +03:00
parent 43aee75f64
commit ca2fe5fff1
20 changed files with 164 additions and 60 deletions

View File

@ -2,6 +2,7 @@
- Fix crash when default locale is ru. - Fix crash when default locale is ru.
- Puzzle app. Fix incorrect update of a layout piece. - Puzzle app. Fix incorrect update of a layout piece.
- Fix visualization for tool Point of intersection line and axis. - Fix visualization for tool Point of intersection line and axis.
- Improved curve segment warnings.
# Valentina 0.7.51 April 18, 2022 # Valentina 0.7.51 April 18, 2022
- Z value change for a layout piece. - Z value change for a layout piece.

View File

@ -406,10 +406,11 @@ VAbstractCubicBezier::~VAbstractCubicBezier()
* @param spl1p3 third point of first spline * @param spl1p3 third point of first spline
* @param spl2p2 second point of second spline * @param spl2p2 second point of second spline
* @param spl2p3 third point of second spline * @param spl2p3 third point of second spline
* @param pointName cutting point name.
* @return point of cutting. This point is forth point of first spline and first point of second spline. * @return point of cutting. This point is forth point of first spline and first point of second spline.
*/ */
QPointF VAbstractCubicBezier::CutSpline(qreal length, QPointF &spl1p2, QPointF &spl1p3, QPointF &spl2p2, QPointF VAbstractCubicBezier::CutSpline(qreal length, QPointF &spl1p2, QPointF &spl1p3, QPointF &spl2p2,
QPointF &spl2p3) const QPointF &spl2p3, const QString &pointName) const
{ {
//Always need return two splines, so we must correct wrong length. //Always need return two splines, so we must correct wrong length.
const qreal minLength = ToPixel(1, Unit::Mm); const qreal minLength = ToPixel(1, Unit::Mm);
@ -423,7 +424,7 @@ QPointF VAbstractCubicBezier::CutSpline(qreal length, QPointF &spl1p2, QPointF &
VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) : VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) :
qWarning() << VAbstractApplication::warningMessageSignature + errorMsg; qWarning() << VAbstractApplication::warningMessageSignature + errorMsg;
return QPointF(); return {};
} }
const qreal maxLength = fullLength - minLength; const qreal maxLength = fullLength - minLength;
@ -432,8 +433,17 @@ QPointF VAbstractCubicBezier::CutSpline(qreal length, QPointF &spl1p2, QPointF &
{ {
length = minLength; length = minLength;
const QString errorMsg = QObject::tr("Curve '%1'. Length of a cut segment is too small. Optimize it to minimal " QString errorMsg;
"value.").arg(name()); if (not pointName.isEmpty())
{
errorMsg = QObject::tr("Curve '%1'. Length of a cut segment (%2) is too small. Optimize it to minimal "
"value.").arg(name(), pointName);
}
else
{
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) : VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) :
qWarning() << VAbstractApplication::warningMessageSignature + errorMsg; qWarning() << VAbstractApplication::warningMessageSignature + errorMsg;
} }
@ -441,8 +451,17 @@ QPointF VAbstractCubicBezier::CutSpline(qreal length, QPointF &spl1p2, QPointF &
{ {
length = maxLength; length = maxLength;
const QString errorMsg = QObject::tr("Curve '%1'. Length of a cut segment is too big. Optimize it to maximal " QString errorMsg;
"value.").arg(name()); if (not pointName.isEmpty())
{
errorMsg = QObject::tr("Curve '%1'. Length of a cut segment (%2) is too big. Optimize it to maximal value.")
.arg(name(), pointName);
}
else
{
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) : VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) :
qWarning() << VAbstractApplication::warningMessageSignature + errorMsg; qWarning() << VAbstractApplication::warningMessageSignature + errorMsg;
} }

View File

@ -57,7 +57,8 @@ public:
virtual VPointF GetP3 () const =0; virtual VPointF GetP3 () const =0;
virtual VPointF GetP4 () const =0; virtual VPointF GetP4 () const =0;
QPointF CutSpline ( qreal length, QPointF &spl1p2, QPointF &spl1p3, QPointF &spl2p2, QPointF &spl2p3) const; QPointF CutSpline (qreal length, QPointF &spl1p2, QPointF &spl1p3, QPointF &spl2p2, QPointF &spl2p3,
const QString &pointName) const;
virtual QString NameForHistory(const QString &toolName) const override; virtual QString NameForHistory(const QString &toolName) const override;

View File

@ -164,10 +164,11 @@ int VAbstractCubicBezierPath::Segment(const QPointF &p) const
* @param spl1p3 second control point first spline. * @param spl1p3 second control point first spline.
* @param spl2p2 first control point second spline. * @param spl2p2 first control point second spline.
* @param spl2p3 second control point second spline. * @param spl2p3 second control point second spline.
* @param pointName cutting point name.
* @return cutting point. * @return cutting point.
*/ */
QPointF VAbstractCubicBezierPath::CutSplinePath(qreal length, qint32 &p1, qint32 &p2, QPointF &spl1p2, QPointF &spl1p3, QPointF VAbstractCubicBezierPath::CutSplinePath(qreal length, qint32 &p1, qint32 &p2, QPointF &spl1p2, QPointF &spl1p3,
QPointF &spl2p2, QPointF &spl2p3) const QPointF &spl2p2, QPointF &spl2p3, const QString &pointName) const
{ {
if (CountSubSpl() < 1) if (CountSubSpl() < 1)
{ {
@ -187,7 +188,7 @@ QPointF VAbstractCubicBezierPath::CutSplinePath(qreal length, qint32 &p1, qint32
VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) : VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) :
qWarning() << VAbstractApplication::warningMessageSignature + errorMsg; qWarning() << VAbstractApplication::warningMessageSignature + errorMsg;
return QPointF(); return {};
} }
const qreal maxLength = fullLength - minLength; const qreal maxLength = fullLength - minLength;
@ -196,8 +197,17 @@ QPointF VAbstractCubicBezierPath::CutSplinePath(qreal length, qint32 &p1, qint32
{ {
length = minLength; length = minLength;
const QString errorMsg = QObject::tr("Curve '%1'. Length of a cut segment is too small. Optimize it to minimal " QString errorMsg;
"value.").arg(name()); if (not pointName.isEmpty())
{
errorMsg = QObject::tr("Curve '%1'. Length of a cut segment (%2) is too small. Optimize it to minimal "
"value.").arg(name(), pointName);
}
else
{
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) : VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) :
qWarning() << VAbstractApplication::warningMessageSignature + errorMsg; qWarning() << VAbstractApplication::warningMessageSignature + errorMsg;
} }
@ -205,8 +215,17 @@ QPointF VAbstractCubicBezierPath::CutSplinePath(qreal length, qint32 &p1, qint32
{ {
length = maxLength; length = maxLength;
const QString errorMsg = QObject::tr("Curve '%1'. Length of a cut segment is too big. Optimize it to maximal " QString errorMsg;
"value.").arg(name()); if (not pointName.isEmpty())
{
errorMsg = QObject::tr("Curve '%1'. Length of a cut segment (%2) is too big. Optimize it to maximal value.")
.arg(name(), pointName);
}
else
{
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) : VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) :
qWarning() << VAbstractApplication::warningMessageSignature + errorMsg; qWarning() << VAbstractApplication::warningMessageSignature + errorMsg;
} }
@ -221,7 +240,8 @@ QPointF VAbstractCubicBezierPath::CutSplinePath(qreal length, qint32 &p1, qint32
{ {
p1 = i-1; p1 = i-1;
p2 = i; p2 = i;
const QPointF point = spl.CutSpline(length - (fullLength - splLength), spl1p2, spl1p3, spl2p2, spl2p3); const QPointF point = spl.CutSpline(length - (fullLength - splLength), spl1p2, spl1p3, spl2p2, spl2p3,
pointName);
const QVector<VSplinePoint> points = GetSplinePath(); const QVector<VSplinePoint> points = GetSplinePath();

View File

@ -72,7 +72,7 @@ public:
int Segment(const QPointF &p) const; int Segment(const QPointF &p) const;
QPointF CutSplinePath(qreal length, qint32 &p1, qint32 &p2, QPointF &spl1p2, QPointF &spl1p3, QPointF &spl2p2, QPointF CutSplinePath(qreal length, qint32 &p1, qint32 &p2, QPointF &spl1p2, QPointF &spl1p3, QPointF &spl2p2,
QPointF &spl2p3) const; QPointF &spl2p3, const QString &pointName) const;
virtual QString NameForHistory(const QString &toolName) const override; virtual QString NameForHistory(const QString &toolName) const override;

View File

@ -342,9 +342,10 @@ QVector<QPointF> VArc::GetPoints() const
* @param length length first arc. * @param length length first arc.
* @param arc1 first arc. * @param arc1 first arc.
* @param arc2 second arc. * @param arc2 second arc.
* @param pointName cutting point name.
* @return point cutting * @return point cutting
*/ */
QPointF VArc::CutArc(qreal length, VArc &arc1, VArc &arc2) const auto VArc::CutArc(qreal length, VArc &arc1, VArc &arc2, const QString &pointName) const -> QPointF
{ {
//Always need return two arcs, so we must correct wrong length. //Always need return two arcs, so we must correct wrong length.
const qreal fullLength = GetLength(); const qreal fullLength = GetLength();
@ -358,7 +359,7 @@ QPointF VArc::CutArc(qreal length, VArc &arc1, VArc &arc2) const
VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) : VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) :
qWarning() << VAbstractApplication::warningMessageSignature + errorMsg; qWarning() << VAbstractApplication::warningMessageSignature + errorMsg;
return QPointF(); return {};
} }
QLineF line(static_cast<QPointF>(GetCenter()), GetP1()); QLineF line(static_cast<QPointF>(GetCenter()), GetP1());
@ -375,15 +376,34 @@ QPointF VArc::CutArc(qreal length, VArc &arc1, VArc &arc2) const
if (length < minLength) if (length < minLength)
{ {
const QString errorMsg = QObject::tr("Curve '%1'. Length of a cut segment is too small. Optimize it to " QString errorMsg;
"minimal value.").arg(name()); if (not pointName.isEmpty())
{
errorMsg = tr("Curve '%1'. Length of a cut segment (%2) is too small. Optimize it to minimal value.")
.arg(name(), pointName);
}
else
{
errorMsg = tr("Curve '%1'. Length of a cut segment is too small. Optimize it to minimal value.")
.arg(name());
}
VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) : VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) :
qWarning() << VAbstractApplication::warningMessageSignature + errorMsg; qWarning() << VAbstractApplication::warningMessageSignature + errorMsg;
} }
else if (length > maxLength) else if (length > maxLength)
{ {
const QString errorMsg = QObject::tr("Curve '%1'. Length of a cut segment is too big. Optimize it to " QString errorMsg;
"maximal value.").arg(name()); if (not pointName.isEmpty())
{
errorMsg = tr("Curve '%1'. Length of a cut segment (%2) is too big. Optimize it to maximal value.")
.arg(name(), pointName);
}
else
{
errorMsg = tr("Curve '%1'. Length of a cut segment is too big. Optimize it to maximal value.")
.arg(name());
}
VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) : VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) :
qWarning() << VAbstractApplication::warningMessageSignature + errorMsg; qWarning() << VAbstractApplication::warningMessageSignature + errorMsg;
} }
@ -404,15 +424,33 @@ QPointF VArc::CutArc(qreal length, VArc &arc1, VArc &arc2) const
if (length > minLength) if (length > minLength)
{ {
const QString errorMsg = QObject::tr("Curve '%1'. Length of a cut segment is too small. Optimize it to " QString errorMsg;
"minimal value.").arg(name()); if (not pointName.isEmpty())
{
errorMsg = tr("Curve '%1'. Length of a cut segment (%2) is too small. Optimize it to minimal value.")
.arg(name(), pointName);
}
else
{
errorMsg = tr("Curve '%1'. Length of a cut segment is too small. Optimize it to minimal value.")
.arg(name());
}
VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) : VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) :
qWarning() << VAbstractApplication::warningMessageSignature + errorMsg; qWarning() << VAbstractApplication::warningMessageSignature + errorMsg;
} }
else if (length < maxLength) else if (length < maxLength)
{ {
const QString errorMsg = QObject::tr("Curve '%1'. Length of a cut segment is too big. Optimize it to " QString errorMsg;
"maximal value.").arg(name()); if (not pointName.isEmpty())
{
errorMsg = tr("Curve '%1'. Length of a cut segment (%2) is too big. Optimize it to maximal value.")
.arg(name(), errorMsg);
}
else
{
errorMsg = tr("Curve '%1'. Length of a cut segment is too big. Optimize it to maximal value.")
.arg(name());
}
VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) : VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) :
qWarning() << VAbstractApplication::warningMessageSignature + errorMsg; qWarning() << VAbstractApplication::warningMessageSignature + errorMsg;
} }
@ -436,11 +474,11 @@ QPointF VArc::CutArc(qreal length, VArc &arc1, VArc &arc2) const
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QPointF VArc::CutArc(qreal length) const QPointF VArc::CutArc(qreal length, const QString &pointName) const
{ {
VArc arc1; VArc arc1;
VArc arc2; VArc arc2;
return this->CutArc(length, arc1, arc2); return this->CutArc(length, arc1, arc2, pointName);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -81,8 +81,8 @@ public:
virtual QVector<QPointF> GetPoints () const override; virtual QVector<QPointF> GetPoints () const override;
QPointF CutArc (qreal length, VArc &arc1, VArc &arc2) const; QPointF CutArc (qreal length, VArc &arc1, VArc &arc2, const QString &pointName) const;
QPointF CutArc (qreal length) const; QPointF CutArc (qreal length, const QString &pointName) const;
protected: protected:
virtual void CreateName() override; virtual void CreateName() override;
virtual void CreateAlias() override; virtual void CreateAlias() override;
@ -93,6 +93,6 @@ private:
qreal MaxLength() const; qreal MaxLength() const;
}; };
Q_DECLARE_TYPEINFO(VArc, Q_MOVABLE_TYPE); Q_DECLARE_TYPEINFO(VArc, Q_MOVABLE_TYPE); // NOLINT
#endif // VARC_H #endif // VARC_H

View File

@ -347,7 +347,8 @@ qreal VEllipticalArc::GetEndAngle() const
* @param arc2 second arc. * @param arc2 second arc.
* @return point cutting * @return point cutting
*/ */
QPointF VEllipticalArc::CutArc(const qreal &length, VEllipticalArc &arc1, VEllipticalArc &arc2) const QPointF VEllipticalArc::CutArc(const qreal &length, VEllipticalArc &arc1, VEllipticalArc &arc2,
const QString &pointName) const
{ {
//Always need return two arcs, so we must correct wrong length. //Always need return two arcs, so we must correct wrong length.
qreal len = 0; qreal len = 0;
@ -363,7 +364,7 @@ QPointF VEllipticalArc::CutArc(const qreal &length, VEllipticalArc &arc1, VEllip
VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) : VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) :
qWarning() << VAbstractApplication::warningMessageSignature + errorMsg; qWarning() << VAbstractApplication::warningMessageSignature + errorMsg;
return QPointF(); return {};
} }
const qreal maxLength = fullLength - minLength; const qreal maxLength = fullLength - minLength;
@ -372,8 +373,17 @@ QPointF VEllipticalArc::CutArc(const qreal &length, VEllipticalArc &arc1, VEllip
{ {
len = minLength; len = minLength;
const QString errorMsg = QObject::tr("Curve '%1'. Length of a cut segment is too small. Optimize it to minimal " QString errorMsg;
"value.").arg(name()); if (not pointName.isEmpty())
{
errorMsg = QObject::tr("Curve '%1'. Length of a cut segment (%2) is too small. Optimize it to minimal "
"value.").arg(name(), pointName);
}
else
{
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) : VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) :
qWarning() << VAbstractApplication::warningMessageSignature + errorMsg; qWarning() << VAbstractApplication::warningMessageSignature + errorMsg;
} }
@ -381,8 +391,17 @@ QPointF VEllipticalArc::CutArc(const qreal &length, VEllipticalArc &arc1, VEllip
{ {
len = maxLength; len = maxLength;
const QString errorMsg = QObject::tr("Curve '%1'. Length of a cut segment is too big. Optimize it to maximal " QString errorMsg;
"value.").arg(name()); if (not pointName.isEmpty())
{
errorMsg = QObject::tr("Curve '%1'. Length of a cut segment (%2) is too big. Optimize it to maximal value.")
.arg(name(), pointName);
}
else
{
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) : VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) :
qWarning() << VAbstractApplication::warningMessageSignature + errorMsg; qWarning() << VAbstractApplication::warningMessageSignature + errorMsg;
} }
@ -405,11 +424,11 @@ QPointF VEllipticalArc::CutArc(const qreal &length, VEllipticalArc &arc1, VEllip
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QPointF VEllipticalArc::CutArc(const qreal &length) const QPointF VEllipticalArc::CutArc(const qreal &length, const QString &pointName) const
{ {
VEllipticalArc arc1; VEllipticalArc arc1;
VEllipticalArc arc2; VEllipticalArc arc2;
return this->CutArc(length, arc1, arc2); return this->CutArc(length, arc1, arc2, pointName);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -101,8 +101,8 @@ public:
virtual qreal GetStartAngle () const override; virtual qreal GetStartAngle () const override;
virtual qreal GetEndAngle () const override; virtual qreal GetEndAngle () const override;
QPointF CutArc (const qreal &length, VEllipticalArc &arc1, VEllipticalArc &arc2) const; QPointF CutArc (const qreal &length, VEllipticalArc &arc1, VEllipticalArc &arc2, const QString &pointName) const;
QPointF CutArc (const qreal &length) const; QPointF CutArc (const qreal &length, const QString &pointName) const;
static qreal OptimizeAngle(qreal angle); static qreal OptimizeAngle(qreal angle);
protected: protected:

View File

@ -196,13 +196,13 @@ qreal VSpline::GetLength () const
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QPointF VSpline::CutSpline(qreal length, VSpline &spl1, VSpline &spl2) const QPointF VSpline::CutSpline(qreal length, VSpline &spl1, VSpline &spl2, const QString &pointName) const
{ {
QPointF spl1p2; QPointF spl1p2;
QPointF spl1p3; QPointF spl1p3;
QPointF spl2p2; QPointF spl2p2;
QPointF spl2p3; QPointF spl2p3;
const QPointF cutPoint = CutSpline (length, spl1p2, spl1p3, spl2p2, spl2p3 ); const QPointF cutPoint = CutSpline(length, spl1p2, spl1p3, spl2p2, spl2p3, pointName);
spl1 = VSpline(GetP1(), spl1p2, spl1p3, VPointF(cutPoint)); spl1 = VSpline(GetP1(), spl1p2, spl1p3, VPointF(cutPoint));
spl1.SetApproximationScale(GetApproximationScale()); spl1.SetApproximationScale(GetApproximationScale());

View File

@ -104,7 +104,7 @@ public:
qreal GetKcurve() const; qreal GetKcurve() const;
using VAbstractCubicBezier::CutSpline; using VAbstractCubicBezier::CutSpline;
QPointF CutSpline ( qreal length, VSpline &spl1, VSpline &spl2) const; QPointF CutSpline(qreal length, VSpline &spl1, VSpline &spl2, const QString &pointName) const;
virtual QVector<QPointF> GetPoints () const override; virtual QVector<QPointF> GetPoints () const override;
// cppcheck-suppress unusedFunction // cppcheck-suppress unusedFunction

View File

@ -127,13 +127,13 @@ VToolCutArc* VToolCutArc::Create(const QPointer<DialogTool> &dialog, VMainGraphi
* @brief Create help create tool. * @brief Create help create tool.
* @param initData init data. * @param initData init data.
*/ */
VToolCutArc* VToolCutArc::Create(VToolCutInitData &initData) auto VToolCutArc::Create(VToolCutInitData &initData) -> VToolCutArc*
{ {
const QSharedPointer<VArc> arc = initData.data->GeometricObject<VArc>(initData.baseCurveId); const QSharedPointer<VArc> arc = initData.data->GeometricObject<VArc>(initData.baseCurveId);
//Declare special variable "CurrentLength" //Declare special variable "CurrentLength"
VCurveLength *length = new VCurveLength(initData.baseCurveId, initData.baseCurveId, arc.data(), auto *length = new VCurveLength(initData.baseCurveId, initData.baseCurveId, arc.data(),
*initData.data->GetPatternUnit()); *initData.data->GetPatternUnit());
length->SetName(currentLength); length->SetName(currentLength);
initData.data->AddVariable(length); initData.data->AddVariable(length);
@ -141,7 +141,7 @@ VToolCutArc* VToolCutArc::Create(VToolCutInitData &initData)
VArc arc1; VArc arc1;
VArc arc2; VArc arc2;
QPointF point = arc->CutArc(VAbstractValApplication::VApp()->toPixel(result), arc1, arc2); QPointF point = arc->CutArc(VAbstractValApplication::VApp()->toPixel(result), arc1, arc2, initData.name);
arc1.SetAliasSuffix(initData.aliasSuffix1); arc1.SetAliasSuffix(initData.aliasSuffix1);
arc2.SetAliasSuffix(initData.aliasSuffix2); arc2.SetAliasSuffix(initData.aliasSuffix2);
@ -296,9 +296,11 @@ QString VToolCutArc::MakeToolTip() const
const QString endAngleStr = tr("end angle"); const QString endAngleStr = tr("end angle");
const QString radiusStr = tr("radius"); const QString radiusStr = tr("radius");
const QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(m_id);
VArc ar1; VArc ar1;
VArc ar2; VArc ar2;
arc->CutArc(VAbstractValApplication::VApp()->toPixel(length), ar1, ar2); arc->CutArc(VAbstractValApplication::VApp()->toPixel(length), ar1, ar2, point->name());
ar1.setId(m_id + 1); ar1.setId(m_id + 1);
ar1.SetAliasSuffix(m_aliasSuffix1); ar1.SetAliasSuffix(m_aliasSuffix1);

View File

@ -143,7 +143,8 @@ VToolCutSpline* VToolCutSpline::Create(VToolCutInitData &initData)
const qreal result = CheckFormula(initData.id, initData.formula, initData.data); const qreal result = CheckFormula(initData.id, initData.formula, initData.data);
QPointF spl1p2, spl1p3, spl2p2, spl2p3; QPointF spl1p2, spl1p3, spl2p2, spl2p3;
QPointF point = spl->CutSpline(VAbstractValApplication::VApp()->toPixel(result), spl1p2, spl1p3, spl2p2, spl2p3); QPointF point = spl->CutSpline(VAbstractValApplication::VApp()->toPixel(result), spl1p2, spl1p3, spl2p2, spl2p3,
initData.name);
VPointF *p = new VPointF(point, initData.name, initData.mx, initData.my); VPointF *p = new VPointF(point, initData.name, initData.mx, initData.my);
p->SetShowLabel(initData.showLabel); p->SetShowLabel(initData.showLabel);
@ -285,8 +286,11 @@ QString VToolCutSpline::MakeToolTip() const
->FormulaToUser(formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); ->FormulaToUser(formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator());
const qreal length = Visualization::FindValFromUser(expression, VAbstractTool::data.DataVariables()); const qreal length = Visualization::FindValFromUser(expression, VAbstractTool::data.DataVariables());
const QSharedPointer<VPointF> p = VAbstractTool::data.GeometricObject<VPointF>(m_id);
QPointF spl1p2, spl1p3, spl2p2, spl2p3; QPointF spl1p2, spl1p3, spl2p2, spl2p3;
QPointF point = spl->CutSpline(VAbstractValApplication::VApp()->toPixel(length), spl1p2, spl1p3, spl2p2, spl2p3); QPointF point = spl->CutSpline(VAbstractValApplication::VApp()->toPixel(length), spl1p2, spl1p3, spl2p2, spl2p3,
p->name());
VSpline spline1 = VSpline(spl->GetP1(), spl1p2, spl1p3, VPointF(point)); VSpline spline1 = VSpline(spl->GetP1(), spl1p2, spl1p3, VPointF(point));
spline1.SetAliasSuffix(m_aliasSuffix1); spline1.SetAliasSuffix(m_aliasSuffix1);

View File

@ -222,7 +222,7 @@ VPointF *VToolCutSplinePath::CutSplinePath(qreal length, const QSharedPointer<VA
QPointF spl1p2, spl1p3, spl2p2, spl2p3; QPointF spl1p2, spl1p3, spl2p2, spl2p3;
qint32 p1 = 0, p2 = 0; qint32 p1 = 0, p2 = 0;
const QPointF point = splPath->CutSplinePath(length, p1, p2, spl1p2, spl1p3, spl2p2, spl2p3); const QPointF point = splPath->CutSplinePath(length, p1, p2, spl1p2, spl1p3, spl2p2, spl2p3, pName);
VPointF *p = new VPointF(point); VPointF *p = new VPointF(point);
p->setName(pName); p->setName(pName);

View File

@ -415,11 +415,11 @@ auto VToolSinglePoint::InitSegments(GOType curveType, qreal segLength, const VPo
QPointF spl1p2, spl1p3, spl2p2, spl2p3; QPointF spl1p2, spl1p3, spl2p2, spl2p3;
if (not VFuzzyComparePossibleNulls(segLength, -1)) if (not VFuzzyComparePossibleNulls(segLength, -1))
{ {
spl->CutSpline(segLength, spl1p2, spl1p3, spl2p2, spl2p3); spl->CutSpline(segLength, spl1p2, spl1p3, spl2p2, spl2p3, p->name());
} }
else else
{ {
spl->CutSpline(0, spl1p2, spl1p3, spl2p2, spl2p3); spl->CutSpline(0, spl1p2, spl1p3, spl2p2, spl2p3, p->name());
} }
VSpline *spl1 = new VSpline(spl->GetP1(), spl1p2, spl1p3, *p); VSpline *spl1 = new VSpline(spl->GetP1(), spl1p2, spl1p3, *p);

View File

@ -113,7 +113,7 @@ protected:
static QPair<QString, QString> InitSegments(GOType curveType, qreal segLength, const VPointF *p, quint32 curveId, static QPair<QString, QString> InitSegments(GOType curveType, qreal segLength, const VPointF *p, quint32 curveId,
VContainer *data, const QString &alias1, const QString &alias2); VContainer *data, const QString &alias1, const QString &alias2);
private: private:
Q_DISABLE_COPY(VToolSinglePoint) Q_DISABLE_COPY(VToolSinglePoint) // NOLINT
}; };
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -131,11 +131,11 @@ inline auto VToolSinglePoint::InitArc(VContainer *data, qreal segLength, const V
if (not VFuzzyComparePossibleNulls(segLength, -1)) if (not VFuzzyComparePossibleNulls(segLength, -1))
{ {
arc->CutArc(segLength, arc1, arc2); arc->CutArc(segLength, arc1, arc2, p->name());
} }
else else
{ {
arc->CutArc(0, arc1, arc2); arc->CutArc(0, arc1, arc2, p->name());
} }
// Arc highly depend on id. Need for creating the name. // Arc highly depend on id. Need for creating the name.

View File

@ -70,7 +70,7 @@ void VisToolCutArc::RefreshGeometry()
{ {
VArc ar1; VArc ar1;
VArc ar2; VArc ar2;
QPointF p = arc->CutArc(length, ar1, ar2); QPointF p = arc->CutArc(length, ar1, ar2, QString());
DrawPoint(point, p, mainColor); DrawPoint(point, p, mainColor);
DrawPath(arc1, ar1.GetPath(), ar1.DirectionArrows(), Qt::darkGreen, lineStyle, Qt::RoundCap); DrawPath(arc1, ar1.GetPath(), ar1.DirectionArrows(), Qt::darkGreen, lineStyle, Qt::RoundCap);

View File

@ -74,7 +74,7 @@ void VisToolCutSpline::RefreshGeometry()
QPointF spl1p3; QPointF spl1p3;
QPointF spl2p2; QPointF spl2p2;
QPointF spl2p3; QPointF spl2p3;
const QPointF p = spl->CutSpline (length, spl1p2, spl1p3, spl2p2, spl2p3 ); const QPointF p = spl->CutSpline(length, spl1p2, spl1p3, spl2p2, spl2p3, QString());
VSpline sp1 = VSpline(spl->GetP1(), spl1p2, spl1p3, VPointF(p)); VSpline sp1 = VSpline(spl->GetP1(), spl1p2, spl1p3, VPointF(p));
sp1.SetApproximationScale(spl->GetApproximationScale()); sp1.SetApproximationScale(spl->GetApproximationScale());

View File

@ -399,7 +399,7 @@ void TST_VArc::TestCutArc()
VArc arc1; VArc arc1;
VArc arc2; VArc arc2;
QPointF point = arc.CutArc(cutLength, arc1, arc2); QPointF point = arc.CutArc(cutLength, arc1, arc2, QString());
QCOMPARE(point, cutPoint); QCOMPARE(point, cutPoint);

View File

@ -785,7 +785,7 @@ void TST_VSpline::TestLengthByPoint_data()
const qreal length = spl.GetLength(); const qreal length = spl.GetLength();
const qreal testLength = length*(2.0/3.0); const qreal testLength = length*(2.0/3.0);
VSpline spl1, spl2; VSpline spl1, spl2;
const QPointF p = spl.CutSpline(testLength, spl1, spl2); const QPointF p = spl.CutSpline(testLength, spl1, spl2, QString());
QTest::newRow("Point on spline") << spl << p << testLength; QTest::newRow("Point on spline") << spl << p << testLength;
QTest::newRow("Wrong point") << spl << QPointF(-10000, -10000) << -1.0; QTest::newRow("Wrong point") << spl << QPointF(-10000, -10000) << -1.0;