Code style.

This commit is contained in:
Roman Telezhynskyi 2022-05-20 17:08:32 +03:00
parent ca2fe5fff1
commit c9c46cc954
13 changed files with 474 additions and 466 deletions

View File

@ -67,7 +67,7 @@ VAbstractArc::VAbstractArc(const VAbstractArc &arc)
{} {}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VAbstractArc &VAbstractArc::operator=(const VAbstractArc &arc) auto VAbstractArc::operator=(const VAbstractArc &arc) -> VAbstractArc &
{ {
if ( &arc == this ) if ( &arc == this )
{ {
@ -81,11 +81,12 @@ VAbstractArc &VAbstractArc::operator=(const VAbstractArc &arc)
#ifdef Q_COMPILER_RVALUE_REFS #ifdef Q_COMPILER_RVALUE_REFS
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VAbstractArc::VAbstractArc(VAbstractArc &&arc) Q_DECL_NOTHROW VAbstractArc::VAbstractArc(VAbstractArc &&arc) Q_DECL_NOTHROW
: VAbstractCurve(arc), d (arc.d) : VAbstractCurve(std::move(arc)),
d(std::move(arc.d))
{} {}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VAbstractArc &VAbstractArc::operator=(VAbstractArc &&arc) Q_DECL_NOTHROW auto VAbstractArc::operator=(VAbstractArc &&arc) Q_DECL_NOTHROW -> VAbstractArc &
{ {
VAbstractCurve::operator=(arc); VAbstractCurve::operator=(arc);
std::swap(d, arc.d); std::swap(d, arc.d);
@ -94,11 +95,11 @@ VAbstractArc &VAbstractArc::operator=(VAbstractArc &&arc) Q_DECL_NOTHROW
#endif #endif
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VAbstractArc::~VAbstractArc() VAbstractArc::~VAbstractArc() // NOLINT(hicpp-use-equals-default, modernize-use-equals-default)
{} {}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QString VAbstractArc::GetFormulaF1() const auto VAbstractArc::GetFormulaF1() const -> QString
{ {
return d->formulaF1; return d->formulaF1;
} }
@ -111,13 +112,13 @@ void VAbstractArc::SetFormulaF1(const QString &formula, qreal value)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
qreal VAbstractArc::GetStartAngle() const auto VAbstractArc::GetStartAngle() const -> qreal
{ {
return d->f1; return d->f1;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QString VAbstractArc::GetFormulaF2() const auto VAbstractArc::GetFormulaF2() const -> QString
{ {
return d->formulaF2; return d->formulaF2;
} }
@ -130,13 +131,13 @@ void VAbstractArc::SetFormulaF2(const QString &formula, qreal value)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
qreal VAbstractArc::GetEndAngle() const auto VAbstractArc::GetEndAngle() const -> qreal
{ {
return d->f2; return d->f2;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPointF VAbstractArc::GetCenter() const auto VAbstractArc::GetCenter() const -> VPointF
{ {
return d->center; return d->center;
} }
@ -148,7 +149,7 @@ void VAbstractArc::SetCenter(const VPointF &point)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QString VAbstractArc::GetFormulaLength() const auto VAbstractArc::GetFormulaLength() const -> QString
{ {
return d->formulaLength; return d->formulaLength;
} }
@ -168,7 +169,7 @@ void VAbstractArc::setId(const quint32 &id)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QString VAbstractArc::NameForHistory(const QString &toolName) const auto VAbstractArc::NameForHistory(const QString &toolName) const -> QString
{ {
QString name = toolName + QString(" %1").arg(GetCenter().name()); QString name = toolName + QString(" %1").arg(GetCenter().name());
@ -193,13 +194,13 @@ QString VAbstractArc::NameForHistory(const QString &toolName) const
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VAbstractArc::IsFlipped() const auto VAbstractArc::IsFlipped() const -> bool
{ {
return d->isFlipped; return d->isFlipped;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
qreal VAbstractArc::AngleArc() const auto VAbstractArc::AngleArc() const -> qreal
{ {
{ {
const qreal angleDiff = qAbs(GetStartAngle() - GetEndAngle()); const qreal angleDiff = qAbs(GetStartAngle() - GetEndAngle());

View File

@ -48,42 +48,42 @@ class VAbstractArc : public VAbstractCurve
{ {
public: public:
explicit VAbstractArc(const GOType &type, const quint32 &idObject = NULL_ID, const Draw &mode = Draw::Calculation); explicit VAbstractArc(const GOType &type, const quint32 &idObject = NULL_ID, const Draw &mode = Draw::Calculation);
VAbstractArc (const GOType &type, const VPointF &center, qreal f1, const QString &formulaF1, qreal f2, VAbstractArc(const GOType &type, const VPointF &center, qreal f1, const QString &formulaF1, qreal f2,
const QString &formulaF2, quint32 idObject = 0, Draw mode = Draw::Calculation); const QString &formulaF2, quint32 idObject = 0, Draw mode = Draw::Calculation);
VAbstractArc (const GOType &type, const VPointF &center, qreal f1, qreal f2, quint32 idObject = 0, VAbstractArc(const GOType &type, const VPointF &center, qreal f1, qreal f2, quint32 idObject = 0,
Draw mode = Draw::Calculation); Draw mode = Draw::Calculation);
VAbstractArc (const GOType &type, const QString &formulaLength, const VPointF &center, qreal f1, VAbstractArc(const GOType &type, const QString &formulaLength, const VPointF &center, qreal f1,
const QString &formulaF1, quint32 idObject = 0, Draw mode = Draw::Calculation); const QString &formulaF1, quint32 idObject = 0, Draw mode = Draw::Calculation);
VAbstractArc (const GOType &type, const VPointF &center, qreal f1, quint32 idObject = 0, VAbstractArc(const GOType &type, const VPointF &center, qreal f1, quint32 idObject = 0,
Draw mode = Draw::Calculation); Draw mode = Draw::Calculation);
explicit VAbstractArc(const VAbstractArc &arc); VAbstractArc(const VAbstractArc &arc);
virtual ~VAbstractArc(); ~VAbstractArc() override;
VAbstractArc& operator= (const VAbstractArc &arc); auto operator= (const VAbstractArc &arc) -> VAbstractArc&;
#ifdef Q_COMPILER_RVALUE_REFS #ifdef Q_COMPILER_RVALUE_REFS
VAbstractArc(VAbstractArc &&arc) Q_DECL_NOTHROW; VAbstractArc(VAbstractArc &&arc) Q_DECL_NOTHROW;
VAbstractArc &operator=(VAbstractArc &&arc) Q_DECL_NOTHROW; auto operator=(VAbstractArc &&arc) Q_DECL_NOTHROW -> VAbstractArc &;
#endif #endif
QString GetFormulaF1 () const; auto GetFormulaF1 () const -> QString;
void SetFormulaF1 (const QString &formula, qreal value); void SetFormulaF1 (const QString &formula, qreal value);
virtual qreal GetStartAngle () const override; auto GetStartAngle () const -> qreal override;
QString GetFormulaF2 () const; auto GetFormulaF2 () const -> QString;
void SetFormulaF2 (const QString &formula, qreal value); void SetFormulaF2 (const QString &formula, qreal value);
virtual qreal GetEndAngle () const override; auto GetEndAngle () const -> qreal override;
virtual VPointF GetCenter () const; auto GetCenter () const -> VPointF;
void SetCenter (const VPointF &point); void SetCenter (const VPointF &point);
QString GetFormulaLength () const; auto GetFormulaLength () const -> QString;
void SetFormulaLength (const QString &formula, qreal value); void SetFormulaLength (const QString &formula, qreal value);
virtual void setId(const quint32 &id) override; void setId(const quint32 &id) override;
virtual QString NameForHistory(const QString &toolName) const override; auto NameForHistory(const QString &toolName) const -> QString override;
bool IsFlipped() const; auto IsFlipped() const -> bool;
qreal AngleArc() const; auto AngleArc() const -> qreal;
protected: protected:
void SetFlipped(bool value); void SetFlipped(bool value);
virtual void FindF2(qreal length)=0; virtual void FindF2(qreal length)=0;

View File

@ -52,7 +52,7 @@ namespace
* @param y2 у coordinate second point. * @param y2 у coordinate second point.
* @return squared length. * @return squared length.
*/ */
inline qreal CalcSqDistance(qreal x1, qreal y1, qreal x2, qreal y2) inline auto CalcSqDistance(qreal x1, qreal y1, qreal x2, qreal y2) -> qreal
{ {
const qreal dx = x2 - x1; const qreal dx = x2 - x1;
const qreal dy = y2 - y1; const qreal dy = y2 - y1;
@ -74,8 +74,8 @@ inline qreal CalcSqDistance(qreal x1, qreal y1, qreal x2, qreal y2)
* @param points spline points coordinates. * @param points spline points coordinates.
* @param approximationScale curve approximation scale. * @param approximationScale curve approximation scale.
*/ */
QVector<QPointF> PointBezier_r(qreal x1, qreal y1, qreal x2, qreal y2, qreal x3, qreal y3, qreal x4, qreal y4, auto PointBezier_r(qreal x1, qreal y1, qreal x2, qreal y2, qreal x3, qreal y3, qreal x4, qreal y4,
qint16 level, QVector<QPointF> points, qreal approximationScale) qint16 level, QVector<QPointF> points, qreal approximationScale) -> QVector<QPointF>
{ {
if (points.size() >= 2) if (points.size() >= 2)
{ {
@ -373,17 +373,10 @@ QVector<QPointF> PointBezier_r(qreal x1, qreal y1, qreal x2, qreal y2, qreal x3,
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VAbstractCubicBezier::VAbstractCubicBezier(const GOType &type, const quint32 &idObject, const Draw &mode) VAbstractCubicBezier::VAbstractCubicBezier(const GOType &type, const quint32 &idObject, const Draw &mode)
: VAbstractBezier(type, idObject, mode) : VAbstractBezier(type, idObject, mode)
{ {}
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VAbstractCubicBezier::VAbstractCubicBezier(const VAbstractCubicBezier &curve) auto VAbstractCubicBezier::operator=(const VAbstractCubicBezier &curve) -> VAbstractCubicBezier &
: VAbstractBezier(curve)
{
}
//---------------------------------------------------------------------------------------------------------------------
VAbstractCubicBezier &VAbstractCubicBezier::operator=(const VAbstractCubicBezier &curve)
{ {
if ( &curve == this ) if ( &curve == this )
{ {
@ -395,8 +388,7 @@ VAbstractCubicBezier &VAbstractCubicBezier::operator=(const VAbstractCubicBezier
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VAbstractCubicBezier::~VAbstractCubicBezier() VAbstractCubicBezier::~VAbstractCubicBezier()
{ {}
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
@ -409,8 +401,8 @@ VAbstractCubicBezier::~VAbstractCubicBezier()
* @param pointName cutting point name. * @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, auto VAbstractCubicBezier::CutSpline(qreal length, QPointF &spl1p2, QPointF &spl1p3, QPointF &spl2p2,
QPointF &spl2p3, const QString &pointName) const QPointF &spl2p3, const QString &pointName) const -> QPointF
{ {
//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);
@ -500,7 +492,7 @@ QPointF VAbstractCubicBezier::CutSpline(qreal length, QPointF &spl1p2, QPointF &
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QString VAbstractCubicBezier::NameForHistory(const QString &toolName) const auto VAbstractCubicBezier::NameForHistory(const QString &toolName) const -> QString
{ {
QString name = toolName + QString(" %1_%2").arg(GetP1().name(), GetP4().name()); QString name = toolName + QString(" %1_%2").arg(GetP1().name(), GetP4().name());
if (GetDuplicate() > 0) if (GetDuplicate() > 0)
@ -589,8 +581,8 @@ void VAbstractCubicBezier::CreateAlias()
* @param approximationScale curve approximation scale. * @param approximationScale curve approximation scale.
* @return list of points. * @return list of points.
*/ */
QVector<QPointF> VAbstractCubicBezier::GetCubicBezierPoints(const QPointF &p1, const QPointF &p2, const QPointF &p3, auto VAbstractCubicBezier::GetCubicBezierPoints(const QPointF &p1, const QPointF &p2, const QPointF &p3,
const QPointF &p4, qreal approximationScale) const QPointF &p4, qreal approximationScale) -> QVector<QPointF>
{ {
QVector<QPointF> pvector; QVector<QPointF> pvector;
pvector.append(p1); pvector.append(p1);
@ -610,14 +602,14 @@ QVector<QPointF> VAbstractCubicBezier::GetCubicBezierPoints(const QPointF &p1, c
* @param approximationScale curve approximation scale. * @param approximationScale curve approximation scale.
* @return length. * @return length.
*/ */
qreal VAbstractCubicBezier::LengthBezier(const QPointF &p1, const QPointF &p2, const QPointF &p3, const QPointF &p4, auto VAbstractCubicBezier::LengthBezier(const QPointF &p1, const QPointF &p2, const QPointF &p3, const QPointF &p4,
qreal approximationScale) qreal approximationScale) -> qreal
{ {
return PathLength(GetCubicBezierPoints(p1, p2, p3, p4, approximationScale)); return PathLength(GetCubicBezierPoints(p1, p2, p3, p4, approximationScale));
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
qreal VAbstractCubicBezier::RealLengthByT(qreal t) const auto VAbstractCubicBezier::RealLengthByT(qreal t) const -> qreal
{ {
if (t < 0 || t > 1) if (t < 0 || t > 1)
{ {

View File

@ -47,35 +47,36 @@ QT_WARNING_DISABLE_GCC("-Wsuggest-final-types")
class VAbstractCubicBezier : public VAbstractBezier class VAbstractCubicBezier : public VAbstractBezier
{ {
public: public:
VAbstractCubicBezier(const GOType &type, const quint32 &idObject = NULL_ID, const Draw &mode = Draw::Calculation); explicit VAbstractCubicBezier(const GOType &type, const quint32 &idObject = NULL_ID,
VAbstractCubicBezier(const VAbstractCubicBezier &curve); const Draw &mode = Draw::Calculation);
VAbstractCubicBezier& operator= (const VAbstractCubicBezier &curve); VAbstractCubicBezier(const VAbstractCubicBezier &curve) = default;
virtual ~VAbstractCubicBezier(); auto operator= (const VAbstractCubicBezier &curve) -> VAbstractCubicBezier&;
~VAbstractCubicBezier() override;
virtual VPointF GetP1 () const =0; virtual auto GetP1 () const -> VPointF =0;
virtual VPointF GetP2 () const =0; virtual auto GetP2 () const -> VPointF =0;
virtual VPointF GetP3 () const =0; virtual auto GetP3 () const -> VPointF =0;
virtual VPointF GetP4 () const =0; virtual auto GetP4 () const -> VPointF =0;
QPointF CutSpline (qreal length, QPointF &spl1p2, QPointF &spl1p3, QPointF &spl2p2, QPointF &spl2p3, auto CutSpline(qreal length, QPointF &spl1p2, QPointF &spl1p3, QPointF &spl2p2, QPointF &spl2p3,
const QString &pointName) const; const QString &pointName) const -> QPointF;
virtual QString NameForHistory(const QString &toolName) const override; auto NameForHistory(const QString &toolName) const -> QString override;
qreal GetParmT(qreal length) const; auto GetParmT(qreal length) const -> qreal;
qreal RealLengthByT(qreal t) const; auto RealLengthByT(qreal t) const -> qreal;
protected: protected:
virtual void CreateName() override; void CreateName() override;
virtual void CreateAlias() override; void CreateAlias() override;
static QVector<QPointF> GetCubicBezierPoints(const QPointF &p1, const QPointF &p2, const QPointF &p3, static auto GetCubicBezierPoints(const QPointF &p1, const QPointF &p2, const QPointF &p3,
const QPointF &p4, qreal approximationScale); const QPointF &p4, qreal approximationScale) -> QVector<QPointF>;
static qreal LengthBezier(const QPointF &p1, const QPointF &p2, const QPointF &p3, const QPointF &p4, static auto LengthBezier(const QPointF &p1, const QPointF &p2, const QPointF &p3, const QPointF &p4,
qreal approximationScale); qreal approximationScale) -> qreal;
virtual QPointF GetControlPoint1() const =0; virtual auto GetControlPoint1() const -> QPointF =0;
virtual QPointF GetControlPoint2() const =0; virtual auto GetControlPoint2() const -> QPointF =0;
virtual auto GetRealLength() const -> qreal =0; virtual auto GetRealLength() const -> qreal =0;
}; };

View File

@ -46,13 +46,7 @@ VAbstractCubicBezierPath::VAbstractCubicBezierPath(const GOType &type, const qui
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VAbstractCubicBezierPath::VAbstractCubicBezierPath(const VAbstractCubicBezierPath &curve) auto VAbstractCubicBezierPath::operator=(const VAbstractCubicBezierPath &curve) -> VAbstractCubicBezierPath &
: VAbstractBezier(curve)
{
}
//---------------------------------------------------------------------------------------------------------------------
VAbstractCubicBezierPath &VAbstractCubicBezierPath::operator=(const VAbstractCubicBezierPath &curve)
{ {
if ( &curve == this ) if ( &curve == this )
{ {
@ -72,7 +66,7 @@ VAbstractCubicBezierPath::~VAbstractCubicBezierPath()
* @brief GetPath return QPainterPath which reprezent spline path. * @brief GetPath return QPainterPath which reprezent spline path.
* @return path. * @return path.
*/ */
QPainterPath VAbstractCubicBezierPath::GetPath() const auto VAbstractCubicBezierPath::GetPath() const -> QPainterPath
{ {
QPainterPath painterPath; QPainterPath painterPath;
for (qint32 i = 1; i <= CountSubSpl(); ++i) for (qint32 i = 1; i <= CountSubSpl(); ++i)
@ -87,7 +81,7 @@ QPainterPath VAbstractCubicBezierPath::GetPath() const
* @brief GetPathPoints return list of points what located on path. * @brief GetPathPoints return list of points what located on path.
* @return list. * @return list.
*/ */
QVector<QPointF> VAbstractCubicBezierPath::GetPoints() const auto VAbstractCubicBezierPath::GetPoints() const -> QVector<QPointF>
{ {
QVector<QPointF> pathPoints; QVector<QPointF> pathPoints;
for (qint32 i = 1; i <= CountSubSpl(); ++i) for (qint32 i = 1; i <= CountSubSpl(); ++i)
@ -107,7 +101,7 @@ QVector<QPointF> VAbstractCubicBezierPath::GetPoints() const
* @brief GetLength return length of spline path. * @brief GetLength return length of spline path.
* @return length. * @return length.
*/ */
qreal VAbstractCubicBezierPath::GetLength() const auto VAbstractCubicBezierPath::GetLength() const -> qreal
{ {
qreal length = 0; qreal length = 0;
for (qint32 i = 1; i <= CountSubSpl(); ++i) for (qint32 i = 1; i <= CountSubSpl(); ++i)
@ -118,7 +112,7 @@ qreal VAbstractCubicBezierPath::GetLength() const
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QVector<DirectionArrow> VAbstractCubicBezierPath::DirectionArrows() const auto VAbstractCubicBezierPath::DirectionArrows() const -> QVector<DirectionArrow>
{ {
QVector<DirectionArrow> arrows; QVector<DirectionArrow> arrows;
for (qint32 i = 1; i <= CountSubSpl(); ++i) for (qint32 i = 1; i <= CountSubSpl(); ++i)
@ -129,7 +123,7 @@ QVector<DirectionArrow> VAbstractCubicBezierPath::DirectionArrows() const
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
int VAbstractCubicBezierPath::Segment(const QPointF &p) const auto VAbstractCubicBezierPath::Segment(const QPointF &p) const -> int
{ {
int index = -1; int index = -1;
for (qint32 i = 1; i <= CountSubSpl(); ++i) for (qint32 i = 1; i <= CountSubSpl(); ++i)
@ -167,8 +161,9 @@ int VAbstractCubicBezierPath::Segment(const QPointF &p) const
* @param pointName cutting point name. * @param pointName cutting point name.
* @return cutting point. * @return cutting point.
*/ */
QPointF VAbstractCubicBezierPath::CutSplinePath(qreal length, qint32 &p1, qint32 &p2, QPointF &spl1p2, QPointF &spl1p3, auto VAbstractCubicBezierPath::CutSplinePath(qreal length, qint32 &p1, qint32 &p2, QPointF &spl1p2, QPointF &spl1p3,
QPointF &spl2p2, QPointF &spl2p3, const QString &pointName) const QPointF &spl2p2, QPointF &spl2p3,
const QString &pointName) const -> QPointF
{ {
if (CountSubSpl() < 1) if (CountSubSpl() < 1)
{ {
@ -184,7 +179,7 @@ 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()); const QString errorMsg = tr("Unable to cut curve '%1'. The curve is too short.").arg(name());
VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) : VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) :
qWarning() << VAbstractApplication::warningMessageSignature + errorMsg; qWarning() << VAbstractApplication::warningMessageSignature + errorMsg;
@ -200,12 +195,12 @@ QPointF VAbstractCubicBezierPath::CutSplinePath(qreal length, qint32 &p1, qint32
QString errorMsg; QString errorMsg;
if (not pointName.isEmpty()) if (not pointName.isEmpty())
{ {
errorMsg = QObject::tr("Curve '%1'. Length of a cut segment (%2) is too small. Optimize it to minimal " errorMsg = tr("Curve '%1'. Length of a cut segment (%2) is too small. Optimize it to minimal value.")
"value.").arg(name(), pointName); .arg(name(), pointName);
} }
else else
{ {
errorMsg = QObject::tr("Curve '%1'. Length of a cut segment is too small. Optimize it to minimal value.") errorMsg = tr("Curve '%1'. Length of a cut segment is too small. Optimize it to minimal value.")
.arg(name()); .arg(name());
} }
VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) : VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) :
@ -218,12 +213,12 @@ QPointF VAbstractCubicBezierPath::CutSplinePath(qreal length, qint32 &p1, qint32
QString errorMsg; QString errorMsg;
if (not pointName.isEmpty()) if (not pointName.isEmpty())
{ {
errorMsg = QObject::tr("Curve '%1'. Length of a cut segment (%2) is too big. Optimize it to maximal value.") errorMsg = tr("Curve '%1'. Length of a cut segment (%2) is too big. Optimize it to maximal value.")
.arg(name(), pointName); .arg(name(), pointName);
} }
else else
{ {
errorMsg = QObject::tr("Curve '%1'. Length of a cut segment is too big. Optimize it to maximal value.") errorMsg = tr("Curve '%1'. Length of a cut segment is too big. Optimize it to maximal value.")
.arg(name()); .arg(name());
} }
VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) : VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) :
@ -247,7 +242,7 @@ QPointF VAbstractCubicBezierPath::CutSplinePath(qreal length, qint32 &p1, qint32
if (p1 > 0) if (p1 > 0)
{ {
const VSplinePoint splP1 = points.at(p1); const VSplinePoint &splP1 = points.at(p1);
QLineF line(splP1.P().toQPointF(), spl1p2); QLineF line(splP1.P().toQPointF(), spl1p2);
if (qFuzzyIsNull(line.length())) if (qFuzzyIsNull(line.length()))
{ {
@ -261,7 +256,7 @@ QPointF VAbstractCubicBezierPath::CutSplinePath(qreal length, qint32 &p1, qint32
if (p2 < points.size() - 1) if (p2 < points.size() - 1)
{ {
const VSplinePoint splP2 = points.at(p2); const VSplinePoint &splP2 = points.at(p2);
QLineF line(splP2.P().toQPointF(), spl2p3); QLineF line(splP2.P().toQPointF(), spl2p3);
if (qFuzzyIsNull(line.length())) if (qFuzzyIsNull(line.length()))
{ {
@ -277,7 +272,7 @@ QPointF VAbstractCubicBezierPath::CutSplinePath(qreal length, qint32 &p1, qint32
} }
p1 = p2 = -1; p1 = p2 = -1;
spl1p2 = spl1p3 = spl2p2 = spl2p3 = QPointF(); spl1p2 = spl1p3 = spl2p2 = spl2p3 = QPointF();
return QPointF(); return {};
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -286,7 +281,7 @@ QPointF VAbstractCubicBezierPath::CutSplinePath(qreal length, qint32 &p1, qint32
* @param toolName first part of name. Like 'Spline path' or 'Cubic Bezier path'. * @param toolName first part of name. Like 'Spline path' or 'Cubic Bezier path'.
* @return name of curve for history records. * @return name of curve for history records.
*/ */
QString VAbstractCubicBezierPath::NameForHistory(const QString &toolName) const auto VAbstractCubicBezierPath::NameForHistory(const QString &toolName) const -> QString
{ {
QString name = toolName; QString name = toolName;
if (CountPoints() > 0) if (CountPoints() > 0)

View File

@ -49,39 +49,39 @@ QT_WARNING_DISABLE_GCC("-Wsuggest-final-methods")
class VAbstractCubicBezierPath : public VAbstractBezier class VAbstractCubicBezierPath : public VAbstractBezier
{ {
Q_DECLARE_TR_FUNCTIONS(VAbstractCubicBezierPath) Q_DECLARE_TR_FUNCTIONS(VAbstractCubicBezierPath) // NOLINT
public: public:
VAbstractCubicBezierPath(const GOType &type, const quint32 &idObject = NULL_ID, explicit VAbstractCubicBezierPath(const GOType &type, const quint32 &idObject = NULL_ID,
const Draw &mode = Draw::Calculation); const Draw &mode = Draw::Calculation);
VAbstractCubicBezierPath(const VAbstractCubicBezierPath &curve); VAbstractCubicBezierPath(const VAbstractCubicBezierPath &curve) = default;
VAbstractCubicBezierPath& operator= (const VAbstractCubicBezierPath &curve); auto operator= (const VAbstractCubicBezierPath &curve) -> VAbstractCubicBezierPath&;
virtual ~VAbstractCubicBezierPath(); ~VAbstractCubicBezierPath() override;
virtual qint32 CountSubSpl() const =0; virtual auto CountSubSpl() const -> qint32 =0;
virtual qint32 CountPoints() const =0; virtual auto CountPoints() const -> qint32 =0;
virtual void Clear() =0; virtual void Clear() =0;
virtual VSpline GetSpline(qint32 index) const =0; virtual auto GetSpline(qint32 index) const -> VSpline =0;
virtual QVector<VSplinePoint> GetSplinePath() const =0; virtual auto GetSplinePath() const -> QVector<VSplinePoint> =0;
virtual QPainterPath GetPath() const override; auto GetPath() const -> QPainterPath override;
virtual QVector<QPointF> GetPoints() const override; auto GetPoints() const -> QVector<QPointF> override;
virtual qreal GetLength() const override; auto GetLength() const -> qreal override;
virtual QVector<DirectionArrow> DirectionArrows() const override; auto DirectionArrows() const -> QVector<DirectionArrow> override;
int Segment(const QPointF &p) const; auto Segment(const QPointF &p) const -> int;
QPointF CutSplinePath(qreal length, qint32 &p1, qint32 &p2, QPointF &spl1p2, QPointF &spl1p3, QPointF &spl2p2, auto CutSplinePath(qreal length, qint32 &p1, qint32 &p2, QPointF &spl1p2, QPointF &spl1p3, QPointF &spl2p2,
QPointF &spl2p3, const QString &pointName) const; QPointF &spl2p3, const QString &pointName) const -> QPointF;
virtual QString NameForHistory(const QString &toolName) const override; auto NameForHistory(const QString &toolName) const -> QString override;
protected: protected:
virtual void CreateName() override; void CreateName() override;
virtual void CreateAlias() override; void CreateAlias() override;
virtual VPointF FirstPoint() const =0; virtual auto FirstPoint() const -> VPointF =0;
virtual VPointF LastPoint() const =0; virtual auto LastPoint() const -> VPointF =0;
}; };
QT_WARNING_POP QT_WARNING_POP

View File

@ -108,7 +108,7 @@ VArc::VArc(const VArc &arc)
* @param arc arc * @param arc arc
* @return arc * @return arc
*/ */
VArc &VArc::operator =(const VArc &arc) auto VArc::operator =(const VArc &arc) -> VArc &
{ {
if ( &arc == this ) if ( &arc == this )
{ {
@ -126,7 +126,7 @@ VArc::VArc(VArc &&arc) Q_DECL_NOTHROW
{} {}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VArc &VArc::operator=(VArc &&arc) Q_DECL_NOTHROW auto VArc::operator=(VArc &&arc) Q_DECL_NOTHROW -> VArc &
{ {
VAbstractArc::operator=(arc); VAbstractArc::operator=(arc);
std::swap(d, arc.d); std::swap(d, arc.d);
@ -135,7 +135,7 @@ VArc &VArc::operator=(VArc &&arc) Q_DECL_NOTHROW
#endif #endif
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VArc VArc::Rotate(const QPointF &originPoint, qreal degrees, const QString &prefix) const auto VArc::Rotate(const QPointF &originPoint, qreal degrees, const QString &prefix) const -> VArc
{ {
const VPointF center = GetCenter().Rotate(originPoint, degrees); const VPointF center = GetCenter().Rotate(originPoint, degrees);
@ -161,7 +161,7 @@ VArc VArc::Rotate(const QPointF &originPoint, qreal degrees, const QString &pref
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VArc VArc::Flip(const QLineF &axis, const QString &prefix) const auto VArc::Flip(const QLineF &axis, const QString &prefix) const -> VArc
{ {
const VPointF center = GetCenter().Flip(axis); const VPointF center = GetCenter().Flip(axis);
@ -187,7 +187,7 @@ VArc VArc::Flip(const QLineF &axis, const QString &prefix) const
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VArc VArc::Move(qreal length, qreal angle, const QString &prefix) const auto VArc::Move(qreal length, qreal angle, const QString &prefix) const -> VArc
{ {
const VPointF center = GetCenter().Move(length, angle); const VPointF center = GetCenter().Move(length, angle);
@ -213,7 +213,7 @@ VArc VArc::Move(qreal length, qreal angle, const QString &prefix) const
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VArc::~VArc() VArc::~VArc() // NOLINT(hicpp-use-equals-default, modernize-use-equals-default)
{} {}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -221,7 +221,7 @@ VArc::~VArc()
* @brief GetLength return arc length. * @brief GetLength return arc length.
* @return length. * @return length.
*/ */
qreal VArc::GetLength() const auto VArc::GetLength() const -> qreal
{ {
qreal length = d->radius * qDegreesToRadians(AngleArc()); qreal length = d->radius * qDegreesToRadians(AngleArc());
if (IsFlipped()) if (IsFlipped())
@ -237,7 +237,7 @@ qreal VArc::GetLength() const
* @brief GetP1 return point associated with start angle. * @brief GetP1 return point associated with start angle.
* @return point. * @return point.
*/ */
QPointF VArc::GetP1() const auto VArc::GetP1() const -> QPointF
{ {
QPointF p1 ( GetCenter().x () + d->radius, GetCenter().y () ); QPointF p1 ( GetCenter().x () + d->radius, GetCenter().y () );
QLineF centerP1(static_cast<QPointF>(GetCenter()), p1); QLineF centerP1(static_cast<QPointF>(GetCenter()), p1);
@ -250,7 +250,7 @@ QPointF VArc::GetP1() const
* @brief GetP2 return point associated with end angle. * @brief GetP2 return point associated with end angle.
* @return точку point. * @return точку point.
*/ */
QPointF VArc::GetP2 () const auto VArc::GetP2 () const -> QPointF
{ {
QPointF p2 ( GetCenter().x () + d->radius, GetCenter().y () ); QPointF p2 ( GetCenter().x () + d->radius, GetCenter().y () );
QLineF centerP2(static_cast<QPointF>(GetCenter()), p2); QLineF centerP2(static_cast<QPointF>(GetCenter()), p2);
@ -263,7 +263,7 @@ QPointF VArc::GetP2 () const
* @brief GetPoints return list of points needed for drawing arc. * @brief GetPoints return list of points needed for drawing arc.
* @return list of points * @return list of points
*/ */
QVector<QPointF> VArc::GetPoints() const auto VArc::GetPoints() const -> QVector<QPointF>
{ {
if (qFuzzyIsNull(GetRadius())) if (qFuzzyIsNull(GetRadius()))
{ {
@ -293,6 +293,7 @@ QVector<QPointF> VArc::GetPoints() const
const qreal angleInterpolation = 45; //degree const qreal angleInterpolation = 45; //degree
const int sections = qFloor(angle / angleInterpolation); const int sections = qFloor(angle / angleInterpolation);
sectionAngle.reserve(sections+1);
for (int i = 0; i < sections; ++i) for (int i = 0; i < sections; ++i)
{ {
sectionAngle.append(angleInterpolation); sectionAngle.append(angleInterpolation);
@ -355,118 +356,23 @@ auto VArc::CutArc(qreal length, VArc &arc1, VArc &arc2, const QString &pointName
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()); const QString errorMsg = tr("Unable to cut curve '%1'. The curve is too short.").arg(name());
VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) : VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) :
qWarning() << VAbstractApplication::warningMessageSignature + errorMsg; qWarning() << VAbstractApplication::warningMessageSignature + errorMsg;
return {}; return {};
} }
QLineF line(static_cast<QPointF>(GetCenter()), GetP1()); QLineF line = not IsFlipped() ? CutPoint(length, fullLength, pointName)
: CutPointFlipped(length, fullLength, pointName);
if (not IsFlipped()) arc1 = VArc(GetCenter(), d->radius, d->formulaRadius, GetStartAngle(), GetFormulaF1(), line.angle(),
{ QString().setNum(line.angle()), getIdObject(), getMode());
if (length < 0)
{
length = fullLength + length;
}
const qreal minLength = ToPixel(1, Unit::Mm);
const qreal maxLength = fullLength - ToPixel(1, Unit::Mm);
if (length < minLength)
{
QString errorMsg;
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) :
qWarning() << VAbstractApplication::warningMessageSignature + errorMsg;
}
else if (length > maxLength)
{
QString errorMsg;
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) :
qWarning() << VAbstractApplication::warningMessageSignature + errorMsg;
}
length = qBound(minLength, length, maxLength);
line.setAngle(line.angle() + qRadiansToDegrees(length/d->radius));
}
else
{
if (length > 0)
{
length = fullLength + length;
}
const qreal minLength = fullLength + ToPixel(1, Unit::Mm);
const qreal maxLength = ToPixel(-1, Unit::Mm);
if (length > minLength)
{
QString errorMsg;
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) :
qWarning() << VAbstractApplication::warningMessageSignature + errorMsg;
}
else if (length < maxLength)
{
QString errorMsg;
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) :
qWarning() << VAbstractApplication::warningMessageSignature + errorMsg;
}
length = qBound(minLength, length, maxLength);
line.setAngle(line.angle() - qRadiansToDegrees(qAbs(length)/d->radius));
}
arc1 = VArc (GetCenter(), d->radius, d->formulaRadius, GetStartAngle(), GetFormulaF1(), line.angle(),
QString().setNum(line.angle()), getIdObject(), getMode());
arc1.SetApproximationScale(GetApproximationScale()); arc1.SetApproximationScale(GetApproximationScale());
arc1.SetFlipped(IsFlipped()); arc1.SetFlipped(IsFlipped());
arc2 = VArc (GetCenter(), d->radius, d->formulaRadius, line.angle(), QString().setNum(line.angle()), GetEndAngle(), arc2 = VArc(GetCenter(), d->radius, d->formulaRadius, line.angle(), QString().setNum(line.angle()), GetEndAngle(),
GetFormulaF2(), getIdObject(), getMode()); GetFormulaF2(), getIdObject(), getMode());
arc2.SetApproximationScale(GetApproximationScale()); arc2.SetApproximationScale(GetApproximationScale());
arc2.SetFlipped(IsFlipped()); arc2.SetFlipped(IsFlipped());
return line.p2(); return line.p2();
@ -474,7 +380,7 @@ auto VArc::CutArc(qreal length, VArc &arc1, VArc &arc2, const QString &pointName
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QPointF VArc::CutArc(qreal length, const QString &pointName) const auto VArc::CutArc(qreal length, const QString &pointName) const -> QPointF
{ {
VArc arc1; VArc arc1;
VArc arc2; VArc arc2;
@ -485,19 +391,20 @@ QPointF VArc::CutArc(qreal length, const QString &pointName) const
void VArc::CreateName() void VArc::CreateName()
{ {
QString name = ARC_ + this->GetCenter().name(); QString name = ARC_ + this->GetCenter().name();
const QString nameStr = QStringLiteral("_%1");
if (getMode() == Draw::Modeling && getIdObject() != NULL_ID) if (getMode() == Draw::Modeling && getIdObject() != NULL_ID)
{ {
name += QString("_%1").arg(getIdObject()); name += nameStr.arg(getIdObject());
} }
else if (VAbstractCurve::id() != NULL_ID) else if (VAbstractCurve::id() != NULL_ID)
{ {
name += QString("_%1").arg(VAbstractCurve::id()); name += nameStr.arg(VAbstractCurve::id());
} }
if (GetDuplicate() > 0) if (GetDuplicate() > 0)
{ {
name += QString("_%1").arg(GetDuplicate()); name += nameStr.arg(GetDuplicate());
} }
setName(name); setName(name);
@ -536,21 +443,124 @@ void VArc::FindF2(qreal length)
QLineF startAngle(0, 0, 100, 0); QLineF startAngle(0, 0, 100, 0);
startAngle.setAngle(GetStartAngle() + arcAngle);// We use QLineF just because it is easy way correct angle value startAngle.setAngle(GetStartAngle() + arcAngle);// We use QLineF just because it is easy way correct angle value
SetFormulaF2(QString().number(startAngle.angle()), startAngle.angle()); SetFormulaF2(QString::number(startAngle.angle()), startAngle.angle());
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
qreal VArc::MaxLength() const auto VArc::MaxLength() const -> qreal
{ {
return M_2PI*d->radius; return M_2PI*d->radius;
} }
//---------------------------------------------------------------------------------------------------------------------
auto VArc::CutPoint(qreal length, qreal fullLength, const QString &pointName) const -> QLineF
{
if (length < 0)
{
length = fullLength + length;
}
const qreal minLength = ToPixel(1, Unit::Mm);
const qreal maxLength = fullLength - ToPixel(1, Unit::Mm);
if (length < minLength)
{
QString errorMsg;
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) :
qWarning() << VAbstractApplication::warningMessageSignature + errorMsg;
}
else if (length > maxLength)
{
QString errorMsg;
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) :
qWarning() << VAbstractApplication::warningMessageSignature + errorMsg;
}
length = qBound(minLength, length, maxLength);
QLineF line(static_cast<QPointF>(GetCenter()), GetP1());
line.setAngle(line.angle() + qRadiansToDegrees(length/d->radius));
return line;
}
//---------------------------------------------------------------------------------------------------------------------
auto VArc::CutPointFlipped(qreal length, qreal fullLength, const QString &pointName) const -> QLineF
{
if (length > 0)
{
length = fullLength + length;
}
const qreal minLength = fullLength + ToPixel(1, Unit::Mm);
const qreal maxLength = ToPixel(-1, Unit::Mm);
if (length > minLength)
{
QString errorMsg;
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) :
qWarning() << VAbstractApplication::warningMessageSignature + errorMsg;
}
else if (length < maxLength)
{
QString errorMsg;
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) :
qWarning() << VAbstractApplication::warningMessageSignature + errorMsg;
}
length = qBound(minLength, length, maxLength);
QLineF line(static_cast<QPointF>(GetCenter()), GetP1());
line.setAngle(line.angle() - qRadiansToDegrees(qAbs(length)/d->radius));
return line;
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief GetRadius return arc radius. * @brief GetRadius return arc radius.
* @return radius. * @return radius.
*/ */
QString VArc::GetFormulaRadius() const auto VArc::GetFormulaRadius() const -> QString
{ {
return d->formulaRadius; return d->formulaRadius;
} }
@ -567,7 +577,7 @@ void VArc::SetFormulaRadius(const QString &formula, qreal value)
* @brief GetRadius return formula for radius. * @brief GetRadius return formula for radius.
* @return string with formula. * @return string with formula.
*/ */
qreal VArc::GetRadius() const auto VArc::GetRadius() const -> qreal
{ {
return d->radius; return d->radius;
} }

View File

@ -49,48 +49,51 @@ class VArcData;
*/ */
class VArc final : public VAbstractArc class VArc final : public VAbstractArc
{ {
Q_DECLARE_TR_FUNCTIONS(VArc) Q_DECLARE_TR_FUNCTIONS(VArc) // NOLINT
public: public:
VArc (); VArc();
VArc (const VPointF &center, qreal radius, const QString &formulaRadius, qreal f1, const QString &formulaF1, VArc(const VPointF &center, qreal radius, const QString &formulaRadius, qreal f1, const QString &formulaF1,
qreal f2, const QString &formulaF2, quint32 idObject = 0, Draw mode = Draw::Calculation); qreal f2, const QString &formulaF2, quint32 idObject = 0, Draw mode = Draw::Calculation);
VArc (const VPointF &center, qreal radius, qreal f1, qreal f2); VArc(const VPointF &center, qreal radius, qreal f1, qreal f2);
VArc (qreal length, const QString &formulaLength, const VPointF &center, qreal radius, const QString &formulaRadius, VArc(qreal length, const QString &formulaLength, const VPointF &center, qreal radius, const QString &formulaRadius,
qreal f1, const QString &formulaF1, quint32 idObject = 0, Draw mode = Draw::Calculation); qreal f1, const QString &formulaF1, quint32 idObject = 0, Draw mode = Draw::Calculation);
VArc (qreal length, const VPointF &center, qreal radius, qreal f1); VArc(qreal length, const VPointF &center, qreal radius, qreal f1);
VArc(const VArc &arc); VArc(const VArc &arc);
VArc Rotate(const QPointF &originPoint, qreal degrees, const QString &prefix = QString()) const; auto Rotate(const QPointF &originPoint, qreal degrees, const QString &prefix = QString()) const -> VArc;
VArc Flip(const QLineF &axis, const QString &prefix = QString()) const; auto Flip(const QLineF &axis, const QString &prefix = QString()) const -> VArc;
VArc Move(qreal length, qreal angle, const QString &prefix = QString()) const; auto Move(qreal length, qreal angle, const QString &prefix = QString()) const -> VArc;
virtual ~VArc() override; ~VArc() override;
VArc& operator= (const VArc &arc); auto operator= (const VArc &arc) -> VArc&;
#ifdef Q_COMPILER_RVALUE_REFS #ifdef Q_COMPILER_RVALUE_REFS
VArc(VArc &&arc) Q_DECL_NOTHROW; VArc(VArc &&arc) Q_DECL_NOTHROW;
VArc &operator=(VArc &&arc) Q_DECL_NOTHROW; auto operator=(VArc &&arc) Q_DECL_NOTHROW -> VArc &;
#endif #endif
QString GetFormulaRadius () const; auto GetFormulaRadius() const -> QString;
void SetFormulaRadius (const QString &formula, qreal value); void SetFormulaRadius(const QString &formula, qreal value);
qreal GetRadius () const; auto GetRadius() const -> qreal;
virtual qreal GetLength () const override; auto GetLength() const -> qreal override;
QPointF GetP1() const; auto GetP1() const -> QPointF;
QPointF GetP2 () const; auto GetP2() const -> QPointF;
virtual QVector<QPointF> GetPoints () const override; auto GetPoints() const -> QVector<QPointF> override;
QPointF CutArc (qreal length, VArc &arc1, VArc &arc2, const QString &pointName) const; auto CutArc(qreal length, VArc &arc1, VArc &arc2, const QString &pointName) const -> QPointF;
QPointF CutArc (qreal length, const QString &pointName) const; auto CutArc(qreal length, const QString &pointName) const -> QPointF;
protected: protected:
virtual void CreateName() override; void CreateName() override;
virtual void CreateAlias() override; void CreateAlias() override;
virtual void FindF2(qreal length) override; void FindF2(qreal length) override;
private: private:
QSharedDataPointer<VArcData> d; QSharedDataPointer<VArcData> d;
qreal MaxLength() const; auto MaxLength() const -> qreal;
auto CutPoint(qreal length, qreal fullLength, const QString &pointName) const -> QLineF;
auto CutPointFlipped(qreal length, qreal fullLength, const QString &pointName) const -> QLineF;
}; };
Q_DECLARE_TYPEINFO(VArc, Q_MOVABLE_TYPE); // NOLINT Q_DECLARE_TYPEINFO(VArc, Q_MOVABLE_TYPE); // NOLINT

View File

@ -116,7 +116,7 @@ VEllipticalArc::VEllipticalArc(const VEllipticalArc &arc)
* @param arc arc * @param arc arc
* @return arc * @return arc
*/ */
VEllipticalArc &VEllipticalArc::operator =(const VEllipticalArc &arc) auto VEllipticalArc::operator =(const VEllipticalArc &arc) -> VEllipticalArc &
{ {
if ( &arc == this ) if ( &arc == this )
{ {
@ -129,12 +129,13 @@ VEllipticalArc &VEllipticalArc::operator =(const VEllipticalArc &arc)
#ifdef Q_COMPILER_RVALUE_REFS #ifdef Q_COMPILER_RVALUE_REFS
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VEllipticalArc::VEllipticalArc(const VEllipticalArc &&arc) Q_DECL_NOTHROW VEllipticalArc::VEllipticalArc(VEllipticalArc &&arc) Q_DECL_NOTHROW
: VAbstractArc(arc), d (arc.d) : VAbstractArc(std::move(arc)),
d(std::move(arc.d))
{} {}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VEllipticalArc &VEllipticalArc::operator=(VEllipticalArc &&arc) Q_DECL_NOTHROW auto VEllipticalArc::operator=(VEllipticalArc &&arc) Q_DECL_NOTHROW -> VEllipticalArc &
{ {
VAbstractArc::operator=(arc); VAbstractArc::operator=(arc);
std::swap(d, arc.d); std::swap(d, arc.d);
@ -143,7 +144,7 @@ VEllipticalArc &VEllipticalArc::operator=(VEllipticalArc &&arc) Q_DECL_NOTHROW
#endif #endif
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VEllipticalArc VEllipticalArc::Rotate(QPointF originPoint, qreal degrees, const QString &prefix) const auto VEllipticalArc::Rotate(QPointF originPoint, qreal degrees, const QString &prefix) const -> VEllipticalArc
{ {
originPoint = d->m_transform.inverted().map(originPoint); originPoint = d->m_transform.inverted().map(originPoint);
@ -169,7 +170,7 @@ VEllipticalArc VEllipticalArc::Rotate(QPointF originPoint, qreal degrees, const
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VEllipticalArc VEllipticalArc::Flip(const QLineF &axis, const QString &prefix) const auto VEllipticalArc::Flip(const QLineF &axis, const QString &prefix) const -> VEllipticalArc
{ {
VEllipticalArc elArc(VAbstractArc::GetCenter(), GetRadius1(), GetRadius2(), VAbstractArc::GetStartAngle(), VEllipticalArc elArc(VAbstractArc::GetCenter(), GetRadius1(), GetRadius2(), VAbstractArc::GetStartAngle(),
VAbstractArc::GetEndAngle(), GetRotationAngle()); VAbstractArc::GetEndAngle(), GetRotationAngle());
@ -188,7 +189,7 @@ VEllipticalArc VEllipticalArc::Flip(const QLineF &axis, const QString &prefix) c
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VEllipticalArc VEllipticalArc::Move(qreal length, qreal angle, const QString &prefix) const auto VEllipticalArc::Move(qreal length, qreal angle, const QString &prefix) const -> VEllipticalArc
{ {
const VPointF oldCenter = VAbstractArc::GetCenter(); const VPointF oldCenter = VAbstractArc::GetCenter();
const VPointF center = oldCenter.Move(length, angle); const VPointF center = oldCenter.Move(length, angle);
@ -216,7 +217,7 @@ VEllipticalArc VEllipticalArc::Move(qreal length, qreal angle, const QString &pr
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VEllipticalArc::~VEllipticalArc() VEllipticalArc::~VEllipticalArc() // NOLINT(hicpp-use-equals-default, modernize-use-equals-default)
{} {}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -224,7 +225,7 @@ VEllipticalArc::~VEllipticalArc()
* @brief GetLength return arc length. * @brief GetLength return arc length.
* @return length. * @return length.
*/ */
qreal VEllipticalArc::GetLength() const auto VEllipticalArc::GetLength() const -> qreal
{ {
qreal length = PathLength(GetPoints()); qreal length = PathLength(GetPoints());
@ -241,7 +242,7 @@ qreal VEllipticalArc::GetLength() const
* @brief GetP1 return point associated with start angle. * @brief GetP1 return point associated with start angle.
* @return point. * @return point.
*/ */
QPointF VEllipticalArc::GetP1() const auto VEllipticalArc::GetP1() const -> QPointF
{ {
return GetTransform().map(GetP(VAbstractArc::GetStartAngle())); return GetTransform().map(GetP(VAbstractArc::GetStartAngle()));
} }
@ -251,13 +252,13 @@ QPointF VEllipticalArc::GetP1() const
* @brief GetP2 return point associated with end angle. * @brief GetP2 return point associated with end angle.
* @return point. * @return point.
*/ */
QPointF VEllipticalArc::GetP2 () const auto VEllipticalArc::GetP2 () const -> QPointF
{ {
return GetTransform().map(GetP(VAbstractArc::GetEndAngle())); return GetTransform().map(GetP(VAbstractArc::GetEndAngle()));
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QTransform VEllipticalArc::GetTransform() const auto VEllipticalArc::GetTransform() const -> QTransform
{ {
return d->m_transform; return d->m_transform;
} }
@ -269,7 +270,7 @@ void VEllipticalArc::SetTransform(const QTransform &matrix, bool combine)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPointF VEllipticalArc::GetCenter() const auto VEllipticalArc::GetCenter() const -> VPointF
{ {
VPointF center = VAbstractArc::GetCenter(); VPointF center = VAbstractArc::GetCenter();
const QPointF p = d->m_transform.map(center.toQPointF()); const QPointF p = d->m_transform.map(center.toQPointF());
@ -283,7 +284,7 @@ VPointF VEllipticalArc::GetCenter() const
* @brief GetPoints return list of points needed for drawing arc. * @brief GetPoints return list of points needed for drawing arc.
* @return list of points * @return list of points
*/ */
QVector<QPointF> VEllipticalArc::GetPoints() const auto VEllipticalArc::GetPoints() const -> QVector<QPointF>
{ {
const QPointF center = VAbstractArc::GetCenter().toQPointF(); const QPointF center = VAbstractArc::GetCenter().toQPointF();
QRectF box(center.x() - d->radius1, center.y() - d->radius2, d->radius1*2, d->radius2*2); QRectF box(center.x() - d->radius1, center.y() - d->radius2, d->radius1*2, d->radius2*2);
@ -328,13 +329,13 @@ QVector<QPointF> VEllipticalArc::GetPoints() const
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
qreal VEllipticalArc::GetStartAngle() const auto VEllipticalArc::GetStartAngle() const -> qreal
{ {
return QLineF(GetCenter().toQPointF(), GetP1()).angle() - GetRotationAngle(); return QLineF(GetCenter().toQPointF(), GetP1()).angle() - GetRotationAngle();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
qreal VEllipticalArc::GetEndAngle() const auto VEllipticalArc::GetEndAngle() const -> qreal
{ {
return QLineF(GetCenter().toQPointF(), GetP2()).angle() - GetRotationAngle(); return QLineF(GetCenter().toQPointF(), GetP2()).angle() - GetRotationAngle();
} }
@ -347,8 +348,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, auto VEllipticalArc::CutArc(const qreal &length, VEllipticalArc &arc1, VEllipticalArc &arc2,
const QString &pointName) const 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.
qreal len = 0; qreal len = 0;
@ -424,7 +425,7 @@ QPointF VEllipticalArc::CutArc(const qreal &length, VEllipticalArc &arc1, VEllip
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QPointF VEllipticalArc::CutArc(const qreal &length, const QString &pointName) const auto VEllipticalArc::CutArc(const qreal &length, const QString &pointName) const -> QPointF
{ {
VEllipticalArc arc1; VEllipticalArc arc1;
VEllipticalArc arc2; VEllipticalArc arc2;
@ -435,19 +436,20 @@ QPointF VEllipticalArc::CutArc(const qreal &length, const QString &pointName) co
void VEllipticalArc::CreateName() void VEllipticalArc::CreateName()
{ {
QString name = ELARC_ + QString("%1").arg(this->GetCenter().name()); QString name = ELARC_ + QString("%1").arg(this->GetCenter().name());
const QString nameStr = QStringLiteral("_%1");
if (getMode() == Draw::Modeling && getIdObject() != NULL_ID) if (getMode() == Draw::Modeling && getIdObject() != NULL_ID)
{ {
name += QString("_%1").arg(getIdObject()); name += nameStr.arg(getIdObject());
} }
else if (VAbstractCurve::id() != NULL_ID) else if (VAbstractCurve::id() != NULL_ID)
{ {
name += QString("_%1").arg(VAbstractCurve::id()); name += nameStr.arg(VAbstractCurve::id());
} }
if (GetDuplicate() > 0) if (GetDuplicate() > 0)
{ {
name += QString("_%1").arg(GetDuplicate()); name += nameStr.arg(GetDuplicate());
} }
setName(name); setName(name);
@ -519,7 +521,7 @@ void VEllipticalArc::FindF2(qreal length)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
qreal VEllipticalArc::MaxLength() const auto VEllipticalArc::MaxLength() const -> qreal
{ {
const qreal h = qPow(d->radius1 - d->radius2, 2) / qPow(d->radius1 + d->radius2, 2); const qreal h = qPow(d->radius1 - d->radius2, 2) / qPow(d->radius1 + d->radius2, 2);
const qreal ellipseLength = M_PI * (d->radius1 + d->radius2) * (1+3*h/(10+qSqrt(4-3*h))); const qreal ellipseLength = M_PI * (d->radius1 + d->radius2) * (1+3*h/(10+qSqrt(4-3*h)));
@ -527,7 +529,7 @@ qreal VEllipticalArc::MaxLength() const
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QPointF VEllipticalArc::GetP(qreal angle) const auto VEllipticalArc::GetP(qreal angle) const -> QPointF
{ {
if (qFuzzyIsNull(GetRadius1()) && qFuzzyIsNull(GetRadius2())) if (qFuzzyIsNull(GetRadius1()) && qFuzzyIsNull(GetRadius2()))
{ {
@ -556,7 +558,7 @@ QPointF VEllipticalArc::GetP(qreal angle) const
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
qreal VEllipticalArc::RealEndAngle() const auto VEllipticalArc::RealEndAngle() const -> qreal
{ {
qreal endAngle = VEllipticalArc::OptimizeAngle(VAbstractArc::GetEndAngle()); qreal endAngle = VEllipticalArc::OptimizeAngle(VAbstractArc::GetEndAngle());
@ -580,7 +582,7 @@ qreal VEllipticalArc::RealEndAngle() const
* @brief GetFormulaRadius1 return formula for major radius. * @brief GetFormulaRadius1 return formula for major radius.
* @return radius. * @return radius.
*/ */
QString VEllipticalArc::GetFormulaRadius1() const auto VEllipticalArc::GetFormulaRadius1() const -> QString
{ {
return d->formulaRadius1; return d->formulaRadius1;
} }
@ -590,7 +592,7 @@ QString VEllipticalArc::GetFormulaRadius1() const
* @brief GetFormulaRadius2 return formula for minor radius. * @brief GetFormulaRadius2 return formula for minor radius.
* @return radius. * @return radius.
*/ */
QString VEllipticalArc::GetFormulaRadius2() const auto VEllipticalArc::GetFormulaRadius2() const -> QString
{ {
return d->formulaRadius2; return d->formulaRadius2;
} }
@ -600,7 +602,7 @@ QString VEllipticalArc::GetFormulaRadius2() const
* @brief GetFormulaRotationAngle return formula for rotation angle. * @brief GetFormulaRotationAngle return formula for rotation angle.
* @return rotationAngle. * @return rotationAngle.
*/ */
QString VEllipticalArc::GetFormulaRotationAngle() const auto VEllipticalArc::GetFormulaRotationAngle() const -> QString
{ {
return d->formulaRotationAngle; return d->formulaRotationAngle;
} }
@ -652,7 +654,7 @@ void VEllipticalArc::SetRotationAngle(qreal value)
* @brief GetRadius1 return elliptical arc major radius. * @brief GetRadius1 return elliptical arc major radius.
* @return string with formula. * @return string with formula.
*/ */
qreal VEllipticalArc::GetRadius1() const auto VEllipticalArc::GetRadius1() const -> qreal
{ {
return d->radius1; return d->radius1;
} }
@ -662,7 +664,7 @@ qreal VEllipticalArc::GetRadius1() const
* @brief GetRadius2 return elliptical arc minor radius. * @brief GetRadius2 return elliptical arc minor radius.
* @return string with formula. * @return string with formula.
*/ */
qreal VEllipticalArc::GetRadius2() const auto VEllipticalArc::GetRadius2() const -> qreal
{ {
return d->radius2; return d->radius2;
} }
@ -672,7 +674,7 @@ qreal VEllipticalArc::GetRadius2() const
* @brief GetRotationAngle return rotation angle. * @brief GetRotationAngle return rotation angle.
* @return rotationAngle. * @return rotationAngle.
*/ */
qreal VEllipticalArc::GetRotationAngle() const auto VEllipticalArc::GetRotationAngle() const -> qreal
{ {
return d->rotationAngle; return d->rotationAngle;
} }

View File

@ -46,84 +46,85 @@ class VEllipticalArcData;
class VEllipticalArc final : public VAbstractArc class VEllipticalArc final : public VAbstractArc
{ {
Q_DECLARE_TR_FUNCTIONS(VEllipticalArc) Q_DECLARE_TR_FUNCTIONS(VEllipticalArc) // NOLINT
public: public:
VEllipticalArc(); VEllipticalArc();
VEllipticalArc (const VPointF &center, qreal radius1, qreal radius2, const QString &formulaRadius1, VEllipticalArc(const VPointF &center, qreal radius1, qreal radius2, const QString &formulaRadius1,
const QString &formulaRadius2, qreal f1, const QString &formulaF1, qreal f2, const QString &formulaRadius2, qreal f1, const QString &formulaF1, qreal f2,
const QString &formulaF2, qreal rotationAngle, const QString &formulaRotationAngle, const QString &formulaF2, qreal rotationAngle, const QString &formulaRotationAngle,
quint32 idObject = 0, Draw mode = Draw::Calculation); quint32 idObject = 0, Draw mode = Draw::Calculation);
VEllipticalArc (const VPointF &center, qreal radius1, qreal radius2, qreal f1, qreal f2, qreal rotationAngle); VEllipticalArc(const VPointF &center, qreal radius1, qreal radius2, qreal f1, qreal f2, qreal rotationAngle);
VEllipticalArc (qreal length, const QString &formulaLength, const VPointF &center, qreal radius1, qreal radius2, VEllipticalArc(qreal length, const QString &formulaLength, const VPointF &center, qreal radius1, qreal radius2,
const QString &formulaRadius1, const QString &formulaRadius2, qreal f1, const QString &formulaF1, const QString &formulaRadius1, const QString &formulaRadius2, qreal f1, const QString &formulaF1,
qreal rotationAngle, const QString &formulaRotationAngle, quint32 idObject = 0, qreal rotationAngle, const QString &formulaRotationAngle, quint32 idObject = 0,
Draw mode = Draw::Calculation); Draw mode = Draw::Calculation);
VEllipticalArc (qreal length, const VPointF &center, qreal radius1, qreal radius2, qreal f1, qreal rotationAngle); VEllipticalArc(qreal length, const VPointF &center, qreal radius1, qreal radius2, qreal f1, qreal rotationAngle);
VEllipticalArc(const VEllipticalArc &arc); VEllipticalArc(const VEllipticalArc &arc);
VEllipticalArc Rotate(QPointF originPoint, qreal degrees, const QString &prefix = QString()) const; auto Rotate(QPointF originPoint, qreal degrees, const QString &prefix = QString()) const -> VEllipticalArc;
VEllipticalArc Flip(const QLineF &axis, const QString &prefix = QString()) const; auto Flip(const QLineF &axis, const QString &prefix = QString()) const -> VEllipticalArc;
VEllipticalArc Move(qreal length, qreal angle, const QString &prefix = QString()) const; auto Move(qreal length, qreal angle, const QString &prefix = QString()) const -> VEllipticalArc;
virtual ~VEllipticalArc() override; ~VEllipticalArc() override;
VEllipticalArc& operator= (const VEllipticalArc &arc); auto operator= (const VEllipticalArc &arc) -> VEllipticalArc&;
#ifdef Q_COMPILER_RVALUE_REFS #ifdef Q_COMPILER_RVALUE_REFS
VEllipticalArc(const VEllipticalArc &&arc) Q_DECL_NOTHROW; VEllipticalArc(VEllipticalArc &&arc) Q_DECL_NOTHROW;
VEllipticalArc &operator=(VEllipticalArc &&arc) Q_DECL_NOTHROW; auto operator=(VEllipticalArc &&arc) Q_DECL_NOTHROW -> VEllipticalArc &;
#endif #endif
QString GetFormulaRotationAngle () const; auto GetFormulaRotationAngle() const -> QString;
void SetFormulaRotationAngle (const QString &formula, qreal value); void SetFormulaRotationAngle(const QString &formula, qreal value);
void SetRotationAngle(qreal value); void SetRotationAngle(qreal value);
qreal GetRotationAngle() const; auto GetRotationAngle() const -> qreal;
QString GetFormulaRadius1 () const; auto GetFormulaRadius1() const -> QString;
void SetFormulaRadius1 (const QString &formula, qreal value); void SetFormulaRadius1(const QString &formula, qreal value);
void SetRadius1 (qreal value); void SetRadius1(qreal value);
qreal GetRadius1 () const; auto GetRadius1() const -> qreal;
QString GetFormulaRadius2 () const; auto GetFormulaRadius2() const -> QString;
void SetFormulaRadius2 (const QString &formula, qreal value); void SetFormulaRadius2(const QString &formula, qreal value);
void SetRadius2 (qreal value); void SetRadius2(qreal value);
qreal GetRadius2 () const; auto GetRadius2() const -> qreal;
virtual qreal GetLength () const override; auto GetLength() const -> qreal override;
QPointF GetP1() const; auto GetP1() const -> QPointF;
QPointF GetP2() const; auto GetP2() const -> QPointF;
QTransform GetTransform() const; auto GetTransform() const -> QTransform;
void SetTransform(const QTransform &matrix, bool combine = false); void SetTransform(const QTransform &matrix, bool combine = false);
virtual VPointF GetCenter () const override; auto GetCenter() const -> VPointF;
virtual QVector<QPointF> GetPoints () const override; auto GetPoints() const -> QVector<QPointF> override;
virtual qreal GetStartAngle () const override; auto GetStartAngle() const -> qreal override;
virtual qreal GetEndAngle () const override; auto GetEndAngle() const -> qreal override;
QPointF CutArc (const qreal &length, VEllipticalArc &arc1, VEllipticalArc &arc2, const QString &pointName) const; auto CutArc (const qreal &length, VEllipticalArc &arc1, VEllipticalArc &arc2,
QPointF CutArc (const qreal &length, const QString &pointName) const; const QString &pointName) const -> QPointF;
auto CutArc (const qreal &length, const QString &pointName) const -> QPointF;
static qreal OptimizeAngle(qreal angle); static auto OptimizeAngle(qreal angle) -> qreal;
protected: protected:
virtual void CreateName() override; void CreateName() override;
virtual void CreateAlias() override; void CreateAlias() override;
virtual void FindF2(qreal length) override; void FindF2(qreal length) override;
private: private:
QSharedDataPointer<VEllipticalArcData> d; QSharedDataPointer<VEllipticalArcData> d;
qreal MaxLength() const; auto MaxLength() const -> qreal;
QPointF GetP(qreal angle) const; auto GetP(qreal angle) const -> QPointF;
qreal RealEndAngle() const; auto RealEndAngle() const -> qreal;
}; };
Q_DECLARE_METATYPE(VEllipticalArc) Q_DECLARE_METATYPE(VEllipticalArc) // NOLINT
Q_DECLARE_TYPEINFO(VEllipticalArc, Q_MOVABLE_TYPE); Q_DECLARE_TYPEINFO(VEllipticalArc, Q_MOVABLE_TYPE); // NOLINT
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
inline qreal VEllipticalArc::OptimizeAngle(qreal angle) inline auto VEllipticalArc::OptimizeAngle(qreal angle) -> qreal
{ {
return angle - 360.*qFloor(angle/360.); return angle - 360.*qFloor(angle/360.);
} }

View File

@ -40,7 +40,8 @@
* @brief VSpline default constructor * @brief VSpline default constructor
*/ */
VSpline::VSpline() VSpline::VSpline()
:VAbstractCubicBezier(GOType::Spline), d(new VSplineData) : VAbstractCubicBezier(GOType::Spline),
d(new VSplineData)
{} {}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -48,8 +49,9 @@ VSpline::VSpline()
* @brief VSpline constructor. * @brief VSpline constructor.
* @param spline spline from which the copy. * @param spline spline from which the copy.
*/ */
VSpline::VSpline ( const VSpline & spline ) VSpline::VSpline(const VSpline &spline)
:VAbstractCubicBezier(spline), d(spline.d) : VAbstractCubicBezier(spline),
d(spline.d)
{} {}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -112,7 +114,7 @@ VSpline::VSpline(const VPointF &p1, const VPointF &p4, qreal angle1, const QStri
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VSpline VSpline::Rotate(const QPointF &originPoint, qreal degrees, const QString &prefix) const auto VSpline::Rotate(const QPointF &originPoint, qreal degrees, const QString &prefix) const -> VSpline
{ {
const VPointF p1 = GetP1().Rotate(originPoint, degrees); const VPointF p1 = GetP1().Rotate(originPoint, degrees);
const VPointF p4 = GetP4().Rotate(originPoint, degrees); const VPointF p4 = GetP4().Rotate(originPoint, degrees);
@ -135,7 +137,7 @@ VSpline VSpline::Rotate(const QPointF &originPoint, qreal degrees, const QString
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VSpline VSpline::Flip(const QLineF &axis, const QString &prefix) const auto VSpline::Flip(const QLineF &axis, const QString &prefix) const -> VSpline
{ {
const VPointF p1 = GetP1().Flip(axis); const VPointF p1 = GetP1().Flip(axis);
const VPointF p4 = GetP4().Flip(axis); const VPointF p4 = GetP4().Flip(axis);
@ -158,7 +160,7 @@ VSpline VSpline::Flip(const QLineF &axis, const QString &prefix) const
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VSpline VSpline::Move(qreal length, qreal angle, const QString &prefix) const auto VSpline::Move(qreal length, qreal angle, const QString &prefix) const -> VSpline
{ {
const VPointF p1 = GetP1().Move(length, angle); const VPointF p1 = GetP1().Move(length, angle);
const VPointF p4 = GetP4().Move(length, angle); const VPointF p4 = GetP4().Move(length, angle);
@ -181,7 +183,7 @@ VSpline VSpline::Move(qreal length, qreal angle, const QString &prefix) const
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VSpline::~VSpline() VSpline::~VSpline() // NOLINT(hicpp-use-equals-default, modernize-use-equals-default)
{} {}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -189,14 +191,14 @@ VSpline::~VSpline()
* @brief GetLength return length of spline. * @brief GetLength return length of spline.
* @return length. * @return length.
*/ */
qreal VSpline::GetLength () const auto VSpline::GetLength () const -> qreal
{ {
return LengthBezier ( static_cast<QPointF>(GetP1()), static_cast<QPointF>(GetP2()), static_cast<QPointF>(GetP3()), return LengthBezier ( static_cast<QPointF>(GetP1()), static_cast<QPointF>(GetP2()), static_cast<QPointF>(GetP3()),
static_cast<QPointF>(GetP4()), GetApproximationScale()); static_cast<QPointF>(GetP4()), GetApproximationScale());
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QPointF VSpline::CutSpline(qreal length, VSpline &spl1, VSpline &spl2, const QString &pointName) const auto VSpline::CutSpline(qreal length, VSpline &spl1, VSpline &spl2, const QString &pointName) const -> QPointF
{ {
QPointF spl1p2; QPointF spl1p2;
QPointF spl1p3; QPointF spl1p3;
@ -217,7 +219,7 @@ QPointF VSpline::CutSpline(qreal length, VSpline &spl1, VSpline &spl2, const QSt
* @brief GetPoints return list with spline points. * @brief GetPoints return list with spline points.
* @return list of points. * @return list of points.
*/ */
QVector<QPointF> VSpline::GetPoints () const auto VSpline::GetPoints () const -> QVector<QPointF>
{ {
return GetCubicBezierPoints(static_cast<QPointF>(GetP1()), static_cast<QPointF>(GetP2()), return GetCubicBezierPoints(static_cast<QPointF>(GetP1()), static_cast<QPointF>(GetP2()),
static_cast<QPointF>(GetP3()), static_cast<QPointF>(GetP4()), GetApproximationScale()); static_cast<QPointF>(GetP3()), static_cast<QPointF>(GetP4()), GetApproximationScale());
@ -236,8 +238,8 @@ QVector<QPointF> VSpline::GetPoints () const
* @return list with spline points. * @return list with spline points.
*/ */
// cppcheck-suppress unusedFunction // cppcheck-suppress unusedFunction
QVector<QPointF> VSpline::SplinePoints(const QPointF &p1, const QPointF &p4, qreal angle1, qreal angle2, qreal kAsm1, auto VSpline::SplinePoints(const QPointF &p1, const QPointF &p4, qreal angle1, qreal angle2, qreal kAsm1,
qreal kAsm2, qreal kCurve, qreal approximationScale) qreal kAsm2, qreal kCurve, qreal approximationScale) -> QVector<QPointF>
{ {
QLineF p1pX(p1.x(), p1.y(), p1.x() + 100, p1.y()); QLineF p1pX(p1.x(), p1.y(), p1.x() + 100, p1.y());
p1pX.setAngle( angle1 ); p1pX.setAngle( angle1 );
@ -254,7 +256,7 @@ QVector<QPointF> VSpline::SplinePoints(const QPointF &p1, const QPointF &p4, qre
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VSpline &VSpline::operator =(const VSpline &spline) auto VSpline::operator =(const VSpline &spline) -> VSpline &
{ {
if ( &spline == this ) if ( &spline == this )
{ {
@ -267,12 +269,13 @@ VSpline &VSpline::operator =(const VSpline &spline)
#ifdef Q_COMPILER_RVALUE_REFS #ifdef Q_COMPILER_RVALUE_REFS
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VSpline::VSpline(const VSpline &&spline) Q_DECL_NOTHROW VSpline::VSpline(VSpline &&spline) Q_DECL_NOTHROW
:VAbstractCubicBezier(spline), d(spline.d) : VAbstractCubicBezier(spline),
d(spline.d)
{} {}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VSpline &VSpline::operator=(VSpline &&spline) Q_DECL_NOTHROW auto VSpline::operator=(VSpline &&spline) Q_DECL_NOTHROW -> VSpline &
{ {
VAbstractCubicBezier::operator=(spline); VAbstractCubicBezier::operator=(spline);
std::swap(d, spline.d); std::swap(d, spline.d);
@ -285,7 +288,7 @@ VSpline &VSpline::operator=(VSpline &&spline) Q_DECL_NOTHROW
* @brief GetP1 return first spline point. * @brief GetP1 return first spline point.
* @return first point. * @return first point.
*/ */
VPointF VSpline::GetP1() const auto VSpline::GetP1() const -> VPointF
{ {
return d->p1; return d->p1;
} }
@ -301,7 +304,7 @@ void VSpline::SetP1(const VPointF &p)
* @brief GetP2 return first control point. * @brief GetP2 return first control point.
* @return first control point. * @return first control point.
*/ */
VPointF VSpline::GetP2() const auto VSpline::GetP2() const -> VPointF
{ {
QLineF p1p2(d->p1.x(), d->p1.y(), d->p1.x() + d->c1Length, d->p1.y()); QLineF p1p2(d->p1.x(), d->p1.y(), d->p1.x() + d->c1Length, d->p1.y());
p1p2.setAngle(d->angle1); p1p2.setAngle(d->angle1);
@ -313,7 +316,7 @@ VPointF VSpline::GetP2() const
* @brief GetP3 return second control point. * @brief GetP3 return second control point.
* @return second control point. * @return second control point.
*/ */
VPointF VSpline::GetP3() const auto VSpline::GetP3() const -> VPointF
{ {
QLineF p4p3(d->p4.x(), d->p4.y(), d->p4.x() + d->c2Length, d->p4.y()); QLineF p4p3(d->p4.x(), d->p4.y(), d->p4.x() + d->c2Length, d->p4.y());
p4p3.setAngle(d->angle2); p4p3.setAngle(d->angle2);
@ -325,7 +328,7 @@ VPointF VSpline::GetP3() const
* @brief GetP4 return last spline point. * @brief GetP4 return last spline point.
* @return остання точка сплайну. * @return остання точка сплайну.
*/ */
VPointF VSpline::GetP4() const auto VSpline::GetP4() const -> VPointF
{ {
return d->p4; return d->p4;
} }
@ -341,7 +344,7 @@ void VSpline::SetP4(const VPointF &p)
* @brief GetAngle1 return first angle control line. * @brief GetAngle1 return first angle control line.
* @return angle. * @return angle.
*/ */
qreal VSpline::GetStartAngle() const auto VSpline::GetStartAngle() const -> qreal
{ {
return d->angle1; return d->angle1;
} }
@ -351,19 +354,19 @@ qreal VSpline::GetStartAngle() const
* @brief GetAngle2 return second angle control line. * @brief GetAngle2 return second angle control line.
* @return angle. * @return angle.
*/ */
qreal VSpline::GetEndAngle() const auto VSpline::GetEndAngle() const -> qreal
{ {
return d->angle2; return d->angle2;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QString VSpline::GetStartAngleFormula() const auto VSpline::GetStartAngleFormula() const -> QString
{ {
return d->angle1F; return d->angle1F;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QString VSpline::GetEndAngleFormula() const auto VSpline::GetEndAngleFormula() const -> QString
{ {
return d->angle2F; return d->angle2F;
} }
@ -383,25 +386,25 @@ void VSpline::SetEndAngle(qreal angle, const QString &formula)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
qreal VSpline::GetC1Length() const auto VSpline::GetC1Length() const -> qreal
{ {
return d->c1Length; return d->c1Length;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
qreal VSpline::GetC2Length() const auto VSpline::GetC2Length() const -> qreal
{ {
return d->c2Length; return d->c2Length;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QString VSpline::GetC1LengthFormula() const auto VSpline::GetC1LengthFormula() const -> QString
{ {
return d->c1LengthF; return d->c1LengthF;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QString VSpline::GetC2LengthFormula() const auto VSpline::GetC2LengthFormula() const -> QString
{ {
return d->c2LengthF; return d->c2LengthF;
} }
@ -425,7 +428,7 @@ void VSpline::SetC2Length(qreal length, const QString &formula)
* @brief GetKasm1 return coefficient of length first control line. * @brief GetKasm1 return coefficient of length first control line.
* @return coefficient. * @return coefficient.
*/ */
qreal VSpline::GetKasm1() const auto VSpline::GetKasm1() const -> qreal
{ {
return QLineF(static_cast<QPointF>(d->p1), static_cast<QPointF>(GetP2())).length() / return QLineF(static_cast<QPointF>(d->p1), static_cast<QPointF>(GetP2())).length() /
VSplineData::GetL(static_cast<QPointF>(d->p1), static_cast<QPointF>(d->p4), d->kCurve); VSplineData::GetL(static_cast<QPointF>(d->p1), static_cast<QPointF>(d->p4), d->kCurve);
@ -436,7 +439,7 @@ qreal VSpline::GetKasm1() const
* @brief GetKasm2 return coefficient of length second control line. * @brief GetKasm2 return coefficient of length second control line.
* @return coefficient. * @return coefficient.
*/ */
qreal VSpline::GetKasm2() const auto VSpline::GetKasm2() const -> qreal
{ {
return QLineF(static_cast<QPointF>(d->p4), static_cast<QPointF>(GetP3())).length() / return QLineF(static_cast<QPointF>(d->p4), static_cast<QPointF>(GetP3())).length() /
VSplineData::GetL(static_cast<QPointF>(d->p1), static_cast<QPointF>(d->p4), d->kCurve); VSplineData::GetL(static_cast<QPointF>(d->p1), static_cast<QPointF>(d->p4), d->kCurve);
@ -447,13 +450,13 @@ qreal VSpline::GetKasm2() const
* @brief GetKcurve return coefficient of curvature spline. * @brief GetKcurve return coefficient of curvature spline.
* @return coefficient * @return coefficient
*/ */
qreal VSpline::GetKcurve() const auto VSpline::GetKcurve() const -> qreal
{ {
return d->kCurve; return d->kCurve;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
int VSpline::Sign(long double ld) auto VSpline::Sign(long double ld) -> int
{ {
if (qAbs(ld)<0.00000000001) if (qAbs(ld)<0.00000000001)
{ {
@ -481,7 +484,7 @@ int VSpline::Sign(long double ld)
* 1 - 1 real root + 2 complex; * 1 - 1 real root + 2 complex;
* 2 - 1 real root + complex roots imaginary part is zero (i.e. 2 real roots). * 2 - 1 real root + complex roots imaginary part is zero (i.e. 2 real roots).
*/ */
qint32 VSpline::Cubic(QVector<qreal> &x, qreal a, qreal b, qreal c) auto VSpline::Cubic(QVector<qreal> &x, qreal a, qreal b, qreal c) -> qint32
{ {
//To find cubic equation roots in the case of real coefficients, calculated at the beginning //To find cubic equation roots in the case of real coefficients, calculated at the beginning
const qreal q = (pow(a, 2) - 3*b)/9.; const qreal q = (pow(a, 2) - 3*b)/9.;
@ -494,26 +497,25 @@ qint32 VSpline::Cubic(QVector<qreal> &x, qreal a, qreal b, qreal c)
x.insert(2, -2.*sqrt(q)*cos(t - (2*M_2PI/3.)) - a/3.); x.insert(2, -2.*sqrt(q)*cos(t - (2*M_2PI/3.)) - a/3.);
return(3); return(3);
} }
else
{ // 1 real root + 2 complex
//Formula Cardano
const qreal aa = -Sign(r)*pow(fabs(r)+sqrt(pow(r, 2)-pow(q, 3)), 1./3.);
const qreal bb = Sign(aa) == 0 ? 0 : q/aa;
x.insert(0, aa+bb-a/3.); // Real root // 1 real root + 2 complex
x.insert(1, (-0.5)*(aa+bb)-a/3.); //Complex root //Formula Cardano
x.insert(2, (sqrt(3.)*0.5)*fabs(aa-bb)); // Complex root const qreal aa = -Sign(r)*pow(fabs(r)+sqrt(pow(r, 2)-pow(q, 3)), 1./3.);
if (qFuzzyIsNull(x.at(2))) const qreal bb = Sign(aa) == 0 ? 0 : q/aa;
{
return(2); x.insert(0, aa+bb-a/3.); // Real root
} x.insert(1, (-0.5)*(aa+bb)-a/3.); //Complex root
return(1); x.insert(2, (sqrt(3.)*0.5)*fabs(aa-bb)); // Complex root
if (qFuzzyIsNull(x.at(2)))
{
return(2);
} }
return(1);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QVector<qreal> VSpline::CalcT (qreal curveCoord1, qreal curveCoord2, qreal curveCoord3, auto VSpline::CalcT(qreal curveCoord1, qreal curveCoord2, qreal curveCoord3, qreal curveCoord4,
qreal curveCoord4, qreal pointCoord) const qreal pointCoord) -> QVector<qreal>
{ {
const qreal a = -curveCoord1 + 3*curveCoord2 - 3*curveCoord3 + curveCoord4; const qreal a = -curveCoord1 + 3*curveCoord2 - 3*curveCoord3 + curveCoord4;
const qreal b = 3*curveCoord1 - 6*curveCoord2 + 3*curveCoord3; const qreal b = 3*curveCoord1 - 6*curveCoord2 + 3*curveCoord3;
@ -524,11 +526,12 @@ QVector<qreal> VSpline::CalcT (qreal curveCoord1, qreal curveCoord2, qreal curve
Cubic(t, b/a, c/a, d/a); Cubic(t, b/a, c/a, d/a);
QVector<qreal> retT; QVector<qreal> retT;
for (int i=0; i < t.size(); ++i) retT.reserve(t.size());
for (auto i : qAsConst(t))
{ {
if ( t.at(i) >= 0 && t.at(i) <= 1 ) if (i >= 0 && i <= 1 )
{ {
retT.append(t.at(i)); retT.append(i);
} }
} }
@ -544,7 +547,7 @@ QVector<qreal> VSpline::CalcT (qreal curveCoord1, qreal curveCoord2, qreal curve
* @param pBt point on curve * @param pBt point on curve
* @return t coeffient that reprezent this point on curve. Return -1 if point doesn't belongs to curve. * @return t coeffient that reprezent this point on curve. Return -1 if point doesn't belongs to curve.
*/ */
qreal VSpline::ParamT (const QPointF &pBt) const auto VSpline::ParamT (const QPointF &pBt) const -> qreal
{ {
QVector<qreal> ts; QVector<qreal> ts;
// Calculate t coefficient for each axis // Calculate t coefficient for each axis
@ -583,7 +586,7 @@ qreal VSpline::ParamT (const QPointF &pBt) const
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QJsonObject VSpline::ToJson() const auto VSpline::ToJson() const -> QJsonObject
{ {
QJsonObject object = VAbstractCubicBezier::ToJson(); QJsonObject object = VAbstractCubicBezier::ToJson();
object[QLatin1String("aScale")] = GetApproximationScale(); object[QLatin1String("aScale")] = GetApproximationScale();
@ -601,13 +604,13 @@ QJsonObject VSpline::ToJson() const
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QPointF VSpline::GetControlPoint1() const auto VSpline::GetControlPoint1() const -> QPointF
{ {
return static_cast<QPointF>(GetP2 ()); return static_cast<QPointF>(GetP2 ());
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QPointF VSpline::GetControlPoint2() const auto VSpline::GetControlPoint2() const -> QPointF
{ {
return static_cast<QPointF>(GetP3 ()); return static_cast<QPointF>(GetP3 ());
} }

View File

@ -52,81 +52,81 @@ class VSpline final :public VAbstractCubicBezier
{ {
public: public:
VSpline(); VSpline();
VSpline (const VSpline &spline ); VSpline(const VSpline &spline );
VSpline (const VPointF &p1, const VPointF &p4, qreal angle1, qreal angle2, qreal kAsm1, qreal kAsm2, qreal kCurve, VSpline(const VPointF &p1, const VPointF &p4, qreal angle1, qreal angle2, qreal kAsm1, qreal kAsm2, qreal kCurve,
quint32 idObject = 0, Draw mode = Draw::Calculation); quint32 idObject = 0, Draw mode = Draw::Calculation);
VSpline (const VPointF &p1, const QPointF &p2, const QPointF &p3, const VPointF &p4, quint32 idObject = 0, VSpline(const VPointF &p1, const QPointF &p2, const QPointF &p3, const VPointF &p4, quint32 idObject = 0,
Draw mode = Draw::Calculation); Draw mode = Draw::Calculation);
VSpline (const VPointF &p1, const VPointF &p4, qreal angle1, const QString &angle1Formula, qreal angle2, VSpline(const VPointF &p1, const VPointF &p4, qreal angle1, const QString &angle1Formula, qreal angle2,
const QString &angle2Formula, qreal c1Length, const QString &c1LengthFormula, qreal c2Length, const QString &angle2Formula, qreal c1Length, const QString &c1LengthFormula, qreal c2Length,
const QString &c2LengthFormula, quint32 idObject = 0, Draw mode = Draw::Calculation); const QString &c2LengthFormula, quint32 idObject = 0, Draw mode = Draw::Calculation);
VSpline Rotate(const QPointF &originPoint, qreal degrees, const QString &prefix = QString()) const; auto Rotate(const QPointF &originPoint, qreal degrees, const QString &prefix = QString()) const -> VSpline;
VSpline Flip(const QLineF &axis, const QString &prefix = QString()) const; auto Flip(const QLineF &axis, const QString &prefix = QString()) const -> VSpline;
VSpline Move(qreal length, qreal angle, const QString &prefix = QString()) const; auto Move(qreal length, qreal angle, const QString &prefix = QString()) const -> VSpline;
virtual ~VSpline(); ~VSpline() override;
VSpline &operator=(const VSpline &spline); auto operator=(const VSpline &spline) -> VSpline &;
#ifdef Q_COMPILER_RVALUE_REFS #ifdef Q_COMPILER_RVALUE_REFS
VSpline(const VSpline &&spline) Q_DECL_NOTHROW; VSpline(VSpline &&spline) Q_DECL_NOTHROW;
VSpline &operator=(VSpline &&spline) Q_DECL_NOTHROW; auto operator=(VSpline &&spline) Q_DECL_NOTHROW -> VSpline &;
#endif #endif
virtual VPointF GetP1 () const override; auto GetP1() const -> VPointF override;
void SetP1 (const VPointF &p); void SetP1(const VPointF &p);
virtual VPointF GetP2 () const override; auto GetP2() const -> VPointF override;
virtual VPointF GetP3 () const override; auto GetP3() const -> VPointF override;
virtual VPointF GetP4 () const override; auto GetP4() const -> VPointF override;
void SetP4 (const VPointF &p); void SetP4(const VPointF &p);
virtual qreal GetStartAngle () const override; auto GetStartAngle() const -> qreal override;
virtual qreal GetEndAngle() const override; auto GetEndAngle() const -> qreal override;
QString GetStartAngleFormula () const; auto GetStartAngleFormula () const -> QString;
QString GetEndAngleFormula() const; auto GetEndAngleFormula() const -> QString;
void SetStartAngle(qreal angle, const QString &formula); void SetStartAngle(qreal angle, const QString &formula);
void SetEndAngle(qreal angle, const QString &formula); void SetEndAngle(qreal angle, const QString &formula);
virtual qreal GetC1Length() const override; auto GetC1Length() const -> qreal override;
virtual qreal GetC2Length() const override; auto GetC2Length() const -> qreal override;
QString GetC1LengthFormula() const; auto GetC1LengthFormula() const -> QString;
QString GetC2LengthFormula() const; auto GetC2LengthFormula() const -> QString;
void SetC1Length(qreal length, const QString &formula); void SetC1Length(qreal length, const QString &formula);
void SetC2Length(qreal length, const QString &formula); void SetC2Length(qreal length, const QString &formula);
virtual qreal GetLength () const override; auto GetLength() const -> qreal override;
qreal GetKasm1() const; auto GetKasm1() const -> qreal;
qreal GetKasm2() const; auto GetKasm2() const -> qreal;
qreal GetKcurve() const; auto GetKcurve() const -> qreal;
using VAbstractCubicBezier::CutSpline; using VAbstractCubicBezier::CutSpline;
QPointF CutSpline(qreal length, VSpline &spl1, VSpline &spl2, const QString &pointName) const; auto CutSpline(qreal length, VSpline &spl1, VSpline &spl2, const QString &pointName) const -> QPointF;
virtual QVector<QPointF> GetPoints () const override; auto GetPoints() const -> QVector<QPointF> override;
// cppcheck-suppress unusedFunction // cppcheck-suppress unusedFunction
static QVector<QPointF> SplinePoints(const QPointF &p1, const QPointF &p4, qreal angle1, qreal angle2, qreal kAsm1, static auto SplinePoints(const QPointF &p1, const QPointF &p4, qreal angle1, qreal angle2, qreal kAsm1,
qreal kAsm2, qreal kCurve, qreal approximationScale); qreal kAsm2, qreal kCurve, qreal approximationScale) -> QVector<QPointF>;
qreal ParamT(const QPointF &pBt) const; auto ParamT(const QPointF &pBt) const -> qreal;
virtual QJsonObject ToJson() const override; auto ToJson() const -> QJsonObject override;
protected: protected:
virtual QPointF GetControlPoint1() const override; auto GetControlPoint1() const -> QPointF override;
virtual QPointF GetControlPoint2() const override; auto GetControlPoint2() const -> QPointF override;
auto GetRealLength () const -> qreal override; auto GetRealLength() const -> qreal override;
private: private:
QSharedDataPointer<VSplineData> d; QSharedDataPointer<VSplineData> d;
QVector<qreal> CalcT(qreal curveCoord1, qreal curveCoord2, qreal curveCoord3, qreal curveCoord4, static auto CalcT(qreal curveCoord1, qreal curveCoord2, qreal curveCoord3, qreal curveCoord4,
qreal pointCoord) const; qreal pointCoord) -> QVector<qreal>;
static qint32 Cubic(QVector<qreal> &x, qreal a, qreal b, qreal c); static auto Cubic(QVector<qreal> &x, qreal a, qreal b, qreal c) -> qint32;
static int Sign(long double ld); static auto Sign(long double ld) -> int;
}; };
Q_DECLARE_METATYPE(VSpline) Q_DECLARE_METATYPE(VSpline) // NOLINT
Q_DECLARE_TYPEINFO(VSpline, Q_MOVABLE_TYPE); Q_DECLARE_TYPEINFO(VSpline, Q_MOVABLE_TYPE); // NOLINT
#endif // VSPLINE_H #endif // VSPLINE_H

View File

@ -278,7 +278,7 @@ void VToolCutSpline::SetVisualization()
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QString VToolCutSpline::MakeToolTip() const auto VToolCutSpline::MakeToolTip() const -> QString
{ {
const auto spl = VAbstractTool::data.GeometricObject<VAbstractCubicBezier>(baseCurveId); const auto spl = VAbstractTool::data.GeometricObject<VAbstractCubicBezier>(baseCurveId);