Refactoring.
This commit is contained in:
parent
576e3bbbf2
commit
05d064af1e
|
@ -53,10 +53,6 @@ const quint16 VAbstractPieceData::classVersion = 3;
|
||||||
|
|
||||||
const qreal maxL = 3.5;
|
const qreal maxL = 3.5;
|
||||||
|
|
||||||
const qreal VSAPoint::passmarkFactor = 0.5;
|
|
||||||
const qreal VSAPoint::maxPassmarkLength = MmToPixel(10.);
|
|
||||||
const qreal VSAPoint::minSAWidth = accuracyPointOnLine + accuracyPointOnLine*0.5;
|
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -1658,45 +1654,6 @@ auto VAbstractPiece::GetUniqueID() const -> QString
|
||||||
return d->m_uuid.toString();
|
return d->m_uuid.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
auto VSAPoint::GetSABefore(qreal width) const -> qreal
|
|
||||||
{
|
|
||||||
if (m_before < 0)
|
|
||||||
{
|
|
||||||
return width;
|
|
||||||
}
|
|
||||||
return qMax(m_before, minSAWidth);
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
auto VSAPoint::GetSAAfter(qreal width) const -> qreal
|
|
||||||
{
|
|
||||||
if (m_after < 0)
|
|
||||||
{
|
|
||||||
return width;
|
|
||||||
}
|
|
||||||
return qMax(m_after, minSAWidth);
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
auto VSAPoint::MaxLocalSA(qreal width) const -> qreal
|
|
||||||
{
|
|
||||||
return qMax(GetSAAfter(width), GetSABefore(width));
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
auto VSAPoint::PassmarkLength(qreal width) const -> qreal
|
|
||||||
{
|
|
||||||
if (not m_manualPassmarkLength)
|
|
||||||
{
|
|
||||||
qreal passmarkLength = MaxLocalSA(width) * passmarkFactor;
|
|
||||||
passmarkLength = qMin(passmarkLength, maxPassmarkLength);
|
|
||||||
return passmarkLength;
|
|
||||||
}
|
|
||||||
|
|
||||||
return m_passmarkLength;
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
auto VSAPoint::toJson() const -> QJsonObject
|
auto VSAPoint::toJson() const -> QJsonObject
|
||||||
{
|
{
|
||||||
|
|
|
@ -28,11 +28,14 @@
|
||||||
#ifndef VSAPOINT_H
|
#ifndef VSAPOINT_H
|
||||||
#define VSAPOINT_H
|
#define VSAPOINT_H
|
||||||
|
|
||||||
|
#include <QtGlobal>
|
||||||
|
#include <QMetaType>
|
||||||
|
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
|
#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
|
||||||
#include "../vmisc/diagnostic.h"
|
#include "../vmisc/diagnostic.h"
|
||||||
#endif // QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
|
#endif // QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
|
||||||
#include "../vmisc/def.h"
|
#include "../vmisc/def.h"
|
||||||
#include "../ifc/ifcdef.h"
|
#include "../vgeometry/vgeometrydef.h"
|
||||||
|
|
||||||
#include <QPointF>
|
#include <QPointF>
|
||||||
|
|
||||||
|
@ -46,35 +49,40 @@ QT_WARNING_DISABLE_GCC("-Wnon-virtual-dtor")
|
||||||
class VSAPoint : public QPointF
|
class VSAPoint : public QPointF
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Q_DECL_CONSTEXPR VSAPoint() V_NOEXCEPT_EXPR (true);
|
QT_WARNING_PUSH
|
||||||
|
QT_WARNING_DISABLE_GCC("-Wnoexcept")
|
||||||
|
|
||||||
|
Q_DECL_CONSTEXPR VSAPoint() = default;
|
||||||
|
|
||||||
|
QT_WARNING_POP
|
||||||
|
|
||||||
Q_DECL_CONSTEXPR VSAPoint(qreal xpos, qreal ypos);
|
Q_DECL_CONSTEXPR VSAPoint(qreal xpos, qreal ypos);
|
||||||
Q_DECL_CONSTEXPR explicit VSAPoint(QPointF p);
|
Q_DECL_CONSTEXPR explicit VSAPoint(QPointF p);
|
||||||
|
|
||||||
Q_DECL_CONSTEXPR qreal GetSABefore() const;
|
Q_DECL_CONSTEXPR auto GetSABefore() const -> qreal;
|
||||||
qreal GetSABefore(qreal width) const;
|
Q_DECL_CONSTEXPR auto GetSAAfter() const -> qreal;
|
||||||
void SetSABefore(qreal value);
|
Q_DECL_CONSTEXPR auto GetAngleType() const -> PieceNodeAngle;
|
||||||
|
Q_DECL_CONSTEXPR auto IsManualPasskmarkLength() const -> bool;
|
||||||
|
Q_DECL_CONSTEXPR auto GetPasskmarkLength() const -> qreal;
|
||||||
|
|
||||||
Q_DECL_CONSTEXPR qreal GetSAAfter() const;
|
Q_DECL_RELAXED_CONSTEXPR auto GetSABefore(qreal width) const -> qreal;
|
||||||
qreal GetSAAfter(qreal width) const;
|
Q_DECL_RELAXED_CONSTEXPR auto GetSAAfter(qreal width) const -> qreal;
|
||||||
void SetSAAfter(qreal value);
|
|
||||||
|
|
||||||
Q_DECL_CONSTEXPR PieceNodeAngle GetAngleType() const;
|
Q_DECL_RELAXED_CONSTEXPR void SetSABefore(qreal value);
|
||||||
void SetAngleType(PieceNodeAngle value);
|
Q_DECL_RELAXED_CONSTEXPR void SetSAAfter(qreal value);
|
||||||
|
|
||||||
Q_DECL_CONSTEXPR bool IsManualPasskmarkLength() const;
|
Q_DECL_RELAXED_CONSTEXPR void SetAngleType(PieceNodeAngle value);
|
||||||
Q_DECL_RELAXED_CONSTEXPR void SetManualPasskmarkLength(bool value);
|
Q_DECL_RELAXED_CONSTEXPR void SetManualPasskmarkLength(bool value);
|
||||||
|
Q_DECL_RELAXED_CONSTEXPR void SetPasskmarkLength(qreal value);
|
||||||
|
|
||||||
Q_DECL_CONSTEXPR qreal GetPasskmarkLength() const;
|
Q_DECL_RELAXED_CONSTEXPR auto MaxLocalSA(qreal width) const -> qreal;
|
||||||
Q_DECL_RELAXED_CONSTEXPR void SetPasskmarkLength(qreal value);
|
Q_DECL_RELAXED_CONSTEXPR auto PassmarkLength(qreal width) const -> qreal;
|
||||||
|
|
||||||
qreal MaxLocalSA(qreal width) const;
|
auto toJson() const -> QJsonObject;
|
||||||
qreal PassmarkLength(qreal width) const;
|
|
||||||
|
|
||||||
QJsonObject toJson() const;
|
static constexpr qreal passmarkFactor{0.5};
|
||||||
|
static constexpr qreal maxPassmarkLength{MmToPixel(10.)};
|
||||||
static const qreal passmarkFactor;
|
static constexpr qreal minSAWidth{accuracyPointOnLine + accuracyPointOnLine*0.5};
|
||||||
static const qreal maxPassmarkLength;
|
|
||||||
static const qreal minSAWidth;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
qreal m_before{-1};
|
qreal m_before{-1};
|
||||||
|
@ -84,13 +92,9 @@ private:
|
||||||
qreal m_passmarkLength{0};
|
qreal m_passmarkLength{0};
|
||||||
};
|
};
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(VSAPoint)
|
Q_DECLARE_METATYPE(VSAPoint) // NOLINT
|
||||||
Q_DECLARE_TYPEINFO(VSAPoint, Q_MOVABLE_TYPE); // NOLINT
|
Q_DECLARE_TYPEINFO(VSAPoint, Q_MOVABLE_TYPE); // NOLINT
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
Q_DECL_CONSTEXPR inline VSAPoint::VSAPoint() V_NOEXCEPT_EXPR (true)
|
|
||||||
{}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
Q_DECL_CONSTEXPR inline VSAPoint::VSAPoint(qreal xpos, qreal ypos)
|
Q_DECL_CONSTEXPR inline VSAPoint::VSAPoint(qreal xpos, qreal ypos)
|
||||||
: QPointF(xpos, ypos)
|
: QPointF(xpos, ypos)
|
||||||
|
@ -102,43 +106,63 @@ Q_DECL_CONSTEXPR inline VSAPoint::VSAPoint(QPointF p)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
Q_DECL_CONSTEXPR inline qreal VSAPoint::GetSABefore() const
|
Q_DECL_CONSTEXPR inline auto VSAPoint::GetSABefore() const -> qreal
|
||||||
{
|
{
|
||||||
return m_before;
|
return m_before;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
inline void VSAPoint::SetSABefore(qreal value)
|
Q_DECL_RELAXED_CONSTEXPR inline auto VSAPoint::GetSABefore(qreal width) const -> qreal
|
||||||
|
{
|
||||||
|
if (m_before < 0)
|
||||||
|
{
|
||||||
|
return width;
|
||||||
|
}
|
||||||
|
return qMax(m_before, minSAWidth);
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
Q_DECL_RELAXED_CONSTEXPR inline void VSAPoint::SetSABefore(qreal value)
|
||||||
{
|
{
|
||||||
value < 0 ? m_before = -1 : m_before = value;
|
value < 0 ? m_before = -1 : m_before = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
Q_DECL_CONSTEXPR inline qreal VSAPoint::GetSAAfter() const
|
Q_DECL_CONSTEXPR inline auto VSAPoint::GetSAAfter() const -> qreal
|
||||||
{
|
{
|
||||||
return m_after;
|
return m_after;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
inline void VSAPoint::SetSAAfter(qreal value)
|
Q_DECL_RELAXED_CONSTEXPR inline auto VSAPoint::GetSAAfter(qreal width) const -> qreal
|
||||||
|
{
|
||||||
|
if (m_after < 0)
|
||||||
|
{
|
||||||
|
return width;
|
||||||
|
}
|
||||||
|
return qMax(m_after, minSAWidth);
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
Q_DECL_RELAXED_CONSTEXPR inline void VSAPoint::SetSAAfter(qreal value)
|
||||||
{
|
{
|
||||||
value < 0 ? m_after = -1 : m_after = value;
|
value < 0 ? m_after = -1 : m_after = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
Q_DECL_CONSTEXPR inline PieceNodeAngle VSAPoint::GetAngleType() const
|
Q_DECL_CONSTEXPR inline auto VSAPoint::GetAngleType() const -> PieceNodeAngle
|
||||||
{
|
{
|
||||||
return m_angle;
|
return m_angle;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
inline void VSAPoint::SetAngleType(PieceNodeAngle value)
|
Q_DECL_RELAXED_CONSTEXPR inline void VSAPoint::SetAngleType(PieceNodeAngle value)
|
||||||
{
|
{
|
||||||
m_angle = value;
|
m_angle = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
Q_DECL_CONSTEXPR inline bool VSAPoint::IsManualPasskmarkLength() const
|
Q_DECL_CONSTEXPR inline auto VSAPoint::IsManualPasskmarkLength() const -> bool
|
||||||
{
|
{
|
||||||
return m_manualPassmarkLength;
|
return m_manualPassmarkLength;
|
||||||
}
|
}
|
||||||
|
@ -150,7 +174,7 @@ Q_DECL_RELAXED_CONSTEXPR inline void VSAPoint::SetManualPasskmarkLength(bool val
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
Q_DECL_CONSTEXPR inline qreal VSAPoint::GetPasskmarkLength() const
|
Q_DECL_CONSTEXPR inline auto VSAPoint::GetPasskmarkLength() const -> qreal
|
||||||
{
|
{
|
||||||
return m_passmarkLength;
|
return m_passmarkLength;
|
||||||
}
|
}
|
||||||
|
@ -161,6 +185,25 @@ Q_DECL_RELAXED_CONSTEXPR inline void VSAPoint::SetPasskmarkLength(qreal value)
|
||||||
m_passmarkLength = value;
|
m_passmarkLength = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
Q_DECL_RELAXED_CONSTEXPR inline auto VSAPoint::MaxLocalSA(qreal width) const -> qreal
|
||||||
|
{
|
||||||
|
return qMax(GetSAAfter(width), GetSABefore(width));
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
Q_DECL_RELAXED_CONSTEXPR inline auto VSAPoint::PassmarkLength(qreal width) const -> qreal
|
||||||
|
{
|
||||||
|
if (not m_manualPassmarkLength)
|
||||||
|
{
|
||||||
|
qreal passmarkLength = MaxLocalSA(width) * passmarkFactor;
|
||||||
|
passmarkLength = qMin(passmarkLength, maxPassmarkLength);
|
||||||
|
return passmarkLength;
|
||||||
|
}
|
||||||
|
|
||||||
|
return m_passmarkLength;
|
||||||
|
}
|
||||||
|
|
||||||
QT_WARNING_POP
|
QT_WARNING_POP
|
||||||
|
|
||||||
#endif // VSAPOINT_H
|
#endif // VSAPOINT_H
|
||||||
|
|
|
@ -1110,6 +1110,9 @@ VPassmark VPiece::CreatePassmark(const QVector<VPieceNode> &path, int previousIn
|
||||||
return VPassmark();
|
return VPassmark();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QT_WARNING_PUSH
|
||||||
|
QT_WARNING_DISABLE_GCC("-Wnoexcept")
|
||||||
|
|
||||||
VPiecePassmarkData passmarkData;
|
VPiecePassmarkData passmarkData;
|
||||||
passmarkData.previousSAPoint = previousSAPoint;
|
passmarkData.previousSAPoint = previousSAPoint;
|
||||||
passmarkData.passmarkSAPoint = passmarkSAPoint;
|
passmarkData.passmarkSAPoint = passmarkSAPoint;
|
||||||
|
@ -1125,6 +1128,8 @@ VPassmark VPiece::CreatePassmark(const QVector<VPieceNode> &path, int previousIn
|
||||||
passmarkData.id = path.at(passmarkIndex).GetId();
|
passmarkData.id = path.at(passmarkIndex).GetId();
|
||||||
passmarkData.globalPassmarkLength = ToPixel(GlobalPassmarkLength(data), *data->GetPatternUnit());
|
passmarkData.globalPassmarkLength = ToPixel(GlobalPassmarkLength(data), *data->GetPatternUnit());
|
||||||
|
|
||||||
|
QT_WARNING_POP
|
||||||
|
|
||||||
return VPassmark(passmarkData);
|
return VPassmark(passmarkData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,9 +30,6 @@
|
||||||
#include "../vpatterndb/vcontainer.h"
|
#include "../vpatterndb/vcontainer.h"
|
||||||
#include "../vpatterndb/vpiece.h"
|
#include "../vpatterndb/vpiece.h"
|
||||||
#include "../vpatterndb/vpassmark.h"
|
#include "../vpatterndb/vpassmark.h"
|
||||||
#include "../vpatterndb/vpiecenode.h"
|
|
||||||
#include "../vpatterndb/vpiecepath.h"
|
|
||||||
#include "../vgeometry/vsplinepath.h"
|
|
||||||
#include "../vmisc/vabstractvalapplication.h"
|
#include "../vmisc/vabstractvalapplication.h"
|
||||||
|
|
||||||
#include <QtTest>
|
#include <QtTest>
|
||||||
|
@ -75,6 +72,9 @@ void TST_VPiece::TestSAPassmark_data()
|
||||||
auto ASSERT_TEST_CASE = [this](const char *title, const QString &passmarkData, const QString &seamAllowance,
|
auto ASSERT_TEST_CASE = [this](const char *title, const QString &passmarkData, const QString &seamAllowance,
|
||||||
const QString &shape)
|
const QString &shape)
|
||||||
{
|
{
|
||||||
|
QT_WARNING_PUSH
|
||||||
|
QT_WARNING_DISABLE_GCC("-Wnoexcept")
|
||||||
|
|
||||||
VPiecePassmarkData inputPassmarkData;
|
VPiecePassmarkData inputPassmarkData;
|
||||||
AbstractTest::PassmarkDataFromJson(passmarkData, inputPassmarkData);
|
AbstractTest::PassmarkDataFromJson(passmarkData, inputPassmarkData);
|
||||||
|
|
||||||
|
@ -85,6 +85,8 @@ void TST_VPiece::TestSAPassmark_data()
|
||||||
AbstractTest::PassmarkShapeFromJson(shape, inputOutputShape);
|
AbstractTest::PassmarkShapeFromJson(shape, inputOutputShape);
|
||||||
|
|
||||||
QTest::newRow(title) << inputPassmarkData << inputSeamAllowance << inputOutputShape;
|
QTest::newRow(title) << inputPassmarkData << inputSeamAllowance << inputOutputShape;
|
||||||
|
|
||||||
|
QT_WARNING_POP
|
||||||
};
|
};
|
||||||
|
|
||||||
// See file src/app/share/collection/bugs/Issue_#924.val
|
// See file src/app/share/collection/bugs/Issue_#924.val
|
||||||
|
|
Loading…
Reference in New Issue
Block a user