Refactoring.
This commit is contained in:
parent
bd10a78f55
commit
6c0863ca62
|
@ -67,7 +67,7 @@
|
|||
namespace
|
||||
{
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QVector<VLayoutPiecePath> ConvertInternalPaths(const VPiece &piece, const VContainer *pattern)
|
||||
auto ConvertInternalPaths(const VPiece &piece, const VContainer *pattern) -> QVector<VLayoutPiecePath>
|
||||
{
|
||||
SCASSERT(pattern != nullptr)
|
||||
|
||||
|
@ -90,8 +90,8 @@ QVector<VLayoutPiecePath> ConvertInternalPaths(const VPiece &piece, const VConta
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
bool FindLabelGeometry(const VPatternLabelData &labelData, const VContainer *pattern, qreal &rotationAngle,
|
||||
qreal &labelWidth, qreal &labelHeight, QPointF &pos)
|
||||
auto FindLabelGeometry(const VPatternLabelData &labelData, const VContainer *pattern, qreal &rotationAngle,
|
||||
qreal &labelWidth, qreal &labelHeight, QPointF &pos) -> bool
|
||||
{
|
||||
SCASSERT(pattern != nullptr)
|
||||
|
||||
|
@ -176,7 +176,7 @@ bool FindLabelGeometry(const VPatternLabelData &labelData, const VContainer *pat
|
|||
* @param dAng angle of rotation
|
||||
* @return position of point pt after rotating it around the center for dAng radians
|
||||
*/
|
||||
QPointF RotatePoint(const QPointF &ptCenter, const QPointF& pt, qreal dAng)
|
||||
auto RotatePoint(const QPointF &ptCenter, const QPointF& pt, qreal dAng) -> QPointF
|
||||
{
|
||||
QPointF ptDest;
|
||||
QPointF ptRel = pt - ptCenter;
|
||||
|
@ -187,7 +187,7 @@ QPointF RotatePoint(const QPointF &ptCenter, const QPointF& pt, qreal dAng)
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QStringList PieceLabelText(const QVector<QPointF> &labelShape, const VTextManager &tm)
|
||||
auto PieceLabelText(const QVector<QPointF> &labelShape, const VTextManager &tm) -> QStringList
|
||||
{
|
||||
QStringList text;
|
||||
if (labelShape.count() > 2)
|
||||
|
@ -203,7 +203,7 @@ QStringList PieceLabelText(const QVector<QPointF> &labelShape, const VTextManage
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QVector<VLayoutPlaceLabel> ConvertPlaceLabels(const VPiece &piece, const VContainer *pattern)
|
||||
auto ConvertPlaceLabels(const VPiece &piece, const VContainer *pattern) -> QVector<VLayoutPlaceLabel>
|
||||
{
|
||||
QVector<VLayoutPlaceLabel> labels;
|
||||
const auto placeLabels = piece.GetPlaceLabels();
|
||||
|
@ -226,17 +226,8 @@ QVector<VLayoutPlaceLabel> ConvertPlaceLabels(const VPiece &piece, const VContai
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QVector<VLayoutPassmark> ConvertPassmarks(const VPiece &piece, const VContainer *pattern)
|
||||
{
|
||||
const QVector<VPassmark> passmarks = piece.Passmarks(pattern);
|
||||
QVector<VLayoutPassmark> layoutPassmarks;
|
||||
for(const auto &passmark : passmarks)
|
||||
{
|
||||
if (not passmark.IsNull())
|
||||
{
|
||||
VPiecePassmarkData pData = passmark.Data();
|
||||
|
||||
auto PreapreBuiltInSAPassmark = [pData, passmark, piece, &layoutPassmarks, pattern]()
|
||||
auto PrepareSAPassmark(const VPiece &piece, const VContainer *pattern, const VPassmark &passmark,
|
||||
PassmarkSide side, bool &ok) -> VLayoutPassmark
|
||||
{
|
||||
QT_WARNING_PUSH
|
||||
QT_WARNING_DISABLE_GCC("-Wnoexcept")
|
||||
|
@ -246,68 +237,21 @@ QVector<VLayoutPassmark> ConvertPassmarks(const VPiece &piece, const VContainer
|
|||
|
||||
QT_WARNING_POP
|
||||
|
||||
VPiecePassmarkData pData = passmark.Data();
|
||||
const QVector<VPieceNode> path = piece.GetUnitedPath(pattern);
|
||||
const int nodeIndex = VPiecePath::indexOfNode(path, pData.id);
|
||||
if (nodeIndex != -1)
|
||||
{
|
||||
const QVector<QLineF> lines = passmark.BuiltInSAPassmark(piece, pattern);
|
||||
if (lines.isEmpty())
|
||||
{
|
||||
const QString errorMsg =
|
||||
QObject::tr("Cannot prepare builtin passmark '%1' for piece '%2'. Passmark is empty.")
|
||||
.arg(pData.nodeName, piece.GetName());
|
||||
VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) :
|
||||
qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
|
||||
return;
|
||||
}
|
||||
|
||||
layoutPassmark.lines = lines;
|
||||
|
||||
const QVector<QLineF> baseLines = passmark.BuiltInSAPassmarkBaseLine(piece);
|
||||
if (baseLines.isEmpty())
|
||||
{
|
||||
const QString errorMsg =
|
||||
QObject::tr("Cannot prepare builtin passmark '%1' for piece '%2'. Passmark base line is "
|
||||
"empty.")
|
||||
.arg(pData.nodeName, piece.GetName());
|
||||
VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) :
|
||||
qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
|
||||
return;
|
||||
}
|
||||
layoutPassmark.baseLine = ConstFirst (baseLines);
|
||||
|
||||
|
||||
layoutPassmark.type = pData.passmarkLineType;
|
||||
layoutPassmark.isBuiltIn = true;
|
||||
|
||||
layoutPassmarks.append(layoutPassmark);
|
||||
}
|
||||
else
|
||||
if (nodeIndex == -1)
|
||||
{
|
||||
const QString errorMsg =
|
||||
QObject::tr("Passmark '%1' is not part of piece '%2'.")
|
||||
.arg(pData.nodeName, piece.GetName());
|
||||
VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) :
|
||||
qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
|
||||
ok = false;
|
||||
return {};
|
||||
}
|
||||
};
|
||||
|
||||
auto PrepareSAPassmark = [pData, passmark, piece, &layoutPassmarks, pattern](PassmarkSide side)
|
||||
{
|
||||
QT_WARNING_PUSH
|
||||
QT_WARNING_DISABLE_GCC("-Wnoexcept")
|
||||
// noexcept-expression evaluates to 'false' because of a call to 'constexpr QPointF::QPointF()'
|
||||
|
||||
VLayoutPassmark layoutPassmark;
|
||||
|
||||
QT_WARNING_POP
|
||||
|
||||
const QVector<VPieceNode> path = piece.GetUnitedPath(pattern);
|
||||
const int nodeIndex = VPiecePath::indexOfNode(path, pData.id);
|
||||
if (nodeIndex != -1)
|
||||
{
|
||||
QVector<QLineF> baseLines =
|
||||
passmark.SAPassmarkBaseLine(piece, pattern, static_cast<PassmarkSide>(side));
|
||||
QVector<QLineF> baseLines = passmark.SAPassmarkBaseLine(piece, pattern, static_cast<PassmarkSide>(side));
|
||||
if (baseLines.isEmpty())
|
||||
{
|
||||
const QString errorMsg =
|
||||
|
@ -315,7 +259,8 @@ QVector<VLayoutPassmark> ConvertPassmarks(const VPiece &piece, const VContainer
|
|||
.arg(pData.nodeName, piece.GetName());
|
||||
VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) :
|
||||
qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
|
||||
return;
|
||||
ok = false;
|
||||
return {};
|
||||
}
|
||||
|
||||
if (side == PassmarkSide::All || side == PassmarkSide::Right)
|
||||
|
@ -335,55 +280,142 @@ QVector<VLayoutPassmark> ConvertPassmarks(const VPiece &piece, const VContainer
|
|||
.arg(pData.nodeName, piece.GetName());
|
||||
VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) :
|
||||
qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
|
||||
return;
|
||||
ok = false;
|
||||
return {};
|
||||
}
|
||||
|
||||
layoutPassmark.lines = lines;
|
||||
layoutPassmark.type = pData.passmarkLineType;
|
||||
layoutPassmark.isBuiltIn = false;
|
||||
|
||||
layoutPassmarks.append(layoutPassmark);
|
||||
ok = true;
|
||||
return layoutPassmark;
|
||||
}
|
||||
else
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
auto PreapreBuiltInSAPassmark(const VPiece &piece, const VContainer *pattern, const VPassmark &passmark,
|
||||
bool &ok) -> VLayoutPassmark
|
||||
{
|
||||
QT_WARNING_PUSH
|
||||
QT_WARNING_DISABLE_GCC("-Wnoexcept")
|
||||
// noexcept-expression evaluates to 'false' because of a call to 'constexpr QPointF::QPointF()'
|
||||
|
||||
VLayoutPassmark layoutPassmark;
|
||||
|
||||
QT_WARNING_POP
|
||||
|
||||
VPiecePassmarkData pData = passmark.Data();
|
||||
const QVector<VPieceNode> path = piece.GetUnitedPath(pattern);
|
||||
const int nodeIndex = VPiecePath::indexOfNode(path, pData.id);
|
||||
if (nodeIndex == -1)
|
||||
{
|
||||
const QString errorMsg =
|
||||
QObject::tr("Passmark '%1' is not part of piece '%2'.")
|
||||
.arg(pData.nodeName, piece.GetName());
|
||||
VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) :
|
||||
qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
|
||||
ok = false;
|
||||
return {};
|
||||
}
|
||||
|
||||
const QVector<QLineF> lines = passmark.BuiltInSAPassmark(piece, pattern);
|
||||
if (lines.isEmpty())
|
||||
{
|
||||
const QString errorMsg =
|
||||
QObject::tr("Cannot prepare builtin passmark '%1' for piece '%2'. Passmark is empty.")
|
||||
.arg(pData.nodeName, piece.GetName());
|
||||
VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) :
|
||||
qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
|
||||
ok = false;
|
||||
return {};
|
||||
}
|
||||
|
||||
layoutPassmark.lines = lines;
|
||||
|
||||
const QVector<QLineF> baseLines = passmark.BuiltInSAPassmarkBaseLine(piece);
|
||||
if (baseLines.isEmpty())
|
||||
{
|
||||
const QString errorMsg =
|
||||
QObject::tr("Cannot prepare builtin passmark '%1' for piece '%2'. Passmark base line is "
|
||||
"empty.")
|
||||
.arg(pData.nodeName, piece.GetName());
|
||||
VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) :
|
||||
qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
|
||||
ok = false;
|
||||
return {};
|
||||
}
|
||||
|
||||
layoutPassmark.baseLine = ConstFirst (baseLines);
|
||||
layoutPassmark.type = pData.passmarkLineType;
|
||||
layoutPassmark.isBuiltIn = true;
|
||||
|
||||
ok = true;
|
||||
return layoutPassmark;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
auto ConvertPassmarks(const VPiece &piece, const VContainer *pattern) -> QVector<VLayoutPassmark>
|
||||
{
|
||||
const QVector<VPassmark> passmarks = piece.Passmarks(pattern);
|
||||
QVector<VLayoutPassmark> layoutPassmarks;
|
||||
layoutPassmarks.reserve(passmarks.size());
|
||||
|
||||
for(const auto &passmark : passmarks)
|
||||
{
|
||||
if (passmark.IsNull())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
auto AddPassmark = [passmark, piece, pattern, &layoutPassmarks](PassmarkSide side)
|
||||
{
|
||||
bool ok = false;
|
||||
VLayoutPassmark layoutPassmark = PrepareSAPassmark(piece, pattern, passmark, side, ok);
|
||||
if (ok)
|
||||
{
|
||||
layoutPassmarks.append(layoutPassmark);
|
||||
}
|
||||
};
|
||||
|
||||
if (not piece.IsSeamAllowanceBuiltIn())
|
||||
auto AddBuiltInPassmark = [passmark, piece, pattern, &layoutPassmarks]()
|
||||
{
|
||||
if (pData.passmarkAngleType == PassmarkAngleType::Straightforward
|
||||
|| pData.passmarkAngleType == PassmarkAngleType::Bisector)
|
||||
bool ok = false;
|
||||
VLayoutPassmark layoutPassmark = PreapreBuiltInSAPassmark(piece, pattern, passmark, ok);
|
||||
if (ok)
|
||||
{
|
||||
PrepareSAPassmark(PassmarkSide::All);
|
||||
layoutPassmarks.append(layoutPassmark);
|
||||
}
|
||||
else if (pData.passmarkAngleType == PassmarkAngleType::Intersection
|
||||
|| pData.passmarkAngleType == PassmarkAngleType::IntersectionOnlyLeft
|
||||
|| pData.passmarkAngleType == PassmarkAngleType::IntersectionOnlyRight
|
||||
|| pData.passmarkAngleType == PassmarkAngleType::Intersection2
|
||||
|| pData.passmarkAngleType == PassmarkAngleType::Intersection2OnlyLeft
|
||||
|| pData.passmarkAngleType == PassmarkAngleType::Intersection2OnlyRight)
|
||||
};
|
||||
|
||||
if (piece.IsSeamAllowanceBuiltIn())
|
||||
{
|
||||
if (pData.passmarkAngleType == PassmarkAngleType::Intersection ||
|
||||
pData.passmarkAngleType == PassmarkAngleType::Intersection2)
|
||||
{
|
||||
PrepareSAPassmark(PassmarkSide::Left);
|
||||
PrepareSAPassmark(PassmarkSide::Right);
|
||||
AddBuiltInPassmark();
|
||||
continue;
|
||||
}
|
||||
else if (pData.passmarkAngleType == PassmarkAngleType::IntersectionOnlyLeft ||
|
||||
pData.passmarkAngleType == PassmarkAngleType::Intersection2OnlyLeft)
|
||||
|
||||
VPiecePassmarkData pData = passmark.Data();
|
||||
|
||||
switch(pData.passmarkAngleType)
|
||||
{
|
||||
PrepareSAPassmark(PassmarkSide::Left);
|
||||
}
|
||||
else if (pData.passmarkAngleType == PassmarkAngleType::IntersectionOnlyRight ||
|
||||
pData.passmarkAngleType == PassmarkAngleType::Intersection2OnlyRight)
|
||||
{
|
||||
PrepareSAPassmark(PassmarkSide::Right);
|
||||
}
|
||||
case PassmarkAngleType::Straightforward:
|
||||
case PassmarkAngleType::Bisector:
|
||||
AddPassmark(PassmarkSide::All);
|
||||
break;
|
||||
case PassmarkAngleType::Intersection:
|
||||
case PassmarkAngleType::Intersection2:
|
||||
AddPassmark(PassmarkSide::Left);
|
||||
AddPassmark(PassmarkSide::Right);
|
||||
break;
|
||||
case PassmarkAngleType::IntersectionOnlyLeft:
|
||||
case PassmarkAngleType::Intersection2OnlyLeft:
|
||||
AddPassmark(PassmarkSide::Left);
|
||||
break;
|
||||
case PassmarkAngleType::IntersectionOnlyRight:
|
||||
case PassmarkAngleType::Intersection2OnlyRight:
|
||||
AddPassmark(PassmarkSide::Right);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (VAbstractApplication::VApp()->Settings()->IsDoublePassmark()
|
||||
|
@ -398,13 +430,7 @@ QVector<VLayoutPassmark> ConvertPassmarks(const VPiece &piece, const VContainer
|
|||
&& pData.passmarkAngleType != PassmarkAngleType::Intersection2OnlyRight
|
||||
&& pData.isShowSecondPassmark)
|
||||
{
|
||||
PreapreBuiltInSAPassmark();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
PreapreBuiltInSAPassmark();
|
||||
}
|
||||
AddBuiltInPassmark();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -509,16 +535,16 @@ auto PrepareGradationId(const QString &label, const VContainer *pattern) -> QStr
|
|||
|
||||
// Friend functions
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QDataStream &operator<<(QDataStream &dataStream, const VLayoutPoint &p)
|
||||
auto operator<<(QDataStream &dataStream, const VLayoutPoint &p) -> QDataStream &
|
||||
{
|
||||
dataStream << static_cast<QPointF>(p);
|
||||
dataStream << static_cast<QPointF>(p); // NOLINT(cppcoreguidelines-slicing)
|
||||
dataStream << p.TurnPoint();
|
||||
dataStream << p.CurvePoint();
|
||||
return dataStream;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QDataStream &operator>>(QDataStream &dataStream, VLayoutPoint &p)
|
||||
auto operator>>(QDataStream &dataStream, VLayoutPoint &p) -> QDataStream &
|
||||
{
|
||||
QPointF tmp;
|
||||
bool turnPointFlag = false;
|
||||
|
@ -535,15 +561,15 @@ QDataStream &operator>>(QDataStream &dataStream, VLayoutPoint &p)
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QDataStream &operator<<(QDataStream &dataStream, const VLayoutPiece &piece)
|
||||
auto operator<<(QDataStream &dataStream, const VLayoutPiece &piece) -> QDataStream &
|
||||
{
|
||||
dataStream << static_cast<VAbstractPiece>(piece);
|
||||
dataStream << static_cast<VAbstractPiece>(piece); // NOLINT(cppcoreguidelines-slicing)
|
||||
dataStream << *piece.d;
|
||||
return dataStream;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QDataStream &operator>>(QDataStream &dataStream, VLayoutPiece &piece)
|
||||
auto operator>>(QDataStream &dataStream, VLayoutPiece &piece) -> QDataStream &
|
||||
{
|
||||
dataStream >> static_cast<VAbstractPiece &>(piece);
|
||||
dataStream >> *piece.d;
|
||||
|
@ -552,16 +578,16 @@ QDataStream &operator>>(QDataStream &dataStream, VLayoutPiece &piece)
|
|||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VLayoutPiece::VLayoutPiece()
|
||||
:VAbstractPiece(), d(new VLayoutPieceData)
|
||||
:d(new VLayoutPieceData)
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VLayoutPiece::VLayoutPiece(const VLayoutPiece &detail)
|
||||
VLayoutPiece::VLayoutPiece(const VLayoutPiece &detail) // NOLINT(modernize-use-equals-default)
|
||||
:VAbstractPiece(detail), d(detail.d)
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VLayoutPiece &VLayoutPiece::operator=(const VLayoutPiece &detail)
|
||||
auto VLayoutPiece::operator=(const VLayoutPiece &detail) -> VLayoutPiece &
|
||||
{
|
||||
if ( &detail == this )
|
||||
{
|
||||
|
@ -579,7 +605,7 @@ VLayoutPiece::VLayoutPiece(VLayoutPiece &&detail) Q_DECL_NOTHROW
|
|||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VLayoutPiece &VLayoutPiece::operator=(VLayoutPiece &&detail) Q_DECL_NOTHROW
|
||||
auto VLayoutPiece::operator=(VLayoutPiece &&detail) Q_DECL_NOTHROW -> VLayoutPiece &
|
||||
{
|
||||
VAbstractPiece::operator=(detail);
|
||||
std::swap(d, detail.d);
|
||||
|
@ -588,11 +614,11 @@ VLayoutPiece &VLayoutPiece::operator=(VLayoutPiece &&detail) Q_DECL_NOTHROW
|
|||
#endif
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VLayoutPiece::~VLayoutPiece()
|
||||
VLayoutPiece::~VLayoutPiece() //NOLINT(modernize-use-equals-default)
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VLayoutPiece VLayoutPiece::Create(const VPiece &piece, vidtype id, const VContainer *pattern)
|
||||
auto VLayoutPiece::Create(const VPiece &piece, vidtype id, const VContainer *pattern) -> VLayoutPiece
|
||||
{
|
||||
QFuture<QVector<VLayoutPoint> > futureSeamAllowance = QtConcurrent::run(piece, &VPiece::SeamAllowancePoints,
|
||||
pattern);
|
||||
|
@ -689,13 +715,13 @@ auto VLayoutPiece::Map(QVector<T> points) const -> QVector<T>
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
template <>
|
||||
QVector<VLayoutPassmark> VLayoutPiece::Map<VLayoutPassmark>(QVector<VLayoutPassmark> passmarks) const
|
||||
template <> // NOLINTNEXTLINE(readability-inconsistent-declaration-parameter-name)
|
||||
auto VLayoutPiece::Map<VLayoutPassmark>(QVector<VLayoutPassmark> passmarks) const -> QVector<VLayoutPassmark>
|
||||
{
|
||||
for (int i = 0; i < passmarks.size(); ++i)
|
||||
for (auto & passmark : passmarks)
|
||||
{
|
||||
passmarks[i].lines = Map(passmarks.at(i).lines);
|
||||
passmarks[i].baseLine = d->m_matrix.map(passmarks.at(i).baseLine);
|
||||
passmark.lines = Map(passmark.lines);
|
||||
passmark.baseLine = d->m_matrix.map(passmark.baseLine);
|
||||
}
|
||||
|
||||
return passmarks;
|
||||
|
@ -703,11 +729,11 @@ QVector<VLayoutPassmark> VLayoutPiece::Map<VLayoutPassmark>(QVector<VLayoutPassm
|
|||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
template <>
|
||||
QVector<VLayoutPoint> VLayoutPiece::Map<VLayoutPoint>(QVector<VLayoutPoint> points) const
|
||||
auto VLayoutPiece::Map<VLayoutPoint>(QVector<VLayoutPoint> points) const -> QVector<VLayoutPoint>
|
||||
{
|
||||
std::transform(points.begin(), points.end(), points.begin(), [this](VLayoutPoint point)
|
||||
{
|
||||
auto p = static_cast<QPointF>(point);
|
||||
auto p = static_cast<QPointF>(point); // NOLINT(cppcoreguidelines-slicing)
|
||||
p = d->m_matrix.map(p);
|
||||
point.rx() = p.x();
|
||||
point.ry() = p.y();
|
||||
|
@ -722,13 +748,13 @@ QVector<VLayoutPoint> VLayoutPiece::Map<VLayoutPoint>(QVector<VLayoutPoint> poin
|
|||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
// cppcheck-suppress unusedFunction
|
||||
QVector<VLayoutPoint> VLayoutPiece::GetMappedContourPoints() const
|
||||
auto VLayoutPiece::GetMappedContourPoints() const -> QVector<VLayoutPoint>
|
||||
{
|
||||
return Map(d->m_contour);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QVector<VLayoutPoint> VLayoutPiece::GetContourPoints() const
|
||||
auto VLayoutPiece::GetContourPoints() const -> QVector<VLayoutPoint>
|
||||
{
|
||||
return d->m_contour;
|
||||
}
|
||||
|
@ -742,13 +768,13 @@ void VLayoutPiece::SetCountourPoints(const QVector<VLayoutPoint> &points, bool h
|
|||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
// cppcheck-suppress unusedFunction
|
||||
QVector<VLayoutPoint> VLayoutPiece::GetMappedSeamAllowancePoints() const
|
||||
auto VLayoutPiece::GetMappedSeamAllowancePoints() const -> QVector<VLayoutPoint>
|
||||
{
|
||||
return Map(d->m_seamAllowance);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QVector<VLayoutPoint> VLayoutPiece::GetSeamAllowancePoints() const
|
||||
auto VLayoutPiece::GetSeamAllowancePoints() const -> QVector<VLayoutPoint>
|
||||
{
|
||||
return d->m_seamAllowance;
|
||||
}
|
||||
|
@ -775,32 +801,30 @@ void VLayoutPiece::SetSeamAllowancePoints(const QVector<VLayoutPoint> &points, b
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QVector<QPointF> VLayoutPiece::GetMappedLayoutAllowancePoints() const
|
||||
auto VLayoutPiece::GetMappedLayoutAllowancePoints() const -> QVector<QPointF>
|
||||
{
|
||||
return Map(d->m_layoutAllowance);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QVector<QPointF> VLayoutPiece::GetLayoutAllowancePoints() const
|
||||
auto VLayoutPiece::GetLayoutAllowancePoints() const -> QVector<QPointF>
|
||||
{
|
||||
return d->m_layoutAllowance;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QPointF VLayoutPiece::GetPieceTextPosition() const
|
||||
auto VLayoutPiece::GetPieceTextPosition() const -> QPointF
|
||||
{
|
||||
if (d->m_detailLabel.count() > 2)
|
||||
{
|
||||
return d->m_matrix.map(ConstFirst(d->m_detailLabel));
|
||||
}
|
||||
else
|
||||
{
|
||||
return QPointF();
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QStringList VLayoutPiece::GetPieceText() const
|
||||
auto VLayoutPiece::GetPieceText() const -> QStringList
|
||||
{
|
||||
return PieceLabelText(d->m_detailLabel, d->m_tmDetail);
|
||||
}
|
||||
|
@ -869,20 +893,18 @@ void VLayoutPiece::SetPieceLabelData(const VTextManager &data)
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QPointF VLayoutPiece::GetPatternTextPosition() const
|
||||
auto VLayoutPiece::GetPatternTextPosition() const -> QPointF
|
||||
{
|
||||
if (d->m_patternInfo.count() > 2)
|
||||
{
|
||||
return d->m_matrix.map(ConstFirst(d->m_patternInfo));
|
||||
}
|
||||
else
|
||||
{
|
||||
return QPointF();
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QStringList VLayoutPiece::GetPatternText() const
|
||||
auto VLayoutPiece::GetPatternText() const -> QStringList
|
||||
{
|
||||
return PieceLabelText(d->m_patternInfo, d->m_tmPattern);
|
||||
}
|
||||
|
@ -970,19 +992,19 @@ void VLayoutPiece::SetGrainline(const VGrainlineData& geom, const VContainer* pa
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QVector<QPointF> VLayoutPiece::GetMappedGrainline() const
|
||||
auto VLayoutPiece::GetMappedGrainline() const -> QVector<QPointF>
|
||||
{
|
||||
return Map(d->m_grainlinePoints);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QVector<QPointF> VLayoutPiece::GetGrainline() const
|
||||
auto VLayoutPiece::GetGrainline() const -> QVector<QPointF>
|
||||
{
|
||||
return d->m_grainlinePoints;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
bool VLayoutPiece::IsGrainlineEnabled() const
|
||||
auto VLayoutPiece::IsGrainlineEnabled() const -> bool
|
||||
{
|
||||
return d->m_grainlineEnabled;
|
||||
}
|
||||
|
@ -1012,19 +1034,19 @@ void VLayoutPiece::SetGrainlinePoints(const QVector<QPointF> &points)
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
qreal VLayoutPiece::GrainlineAngle() const
|
||||
auto VLayoutPiece::GrainlineAngle() const -> qreal
|
||||
{
|
||||
return d->m_grainlineAngle;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
GrainlineArrowDirection VLayoutPiece::GrainlineArrowType() const
|
||||
auto VLayoutPiece::GrainlineArrowType() const -> GrainlineArrowDirection
|
||||
{
|
||||
return d->m_grainlineArrowType;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QTransform VLayoutPiece::GetMatrix() const
|
||||
auto VLayoutPiece::GetMatrix() const -> QTransform
|
||||
{
|
||||
return d->m_matrix;
|
||||
}
|
||||
|
@ -1036,7 +1058,7 @@ void VLayoutPiece::SetMatrix(const QTransform &matrix)
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
qreal VLayoutPiece::GetLayoutWidth() const
|
||||
auto VLayoutPiece::GetLayoutWidth() const -> qreal
|
||||
{
|
||||
return d->m_layoutWidth;
|
||||
}
|
||||
|
@ -1048,7 +1070,7 @@ void VLayoutPiece::SetLayoutWidth(qreal value)
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
quint16 VLayoutPiece::GetQuantity() const
|
||||
auto VLayoutPiece::GetQuantity() const -> quint16
|
||||
{
|
||||
return d->m_quantity;
|
||||
}
|
||||
|
@ -1060,7 +1082,7 @@ void VLayoutPiece::SetQuantity(quint16 value)
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
vidtype VLayoutPiece::GetId() const
|
||||
auto VLayoutPiece::GetId() const -> vidtype
|
||||
{
|
||||
return d->m_id;
|
||||
}
|
||||
|
@ -1149,77 +1171,67 @@ void VLayoutPiece::Mirror()
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
int VLayoutPiece::DetailEdgesCount() const
|
||||
auto VLayoutPiece::DetailEdgesCount() const -> int
|
||||
{
|
||||
return DetailPath().count();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
int VLayoutPiece::LayoutEdgesCount() const
|
||||
auto VLayoutPiece::LayoutEdgesCount() const -> int
|
||||
{
|
||||
const int count = d->m_layoutAllowance.count();
|
||||
return count > 2 ? count : 0;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QLineF VLayoutPiece::LayoutEdge(int i) const
|
||||
auto VLayoutPiece::LayoutEdge(int i) const -> QLineF
|
||||
{
|
||||
return Edge(d->m_layoutAllowance, i);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
int VLayoutPiece::LayoutEdgeByPoint(const QPointF &p1) const
|
||||
auto VLayoutPiece::LayoutEdgeByPoint(const QPointF &p1) const -> int
|
||||
{
|
||||
return EdgeByPoint(d->m_layoutAllowance, p1);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QRectF VLayoutPiece::MappedDetailBoundingRect() const
|
||||
auto VLayoutPiece::MappedDetailBoundingRect() const -> QRectF
|
||||
{
|
||||
return BoundingRect(CastTo<QPointF>(GetMappedExternalContourPoints()));
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QRectF VLayoutPiece::DetailBoundingRect() const
|
||||
auto VLayoutPiece::DetailBoundingRect() const -> QRectF
|
||||
{
|
||||
return BoundingRect(CastTo<QPointF>(GetExternalContourPoints()));
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QRectF VLayoutPiece::MappedLayoutBoundingRect() const
|
||||
auto VLayoutPiece::MappedLayoutBoundingRect() const -> QRectF
|
||||
{
|
||||
return BoundingRect(GetMappedLayoutAllowancePoints());
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
qreal VLayoutPiece::Diagonal() const
|
||||
auto VLayoutPiece::Diagonal() const -> qreal
|
||||
{
|
||||
const QRectF rec = MappedLayoutBoundingRect();
|
||||
return qSqrt(pow(rec.height(), 2) + pow(rec.width(), 2));
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
bool VLayoutPiece::isNull() const
|
||||
auto VLayoutPiece::isNull() const -> bool
|
||||
{
|
||||
if (d->m_contour.isEmpty() == false && d->m_layoutWidth > 0)
|
||||
if (not d->m_contour.isEmpty() && d->m_layoutWidth > 0)
|
||||
{
|
||||
if (IsSeamAllowance() && not IsSeamAllowanceBuiltIn() && d->m_seamAllowance.isEmpty() == false)
|
||||
{
|
||||
return false;
|
||||
return not (IsSeamAllowance() && not IsSeamAllowanceBuiltIn() && not d->m_seamAllowance.isEmpty());
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
qint64 VLayoutPiece::Square() const
|
||||
auto VLayoutPiece::Square() const -> qint64
|
||||
{
|
||||
return d->m_square;
|
||||
}
|
||||
|
@ -1261,27 +1273,27 @@ void VLayoutPiece::SetLayoutAllowancePoints()
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QVector<VLayoutPoint> VLayoutPiece::GetMappedExternalContourPoints() const
|
||||
auto VLayoutPiece::GetMappedExternalContourPoints() const -> QVector<VLayoutPoint>
|
||||
{
|
||||
return IsSeamAllowance() && not IsSeamAllowanceBuiltIn() ? GetMappedSeamAllowancePoints() :
|
||||
GetMappedContourPoints();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QVector<VLayoutPoint> VLayoutPiece::GetExternalContourPoints() const
|
||||
auto VLayoutPiece::GetExternalContourPoints() const -> QVector<VLayoutPoint>
|
||||
{
|
||||
return IsSeamAllowance() && not IsSeamAllowanceBuiltIn() ? GetSeamAllowancePoints() :
|
||||
GetContourPoints();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QVector<VLayoutPassmark> VLayoutPiece::GetMappedPassmarks() const
|
||||
auto VLayoutPiece::GetMappedPassmarks() const -> QVector<VLayoutPassmark>
|
||||
{
|
||||
return Map(d->m_passmarks);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QVector<VLayoutPassmark> VLayoutPiece::GetPassmarks() const
|
||||
auto VLayoutPiece::GetPassmarks() const -> QVector<VLayoutPassmark>
|
||||
{
|
||||
return d->m_passmarks;
|
||||
}
|
||||
|
@ -1296,7 +1308,7 @@ void VLayoutPiece::SetPassmarks(const QVector<VLayoutPassmark> &passmarks)
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QVector<VLayoutPlaceLabel> VLayoutPiece::GetPlaceLabels() const
|
||||
auto VLayoutPiece::GetPlaceLabels() const -> QVector<VLayoutPlaceLabel>
|
||||
{
|
||||
return d->m_placeLabels;
|
||||
}
|
||||
|
@ -1308,7 +1320,7 @@ void VLayoutPiece::SetPlaceLabels(const QVector<VLayoutPlaceLabel> &labels)
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QVector<QVector<VLayoutPoint> > VLayoutPiece::MappedInternalPathsForCut(bool cut) const
|
||||
auto VLayoutPiece::MappedInternalPathsForCut(bool cut) const -> QVector<QVector<VLayoutPoint> >
|
||||
{
|
||||
QVector<QVector<VLayoutPoint> > paths;
|
||||
paths.reserve(d->m_internalPaths.size());
|
||||
|
@ -1325,7 +1337,7 @@ QVector<QVector<VLayoutPoint> > VLayoutPiece::MappedInternalPathsForCut(bool cut
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QVector<VLayoutPiecePath> VLayoutPiece::GetInternalPaths() const
|
||||
auto VLayoutPiece::GetInternalPaths() const -> QVector<VLayoutPiecePath>
|
||||
{
|
||||
return d->m_internalPaths;
|
||||
}
|
||||
|
@ -1337,13 +1349,13 @@ void VLayoutPiece::SetInternalPaths(const QVector<VLayoutPiecePath> &internalPat
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QPainterPath VLayoutPiece::MappedContourPath() const
|
||||
auto VLayoutPiece::MappedContourPath() const -> QPainterPath
|
||||
{
|
||||
return d->m_matrix.map(ContourPath());
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QPainterPath VLayoutPiece::ContourPath() const
|
||||
auto VLayoutPiece::ContourPath() const -> QPainterPath
|
||||
{
|
||||
QPainterPath path;
|
||||
|
||||
|
@ -1396,7 +1408,7 @@ QPainterPath VLayoutPiece::ContourPath() const
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QPainterPath VLayoutPiece::MappedLayoutAllowancePath() const
|
||||
auto VLayoutPiece::MappedLayoutAllowancePath() const -> QPainterPath
|
||||
{
|
||||
return PainterPath(GetMappedLayoutAllowancePoints());
|
||||
}
|
||||
|
@ -1438,7 +1450,7 @@ void VLayoutPiece::DrawMiniature(QPainter &painter) const
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QGraphicsItem *VLayoutPiece::GetItem(bool textAsPaths) const
|
||||
auto VLayoutPiece::GetItem(bool textAsPaths) const -> QGraphicsItem *
|
||||
{
|
||||
QGraphicsPathItem *item = GetMainItem();
|
||||
|
||||
|
@ -1470,7 +1482,7 @@ QGraphicsItem *VLayoutPiece::GetItem(bool textAsPaths) const
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
bool VLayoutPiece::IsLayoutAllowanceValid() const
|
||||
auto VLayoutPiece::IsLayoutAllowanceValid() const -> bool
|
||||
{
|
||||
QVector<VLayoutPoint> base = (IsSeamAllowance() && not IsSeamAllowanceBuiltIn()) ?
|
||||
d->m_seamAllowance : d->m_contour;
|
||||
|
@ -1478,7 +1490,7 @@ bool VLayoutPiece::IsLayoutAllowanceValid() const
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
qreal VLayoutPiece::BiggestEdge() const
|
||||
auto VLayoutPiece::BiggestEdge() const -> qreal
|
||||
{
|
||||
qreal edge = 0;
|
||||
|
||||
|
@ -1501,18 +1513,18 @@ qreal VLayoutPiece::BiggestEdge() const
|
|||
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
PlaceLabelImg VLayoutPiece::MapPlaceLabelShape(PlaceLabelImg shape) const
|
||||
auto VLayoutPiece::MapPlaceLabelShape(PlaceLabelImg shape) const -> PlaceLabelImg
|
||||
{
|
||||
for (int i = 0; i < shape.size(); ++i)
|
||||
for (auto & i : shape)
|
||||
{
|
||||
shape[i] = Map(shape.at(i));
|
||||
i = Map(i);
|
||||
}
|
||||
|
||||
return shape;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QRectF VLayoutPiece::BoundingRect(QVector<QPointF> points)
|
||||
auto VLayoutPiece::BoundingRect(QVector<QPointF> points) -> QRectF
|
||||
{
|
||||
points.append(ConstFirst(points));
|
||||
return QPolygonF(points).boundingRect();
|
||||
|
@ -1524,8 +1536,11 @@ void VLayoutPiece::CreateLabelStrings(QGraphicsItem *parent, const QVector<QPoin
|
|||
{
|
||||
SCASSERT(parent != nullptr)
|
||||
|
||||
if (labelShape.count() > 2)
|
||||
if (labelShape.count() <= 2)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const qreal dW = QLineF(labelShape.at(0), labelShape.at(1)).length();
|
||||
const qreal dH = QLineF(labelShape.at(1), labelShape.at(2)).length();
|
||||
const qreal angle = - QLineF(labelShape.at(0), labelShape.at(1)).angle();
|
||||
|
@ -1533,7 +1548,6 @@ void VLayoutPiece::CreateLabelStrings(QGraphicsItem *parent, const QVector<QPoin
|
|||
|
||||
for (int i = 0; i < tm.GetSourceLinesCount(); ++i)
|
||||
{
|
||||
|
||||
const TextLine& tl = tm.GetSourceLine(i);
|
||||
QFont fnt = tm.GetFont();
|
||||
fnt.setPixelSize(tm.GetFont().pixelSize() + tl.m_iFontSize);
|
||||
|
@ -1613,7 +1627,6 @@ void VLayoutPiece::CreateLabelStrings(QGraphicsItem *parent, const QVector<QPoin
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VLayoutPiece::CreateGrainlineItem(QGraphicsItem *parent) const
|
||||
|
@ -1639,7 +1652,7 @@ void VLayoutPiece::CreateGrainlineItem(QGraphicsItem *parent) const
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QVector<VLayoutPoint> VLayoutPiece::DetailPath() const
|
||||
auto VLayoutPiece::DetailPath() const -> QVector<VLayoutPoint>
|
||||
{
|
||||
if (IsSeamAllowance() && not IsSeamAllowanceBuiltIn())
|
||||
{
|
||||
|
@ -1650,9 +1663,9 @@ QVector<VLayoutPoint> VLayoutPiece::DetailPath() const
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QGraphicsPathItem *VLayoutPiece::GetMainItem() const
|
||||
auto VLayoutPiece::GetMainItem() const -> QGraphicsPathItem *
|
||||
{
|
||||
QGraphicsPathItem *item = new QGraphicsPathItem();
|
||||
auto *item = new QGraphicsPathItem();
|
||||
QPen pen = item->pen();
|
||||
pen.setWidthF(VAbstractApplication::VApp()->Settings()->WidthHairLine());
|
||||
item->setPen(pen);
|
||||
|
@ -1661,9 +1674,9 @@ QGraphicsPathItem *VLayoutPiece::GetMainItem() const
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QGraphicsPathItem *VLayoutPiece::GetMainPathItem() const
|
||||
auto VLayoutPiece::GetMainPathItem() const -> QGraphicsPathItem *
|
||||
{
|
||||
QGraphicsPathItem *item = new QGraphicsPathItem();
|
||||
auto *item = new QGraphicsPathItem();
|
||||
QPen pen = item->pen();
|
||||
pen.setWidthF(VAbstractApplication::VApp()->Settings()->WidthHairLine());
|
||||
item->setPen(pen);
|
||||
|
@ -1685,7 +1698,7 @@ QGraphicsPathItem *VLayoutPiece::GetMainPathItem() const
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
bool VLayoutPiece::IsMirror() const
|
||||
auto VLayoutPiece::IsMirror() const -> bool
|
||||
{
|
||||
return d->m_mirror;
|
||||
}
|
||||
|
@ -1733,11 +1746,11 @@ void VLayoutPiece::SetYScale(qreal ys)
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QLineF VLayoutPiece::Edge(const QVector<QPointF> &path, int i) const
|
||||
auto VLayoutPiece::Edge(const QVector<QPointF> &path, int i) const -> QLineF
|
||||
{
|
||||
if (i < 1)
|
||||
{ // Doesn't exist such edge
|
||||
return QLineF();
|
||||
return {};
|
||||
}
|
||||
|
||||
int i1, i2;
|
||||
|
@ -1755,17 +1768,14 @@ QLineF VLayoutPiece::Edge(const QVector<QPointF> &path, int i) const
|
|||
if (d->m_mirror)
|
||||
{
|
||||
QVector<QPointF> newPath = Map(path);
|
||||
return QLineF(newPath.at(i1), newPath.at(i2));
|
||||
}
|
||||
else
|
||||
{
|
||||
return QLineF(d->m_matrix.map(path.at(i1)), d->m_matrix.map(path.at(i2)));
|
||||
return {newPath.at(i1), newPath.at(i2)};
|
||||
}
|
||||
return {d->m_matrix.map(path.at(i1)), d->m_matrix.map(path.at(i2))};
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
// NOTE: Once C++17 is made mandatory, this method can further be refactored with std::optional<int>
|
||||
int VLayoutPiece::EdgeByPoint(const QVector<QPointF> &path, const QPointF &p1) const
|
||||
auto VLayoutPiece::EdgeByPoint(const QVector<QPointF> &path, const QPointF &p1) const -> int
|
||||
{
|
||||
if (p1.isNull() || path.count() < 3)
|
||||
{
|
||||
|
@ -1773,7 +1783,7 @@ int VLayoutPiece::EdgeByPoint(const QVector<QPointF> &path, const QPointF &p1) c
|
|||
}
|
||||
|
||||
const auto points = Map(path);
|
||||
const auto posIter = std::find_if(points.cbegin(), points.cend(),
|
||||
const auto *const posIter = std::find_if(points.cbegin(), points.cend(),
|
||||
[&p1](const QPointF &point){ return VFuzzyComparePoints(point, p1); });
|
||||
if (posIter != points.cend())
|
||||
{
|
||||
|
|
|
@ -68,74 +68,74 @@ public:
|
|||
VLayoutPiece();
|
||||
VLayoutPiece(const VLayoutPiece &detail);
|
||||
|
||||
virtual ~VLayoutPiece() override;
|
||||
~VLayoutPiece() override;
|
||||
|
||||
VLayoutPiece &operator=(const VLayoutPiece &detail);
|
||||
auto operator=(const VLayoutPiece &detail) -> VLayoutPiece &;
|
||||
#ifdef Q_COMPILER_RVALUE_REFS
|
||||
VLayoutPiece(VLayoutPiece &&detail) Q_DECL_NOTHROW;
|
||||
VLayoutPiece &operator=(VLayoutPiece &&detail) Q_DECL_NOTHROW;
|
||||
auto operator=(VLayoutPiece &&detail) Q_DECL_NOTHROW -> VLayoutPiece &;
|
||||
#endif
|
||||
|
||||
static VLayoutPiece Create(const VPiece &piece, vidtype id, const VContainer *pattern);
|
||||
static auto Create(const VPiece &piece, vidtype id, const VContainer *pattern) -> VLayoutPiece;
|
||||
|
||||
virtual auto GetUniqueID() const -> QString override;
|
||||
auto GetUniqueID() const -> QString override;
|
||||
|
||||
QVector<VLayoutPoint> GetMappedContourPoints() const;
|
||||
QVector<VLayoutPoint> GetContourPoints() const;
|
||||
auto GetMappedContourPoints() const -> QVector<VLayoutPoint>;
|
||||
auto GetContourPoints() const -> QVector<VLayoutPoint>;
|
||||
void SetCountourPoints(const QVector<VLayoutPoint> &points, bool hideMainPath = false);
|
||||
|
||||
QVector<VLayoutPoint> GetMappedSeamAllowancePoints() const;
|
||||
QVector<VLayoutPoint> GetSeamAllowancePoints() const;
|
||||
auto GetMappedSeamAllowancePoints() const -> QVector<VLayoutPoint>;
|
||||
auto GetSeamAllowancePoints() const -> QVector<VLayoutPoint>;
|
||||
void SetSeamAllowancePoints(const QVector<VLayoutPoint> &points, bool seamAllowance = true,
|
||||
bool seamAllowanceBuiltIn = false);
|
||||
|
||||
QVector<QPointF> GetMappedLayoutAllowancePoints() const;
|
||||
QVector<QPointF> GetLayoutAllowancePoints() const;
|
||||
auto GetMappedLayoutAllowancePoints() const -> QVector<QPointF>;
|
||||
auto GetLayoutAllowancePoints() const -> QVector<QPointF>;
|
||||
void SetLayoutAllowancePoints();
|
||||
|
||||
QVector<VLayoutPoint> GetMappedExternalContourPoints() const;
|
||||
QVector<VLayoutPoint> GetExternalContourPoints() const;
|
||||
auto GetMappedExternalContourPoints() const -> QVector<VLayoutPoint>;
|
||||
auto GetExternalContourPoints() const -> QVector<VLayoutPoint>;
|
||||
|
||||
QVector<VLayoutPassmark> GetMappedPassmarks() const;
|
||||
QVector<VLayoutPassmark> GetPassmarks() const;
|
||||
auto GetMappedPassmarks() const -> QVector<VLayoutPassmark>;
|
||||
auto GetPassmarks() const -> QVector<VLayoutPassmark>;
|
||||
void SetPassmarks(const QVector<VLayoutPassmark> &passmarks);
|
||||
|
||||
QVector<VLayoutPlaceLabel> GetPlaceLabels() const;
|
||||
auto GetPlaceLabels() const -> QVector<VLayoutPlaceLabel>;
|
||||
void SetPlaceLabels(const QVector<VLayoutPlaceLabel> &labels);
|
||||
|
||||
QVector<QVector<VLayoutPoint> > MappedInternalPathsForCut(bool cut) const;
|
||||
QVector<VLayoutPiecePath> GetInternalPaths() const;
|
||||
auto MappedInternalPathsForCut(bool cut) const -> QVector<QVector<VLayoutPoint> >;
|
||||
auto GetInternalPaths() const -> QVector<VLayoutPiecePath>;
|
||||
void SetInternalPaths(const QVector<VLayoutPiecePath> &internalPaths);
|
||||
|
||||
QPointF GetPieceTextPosition() const;
|
||||
QStringList GetPieceText() const;
|
||||
auto GetPieceTextPosition() const -> QPointF;
|
||||
auto GetPieceText() const -> QStringList;
|
||||
void SetPieceText(const QString &qsName, const VPieceLabelData& data, const QFont& font, const VContainer *pattern);
|
||||
|
||||
QPointF GetPatternTextPosition() const;
|
||||
QStringList GetPatternText() const;
|
||||
auto GetPatternTextPosition() const -> QPointF;
|
||||
auto GetPatternText() const -> QStringList;
|
||||
void SetPatternInfo(VAbstractPattern *pDoc, const VPatternLabelData& geom, const QFont& font,
|
||||
const VContainer *pattern);
|
||||
|
||||
void SetGrainline(const VGrainlineData& geom, const VContainer *pattern);
|
||||
QVector<QPointF> GetMappedGrainline() const;
|
||||
QVector<QPointF> GetGrainline() const;
|
||||
bool IsGrainlineEnabled() const;
|
||||
qreal GrainlineAngle() const;
|
||||
GrainlineArrowDirection GrainlineArrowType() const;
|
||||
auto GetMappedGrainline() const -> QVector<QPointF>;
|
||||
auto GetGrainline() const -> QVector<QPointF>;
|
||||
auto IsGrainlineEnabled() const -> bool;
|
||||
auto GrainlineAngle() const -> qreal;
|
||||
auto GrainlineArrowType() const -> GrainlineArrowDirection;
|
||||
|
||||
QTransform GetMatrix() const;
|
||||
auto GetMatrix() const -> QTransform;
|
||||
void SetMatrix(const QTransform &matrix);
|
||||
|
||||
qreal GetLayoutWidth() const;
|
||||
auto GetLayoutWidth() const -> qreal;
|
||||
void SetLayoutWidth(qreal value);
|
||||
|
||||
quint16 GetQuantity() const;
|
||||
auto GetQuantity() const -> quint16;
|
||||
void SetQuantity(quint16 value);
|
||||
|
||||
vidtype GetId() const;
|
||||
auto GetId() const -> vidtype;
|
||||
void SetId(vidtype id);
|
||||
|
||||
bool IsMirror() const;
|
||||
auto IsMirror() const -> bool;
|
||||
void SetMirror(bool value);
|
||||
|
||||
void SetGradationId(const QString &id);
|
||||
|
@ -154,36 +154,36 @@ public:
|
|||
void Mirror(const QLineF &edge);
|
||||
void Mirror();
|
||||
|
||||
int DetailEdgesCount() const;
|
||||
int LayoutEdgesCount() const;
|
||||
auto DetailEdgesCount() const -> int;
|
||||
auto LayoutEdgesCount() const -> int;
|
||||
|
||||
QLineF LayoutEdge(int i) const;
|
||||
int LayoutEdgeByPoint(const QPointF &p1) const;
|
||||
auto LayoutEdge(int i) const -> QLineF;
|
||||
auto LayoutEdgeByPoint(const QPointF &p1) const -> int;
|
||||
|
||||
QRectF MappedDetailBoundingRect() const;
|
||||
QRectF DetailBoundingRect() const;
|
||||
QRectF MappedLayoutBoundingRect() const;
|
||||
qreal Diagonal() const;
|
||||
auto MappedDetailBoundingRect() const -> QRectF;
|
||||
auto DetailBoundingRect() const -> QRectF;
|
||||
auto MappedLayoutBoundingRect() const -> QRectF;
|
||||
auto Diagonal() const -> qreal;
|
||||
|
||||
static QRectF BoundingRect(QVector<QPointF> points);
|
||||
static auto BoundingRect(QVector<QPointF> points) -> QRectF;
|
||||
|
||||
bool isNull() const;
|
||||
qint64 Square() const;
|
||||
auto isNull() const -> bool;
|
||||
auto Square() const -> qint64;
|
||||
|
||||
QPainterPath MappedContourPath() const;
|
||||
QPainterPath ContourPath() const;
|
||||
QPainterPath MappedLayoutAllowancePath() const;
|
||||
auto MappedContourPath() const -> QPainterPath;
|
||||
auto ContourPath() const -> QPainterPath;
|
||||
auto MappedLayoutAllowancePath() const -> QPainterPath;
|
||||
|
||||
void DrawMiniature(QPainter &painter) const;
|
||||
|
||||
Q_REQUIRED_RESULT QGraphicsItem *GetItem(bool textAsPaths) const;
|
||||
Q_REQUIRED_RESULT auto GetItem(bool textAsPaths) const -> QGraphicsItem *;
|
||||
|
||||
bool IsLayoutAllowanceValid() const;
|
||||
auto IsLayoutAllowanceValid() const -> bool;
|
||||
|
||||
qreal BiggestEdge() const;
|
||||
auto BiggestEdge() const -> qreal;
|
||||
|
||||
friend QDataStream& operator<< (QDataStream& dataStream, const VLayoutPiece& piece);
|
||||
friend QDataStream& operator>> (QDataStream& dataStream, VLayoutPiece& piece);
|
||||
friend auto operator<< (QDataStream& dataStream, const VLayoutPiece& piece) -> QDataStream&;
|
||||
friend auto operator>> (QDataStream& dataStream, VLayoutPiece& piece) -> QDataStream&;
|
||||
|
||||
auto MapPlaceLabelShape(PlaceLabelImg shape) const -> PlaceLabelImg;
|
||||
|
||||
|
@ -208,20 +208,20 @@ protected:
|
|||
private:
|
||||
QSharedDataPointer<VLayoutPieceData> d;
|
||||
|
||||
QVector<VLayoutPoint> DetailPath() const;
|
||||
auto DetailPath() const -> QVector<VLayoutPoint>;
|
||||
|
||||
Q_REQUIRED_RESULT QGraphicsPathItem *GetMainItem() const;
|
||||
Q_REQUIRED_RESULT QGraphicsPathItem *GetMainPathItem() const;
|
||||
Q_REQUIRED_RESULT auto GetMainItem() const -> QGraphicsPathItem *;
|
||||
Q_REQUIRED_RESULT auto GetMainPathItem() const -> QGraphicsPathItem *;
|
||||
|
||||
void CreateLabelStrings(QGraphicsItem *parent, const QVector<QPointF> &labelShape, const VTextManager &tm,
|
||||
bool textAsPaths) const;
|
||||
void CreateGrainlineItem(QGraphicsItem *parent) const;
|
||||
|
||||
template <class T>
|
||||
QVector<T> Map(QVector<T> points) const;
|
||||
auto Map(QVector<T> points) const -> QVector<T>;
|
||||
|
||||
QLineF Edge(const QVector<QPointF> &path, int i) const;
|
||||
int EdgeByPoint(const QVector<QPointF> &path, const QPointF &p1) const;
|
||||
auto Edge(const QVector<QPointF> &path, int i) const -> QLineF;
|
||||
auto EdgeByPoint(const QVector<QPointF> &path, const QPointF &p1) const -> int;
|
||||
};
|
||||
|
||||
QT_WARNING_POP
|
||||
|
|
Loading…
Reference in New Issue
Block a user