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)
: VAbstractCurve(curve)
{
}
//---------------------------------------------------------------------------------------------------------------------
VAbstractBezier &VAbstractBezier::operator=(const VAbstractBezier &curve)
auto VAbstractBezier::operator=(const VAbstractBezier &curve) -> VAbstractBezier &
{
if ( &curve == this )
{
@ -50,8 +44,3 @@ VAbstractBezier &VAbstractBezier::operator=(const VAbstractBezier &curve)
VAbstractCurve::operator=(curve);
return *this;
}
//---------------------------------------------------------------------------------------------------------------------
VAbstractBezier::~VAbstractBezier()
{
}

View File

@ -36,13 +36,19 @@
class VAbstractBezier : public VAbstractCurve
{
public:
VAbstractBezier(const GOType &type, const quint32 &idObject = NULL_ID, const Draw &mode = Draw::Calculation);
VAbstractBezier(const VAbstractBezier &curve);
VAbstractBezier& operator= (const VAbstractBezier &curve);
virtual ~VAbstractBezier();
explicit VAbstractBezier(const GOType &type, const quint32 &idObject = NULL_ID,
const Draw &mode = Draw::Calculation);
VAbstractBezier(const VAbstractBezier &curve) =default;
auto operator= (const VAbstractBezier &curve) -> VAbstractBezier&;
~VAbstractBezier() override =default;
virtual qreal GetC1Length() const =0;
virtual qreal GetC2Length() const =0;
#ifdef Q_COMPILER_RVALUE_REFS
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

View File

@ -386,10 +386,6 @@ auto VAbstractCubicBezier::operator=(const VAbstractCubicBezier &curve) -> VAbst
return *this;
}
//---------------------------------------------------------------------------------------------------------------------
VAbstractCubicBezier::~VAbstractCubicBezier()
{}
//---------------------------------------------------------------------------------------------------------------------
/**
* @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
{
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)
{
name += QString("_%1").arg(GetDuplicate());
name += QStringLiteral("_%1").arg(GetDuplicate());
}
QString alias;
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()
{
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)
{
name += QString("_%1").arg(GetDuplicate());
name += QStringLiteral("_%1").arg(GetDuplicate());
}
setName(name);

View File

@ -50,7 +50,12 @@ public:
const Draw &mode = Draw::Calculation);
VAbstractCubicBezier(const VAbstractCubicBezier &curve) = default;
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 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)
{}
//---------------------------------------------------------------------------------------------------------------------
VAbstractCurve &VAbstractCurve::operator=(const VAbstractCurve &curve)
auto VAbstractCurve::operator=(const VAbstractCurve &curve) -> VAbstractCurve &
{
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);
std::swap(d, curve.d);
@ -77,12 +77,12 @@ VAbstractCurve &VAbstractCurve::operator=(VAbstractCurve &&curve) Q_DECL_NOTHROW
#endif
//---------------------------------------------------------------------------------------------------------------------
VAbstractCurve::~VAbstractCurve()
VAbstractCurve::~VAbstractCurve() // NOLINT(modernize-use-equals-default)
{}
//---------------------------------------------------------------------------------------------------------------------
QVector<QPointF> VAbstractCurve::GetSegmentPoints(const QVector<QPointF> &points, const QPointF &begin,
const QPointF &end, bool reverse, QString &error)
auto VAbstractCurve::GetSegmentPoints(const QVector<QPointF> &points, const QPointF &begin, const QPointF &end,
bool reverse, QString &error) -> QVector<QPointF>
{
QVector<QPointF> segment = points;
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,
const QString &piece) const
auto VAbstractCurve::GetSegmentPoints(const QPointF &begin, const QPointF &end, bool reverse,
const QString &piece) const -> QVector<QPointF>
{
QString 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)
{
@ -205,27 +205,23 @@ QVector<QPointF> VAbstractCurve::FromBegin(const QVector<QPointF> &points, const
}
return points;
}
else
{
if (ok != nullptr)
{
*ok = true;
}
return segment;
}
}
else
{
if (ok != nullptr)
{
*ok = false;
*ok = true;
}
return points;
return segment;
}
if (ok != nullptr)
{
*ok = false;
}
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);
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;
@ -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();
if (points.size() < 2)
@ -278,37 +274,36 @@ qreal VAbstractCurve::GetLengthByPoint(const QPointF &point) const
* @param line line that intersect with curve
* @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);
}
//---------------------------------------------------------------------------------------------------------------------
bool VAbstractCurve::IsIntersectLine(const QLineF &line) const
auto VAbstractCurve::IsIntersectLine(const QLineF &line) const -> bool
{
const QVector<QPointF> points = IntersectLine(line);
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())
{
return false;
}
else if (points.size() < 2)
if (points.size() < 2)
{
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)))
{
return true;
}
return true;
}
}
@ -316,14 +311,14 @@ bool VAbstractCurve::IsPointOnCurve(const QVector<QPointF> &points, const QPoint
}
//---------------------------------------------------------------------------------------------------------------------
bool VAbstractCurve::IsPointOnCurve(const QPointF &p) const
auto VAbstractCurve::IsPointOnCurve(const QPointF &p) const -> bool
{
return IsPointOnCurve(GetPoints(), p);
}
//---------------------------------------------------------------------------------------------------------------------
bool VAbstractCurve::SubdividePath(const QVector<QPointF> &points, QPointF p, QVector<QPointF> &sub1,
QVector<QPointF> &sub2)
auto VAbstractCurve::SubdividePath(const QVector<QPointF> &points, QPointF p, QVector<QPointF> &sub1,
QVector<QPointF> &sub2) -> bool
{
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;
}
@ -403,7 +398,7 @@ void VAbstractCurve::SetDuplicate(quint32 number)
}
//---------------------------------------------------------------------------------------------------------------------
QString VAbstractCurve::GetColor() const
auto VAbstractCurve::GetColor() const -> QString
{
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;
}
@ -427,7 +422,7 @@ void VAbstractCurve::SetPenStyle(const QString &penStyle)
}
//---------------------------------------------------------------------------------------------------------------------
qreal VAbstractCurve::GetApproximationScale() const
auto VAbstractCurve::GetApproximationScale() const -> qreal
{
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;
intersections.reserve(points.count()-1);
for ( auto i = 0; i < points.count()-1; ++i )
{
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,
QPointF *intersectionPoint)
auto VAbstractCurve::CurveIntersectAxis(const QPointF &point, qreal angle, const QVector<QPointF> &curvePoints,
QPointF *intersectionPoint) -> bool
{
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;
@ -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;
@ -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;
}
@ -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)
{

View File

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

View File

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

View File

@ -49,7 +49,7 @@ VSpline::VSpline()
* @brief VSpline constructor.
* @param spline spline from which the copy.
*/
VSpline::VSpline(const VSpline &spline)
VSpline::VSpline(const VSpline &spline) // NOLINT(modernize-use-equals-default)
: VAbstractCubicBezier(spline),
d(spline.d)
{}

View File

@ -40,7 +40,6 @@
#include <QtGlobal>
#include "vabstractcubicbezier.h"
#include "vgeometrydef.h"
#include "vpointf.h"
class VSplineData;
@ -52,7 +51,7 @@ class VSpline final :public VAbstractCubicBezier
{
public:
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,
quint32 idObject = 0, Draw mode = Draw::Calculation);
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 <QJsonArray>
#include <QJsonDocument>
#include <QtMath>
const quint32 VAbstractPieceData::streamHeader = 0x05CDD73A; // CRC-32Q string "VAbstractPieceData"
const quint16 VAbstractPieceData::classVersion = 3;

View File

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

View File

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

View File

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

View File

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