Refactoring.

This commit is contained in:
Roman Telezhynskyi 2022-08-13 19:26:55 +03:00
parent 2cf2dc5985
commit 46b2814981
14 changed files with 144 additions and 156 deletions

View File

@ -35,13 +35,7 @@ VAbstractBezier::VAbstractBezier(const GOType &type, const quint32 &idObject, co
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VAbstractBezier::VAbstractBezier(const VAbstractBezier &curve) auto VAbstractBezier::operator=(const VAbstractBezier &curve) -> VAbstractBezier &
: VAbstractCurve(curve)
{
}
//---------------------------------------------------------------------------------------------------------------------
VAbstractBezier &VAbstractBezier::operator=(const VAbstractBezier &curve)
{ {
if ( &curve == this ) if ( &curve == this )
{ {
@ -50,8 +44,3 @@ VAbstractBezier &VAbstractBezier::operator=(const VAbstractBezier &curve)
VAbstractCurve::operator=(curve); VAbstractCurve::operator=(curve);
return *this; return *this;
} }
//---------------------------------------------------------------------------------------------------------------------
VAbstractBezier::~VAbstractBezier()
{
}

View File

@ -36,13 +36,19 @@
class VAbstractBezier : public VAbstractCurve class VAbstractBezier : public VAbstractCurve
{ {
public: public:
VAbstractBezier(const GOType &type, const quint32 &idObject = NULL_ID, const Draw &mode = Draw::Calculation); explicit VAbstractBezier(const GOType &type, const quint32 &idObject = NULL_ID,
VAbstractBezier(const VAbstractBezier &curve); const Draw &mode = Draw::Calculation);
VAbstractBezier& operator= (const VAbstractBezier &curve); VAbstractBezier(const VAbstractBezier &curve) =default;
virtual ~VAbstractBezier(); auto operator= (const VAbstractBezier &curve) -> VAbstractBezier&;
~VAbstractBezier() override =default;
virtual qreal GetC1Length() const =0; #ifdef Q_COMPILER_RVALUE_REFS
virtual qreal GetC2Length() const =0; VAbstractBezier(VAbstractBezier &&curve) Q_DECL_NOTHROW =default;
auto operator=(VAbstractBezier &&curve) Q_DECL_NOTHROW -> VAbstractBezier & =default;
#endif
virtual auto GetC1Length() const -> qreal =0;
virtual auto GetC2Length() const -> qreal =0;
}; };
#endif // VABSTRACTBEZIER_H #endif // VABSTRACTBEZIER_H

View File

@ -386,10 +386,6 @@ auto VAbstractCubicBezier::operator=(const VAbstractCubicBezier &curve) -> VAbst
return *this; return *this;
} }
//---------------------------------------------------------------------------------------------------------------------
VAbstractCubicBezier::~VAbstractCubicBezier()
{}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief CutSpline cut spline. * @brief CutSpline cut spline.
@ -494,20 +490,20 @@ auto VAbstractCubicBezier::CutSpline(qreal length, QPointF &spl1p2, QPointF &spl
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VAbstractCubicBezier::NameForHistory(const QString &toolName) const -> QString auto VAbstractCubicBezier::NameForHistory(const QString &toolName) const -> QString
{ {
QString name = toolName + QString(" %1_%2").arg(GetP1().name(), GetP4().name()); QString name = toolName + QStringLiteral(" %1_%2").arg(GetP1().name(), GetP4().name());
if (GetDuplicate() > 0) if (GetDuplicate() > 0)
{ {
name += QString("_%1").arg(GetDuplicate()); name += QStringLiteral("_%1").arg(GetDuplicate());
} }
QString alias; QString alias;
if (not GetAliasSuffix().isEmpty()) if (not GetAliasSuffix().isEmpty())
{ {
alias = QString("%1 %2").arg(toolName, GetAliasSuffix()); alias = QStringLiteral("%1 %2").arg(toolName, GetAliasSuffix());
} }
return not alias.isEmpty() ? QString("%1 (%2)").arg(alias, name) : name; return not alias.isEmpty() ? QStringLiteral("%1 (%2)").arg(alias, name) : name;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -549,10 +545,10 @@ auto VAbstractCubicBezier::GetParmT(qreal length) const -> qreal
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VAbstractCubicBezier::CreateName() void VAbstractCubicBezier::CreateName()
{ {
QString name = SPL_ + QString("%1_%2").arg(GetP1().name(), GetP4().name()); QString name = SPL_ + QStringLiteral("%1_%2").arg(GetP1().name(), GetP4().name());
if (GetDuplicate() > 0) if (GetDuplicate() > 0)
{ {
name += QString("_%1").arg(GetDuplicate()); name += QStringLiteral("_%1").arg(GetDuplicate());
} }
setName(name); setName(name);

View File

@ -50,7 +50,12 @@ public:
const Draw &mode = Draw::Calculation); const Draw &mode = Draw::Calculation);
VAbstractCubicBezier(const VAbstractCubicBezier &curve) = default; VAbstractCubicBezier(const VAbstractCubicBezier &curve) = default;
auto operator= (const VAbstractCubicBezier &curve) -> VAbstractCubicBezier&; auto operator= (const VAbstractCubicBezier &curve) -> VAbstractCubicBezier&;
~VAbstractCubicBezier() override; ~VAbstractCubicBezier() override = default;
#ifdef Q_COMPILER_RVALUE_REFS
VAbstractCubicBezier(VAbstractCubicBezier &&curve) Q_DECL_NOTHROW =default;
auto operator=(VAbstractCubicBezier &&curve) Q_DECL_NOTHROW -> VAbstractCubicBezier & =default;
#endif
virtual auto GetP1 () const -> VPointF =0; virtual auto GetP1 () const -> VPointF =0;
virtual auto GetP2 () const -> VPointF =0; virtual auto GetP2 () const -> VPointF =0;

View File

@ -45,12 +45,12 @@ VAbstractCurve::VAbstractCurve(const GOType &type, const quint32 &idObject, cons
{} {}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VAbstractCurve::VAbstractCurve(const VAbstractCurve &curve) VAbstractCurve::VAbstractCurve(const VAbstractCurve &curve) // NOLINT(modernize-use-equals-default)
:VGObject(curve), d (curve.d) :VGObject(curve), d (curve.d)
{} {}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VAbstractCurve &VAbstractCurve::operator=(const VAbstractCurve &curve) auto VAbstractCurve::operator=(const VAbstractCurve &curve) -> VAbstractCurve &
{ {
if ( &curve == this ) if ( &curve == this )
{ {
@ -68,7 +68,7 @@ VAbstractCurve::VAbstractCurve(VAbstractCurve &&curve) Q_DECL_NOTHROW
{} {}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VAbstractCurve &VAbstractCurve::operator=(VAbstractCurve &&curve) Q_DECL_NOTHROW auto VAbstractCurve::operator=(VAbstractCurve &&curve) Q_DECL_NOTHROW -> VAbstractCurve &
{ {
VGObject::operator=(curve); VGObject::operator=(curve);
std::swap(d, curve.d); std::swap(d, curve.d);
@ -77,12 +77,12 @@ VAbstractCurve &VAbstractCurve::operator=(VAbstractCurve &&curve) Q_DECL_NOTHROW
#endif #endif
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VAbstractCurve::~VAbstractCurve() VAbstractCurve::~VAbstractCurve() // NOLINT(modernize-use-equals-default)
{} {}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QVector<QPointF> VAbstractCurve::GetSegmentPoints(const QVector<QPointF> &points, const QPointF &begin, auto VAbstractCurve::GetSegmentPoints(const QVector<QPointF> &points, const QPointF &begin, const QPointF &end,
const QPointF &end, bool reverse, QString &error) bool reverse, QString &error) -> QVector<QPointF>
{ {
QVector<QPointF> segment = points; QVector<QPointF> segment = points;
if (reverse) if (reverse)
@ -126,8 +126,8 @@ QVector<QPointF> VAbstractCurve::GetSegmentPoints(const QVector<QPointF> &points
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QVector<QPointF> VAbstractCurve::GetSegmentPoints(const QPointF &begin, const QPointF &end, bool reverse, auto VAbstractCurve::GetSegmentPoints(const QPointF &begin, const QPointF &end, bool reverse,
const QString &piece) const const QString &piece) const -> QVector<QPointF>
{ {
QString error; QString error;
QVector<QPointF> segment = GetSegmentPoints(GetPoints(), begin, end, reverse, error); QVector<QPointF> segment = GetSegmentPoints(GetPoints(), begin, end, reverse, error);
@ -153,7 +153,7 @@ QVector<QPointF> VAbstractCurve::GetSegmentPoints(const QPointF &begin, const QP
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QVector<QPointF> VAbstractCurve::FromBegin(const QVector<QPointF> &points, const QPointF &begin, bool *ok) auto VAbstractCurve::FromBegin(const QVector<QPointF> &points, const QPointF &begin, bool *ok) -> QVector<QPointF>
{ {
if (points.count() >= 2) if (points.count() >= 2)
{ {
@ -205,27 +205,23 @@ QVector<QPointF> VAbstractCurve::FromBegin(const QVector<QPointF> &points, const
} }
return points; return points;
} }
else
{
if (ok != nullptr) if (ok != nullptr)
{ {
*ok = true; *ok = true;
} }
return segment; return segment;
} }
}
else
{
if (ok != nullptr) if (ok != nullptr)
{ {
*ok = false; *ok = false;
} }
return points; return points;
}
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QVector<QPointF> VAbstractCurve::ToEnd(const QVector<QPointF> &points, const QPointF &end, bool *ok) auto VAbstractCurve::ToEnd(const QVector<QPointF> &points, const QPointF &end, bool *ok) -> QVector<QPointF>
{ {
QVector<QPointF> reversed = Reverse(points); QVector<QPointF> reversed = Reverse(points);
reversed = FromBegin(reversed, end, ok); reversed = FromBegin(reversed, end, ok);
@ -233,7 +229,7 @@ QVector<QPointF> VAbstractCurve::ToEnd(const QVector<QPointF> &points, const QPo
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QPainterPath VAbstractCurve::GetPath() const auto VAbstractCurve::GetPath() const -> QPainterPath
{ {
QPainterPath path; QPainterPath path;
@ -250,7 +246,7 @@ QPainterPath VAbstractCurve::GetPath() const
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
qreal VAbstractCurve::GetLengthByPoint(const QPointF &point) const auto VAbstractCurve::GetLengthByPoint(const QPointF &point) const -> qreal
{ {
const QVector<QPointF> points = GetPoints(); const QVector<QPointF> points = GetPoints();
if (points.size() < 2) if (points.size() < 2)
@ -278,31 +274,31 @@ qreal VAbstractCurve::GetLengthByPoint(const QPointF &point) const
* @param line line that intersect with curve * @param line line that intersect with curve
* @return list of intersection points * @return list of intersection points
*/ */
QVector<QPointF> VAbstractCurve::IntersectLine(const QLineF &line) const auto VAbstractCurve::IntersectLine(const QLineF &line) const -> QVector<QPointF>
{ {
return CurveIntersectLine(this->GetPoints(), line); return CurveIntersectLine(this->GetPoints(), line);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VAbstractCurve::IsIntersectLine(const QLineF &line) const auto VAbstractCurve::IsIntersectLine(const QLineF &line) const -> bool
{ {
const QVector<QPointF> points = IntersectLine(line); const QVector<QPointF> points = IntersectLine(line);
return not points.isEmpty(); return not points.isEmpty();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VAbstractCurve::IsPointOnCurve(const QVector<QPointF> &points, const QPointF &p) auto VAbstractCurve::IsPointOnCurve(const QVector<QPointF> &points, const QPointF &p) -> bool
{ {
if (points.isEmpty()) if (points.isEmpty())
{ {
return false; return false;
} }
else if (points.size() < 2)
if (points.size() < 2)
{ {
return points.at(0) == p; return points.at(0) == p;
} }
else
{
for (qint32 i = 0; i < points.count()-1; ++i) for (qint32 i = 0; i < points.count()-1; ++i)
{ {
if (IsPointOnLineSegment(p, points.at(i), points.at(i+1))) if (IsPointOnLineSegment(p, points.at(i), points.at(i+1)))
@ -310,20 +306,19 @@ bool VAbstractCurve::IsPointOnCurve(const QVector<QPointF> &points, const QPoint
return true; return true;
} }
} }
}
return false; return false;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VAbstractCurve::IsPointOnCurve(const QPointF &p) const auto VAbstractCurve::IsPointOnCurve(const QPointF &p) const -> bool
{ {
return IsPointOnCurve(GetPoints(), p); return IsPointOnCurve(GetPoints(), p);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VAbstractCurve::SubdividePath(const QVector<QPointF> &points, QPointF p, QVector<QPointF> &sub1, auto VAbstractCurve::SubdividePath(const QVector<QPointF> &points, QPointF p, QVector<QPointF> &sub1,
QVector<QPointF> &sub2) QVector<QPointF> &sub2) -> bool
{ {
if (points.size() < 2) if (points.size() < 2)
{ {
@ -390,7 +385,7 @@ bool VAbstractCurve::SubdividePath(const QVector<QPointF> &points, QPointF p, QV
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
quint32 VAbstractCurve::GetDuplicate() const auto VAbstractCurve::GetDuplicate() const -> quint32
{ {
return d->duplicate; return d->duplicate;
} }
@ -403,7 +398,7 @@ void VAbstractCurve::SetDuplicate(quint32 number)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QString VAbstractCurve::GetColor() const auto VAbstractCurve::GetColor() const -> QString
{ {
return d->color; return d->color;
} }
@ -415,7 +410,7 @@ void VAbstractCurve::SetColor(const QString &color)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QString VAbstractCurve::GetPenStyle() const auto VAbstractCurve::GetPenStyle() const -> QString
{ {
return d->penStyle; return d->penStyle;
} }
@ -427,7 +422,7 @@ void VAbstractCurve::SetPenStyle(const QString &penStyle)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
qreal VAbstractCurve::GetApproximationScale() const auto VAbstractCurve::GetApproximationScale() const -> qreal
{ {
return d->approximationScale; return d->approximationScale;
} }
@ -439,9 +434,10 @@ void VAbstractCurve::SetApproximationScale(qreal value)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QVector<QPointF> VAbstractCurve::CurveIntersectLine(const QVector<QPointF> &points, const QLineF &line) auto VAbstractCurve::CurveIntersectLine(const QVector<QPointF> &points, const QLineF &line) -> QVector<QPointF>
{ {
QVector<QPointF> intersections; QVector<QPointF> intersections;
intersections.reserve(points.count()-1);
for ( auto i = 0; i < points.count()-1; ++i ) for ( auto i = 0; i < points.count()-1; ++i )
{ {
QPointF crosPoint; QPointF crosPoint;
@ -459,8 +455,8 @@ QVector<QPointF> VAbstractCurve::CurveIntersectLine(const QVector<QPointF> &poin
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VAbstractCurve::CurveIntersectAxis(const QPointF &point, qreal angle, const QVector<QPointF> &curvePoints, auto VAbstractCurve::CurveIntersectAxis(const QPointF &point, qreal angle, const QVector<QPointF> &curvePoints,
QPointF *intersectionPoint) QPointF *intersectionPoint) -> bool
{ {
SCASSERT(intersectionPoint != nullptr) SCASSERT(intersectionPoint != nullptr)
@ -542,7 +538,7 @@ bool VAbstractCurve::CurveIntersectAxis(const QPointF &point, qreal angle, const
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QVector<DirectionArrow> VAbstractCurve::DirectionArrows() const auto VAbstractCurve::DirectionArrows() const -> QVector<DirectionArrow>
{ {
QVector<DirectionArrow> arrows; QVector<DirectionArrow> arrows;
@ -586,7 +582,7 @@ QVector<DirectionArrow> VAbstractCurve::DirectionArrows() const
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QPainterPath VAbstractCurve::ShowDirection(const QVector<DirectionArrow> &arrows, qreal width) auto VAbstractCurve::ShowDirection(const QVector<DirectionArrow> &arrows, qreal width) -> QPainterPath
{ {
QPainterPath path; QPainterPath path;
@ -613,7 +609,7 @@ QPainterPath VAbstractCurve::ShowDirection(const QVector<DirectionArrow> &arrows
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
qreal VAbstractCurve::LengthCurveDirectionArrow() auto VAbstractCurve::LengthCurveDirectionArrow() -> qreal
{ {
return VAbstractApplication::VApp()->Settings()->GetLineWidth() * 8.0; return VAbstractApplication::VApp()->Settings()->GetLineWidth() * 8.0;
} }
@ -626,7 +622,7 @@ void VAbstractCurve::SetAliasSuffix(const QString &aliasSuffix)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
qreal VAbstractCurve::PathLength(const QVector<QPointF> &path) auto VAbstractCurve::PathLength(const QVector<QPointF> &path) -> qreal
{ {
if (path.size() < 2) if (path.size() < 2)
{ {

View File

@ -37,12 +37,10 @@
#include <QVector> #include <QVector>
#include <QtGlobal> #include <QtGlobal>
#include "../ifc/ifcdef.h"
#include "../vmisc/vmath.h"
#include "vgeometrydef.h" #include "vgeometrydef.h"
#include "vgobject.h" #include "vgobject.h"
typedef QPair<QLineF, QLineF> DirectionArrow; using DirectionArrow = QPair<QLineF, QLineF>;
class QPainterPath; class QPainterPath;
class VAbstractCurveData; class VAbstractCurveData;
@ -56,69 +54,69 @@ class VAbstractCurve :public VGObject
public: public:
explicit VAbstractCurve(const GOType &type, const quint32 &idObject = NULL_ID, explicit VAbstractCurve(const GOType &type, const quint32 &idObject = NULL_ID,
const Draw &mode = Draw::Calculation); const Draw &mode = Draw::Calculation);
explicit VAbstractCurve(const VAbstractCurve &curve); VAbstractCurve(const VAbstractCurve &curve);
virtual ~VAbstractCurve() override; ~VAbstractCurve() override;
VAbstractCurve& operator= (const VAbstractCurve &curve); auto operator= (const VAbstractCurve &curve) -> VAbstractCurve&;
#ifdef Q_COMPILER_RVALUE_REFS #ifdef Q_COMPILER_RVALUE_REFS
VAbstractCurve(VAbstractCurve &&curve) Q_DECL_NOTHROW; VAbstractCurve(VAbstractCurve &&curve) Q_DECL_NOTHROW;
VAbstractCurve &operator=(VAbstractCurve &&curve) Q_DECL_NOTHROW; auto operator=(VAbstractCurve &&curve) Q_DECL_NOTHROW -> VAbstractCurve &;
#endif #endif
virtual QVector<QPointF> GetPoints() const =0; virtual auto GetPoints() const -> QVector<QPointF> =0;
static QVector<QPointF> GetSegmentPoints(const QVector<QPointF> &points, const QPointF &begin, const QPointF &end, static auto GetSegmentPoints(const QVector<QPointF> &points, const QPointF &begin, const QPointF &end,
bool reverse, QString &error); bool reverse, QString &error) -> QVector<QPointF>;
QVector<QPointF> GetSegmentPoints(const QPointF &begin, const QPointF &end, bool reverse, auto GetSegmentPoints(const QPointF &begin, const QPointF &end, bool reverse,
const QString &piece = QString()) const; const QString &piece = QString()) const -> QVector<QPointF>;
virtual QPainterPath GetPath() const; virtual auto GetPath() const -> QPainterPath;
virtual qreal GetLength() const =0; virtual auto GetLength() const -> qreal =0;
qreal GetLengthByPoint(const QPointF &point) const; auto GetLengthByPoint(const QPointF &point) const -> qreal;
virtual QVector<QPointF> IntersectLine(const QLineF &line) const; virtual auto IntersectLine(const QLineF &line) const -> QVector<QPointF>;
virtual bool IsIntersectLine(const QLineF &line) const; virtual auto IsIntersectLine(const QLineF &line) const -> bool;
static bool IsPointOnCurve(const QVector<QPointF> &points, const QPointF &p); static auto IsPointOnCurve(const QVector<QPointF> &points, const QPointF &p) -> bool;
bool IsPointOnCurve(const QPointF &p) const; auto IsPointOnCurve(const QPointF &p) const -> bool;
static bool SubdividePath(const QVector<QPointF> &points, QPointF p, QVector<QPointF> &sub1, static auto SubdividePath(const QVector<QPointF> &points, QPointF p, QVector<QPointF> &sub1,
QVector<QPointF> &sub2); QVector<QPointF> &sub2) -> bool;
virtual qreal GetStartAngle () const=0; virtual auto GetStartAngle () const -> qreal=0;
virtual qreal GetEndAngle () const=0; virtual auto GetEndAngle () const -> qreal=0;
quint32 GetDuplicate() const; auto GetDuplicate() const -> quint32;
void SetDuplicate(quint32 number); void SetDuplicate(quint32 number);
QString GetColor() const; auto GetColor() const -> QString;
void SetColor(const QString &color); void SetColor(const QString &color);
QString GetPenStyle() const; auto GetPenStyle() const -> QString;
void SetPenStyle(const QString &penStyle); void SetPenStyle(const QString &penStyle);
qreal GetApproximationScale() const; auto GetApproximationScale() const -> qreal;
void SetApproximationScale(qreal value); void SetApproximationScale(qreal value);
static qreal PathLength(const QVector<QPointF> &path); static auto PathLength(const QVector<QPointF> &path) -> qreal;
static QVector<QPointF> CurveIntersectLine(const QVector<QPointF> &points, const QLineF &line); static auto CurveIntersectLine(const QVector<QPointF> &points, const QLineF &line) -> QVector<QPointF>;
static bool CurveIntersectAxis(const QPointF &point, qreal angle, const QVector<QPointF> &curvePoints, static auto CurveIntersectAxis(const QPointF &point, qreal angle, const QVector<QPointF> &curvePoints,
QPointF *intersectionPoint); QPointF *intersectionPoint) -> bool;
virtual QString NameForHistory(const QString &toolName) const=0; virtual auto NameForHistory(const QString &toolName) const -> QString=0;
virtual QVector<DirectionArrow> DirectionArrows() const; virtual auto DirectionArrows() const -> QVector<DirectionArrow>;
static QPainterPath ShowDirection(const QVector<DirectionArrow> &arrows, qreal width); static auto ShowDirection(const QVector<DirectionArrow> &arrows, qreal width) -> QPainterPath;
static qreal LengthCurveDirectionArrow(); static auto LengthCurveDirectionArrow() -> qreal;
virtual void SetAliasSuffix(const QString &aliasSuffix) override; void SetAliasSuffix(const QString &aliasSuffix) override;
protected: protected:
virtual void CreateName() =0; virtual void CreateName() =0;
virtual void CreateAlias() =0; virtual void CreateAlias() =0;
private: private:
QSharedDataPointer<VAbstractCurveData> d; QSharedDataPointer<VAbstractCurveData> d;
static QVector<QPointF> FromBegin(const QVector<QPointF> &points, const QPointF &begin, bool *ok = nullptr); static auto FromBegin(const QVector<QPointF> &points, const QPointF &begin, bool *ok = nullptr) -> QVector<QPointF>;
static QVector<QPointF> ToEnd(const QVector<QPointF> &points, const QPointF &end, bool *ok = nullptr); static auto ToEnd(const QVector<QPointF> &points, const QPointF &end, bool *ok = nullptr) -> QVector<QPointF>;
}; };
QT_WARNING_POP QT_WARNING_POP

View File

@ -37,9 +37,9 @@
#include <QTypeInfo> #include <QTypeInfo>
#include <QVector> #include <QVector>
#include <QtGlobal> #include <QtGlobal>
#include <QtMath>
#include "vabstractarc.h" #include "vabstractarc.h"
#include "vgeometrydef.h"
#include "vpointf.h" #include "vpointf.h"
class VEllipticalArcData; class VEllipticalArcData;

View File

@ -49,7 +49,7 @@ 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) // NOLINT(modernize-use-equals-default)
: VAbstractCubicBezier(spline), : VAbstractCubicBezier(spline),
d(spline.d) d(spline.d)
{} {}

View File

@ -40,7 +40,6 @@
#include <QtGlobal> #include <QtGlobal>
#include "vabstractcubicbezier.h" #include "vabstractcubicbezier.h"
#include "vgeometrydef.h"
#include "vpointf.h" #include "vpointf.h"
class VSplineData; class VSplineData;
@ -52,7 +51,7 @@ 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,

View File

@ -46,6 +46,7 @@
#include <QJsonObject> #include <QJsonObject>
#include <QJsonArray> #include <QJsonArray>
#include <QJsonDocument> #include <QJsonDocument>
#include <QtMath>
const quint32 VAbstractPieceData::streamHeader = 0x05CDD73A; // CRC-32Q string "VAbstractPieceData" const quint32 VAbstractPieceData::streamHeader = 0x05CDD73A; // CRC-32Q string "VAbstractPieceData"
const quint16 VAbstractPieceData::classVersion = 3; const quint16 VAbstractPieceData::classVersion = 3;

View File

@ -56,8 +56,8 @@
template <class T> class QSharedPointer; template <class T> class QSharedPointer;
const QString VToolCutSpline::ToolType = QStringLiteral("cutSpline"); const QString VToolCutSpline::ToolType = QStringLiteral("cutSpline"); // NOLINT(cert-err58-cpp)
const QString VToolCutSpline::AttrSpline = QStringLiteral("spline"); const QString VToolCutSpline::AttrSpline = QStringLiteral("spline"); // NOLINT(cert-err58-cpp)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
@ -97,8 +97,8 @@ void VToolCutSpline::setDialog()
* @param doc dom document container. * @param doc dom document container.
* @param data container with variables. * @param data container with variables.
*/ */
VToolCutSpline* VToolCutSpline::Create(const QPointer<DialogTool> &dialog, VMainGraphicsScene *scene, auto VToolCutSpline::Create(const QPointer<DialogTool> &dialog, VMainGraphicsScene *scene, VAbstractPattern *doc,
VAbstractPattern *doc, VContainer *data) VContainer *data) -> VToolCutSpline*
{ {
SCASSERT(not dialog.isNull()) SCASSERT(not dialog.isNull())
const QPointer<DialogCutSpline> dialogTool = qobject_cast<DialogCutSpline *>(dialog); const QPointer<DialogCutSpline> dialogTool = qobject_cast<DialogCutSpline *>(dialog);
@ -130,12 +130,12 @@ VToolCutSpline* VToolCutSpline::Create(const QPointer<DialogTool> &dialog, VMain
* @brief Create help create tool. * @brief Create help create tool.
* @param initData init data. * @param initData init data.
*/ */
VToolCutSpline* VToolCutSpline::Create(VToolCutInitData &initData) auto VToolCutSpline::Create(VToolCutInitData &initData) -> VToolCutSpline*
{ {
const auto spl = initData.data->GeometricObject<VAbstractCubicBezier>(initData.baseCurveId); const auto spl = initData.data->GeometricObject<VAbstractCubicBezier>(initData.baseCurveId);
//Declare special variable "CurrentLength" //Declare special variable "CurrentLength"
VCurveLength *length = new VCurveLength(initData.baseCurveId, initData.baseCurveId, spl.data(), auto *length = new VCurveLength(initData.baseCurveId, initData.baseCurveId, spl.data(),
*initData.data->GetPatternUnit()); *initData.data->GetPatternUnit());
length->SetName(currentLength); length->SetName(currentLength);
initData.data->AddVariable(length); initData.data->AddVariable(length);
@ -146,7 +146,7 @@ VToolCutSpline* VToolCutSpline::Create(VToolCutInitData &initData)
QPointF point = spl->CutSpline(VAbstractValApplication::VApp()->toPixel(result), spl1p2, spl1p3, spl2p2, spl2p3, QPointF point = spl->CutSpline(VAbstractValApplication::VApp()->toPixel(result), spl1p2, spl1p3, spl2p2, spl2p3,
initData.name); initData.name);
VPointF *p = new VPointF(point, initData.name, initData.mx, initData.my); auto *p = new VPointF(point, initData.name, initData.mx, initData.my);
p->SetShowLabel(initData.showLabel); p->SetShowLabel(initData.showLabel);
auto spline1 = QSharedPointer<VAbstractBezier>(new VSpline(spl->GetP1(), spl1p2, spl1p3, *p)); auto spline1 = QSharedPointer<VAbstractBezier>(new VSpline(spl->GetP1(), spl1p2, spl1p3, *p));
@ -257,8 +257,8 @@ void VToolCutSpline::ReadToolAttributes(const QDomElement &domElement)
{ {
VToolCut::ReadToolAttributes(domElement); VToolCut::ReadToolAttributes(domElement);
formula = doc->GetParametrString(domElement, AttrLength, QString()); formula = VDomDocument::GetParametrString(domElement, AttrLength, QString());
baseCurveId = doc->GetParametrUInt(domElement, AttrSpline, NULL_ID_STR); baseCurveId = VDomDocument::GetParametrUInt(domElement, AttrSpline, NULL_ID_STR);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -266,7 +266,7 @@ void VToolCutSpline::SetVisualization()
{ {
if (not vis.isNull()) if (not vis.isNull())
{ {
VisToolCutSpline *visual = qobject_cast<VisToolCutSpline *>(vis); auto *visual = qobject_cast<VisToolCutSpline *>(vis);
SCASSERT(visual != nullptr) SCASSERT(visual != nullptr)
visual->setObject1Id(baseCurveId); visual->setObject1Id(baseCurveId);
@ -310,13 +310,13 @@ auto VToolCutSpline::MakeToolTip() const -> QString
"<tr> <td><b>%8:</b> %9</td> </tr>" "<tr> <td><b>%8:</b> %9</td> </tr>"
"<tr> <td><b>%4:</b> %5 %3</td> </tr>" "<tr> <td><b>%4:</b> %5 %3</td> </tr>"
"</table>") "</table>")
.arg(curveStr + QLatin1String("1 ") + lengthStr) .arg(curveStr + QStringLiteral("1 ") + lengthStr)
.arg(VAbstractValApplication::VApp()->fromPixel(spline1.GetLength())) .arg(VAbstractValApplication::VApp()->fromPixel(spline1.GetLength()))
.arg(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true), .arg(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true),
curveStr + QLatin1String("2 ") + lengthStr) curveStr + QStringLiteral("2 ") + lengthStr)
.arg(VAbstractValApplication::VApp()->fromPixel(spline2.GetLength())) .arg(VAbstractValApplication::VApp()->fromPixel(spline2.GetLength()))
.arg(curveStr + QLatin1String(" 1") + tr("label"), spline1.ObjectName(), .arg(curveStr + QStringLiteral(" 1") + tr("label"), spline1.ObjectName(),
curveStr + QLatin1String(" 2") + tr("label"), spline2.ObjectName()); curveStr + QStringLiteral(" 2") + tr("label"), spline2.ObjectName());
return toolTip; return toolTip;
} }

View File

@ -50,24 +50,24 @@ class VToolCutSpline : public VToolCut
{ {
Q_OBJECT // NOLINT Q_OBJECT // NOLINT
public: public:
virtual void setDialog() override; ~VToolCutSpline() override =default;
static VToolCutSpline *Create(const QPointer<DialogTool> &dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, void setDialog() override;
VContainer *data); static auto Create(const QPointer<DialogTool> &dialog, VMainGraphicsScene *scene, VAbstractPattern *doc,
static VToolCutSpline *Create(VToolCutInitData &initData); VContainer *data) -> VToolCutSpline *;
static auto Create(VToolCutInitData &initData) -> VToolCutSpline *;
static const QString ToolType; static const QString ToolType;
static const QString AttrSpline; static const QString AttrSpline;
virtual int type() const override {return Type;} auto type() const -> int override {return Type;}
enum { Type = UserType + static_cast<int>(Tool::CutSpline)}; enum { Type = UserType + static_cast<int>(Tool::CutSpline)};
virtual void ShowVisualization(bool show) override; void ShowVisualization(bool show) override;
protected slots: protected slots:
virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id=NULL_ID) override; void ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id=NULL_ID) override;
protected: protected:
virtual void SaveDialog(QDomElement &domElement, QList<quint32> &oldDependencies, void SaveDialog(QDomElement &domElement, QList<quint32> &oldDependencies, QList<quint32> &newDependencies) override;
QList<quint32> &newDependencies) override; void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) override;
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) override; void ReadToolAttributes(const QDomElement &domElement) override;
virtual void ReadToolAttributes(const QDomElement &domElement) override; void SetVisualization() override;
virtual void SetVisualization() override; auto MakeToolTip() const -> QString override;
virtual QString MakeToolTip() const override;
private: private:
Q_DISABLE_COPY_MOVE(VToolCutSpline) // NOLINT Q_DISABLE_COPY_MOVE(VToolCutSpline) // NOLINT

View File

@ -33,16 +33,14 @@
#include <QSharedPointer> #include <QSharedPointer>
#include <Qt> #include <Qt>
#include <new> #include <new>
#include <QtMath>
#include "../ifc/ifcdef.h"
#include "../vgeometry/vabstractcurve.h" #include "../vgeometry/vabstractcurve.h"
#include "../vgeometry/varc.h" #include "../vgeometry/varc.h"
#include "../vgeometry/vpointf.h" #include "../vgeometry/vpointf.h"
#include "../vpatterndb/vcontainer.h" #include "../vpatterndb/vcontainer.h"
#include "../visualization.h" #include "../visualization.h"
#include "def.h" #include "def.h"
#include "qglobal.h"
#include "qmudef.h"
#include "qnamespace.h" #include "qnamespace.h"
#include "vgeometrydef.h" #include "vgeometrydef.h"
#include "vispath.h" #include "vispath.h"

View File

@ -33,8 +33,8 @@
#include <QSharedPointer> #include <QSharedPointer>
#include <Qt> #include <Qt>
#include <new> #include <new>
#include <QtMath>
#include "../ifc/ifcdef.h"
#include "../vgeometry/vabstractcurve.h" #include "../vgeometry/vabstractcurve.h"
#include "../vgeometry/varc.h" #include "../vgeometry/varc.h"
#include "../vgeometry/vpointf.h" #include "../vgeometry/vpointf.h"