Fix build with GCC 4.9.

This commit is contained in:
Roman Telezhynskyi 2023-07-15 10:58:28 +03:00
parent 7275ad5a7f
commit 41464eece0
63 changed files with 1304 additions and 1404 deletions

View file

@ -72,7 +72,7 @@ VAbstractArc::VAbstractArc(const GOType &type, const VPointF &center, qreal f1,
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VAbstractArc::VAbstractArc(const VAbstractArc &arc) = default; COPY_CONSTRUCTOR_IMPL_2(VAbstractArc, VAbstractCurve)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VAbstractArc::operator=(const VAbstractArc &arc) -> VAbstractArc & auto VAbstractArc::operator=(const VAbstractArc &arc) -> VAbstractArc &

View file

@ -35,10 +35,10 @@
#include <QPoint> #include <QPoint>
#include <QtDebug> #include <QtDebug>
#include "vabstractcurve_p.h"
#include "../vmisc/vabstractvalapplication.h"
#include "../vmisc/compatibility.h"
#include "../ifc/exception/vexceptionobjecterror.h" #include "../ifc/exception/vexceptionobjecterror.h"
#include "../vmisc/compatibility.h"
#include "../vmisc/vabstractvalapplication.h"
#include "vabstractcurve_p.h"
// See https://stackoverflow.com/a/46719572/3045403 // See https://stackoverflow.com/a/46719572/3045403
#if __cplusplus < 201703L #if __cplusplus < 201703L
@ -47,18 +47,18 @@ constexpr qreal VAbstractCurve::minLength; // NOLINT(readability-redundant-decla
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VAbstractCurve::VAbstractCurve(const GOType &type, const quint32 &idObject, const Draw &mode) VAbstractCurve::VAbstractCurve(const GOType &type, const quint32 &idObject, const Draw &mode)
:VGObject(type, idObject, mode), d (new VAbstractCurveData()) : VGObject(type, idObject, mode),
{} d(new VAbstractCurveData())
{
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VAbstractCurve::VAbstractCurve(const VAbstractCurve &curve) // NOLINT(modernize-use-equals-default) COPY_CONSTRUCTOR_IMPL_2(VAbstractCurve, VGObject)
:VGObject(curve), d (curve.d)
{}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VAbstractCurve::operator=(const VAbstractCurve &curve) -> VAbstractCurve & auto VAbstractCurve::operator=(const VAbstractCurve &curve) -> VAbstractCurve &
{ {
if ( &curve == this ) if (&curve == this)
{ {
return *this; return *this;
} }
@ -70,8 +70,10 @@ auto VAbstractCurve::operator=(const VAbstractCurve &curve) -> VAbstractCurve &
#ifdef Q_COMPILER_RVALUE_REFS #ifdef Q_COMPILER_RVALUE_REFS
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VAbstractCurve::VAbstractCurve(VAbstractCurve &&curve) noexcept VAbstractCurve::VAbstractCurve(VAbstractCurve &&curve) noexcept
:VGObject(std::move(curve)), d (std::move(curve.d)) : VGObject(std::move(curve)),
{} d(std::move(curve.d))
{
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VAbstractCurve::operator=(VAbstractCurve &&curve) noexcept -> VAbstractCurve & auto VAbstractCurve::operator=(VAbstractCurve &&curve) noexcept -> VAbstractCurve &
@ -83,8 +85,7 @@ auto VAbstractCurve::operator=(VAbstractCurve &&curve) noexcept -> VAbstractCurv
#endif #endif
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VAbstractCurve::~VAbstractCurve() // NOLINT(modernize-use-equals-default) VAbstractCurve::~VAbstractCurve() = default;
{}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VAbstractCurve::GetSegmentPoints(const QVector<QPointF> &points, const QPointF &begin, const QPointF &end, auto VAbstractCurve::GetSegmentPoints(const QVector<QPointF> &points, const QPointF &begin, const QPointF &end,
@ -143,16 +144,16 @@ auto VAbstractCurve::GetSegmentPoints(const QPointF &begin, const QPointF &end,
QString errorMsg; QString errorMsg;
if (piece.isEmpty()) if (piece.isEmpty())
{ {
errorMsg = QObject::tr("Error calculating segment for curve '%1'. %2") errorMsg = QObject::tr("Error calculating segment for curve '%1'. %2").arg(name(), error);
.arg(name(), error);
} }
else else
{ {
errorMsg = QObject::tr("Error in path '%1'. Calculating segment for curve '%2' has failed. %3") errorMsg = QObject::tr("Error in path '%1'. Calculating segment for curve '%2' has failed. %3")
.arg(piece, name(), error); .arg(piece, name(), error);
} }
VAbstractApplication::VApp()->IsPedantic() ? throw VExceptionObjectError(errorMsg) : VAbstractApplication::VApp()->IsPedantic()
qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; ? throw VExceptionObjectError(errorMsg)
: qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
} }
return segment; return segment;
@ -161,69 +162,65 @@ auto VAbstractCurve::GetSegmentPoints(const QPointF &begin, const QPointF &end,
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VAbstractCurve::FromBegin(const QVector<QPointF> &points, const QPointF &begin, bool *ok) -> QVector<QPointF> auto VAbstractCurve::FromBegin(const QVector<QPointF> &points, const QPointF &begin, bool *ok) -> QVector<QPointF>
{ {
if (points.count() >= 2) auto SetResult = [&ok](bool res)
{ {
if (ConstFirst(points).toPoint() == begin.toPoint())
{
if (ok != nullptr)
{
*ok = true;
}
return points;
}
QVector<QPointF> segment;
bool theBegin = false;
for (qint32 i = 0; i < points.count()-1; ++i)
{
if (not theBegin)
{
if (IsPointOnLineSegment(begin, points.at(i), points.at(i+1)))
{
theBegin = true;
if (not VFuzzyComparePoints(begin, points.at(i+1)))
{
segment.append(begin);
}
if (i == points.count()-2)
{
segment.append(points.at(i+1));
}
}
}
else
{
segment.append(points.at(i));
if (i == points.count()-2)
{
segment.append(points.at(i+1));
}
}
}
if (segment.isEmpty())
{
if (ok != nullptr)
{
*ok = false;
}
return points;
}
if (ok != nullptr) if (ok != nullptr)
{ {
*ok = true; *ok = res;
} }
return segment; };
if (points.count() < 2)
{
SetResult(false);
return points;
} }
if (ok != nullptr) if (ConstFirst(points).toPoint() == begin.toPoint())
{ {
*ok = false; SetResult(true);
return points;
} }
return points;
QVector<QPointF> segment;
bool theBegin = false;
for (qint32 i = 0; i < points.count() - 1; ++i)
{
if (not theBegin)
{
if (IsPointOnLineSegment(begin, points.at(i), points.at(i + 1)))
{
theBegin = true;
if (not VFuzzyComparePoints(begin, points.at(i + 1)))
{
segment.append(begin);
}
if (i == points.count() - 2)
{
segment.append(points.at(i + 1));
}
}
}
else
{
segment.append(points.at(i));
if (i == points.count() - 2)
{
segment.append(points.at(i + 1));
}
}
}
if (segment.isEmpty())
{
SetResult(false);
return points;
}
SetResult(true);
return segment;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -252,11 +249,11 @@ auto VAbstractCurve::ClosestPoint(QPointF scenePoint) const -> QPointF
qreal bestDistance = INT_MAX; qreal bestDistance = INT_MAX;
bool found = false; bool found = false;
for (qint32 i = 0; i < points.count()-1; ++i) for (qint32 i = 0; i < points.count() - 1; ++i)
{ {
const QPointF cPoint = VGObject::ClosestPoint(QLineF(points.at(i), points.at(i+1)), scenePoint); const QPointF cPoint = VGObject::ClosestPoint(QLineF(points.at(i), points.at(i + 1)), scenePoint);
if (IsPointOnLineSegment(cPoint, points.at(i), points.at(i+1))) if (IsPointOnLineSegment(cPoint, points.at(i), points.at(i + 1)))
{ {
const qreal length = QLineF(scenePoint, cPoint).length(); const qreal length = QLineF(scenePoint, cPoint).length();
if (length < bestDistance) if (length < bestDistance)
@ -290,7 +287,7 @@ auto VAbstractCurve::GetPath() const -> QPainterPath
} }
else else
{ {
qDebug()<<"points.count() < 2"<<Q_FUNC_INFO; qDebug() << "points.count() < 2" << Q_FUNC_INFO;
} }
return path; return path;
} }
@ -349,9 +346,9 @@ auto VAbstractCurve::IsPointOnCurve(const QVector<QPointF> &points, const QPoint
return points.at(0) == p; return points.at(0) == p;
} }
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;
} }
@ -379,11 +376,11 @@ auto VAbstractCurve::SubdividePath(const QVector<QPointF> &points, QPointF p, QV
sub1.clear(); sub1.clear();
sub2.clear(); sub2.clear();
for (qint32 i = 0; i < points.count()-1; ++i) for (qint32 i = 0; i < points.count() - 1; ++i)
{ {
if (not found) if (not found)
{ {
if (IsPointOnLineSegment(p, points.at(i), points.at(i+1))) if (IsPointOnLineSegment(p, points.at(i), points.at(i + 1)))
{ {
if (not VFuzzyComparePoints(points.at(i), p)) if (not VFuzzyComparePoints(points.at(i), p))
{ {
@ -398,13 +395,13 @@ auto VAbstractCurve::SubdividePath(const QVector<QPointF> &points, QPointF p, QV
} }
} }
if (not VFuzzyComparePoints(points.at(i+1), p)) if (not VFuzzyComparePoints(points.at(i + 1), p))
{ {
sub2.append(p); sub2.append(p);
if (i+1 == points.count()-1) if (i + 1 == points.count() - 1)
{ {
sub2.append(points.at(i+1)); sub2.append(points.at(i + 1));
} }
} }
@ -419,9 +416,9 @@ auto VAbstractCurve::SubdividePath(const QVector<QPointF> &points, QPointF p, QV
{ {
sub2.append(points.at(i)); sub2.append(points.at(i));
if (i+1 == points.count()-1) if (i + 1 == points.count() - 1)
{ {
sub2.append(points.at(i+1)); sub2.append(points.at(i + 1));
} }
} }
} }
@ -487,16 +484,16 @@ void VAbstractCurve::SetApproximationScale(qreal value)
auto VAbstractCurve::CurveIntersectLine(const QVector<QPointF> &points, const QLineF &line) -> QVector<QPointF> auto VAbstractCurve::CurveIntersectLine(const QVector<QPointF> &points, const QLineF &line) -> QVector<QPointF>
{ {
QVector<QPointF> intersections; QVector<QPointF> intersections;
intersections.reserve(points.count()-1); intersections.reserve(points.count() - 1);
for ( auto i = 0; i < points.count()-1; ++i ) for (auto i = 0; i < points.count() - 1; ++i)
{ {
QPointF crosPoint; QPointF crosPoint;
auto type = Intersects(line, QLineF(points.at(i), points.at(i+1)), &crosPoint); auto type = Intersects(line, QLineF(points.at(i), points.at(i + 1)), &crosPoint);
// QLineF::intersects not always accurate on edge cases // QLineF::intersects not always accurate on edge cases
if (type == QLineF::BoundedIntersection || if (type == QLineF::BoundedIntersection ||
(VGObject::IsPointOnLineSegment (crosPoint, points.at(i), points.at(i+1)) && (VGObject::IsPointOnLineSegment(crosPoint, points.at(i), points.at(i + 1)) &&
VGObject::IsPointOnLineSegment (crosPoint, line.p1(), line.p2()))) VGObject::IsPointOnLineSegment(crosPoint, line.p1(), line.p2())))
{ {
intersections.append(crosPoint); intersections.append(crosPoint);
} }
@ -512,13 +509,13 @@ auto VAbstractCurve::CurveIntersectAxis(const QPointF &point, qreal angle, const
// Normalize an angle // Normalize an angle
{ {
QLineF line(QPointF(10,10), QPointF(100, 10)); QLineF line(QPointF(10, 10), QPointF(100, 10));
line.setAngle(angle); line.setAngle(angle);
angle = line.angle(); angle = line.angle();
} }
QRectF rec = QRectF(0, 0, INT_MAX, INT_MAX); QRectF rec = QRectF(0, 0, INT_MAX, INT_MAX);
rec.translate(-INT_MAX/2.0, -INT_MAX/2.0); rec.translate(-INT_MAX / 2.0, -INT_MAX / 2.0);
// Instead of using axis compare two rays. See issue #963. // Instead of using axis compare two rays. See issue #963.
QLineF axis = QLineF(point, VGObject::BuildRay(point, angle, rec)); QLineF axis = QLineF(point, VGObject::BuildRay(point, angle, rec));
@ -538,7 +535,7 @@ auto VAbstractCurve::CurveIntersectAxis(const QPointF &point, qreal angle, const
QMap<qreal, int> forward; QMap<qreal, int> forward;
QMap<qreal, int> backward; QMap<qreal, int> backward;
for ( qint32 i = 0; i < points.size(); ++i ) for (qint32 i = 0; i < points.size(); ++i)
{ {
if (VFuzzyComparePoints(points.at(i), point)) if (VFuzzyComparePoints(points.at(i), point))
{ // Always seek unique intersection { // Always seek unique intersection
@ -546,7 +543,7 @@ auto VAbstractCurve::CurveIntersectAxis(const QPointF &point, qreal angle, const
} }
const QLineF length(point, points.at(i)); const QLineF length(point, points.at(i));
if (qAbs(length.angle()-angle) < 0.1) if (qAbs(length.angle() - angle) < 0.1)
{ {
forward.insert(length.length(), i); forward.insert(length.length(), i);
} }
@ -597,33 +594,33 @@ auto VAbstractCurve::DirectionArrows() const -> QVector<DirectionArrow>
{ {
/*Need find coordinate midle of curve. /*Need find coordinate midle of curve.
Universal way is take all points and find sum.*/ Universal way is take all points and find sum.*/
const qreal seek_length = qAbs(GetLength())/2.0; const qreal seek_length = qAbs(GetLength()) / 2.0;
qreal found_length = 0; qreal found_length = 0;
QLineF arrow; QLineF arrow;
for (qint32 i = 1; i <= points.size()-1; ++i) for (qint32 i = 1; i <= points.size() - 1; ++i)
{ {
arrow = QLineF(points.at(i-1), points.at(i)); arrow = QLineF(points.at(i - 1), points.at(i));
found_length += arrow.length();//Length that we aready find found_length += arrow.length(); // Length that we aready find
if (seek_length <= found_length)// if have found more that need stop. if (seek_length <= found_length) // if have found more that need stop.
{ {
//subtract length in last line and you will find position of the middle point. // subtract length in last line and you will find position of the middle point.
arrow.setLength(arrow.length() - (found_length - seek_length)); arrow.setLength(arrow.length() - (found_length - seek_length));
break; break;
} }
} }
//Reverse line because we want start arrow from this point // Reverse line because we want start arrow from this point
arrow = QLineF(arrow.p2(), arrow.p1()); arrow = QLineF(arrow.p2(), arrow.p1());
const qreal angle = arrow.angle();//we each time change line angle, better save original angle value const qreal angle = arrow.angle(); // we each time change line angle, better save original angle value
arrow.setLength(VAbstractCurve::LengthCurveDirectionArrow()); arrow.setLength(VAbstractCurve::LengthCurveDirectionArrow());
DirectionArrow dArrow; DirectionArrow dArrow;
arrow.setAngle(angle-35); arrow.setAngle(angle - 35);
dArrow.first = arrow; dArrow.first = arrow;
arrow.setAngle(angle+35); arrow.setAngle(angle + 35);
dArrow.second = arrow; dArrow.second = arrow;
arrows.append(dArrow); arrows.append(dArrow);

View file

@ -32,24 +32,25 @@
#include <QPointF> #include <QPointF>
#include <QtDebug> #include <QtDebug>
#include "../vmisc/def.h" #include "../ifc/exception/vexception.h"
#include "../vmisc/vmath.h"
#include "../vmisc/compatibility.h"
#include "../vmisc/vabstractapplication.h"
#include "../ifc/ifcdef.h" #include "../ifc/ifcdef.h"
#include "../vmisc/compatibility.h"
#include "../vmisc/def.h"
#include "../vmisc/vabstractapplication.h"
#include "../vmisc/vmath.h"
#include "vabstractcurve.h" #include "vabstractcurve.h"
#include "varc_p.h" #include "varc_p.h"
#include "vspline.h" #include "vspline.h"
#include "../ifc/exception/vexception.h"
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief VArc default constructor. * @brief VArc default constructor.
*/ */
VArc::VArc () VArc::VArc()
: VAbstractArc(GOType::Arc), : VAbstractArc(GOType::Arc),
d (new VArcData) d(new VArcData)
{} {
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
@ -59,18 +60,18 @@ VArc::VArc ()
* @param f1 start angle (degree). * @param f1 start angle (degree).
* @param f2 end angle (degree). * @param f2 end angle (degree).
*/ */
VArc::VArc (const VPointF &center, qreal radius, const QString &formulaRadius, qreal f1, const QString &formulaF1, VArc::VArc(const VPointF &center, qreal radius, const QString &formulaRadius, qreal f1, const QString &formulaF1,
qreal f2, const QString &formulaF2, quint32 idObject, Draw mode) qreal f2, const QString &formulaF2, quint32 idObject, Draw mode)
: VAbstractArc(GOType::Arc, center, f1, formulaF1, f2, formulaF2, idObject, mode), : VAbstractArc(GOType::Arc, center, f1, formulaF1, f2, formulaF2, idObject, mode),
d (new VArcData(radius, formulaRadius)) d(new VArcData(radius, formulaRadius))
{ {
CreateName(); CreateName();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VArc::VArc(const VPointF &center, qreal radius, qreal f1, qreal f2) VArc::VArc(const VPointF &center, qreal radius, qreal f1, qreal f2)
: VAbstractArc(GOType::Arc, center, f1, f2, NULL_ID, Draw::Calculation), : VAbstractArc(GOType::Arc, center, f1, f2, NULL_ID, Draw::Calculation),
d (new VArcData(radius)) d(new VArcData(radius))
{ {
CreateName(); CreateName();
} }
@ -78,8 +79,8 @@ VArc::VArc(const VPointF &center, qreal radius, qreal f1, qreal f2)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VArc::VArc(qreal length, const QString &formulaLength, const VPointF &center, qreal radius, VArc::VArc(qreal length, const QString &formulaLength, const VPointF &center, qreal radius,
const QString &formulaRadius, qreal f1, const QString &formulaF1, quint32 idObject, Draw mode) const QString &formulaRadius, qreal f1, const QString &formulaF1, quint32 idObject, Draw mode)
: VAbstractArc(GOType::Arc, formulaLength, center, f1, formulaF1, idObject, mode), : VAbstractArc(GOType::Arc, formulaLength, center, f1, formulaF1, idObject, mode),
d (new VArcData(radius, formulaRadius)) d(new VArcData(radius, formulaRadius))
{ {
CreateName(); CreateName();
FindF2(length); FindF2(length);
@ -87,21 +88,15 @@ VArc::VArc(qreal length, const QString &formulaLength, const VPointF &center, qr
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VArc::VArc(qreal length, const VPointF &center, qreal radius, qreal f1) VArc::VArc(qreal length, const VPointF &center, qreal radius, qreal f1)
: VAbstractArc(GOType::Arc, center, f1, NULL_ID, Draw::Calculation), : VAbstractArc(GOType::Arc, center, f1, NULL_ID, Draw::Calculation),
d (new VArcData(radius)) d(new VArcData(radius))
{ {
CreateName(); CreateName();
FindF2(length); FindF2(length);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** COPY_CONSTRUCTOR_IMPL_2(VArc, VAbstractArc)
* @brief VArc copy constructor
* @param arc arc
*/
VArc::VArc(const VArc &arc)
: VAbstractArc(arc), d (arc.d)
{}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
@ -109,9 +104,9 @@ VArc::VArc(const VArc &arc)
* @param arc arc * @param arc arc
* @return arc * @return arc
*/ */
auto VArc::operator =(const VArc &arc) -> VArc & auto VArc::operator=(const VArc &arc) -> VArc &
{ {
if ( &arc == this ) if (&arc == this)
{ {
return *this; return *this;
} }
@ -123,8 +118,10 @@ auto VArc::operator =(const VArc &arc) -> VArc &
#ifdef Q_COMPILER_RVALUE_REFS #ifdef Q_COMPILER_RVALUE_REFS
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VArc::VArc(VArc &&arc) noexcept VArc::VArc(VArc &&arc) noexcept
: VAbstractArc(std::move(arc)), d (std::move(arc.d)) : VAbstractArc(std::move(arc)),
{} d(std::move(arc.d))
{
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VArc::operator=(VArc &&arc) noexcept -> VArc & auto VArc::operator=(VArc &&arc) noexcept -> VArc &
@ -214,8 +211,7 @@ auto VArc::Move(qreal length, qreal angle, const QString &prefix) const -> VArc
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VArc::~VArc() // NOLINT(hicpp-use-equals-default, modernize-use-equals-default) VArc::~VArc() = default;
{}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
@ -240,7 +236,7 @@ auto VArc::GetLength() const -> qreal
*/ */
auto VArc::GetP1() const -> QPointF auto VArc::GetP1() const -> QPointF
{ {
QPointF p1 ( GetCenter().x () + d->radius, GetCenter().y () ); QPointF p1(GetCenter().x() + d->radius, GetCenter().y());
QLineF centerP1(static_cast<QPointF>(GetCenter()), p1); QLineF centerP1(static_cast<QPointF>(GetCenter()), p1);
centerP1.setAngle(GetStartAngle()); centerP1.setAngle(GetStartAngle());
return centerP1.p2(); return centerP1.p2();
@ -251,9 +247,9 @@ auto VArc::GetP1() const -> QPointF
* @brief GetP2 return point associated with end angle. * @brief GetP2 return point associated with end angle.
* @return точку point. * @return точку point.
*/ */
auto VArc::GetP2 () const -> QPointF auto VArc::GetP2() const -> QPointF
{ {
QPointF p2 ( GetCenter().x () + d->radius, GetCenter().y () ); QPointF p2(GetCenter().x() + d->radius, GetCenter().y());
QLineF centerP2(static_cast<QPointF>(GetCenter()), p2); QLineF centerP2(static_cast<QPointF>(GetCenter()), p2);
centerP2.setAngle(GetEndAngle()); centerP2.setAngle(GetEndAngle());
return centerP2.p2(); return centerP2.p2();
@ -286,15 +282,15 @@ auto VArc::GetPoints() const -> QVector<QPointF>
} }
if (angle > 360 || angle < 0) if (angle > 360 || angle < 0)
{// Filter incorect value { // Filter incorect value
QLineF dummy(0,0, 100, 0); QLineF dummy(0, 0, 100, 0);
dummy.setAngle(angle); dummy.setAngle(angle);
angle = dummy.angle(); angle = dummy.angle();
} }
const qreal angleInterpolation = 45; //degree const qreal angleInterpolation = 45; // degree
const int sections = qFloor(angle / angleInterpolation); const int sections = qFloor(angle / angleInterpolation);
sectionAngle.reserve(sections+1); sectionAngle.reserve(sections + 1);
for (int i = 0; i < sections; ++i) for (int i = 0; i < sections; ++i)
{ {
sectionAngle.append(angleInterpolation); sectionAngle.append(angleInterpolation);
@ -309,7 +305,7 @@ auto VArc::GetPoints() const -> QVector<QPointF>
for (int i = 0; i < sectionAngle.size(); ++i) for (int i = 0; i < sectionAngle.size(); ++i)
{ {
const qreal lDistance = GetRadius() * 4.0/3.0 * qTan(qDegreesToRadians(sectionAngle.at(i)) * 0.25); const qreal lDistance = GetRadius() * 4.0 / 3.0 * qTan(qDegreesToRadians(sectionAngle.at(i)) * 0.25);
const QPointF center = static_cast<QPointF>(GetCenter()); const QPointF center = static_cast<QPointF>(GetCenter());
@ -319,7 +315,7 @@ auto VArc::GetPoints() const -> QVector<QPointF>
QLineF lineP4P3(center, pStart); QLineF lineP4P3(center, pStart);
lineP4P3.setAngle(lineP4P3.angle() + sectionAngle.at(i)); lineP4P3.setAngle(lineP4P3.angle() + sectionAngle.at(i));
lineP4P3.setLength(GetRadius());//in case of computing error lineP4P3.setLength(GetRadius()); // in case of computing error
lineP4P3 = QLineF(lineP4P3.p2(), center); lineP4P3 = QLineF(lineP4P3.p2(), center);
lineP4P3.setAngle(lineP4P3.angle() + 90.0); lineP4P3.setAngle(lineP4P3.angle() + 90.0);
lineP4P3.setLength(lDistance); lineP4P3.setLength(lDistance);
@ -349,7 +345,7 @@ auto VArc::GetPoints() const -> QVector<QPointF>
*/ */
auto VArc::CutArc(qreal length, VArc &arc1, VArc &arc2, const QString &pointName) const -> QPointF auto VArc::CutArc(qreal length, VArc &arc1, VArc &arc2, const QString &pointName) const -> QPointF
{ {
//Always need return two arcs, so we must correct wrong length. // Always need return two arcs, so we must correct wrong length.
const qreal fullLength = GetLength(); const qreal fullLength = GetLength();
if (qAbs(fullLength) < ToPixel(2, Unit::Mm)) if (qAbs(fullLength) < ToPixel(2, Unit::Mm))
@ -358,14 +354,15 @@ auto VArc::CutArc(qreal length, VArc &arc1, VArc &arc2, const QString &pointName
arc2 = VArc(); arc2 = VArc();
const QString errorMsg = tr("Unable to cut curve '%1'. The curve is too short.").arg(name()); const QString errorMsg = tr("Unable to cut curve '%1'. The curve is too short.").arg(name());
VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) : VAbstractApplication::VApp()->IsPedantic()
qWarning() << VAbstractApplication::warningMessageSignature + errorMsg; ? throw VException(errorMsg)
: qWarning() << VAbstractApplication::warningMessageSignature + errorMsg;
return {}; return {};
} }
QLineF line = not IsFlipped() ? CutPoint(length, fullLength, pointName) QLineF line =
: CutPointFlipped(length, fullLength, pointName); not IsFlipped() ? CutPoint(length, fullLength, pointName) : CutPointFlipped(length, fullLength, pointName);
arc1 = VArc(GetCenter(), d->radius, d->formulaRadius, GetStartAngle(), GetFormulaF1(), line.angle(), arc1 = VArc(GetCenter(), d->radius, d->formulaRadius, GetStartAngle(), GetFormulaF1(), line.angle(),
QString().setNum(line.angle()), getIdObject(), getMode()); QString().setNum(line.angle()), getIdObject(), getMode());
@ -379,7 +376,6 @@ auto VArc::CutArc(qreal length, VArc &arc1, VArc &arc2, const QString &pointName
return line.p2(); return line.p2();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VArc::CutArc(qreal length, const QString &pointName) const -> QPointF auto VArc::CutArc(qreal length, const QString &pointName) const -> QPointF
{ {
@ -434,7 +430,7 @@ void VArc::FindF2(qreal length)
length = MaxLength(); length = MaxLength();
} }
qreal arcAngle = qAbs(qRadiansToDegrees(length/d->radius)); qreal arcAngle = qAbs(qRadiansToDegrees(length / d->radius));
if (IsFlipped()) if (IsFlipped())
{ {
@ -442,7 +438,7 @@ void VArc::FindF2(qreal length)
} }
QLineF startAngle(0, 0, 100, 0); QLineF startAngle(0, 0, 100, 0);
startAngle.setAngle(GetStartAngle() + arcAngle);// We use QLineF just because it is easy way correct angle value startAngle.setAngle(GetStartAngle() + arcAngle); // We use QLineF just because it is easy way correct angle value
SetFormulaF2(QString::number(startAngle.angle()), startAngle.angle()); SetFormulaF2(QString::number(startAngle.angle()), startAngle.angle());
} }
@ -450,7 +446,7 @@ void VArc::FindF2(qreal length)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VArc::MaxLength() const -> qreal auto VArc::MaxLength() const -> qreal
{ {
return M_2PI*d->radius; return M_2PI * d->radius;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -469,15 +465,16 @@ auto VArc::CutPoint(qreal length, qreal fullLength, const QString &pointName) co
if (not pointName.isEmpty()) if (not pointName.isEmpty())
{ {
errorMsg = tr("Curve '%1'. Length of a cut segment (%2) is too small. Optimize it to minimal value.") errorMsg = tr("Curve '%1'. Length of a cut segment (%2) is too small. Optimize it to minimal value.")
.arg(name(), pointName); .arg(name(), pointName);
} }
else else
{ {
errorMsg = tr("Curve '%1'. Length of a cut segment is too small. Optimize it to minimal value.") errorMsg =
.arg(name()); tr("Curve '%1'. Length of a cut segment is too small. Optimize it to minimal value.").arg(name());
} }
VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) : VAbstractApplication::VApp()->IsPedantic()
qWarning() << VAbstractApplication::warningMessageSignature + errorMsg; ? throw VException(errorMsg)
: qWarning() << VAbstractApplication::warningMessageSignature + errorMsg;
} }
else if (length > maxLength) else if (length > maxLength)
{ {
@ -485,22 +482,22 @@ auto VArc::CutPoint(qreal length, qreal fullLength, const QString &pointName) co
if (not pointName.isEmpty()) if (not pointName.isEmpty())
{ {
errorMsg = tr("Curve '%1'. Length of a cut segment (%2) is too big. Optimize it to maximal value.") errorMsg = tr("Curve '%1'. Length of a cut segment (%2) is too big. Optimize it to maximal value.")
.arg(name(), pointName); .arg(name(), pointName);
} }
else else
{ {
errorMsg = tr("Curve '%1'. Length of a cut segment is too big. Optimize it to maximal value.") errorMsg = tr("Curve '%1'. Length of a cut segment is too big. Optimize it to maximal value.").arg(name());
.arg(name());
} }
VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) : VAbstractApplication::VApp()->IsPedantic()
qWarning() << VAbstractApplication::warningMessageSignature + errorMsg; ? throw VException(errorMsg)
: qWarning() << VAbstractApplication::warningMessageSignature + errorMsg;
} }
length = qBound(minLength, length, maxLength); length = qBound(minLength, length, maxLength);
QLineF line(static_cast<QPointF>(GetCenter()), GetP1()); QLineF line(static_cast<QPointF>(GetCenter()), GetP1());
line.setAngle(line.angle() + qRadiansToDegrees(length/d->radius)); line.setAngle(line.angle() + qRadiansToDegrees(length / d->radius));
return line; return line;
} }
@ -521,15 +518,16 @@ auto VArc::CutPointFlipped(qreal length, qreal fullLength, const QString &pointN
if (not pointName.isEmpty()) if (not pointName.isEmpty())
{ {
errorMsg = tr("Curve '%1'. Length of a cut segment (%2) is too small. Optimize it to minimal value.") errorMsg = tr("Curve '%1'. Length of a cut segment (%2) is too small. Optimize it to minimal value.")
.arg(name(), pointName); .arg(name(), pointName);
} }
else else
{ {
errorMsg = tr("Curve '%1'. Length of a cut segment is too small. Optimize it to minimal value.") errorMsg =
.arg(name()); tr("Curve '%1'. Length of a cut segment is too small. Optimize it to minimal value.").arg(name());
} }
VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) : VAbstractApplication::VApp()->IsPedantic()
qWarning() << VAbstractApplication::warningMessageSignature + errorMsg; ? throw VException(errorMsg)
: qWarning() << VAbstractApplication::warningMessageSignature + errorMsg;
} }
else if (length > maxLengthFlipped) else if (length > maxLengthFlipped)
{ {
@ -537,21 +535,21 @@ auto VArc::CutPointFlipped(qreal length, qreal fullLength, const QString &pointN
if (not pointName.isEmpty()) if (not pointName.isEmpty())
{ {
errorMsg = tr("Curve '%1'. Length of a cut segment (%2) is too big. Optimize it to maximal value.") errorMsg = tr("Curve '%1'. Length of a cut segment (%2) is too big. Optimize it to maximal value.")
.arg(name(), errorMsg); .arg(name(), errorMsg);
} }
else else
{ {
errorMsg = tr("Curve '%1'. Length of a cut segment is too big. Optimize it to maximal value.") errorMsg = tr("Curve '%1'. Length of a cut segment is too big. Optimize it to maximal value.").arg(name());
.arg(name());
} }
VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) : VAbstractApplication::VApp()->IsPedantic()
qWarning() << VAbstractApplication::warningMessageSignature + errorMsg; ? throw VException(errorMsg)
: qWarning() << VAbstractApplication::warningMessageSignature + errorMsg;
} }
length = qBound(minLengthFlipped, length, maxLengthFlipped); length = qBound(minLengthFlipped, length, maxLengthFlipped);
QLineF line(static_cast<QPointF>(GetCenter()), GetP1()); QLineF line(static_cast<QPointF>(GetCenter()), GetP1());
line.setAngle(line.angle() - qRadiansToDegrees(qAbs(length)/d->radius)); line.setAngle(line.angle() - qRadiansToDegrees(qAbs(length) / d->radius));
return line; return line;
} }

View file

@ -34,20 +34,19 @@
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VCubicBezier::VCubicBezier() VCubicBezier::VCubicBezier()
: VAbstractCubicBezier(GOType::CubicBezier), d(new VCubicBezierData) : VAbstractCubicBezier(GOType::CubicBezier),
d(new VCubicBezierData)
{ {
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VCubicBezier::VCubicBezier(const VCubicBezier &curve) COPY_CONSTRUCTOR_IMPL_2(VCubicBezier, VAbstractCubicBezier)
: VAbstractCubicBezier(curve), d(curve.d)
{
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VCubicBezier::VCubicBezier(const VPointF &p1, const VPointF &p2, const VPointF &p3, const VPointF &p4, quint32 idObject, VCubicBezier::VCubicBezier(const VPointF &p1, const VPointF &p2, const VPointF &p3, const VPointF &p4, quint32 idObject,
Draw mode) Draw mode)
: VAbstractCubicBezier(GOType::CubicBezier, idObject, mode), d(new VCubicBezierData(p1, p2, p3, p4)) : VAbstractCubicBezier(GOType::CubicBezier, idObject, mode),
d(new VCubicBezierData(p1, p2, p3, p4))
{ {
CreateName(); CreateName();
} }
@ -55,7 +54,7 @@ VCubicBezier::VCubicBezier(const VPointF &p1, const VPointF &p2, const VPointF &
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VCubicBezier::operator=(const VCubicBezier &curve) -> VCubicBezier & auto VCubicBezier::operator=(const VCubicBezier &curve) -> VCubicBezier &
{ {
if ( &curve == this ) if (&curve == this)
{ {
return *this; return *this;
} }
@ -67,11 +66,13 @@ auto VCubicBezier::operator=(const VCubicBezier &curve) -> VCubicBezier &
#ifdef Q_COMPILER_RVALUE_REFS #ifdef Q_COMPILER_RVALUE_REFS
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VCubicBezier::VCubicBezier(VCubicBezier &&curve) noexcept VCubicBezier::VCubicBezier(VCubicBezier &&curve) noexcept
: VAbstractCubicBezier(std::move(curve)), d(std::move(curve.d)) : VAbstractCubicBezier(std::move(curve)),
{} d(std::move(curve.d))
{
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VCubicBezier::operator=(VCubicBezier &&curve) noexcept->VCubicBezier & auto VCubicBezier::operator=(VCubicBezier &&curve) noexcept -> VCubicBezier &
{ {
VAbstractCubicBezier::operator=(curve); VAbstractCubicBezier::operator=(curve);
std::swap(d, curve.d); std::swap(d, curve.d);
@ -143,9 +144,7 @@ auto VCubicBezier::Move(qreal length, qreal angle, const QString &prefix) const
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VCubicBezier::~VCubicBezier() VCubicBezier::~VCubicBezier() = default;
{
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VCubicBezier::GetP1() const -> VPointF auto VCubicBezier::GetP1() const -> VPointF
@ -214,8 +213,8 @@ auto VCubicBezier::GetEndAngle() const -> qreal
*/ */
auto VCubicBezier::GetLength() const -> qreal auto VCubicBezier::GetLength() const -> qreal
{ {
return LengthBezier (static_cast<QPointF>(GetP1()), static_cast<QPointF>(GetP2()), return LengthBezier(static_cast<QPointF>(GetP1()), static_cast<QPointF>(GetP2()), static_cast<QPointF>(GetP3()),
static_cast<QPointF>(GetP3()), static_cast<QPointF>(GetP4()), GetApproximationScale()); static_cast<QPointF>(GetP4()), GetApproximationScale());
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -256,6 +255,6 @@ auto VCubicBezier::GetControlPoint2() const -> QPointF
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VCubicBezier::GetRealLength() const -> qreal auto VCubicBezier::GetRealLength() const -> qreal
{ {
return LengthBezier (static_cast<QPointF>(GetP1()), static_cast<QPointF>(GetP2()), return LengthBezier(static_cast<QPointF>(GetP1()), static_cast<QPointF>(GetP2()), static_cast<QPointF>(GetP3()),
static_cast<QPointF>(GetP3()), static_cast<QPointF>(GetP4()), maxCurveApproximationScale); static_cast<QPointF>(GetP4()), maxCurveApproximationScale);
} }

View file

@ -51,7 +51,7 @@ public:
auto Rotate(const QPointF &originPoint, qreal degrees, const QString &prefix = QString()) const -> VCubicBezier; auto Rotate(const QPointF &originPoint, qreal degrees, const QString &prefix = QString()) const -> VCubicBezier;
auto Flip(const QLineF &axis, const QString &prefix = QString()) const -> VCubicBezier; auto Flip(const QLineF &axis, const QString &prefix = QString()) const -> VCubicBezier;
auto Move(qreal length, qreal angle, const QString &prefix = QString()) const -> VCubicBezier; auto Move(qreal length, qreal angle, const QString &prefix = QString()) const -> VCubicBezier;
virtual ~VCubicBezier(); ~VCubicBezier() override;
auto operator=(const VCubicBezier &curve) -> VCubicBezier &; auto operator=(const VCubicBezier &curve) -> VCubicBezier &;
#ifdef Q_COMPILER_RVALUE_REFS #ifdef Q_COMPILER_RVALUE_REFS
@ -59,29 +59,29 @@ public:
auto operator=(VCubicBezier &&curve) noexcept -> VCubicBezier &; auto operator=(VCubicBezier &&curve) noexcept -> VCubicBezier &;
#endif #endif
virtual auto GetP1() const -> VPointF override; auto GetP1() const -> VPointF override;
void SetP1(const VPointF &p); void SetP1(const VPointF &p);
virtual auto GetP2() const -> VPointF override; auto GetP2() const -> VPointF override;
void SetP2(const VPointF &p); void SetP2(const VPointF &p);
virtual auto GetP3() const -> VPointF override; auto GetP3() const -> VPointF override;
void SetP3(const VPointF &p); void SetP3(const VPointF &p);
virtual auto GetP4() const -> VPointF override; auto GetP4() const -> VPointF override;
void SetP4(const VPointF &p); void SetP4(const VPointF &p);
virtual auto GetStartAngle() const -> qreal override; auto GetStartAngle() const -> qreal override;
virtual auto GetEndAngle() const -> qreal override; auto GetEndAngle() const -> qreal override;
virtual auto GetLength() const -> qreal override; auto GetLength() const -> qreal override;
virtual auto GetPoints() const -> QVector<QPointF> override; auto GetPoints() const -> QVector<QPointF> override;
virtual auto GetC1Length() const -> qreal override; auto GetC1Length() const -> qreal override;
virtual auto GetC2Length() const -> qreal override; auto GetC2Length() const -> qreal override;
protected: protected:
virtual auto GetControlPoint1() const -> QPointF override; auto GetControlPoint1() const -> QPointF override;
virtual auto GetControlPoint2() const -> QPointF override; auto GetControlPoint2() const -> QPointF override;
auto GetRealLength() const -> qreal override; auto GetRealLength() const -> qreal override;
private: private:

View file

@ -47,7 +47,7 @@ VCubicBezierPath::VCubicBezierPath(quint32 idObject, Draw mode)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VCubicBezierPath::VCubicBezierPath(const VCubicBezierPath &curve) = default; COPY_CONSTRUCTOR_IMPL_2(VCubicBezierPath, VAbstractCubicBezierPath)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VCubicBezierPath::VCubicBezierPath(const QVector<VPointF> &points, quint32 idObject, Draw mode) VCubicBezierPath::VCubicBezierPath(const QVector<VPointF> &points, quint32 idObject, Draw mode)

View file

@ -49,11 +49,11 @@ class VCubicBezierPath final : public VAbstractCubicBezierPath
public: public:
explicit VCubicBezierPath(quint32 idObject = 0, Draw mode = Draw::Calculation); explicit VCubicBezierPath(quint32 idObject = 0, Draw mode = Draw::Calculation);
VCubicBezierPath(const VCubicBezierPath &curve); VCubicBezierPath(const VCubicBezierPath &curve);
VCubicBezierPath(const QVector<VPointF> &points, quint32 idObject = 0, Draw mode = Draw::Calculation); explicit VCubicBezierPath(const QVector<VPointF> &points, quint32 idObject = 0, Draw mode = Draw::Calculation);
auto Rotate(const QPointF &originPoint, qreal degrees, const QString &prefix = QString()) const -> VCubicBezierPath; auto Rotate(const QPointF &originPoint, qreal degrees, const QString &prefix = QString()) const -> VCubicBezierPath;
auto Flip(const QLineF &axis, const QString &prefix = QString()) const -> VCubicBezierPath; auto Flip(const QLineF &axis, const QString &prefix = QString()) const -> VCubicBezierPath;
auto Move(qreal length, qreal angle, const QString &prefix = QString()) const -> VCubicBezierPath; auto Move(qreal length, qreal angle, const QString &prefix = QString()) const -> VCubicBezierPath;
virtual ~VCubicBezierPath(); ~VCubicBezierPath() override;
auto operator=(const VCubicBezierPath &curve) -> VCubicBezierPath &; auto operator=(const VCubicBezierPath &curve) -> VCubicBezierPath &;
#ifdef Q_COMPILER_RVALUE_REFS #ifdef Q_COMPILER_RVALUE_REFS
@ -67,17 +67,17 @@ public:
void append(const VPointF &point); void append(const VPointF &point);
virtual auto CountSubSpl() const -> vsizetype override; auto CountSubSpl() const -> vsizetype override;
virtual auto CountPoints() const -> vsizetype override; auto CountPoints() const -> vsizetype override;
virtual void Clear() override; void Clear() override;
virtual auto GetSpline(vsizetype index) const -> VSpline override; auto GetSpline(vsizetype index) const -> VSpline override;
virtual auto GetStartAngle() const -> qreal override; auto GetStartAngle() const -> qreal override;
virtual auto GetEndAngle() const -> qreal override; auto GetEndAngle() const -> qreal override;
virtual auto GetC1Length() const -> qreal override; auto GetC1Length() const -> qreal override;
virtual auto GetC2Length() const -> qreal override; auto GetC2Length() const -> qreal override;
virtual auto GetSplinePath() const -> QVector<VSplinePoint> override; auto GetSplinePath() const -> QVector<VSplinePoint> override;
auto GetCubicPath() const -> QVector<VPointF>; auto GetCubicPath() const -> QVector<VPointF>;
static auto CountSubSpl(vsizetype size) -> vsizetype; static auto CountSubSpl(vsizetype size) -> vsizetype;
@ -85,8 +85,8 @@ public:
static auto SubSplPointsCount(vsizetype countSubSpl) -> vsizetype; static auto SubSplPointsCount(vsizetype countSubSpl) -> vsizetype;
protected: protected:
virtual auto FirstPoint() const -> VPointF override; auto FirstPoint() const -> VPointF override;
virtual auto LastPoint() const -> VPointF override; auto LastPoint() const -> VPointF override;
private: private:
QSharedDataPointer<VCubicBezierPathData> d; QSharedDataPointer<VCubicBezierPathData> d;

View file

@ -29,24 +29,24 @@
#include "vellipticalarc.h" #include "vellipticalarc.h"
#include <QLineF> #include <QLineF>
#include <QPoint>
#include <QPainterPath> #include <QPainterPath>
#include <QPoint>
#include <QtDebug> #include <QtDebug>
#include "../vmisc/def.h"
#include "../ifc/ifcdef.h"
#include "../ifc/exception/vexception.h" #include "../ifc/exception/vexception.h"
#include "../vmisc/vabstractapplication.h" #include "../ifc/ifcdef.h"
#include "../vmisc/compatibility.h"
#include "../vmisc/def.h"
#include "../vmisc/fpm/fixed.hpp" #include "../vmisc/fpm/fixed.hpp"
#include "../vmisc/fpm/math.hpp" #include "../vmisc/fpm/math.hpp"
#include "../vmisc/compatibility.h" #include "../vmisc/vabstractapplication.h"
#include "../vmisc/vmath.h"
#include "vabstractcurve.h" #include "vabstractcurve.h"
#include "vellipticalarc_p.h" #include "vellipticalarc_p.h"
#include "../vmisc/vmath.h"
namespace namespace
{ {
constexpr qreal tolerance = accuracyPointOnLine/8; constexpr qreal tolerance = accuracyPointOnLine / 8;
// Because of overflow we cannot generate arcs more than maxRadius // Because of overflow we cannot generate arcs more than maxRadius
constexpr int maxRadius = 10000; constexpr int maxRadius = 10000;
@ -58,10 +58,10 @@ auto VLen(fpm::fixed_16_16 x, fpm::fixed_16_16 y) -> fpm::fixed_16_16
y = fpm::abs(y); y = fpm::abs(y);
if (x > y) if (x > y)
{ {
return x + qMax(y/8, y/2 - x/8); return x + qMax(y / 8, y / 2 - x / 8);
} }
return y + qMax(x/8, x/2 - y/8); return y + qMax(x / 8, x / 2 - y / 8);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -73,7 +73,7 @@ auto AuxRadius(fpm::fixed_16_16 xP, fpm::fixed_16_16 yP, fpm::fixed_16_16 xQ, fp
fpm::fixed_16_16 dK = VLen(xP - xQ, yP - yQ); fpm::fixed_16_16 dK = VLen(xP - xQ, yP - yQ);
fpm::fixed_16_16 r1 = qMax(dP, dQ); fpm::fixed_16_16 r1 = qMax(dP, dQ);
fpm::fixed_16_16 r2 = qMax(dJ, dK); fpm::fixed_16_16 r2 = qMax(dJ, dK);
return qMax(r1 + r1/16, r2 - r2/4); return qMax(r1 + r1 / 16, r2 - r2 / 4);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -100,7 +100,7 @@ auto AngularInc(fpm::fixed_16_16 xP, fpm::fixed_16_16 yP, fpm::fixed_16_16 xQ, f
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
inline void CircleGen(fpm::fixed_16_16& u, fpm::fixed_16_16& v, uint k) inline void CircleGen(fpm::fixed_16_16 &u, fpm::fixed_16_16 &v, uint k)
{ {
u -= v >> k; u -= v >> k;
v += u >> k; v += u >> k;
@ -109,8 +109,8 @@ inline void CircleGen(fpm::fixed_16_16& u, fpm::fixed_16_16& v, uint k)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto InitialValue(fpm::fixed_16_16 u0, fpm::fixed_16_16 v0, uint k) -> fpm::fixed_16_16 auto InitialValue(fpm::fixed_16_16 u0, fpm::fixed_16_16 v0, uint k) -> fpm::fixed_16_16
{ {
uint shift = 2*k + 3; uint shift = 2 * k + 3;
fpm::fixed_16_16 w {u0 >> shift}; fpm::fixed_16_16 w{u0 >> shift};
fpm::fixed_16_16 U0 = u0 - w + (v0 >> (k + 1)); fpm::fixed_16_16 U0 = u0 - w + (v0 >> (k + 1));
w >>= (shift + 1); w >>= (shift + 1);
@ -122,8 +122,8 @@ auto InitialValue(fpm::fixed_16_16 u0, fpm::fixed_16_16 v0, uint k) -> fpm::fixe
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto EllipseCore(fpm::fixed_16_16 xC, fpm::fixed_16_16 yC, fpm::fixed_16_16 xP, fpm::fixed_16_16 yP, auto EllipseCore(fpm::fixed_16_16 xC, fpm::fixed_16_16 yC, fpm::fixed_16_16 xP, fpm::fixed_16_16 yP,
fpm::fixed_16_16 xQ, fpm::fixed_16_16 yQ, fpm::fixed_16_16 sweep, fpm::fixed_16_16 xQ, fpm::fixed_16_16 yQ, fpm::fixed_16_16 sweep, fpm::fixed_16_16 flatness)
fpm::fixed_16_16 flatness) -> QVector<QPointF> -> QVector<QPointF>
{ {
uint k = qMin(static_cast<uint>(AngularInc(xP, yP, xQ, yQ, flatness)), 16U); uint k = qMin(static_cast<uint>(AngularInc(xP, yP, xQ, yQ, flatness)), 16U);
const uint count = static_cast<std::uint32_t>(sweep.raw_value()) >> (16 - k); const uint count = static_cast<std::uint32_t>(sweep.raw_value()) >> (16 - k);
@ -148,8 +148,8 @@ auto EllipseCore(fpm::fixed_16_16 xC, fpm::fixed_16_16 yC, fpm::fixed_16_16 xP,
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto EllipticArcPoints(QPointF c, qreal radius1, qreal radius2, qreal astart, qreal asweep, auto EllipticArcPoints(QPointF c, qreal radius1, qreal radius2, qreal astart, qreal asweep, qreal approximationScale)
qreal approximationScale) -> QVector<QPointF> -> QVector<QPointF>
{ {
fpm::fixed_16_16 xC{c.x()}; fpm::fixed_16_16 xC{c.x()};
fpm::fixed_16_16 yC{c.y()}; fpm::fixed_16_16 yC{c.y()};
@ -168,10 +168,10 @@ auto EllipticArcPoints(QPointF c, qreal radius1, qreal radius2, qreal astart, qr
if (not qFuzzyIsNull(astart)) if (not qFuzzyIsNull(astart))
{ {
// Set new conjugate diameter end points P and Q // Set new conjugate diameter end points P and Q
fpm::fixed_16_16 cosa {cos(astart)}; fpm::fixed_16_16 cosa{cos(astart)};
fpm::fixed_16_16 sina {sin(astart)}; fpm::fixed_16_16 sina{sin(astart)};
fpm::fixed_16_16 x {xP * cosa + xQ * sina}; fpm::fixed_16_16 x{xP * cosa + xQ * sina};
fpm::fixed_16_16 y {yP * cosa + yQ * sina}; fpm::fixed_16_16 y{yP * cosa + yQ * sina};
xQ = xQ * cosa - xP * sina; xQ = xQ * cosa - xP * sina;
yQ = yQ * cosa - yP * sina; yQ = yQ * cosa - yP * sina;
@ -187,21 +187,21 @@ auto EllipticArcPoints(QPointF c, qreal radius1, qreal radius2, qreal astart, qr
asweep = -asweep; asweep = -asweep;
} }
if(approximationScale < minCurveApproximationScale || approximationScale > maxCurveApproximationScale) if (approximationScale < minCurveApproximationScale || approximationScale > maxCurveApproximationScale)
{ {
approximationScale = VAbstractApplication::VApp()->Settings()->GetCurveApproximationScale(); approximationScale = VAbstractApplication::VApp()->Settings()->GetCurveApproximationScale();
} }
fpm::fixed_16_16 flatness {maxCurveApproximationScale / approximationScale * tolerance}; fpm::fixed_16_16 flatness{maxCurveApproximationScale / approximationScale * tolerance};
fpm::fixed_16_16 swangle{asweep}; fpm::fixed_16_16 swangle{asweep};
QVector<QPointF> arc = EllipseCore(xC, yC, xP, yP, xQ, yQ, swangle, flatness); QVector<QPointF> arc = EllipseCore(xC, yC, xP, yP, xQ, yQ, swangle, flatness);
// Arc end point // Arc end point
fpm::fixed_16_16 cosb {qCos(asweep)}; fpm::fixed_16_16 cosb{qCos(asweep)};
fpm::fixed_16_16 sinb {qSin(asweep)}; fpm::fixed_16_16 sinb{qSin(asweep)};
xP = xP*cosb + xQ*sinb; xP = xP * cosb + xQ * sinb;
yP = yP*cosb + yQ*sinb; yP = yP * cosb + yQ * sinb;
arc.append({static_cast<qreal>(xP+xC), static_cast<qreal>(yP+yC)}); arc.append({static_cast<qreal>(xP + xC), static_cast<qreal>(yP + yC)});
return arc; return arc;
} }
@ -226,15 +226,17 @@ auto JoinVectors(const QVector<QPointF> &v1, const QVector<QPointF> &v2) -> QVec
return v; return v;
} }
} // namespace } // namespace
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief VEllipticalArc default constructor. * @brief VEllipticalArc default constructor.
*/ */
VEllipticalArc::VEllipticalArc() VEllipticalArc::VEllipticalArc()
: VAbstractArc(GOType::EllipticalArc), d (new VEllipticalArcData) : VAbstractArc(GOType::EllipticalArc),
{} d(new VEllipticalArcData)
{
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
@ -245,12 +247,12 @@ VEllipticalArc::VEllipticalArc()
* @param f1 start angle (degree). * @param f1 start angle (degree).
* @param f2 end angle (degree). * @param f2 end angle (degree).
*/ */
VEllipticalArc::VEllipticalArc (const VPointF &center, qreal radius1, qreal radius2, const QString &formulaRadius1, VEllipticalArc::VEllipticalArc(const VPointF &center, qreal radius1, qreal radius2, const QString &formulaRadius1,
const QString &formulaRadius2, qreal f1, const QString &formulaF1, qreal f2, const QString &formulaRadius2, qreal f1, const QString &formulaF1, qreal f2,
const QString &formulaF2, qreal rotationAngle, const QString &formulaRotationAngle, const QString &formulaF2, qreal rotationAngle, const QString &formulaRotationAngle,
quint32 idObject, Draw mode) quint32 idObject, Draw mode)
: VAbstractArc(GOType::EllipticalArc, center, f1, formulaF1, f2, formulaF2, idObject, mode), : VAbstractArc(GOType::EllipticalArc, center, f1, formulaF1, f2, formulaF2, idObject, mode),
d (new VEllipticalArcData(radius1, radius2, formulaRadius1, formulaRadius2, rotationAngle, formulaRotationAngle)) d(new VEllipticalArcData(radius1, radius2, formulaRadius1, formulaRadius2, rotationAngle, formulaRotationAngle))
{ {
CreateName(); CreateName();
} }
@ -258,8 +260,8 @@ VEllipticalArc::VEllipticalArc (const VPointF &center, qreal radius1, qreal radi
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VEllipticalArc::VEllipticalArc(const VPointF &center, qreal radius1, qreal radius2, qreal f1, qreal f2, VEllipticalArc::VEllipticalArc(const VPointF &center, qreal radius1, qreal radius2, qreal f1, qreal f2,
qreal rotationAngle) qreal rotationAngle)
: VAbstractArc(GOType::EllipticalArc, center, f1, f2, NULL_ID, Draw::Calculation), : VAbstractArc(GOType::EllipticalArc, center, f1, f2, NULL_ID, Draw::Calculation),
d (new VEllipticalArcData(radius1, radius2, rotationAngle)) d(new VEllipticalArcData(radius1, radius2, rotationAngle))
{ {
CreateName(); CreateName();
} }
@ -269,8 +271,8 @@ VEllipticalArc::VEllipticalArc(qreal length, const QString &formulaLength, const
qreal radius2, const QString &formulaRadius1, const QString &formulaRadius2, qreal f1, qreal radius2, const QString &formulaRadius1, const QString &formulaRadius2, qreal f1,
const QString &formulaF1, qreal rotationAngle, const QString &formulaRotationAngle, const QString &formulaF1, qreal rotationAngle, const QString &formulaRotationAngle,
quint32 idObject, Draw mode) quint32 idObject, Draw mode)
: VAbstractArc(GOType::EllipticalArc, formulaLength, center, f1, formulaF1, idObject, mode), : VAbstractArc(GOType::EllipticalArc, formulaLength, center, f1, formulaF1, idObject, mode),
d (new VEllipticalArcData(radius1, radius2, formulaRadius1, formulaRadius2, rotationAngle, formulaRotationAngle)) d(new VEllipticalArcData(radius1, radius2, formulaRadius1, formulaRadius2, rotationAngle, formulaRotationAngle))
{ {
CreateName(); CreateName();
FindF2(length); FindF2(length);
@ -279,8 +281,8 @@ VEllipticalArc::VEllipticalArc(qreal length, const QString &formulaLength, const
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VEllipticalArc::VEllipticalArc(qreal length, const VPointF &center, qreal radius1, qreal radius2, qreal f1, VEllipticalArc::VEllipticalArc(qreal length, const VPointF &center, qreal radius1, qreal radius2, qreal f1,
qreal rotationAngle) qreal rotationAngle)
: VAbstractArc(GOType::EllipticalArc, center, f1, NULL_ID, Draw::Calculation), : VAbstractArc(GOType::EllipticalArc, center, f1, NULL_ID, Draw::Calculation),
d (new VEllipticalArcData(radius1, radius2, rotationAngle)) d(new VEllipticalArcData(radius1, radius2, rotationAngle))
{ {
CreateName(); CreateName();
FindF2(length); FindF2(length);
@ -288,13 +290,7 @@ VEllipticalArc::VEllipticalArc(qreal length, const VPointF &center, qreal radius
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** COPY_CONSTRUCTOR_IMPL_2(VEllipticalArc, VAbstractArc)
* @brief VEllipticalArc copy constructor
* @param arc arc
*/
VEllipticalArc::VEllipticalArc(const VEllipticalArc &arc)
: VAbstractArc(arc), d (arc.d)
{}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
@ -302,9 +298,9 @@ VEllipticalArc::VEllipticalArc(const VEllipticalArc &arc)
* @param arc arc * @param arc arc
* @return arc * @return arc
*/ */
auto VEllipticalArc::operator =(const VEllipticalArc &arc) -> VEllipticalArc & auto VEllipticalArc::operator=(const VEllipticalArc &arc) -> VEllipticalArc &
{ {
if ( &arc == this ) if (&arc == this)
{ {
return *this; return *this;
} }
@ -316,9 +312,10 @@ auto VEllipticalArc::operator =(const VEllipticalArc &arc) -> VEllipticalArc &
#ifdef Q_COMPILER_RVALUE_REFS #ifdef Q_COMPILER_RVALUE_REFS
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VEllipticalArc::VEllipticalArc(VEllipticalArc &&arc) noexcept VEllipticalArc::VEllipticalArc(VEllipticalArc &&arc) noexcept
: VAbstractArc(std::move(arc)), : VAbstractArc(std::move(arc)),
d(std::move(arc.d)) d(std::move(arc.d))
{} {
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VEllipticalArc::operator=(VEllipticalArc &&arc) noexcept -> VEllipticalArc & auto VEllipticalArc::operator=(VEllipticalArc &&arc) noexcept -> VEllipticalArc &
@ -382,8 +379,8 @@ auto VEllipticalArc::Move(qreal length, qreal angle, const QString &prefix) cons
const VPointF oldCenter = VAbstractArc::GetCenter(); const VPointF oldCenter = VAbstractArc::GetCenter();
const VPointF center = oldCenter.Move(length, angle); const VPointF center = oldCenter.Move(length, angle);
const QPointF position = d->m_transform.inverted().map(center.toQPointF()) - const QPointF position =
d->m_transform.inverted().map(oldCenter.toQPointF()); d->m_transform.inverted().map(center.toQPointF()) - d->m_transform.inverted().map(oldCenter.toQPointF());
QTransform t = d->m_transform; QTransform t = d->m_transform;
t.translate(position.x(), position.y()); t.translate(position.x(), position.y());
@ -406,8 +403,7 @@ auto VEllipticalArc::Move(qreal length, qreal angle, const QString &prefix) cons
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VEllipticalArc::~VEllipticalArc() // NOLINT(hicpp-use-equals-default, modernize-use-equals-default) VEllipticalArc::~VEllipticalArc() = default;
{}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
@ -441,7 +437,7 @@ auto VEllipticalArc::GetP1() const -> QPointF
* @brief GetP2 return point associated with end angle. * @brief GetP2 return point associated with end angle.
* @return point. * @return point.
*/ */
auto VEllipticalArc::GetP2 () const -> QPointF auto VEllipticalArc::GetP2() const -> QPointF
{ {
return GetTransform().map(GetP(VAbstractArc::GetEndAngle())); return GetTransform().map(GetP(VAbstractArc::GetEndAngle()));
} }
@ -534,7 +530,7 @@ auto VEllipticalArc::GetEndAngle() const -> qreal
auto VEllipticalArc::CutArc(const qreal &length, VEllipticalArc &arc1, VEllipticalArc &arc2, auto VEllipticalArc::CutArc(const qreal &length, VEllipticalArc &arc1, VEllipticalArc &arc2,
const QString &pointName) const -> QPointF const QString &pointName) const -> QPointF
{ {
//Always need return two arcs, so we must correct wrong length. // Always need return two arcs, so we must correct wrong length.
qreal len = 0; qreal len = 0;
const qreal fullLength = GetLength(); const qreal fullLength = GetLength();
@ -544,8 +540,9 @@ auto VEllipticalArc::CutArc(const qreal &length, VEllipticalArc &arc1, VElliptic
arc2 = VEllipticalArc(); arc2 = VEllipticalArc();
const QString errorMsg = QObject::tr("Unable to cut curve '%1'. The curve is too short.").arg(name()); const QString errorMsg = QObject::tr("Unable to cut curve '%1'. The curve is too short.").arg(name());
VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) : VAbstractApplication::VApp()->IsPedantic()
qWarning() << VAbstractApplication::warningMessageSignature + errorMsg; ? throw VException(errorMsg)
: qWarning() << VAbstractApplication::warningMessageSignature + errorMsg;
return {}; return {};
} }
@ -560,15 +557,17 @@ auto VEllipticalArc::CutArc(const qreal &length, VEllipticalArc &arc1, VElliptic
if (not pointName.isEmpty()) if (not pointName.isEmpty())
{ {
errorMsg = QObject::tr("Curve '%1'. Length of a cut segment (%2) is too small. Optimize it to minimal " errorMsg = QObject::tr("Curve '%1'. Length of a cut segment (%2) is too small. Optimize it to minimal "
"value.").arg(name(), pointName); "value.")
.arg(name(), pointName);
} }
else else
{ {
errorMsg = QObject::tr("Curve '%1'. Length of a cut segment is too small. Optimize it to minimal value.") errorMsg = QObject::tr("Curve '%1'. Length of a cut segment is too small. Optimize it to minimal value.")
.arg(name()); .arg(name());
} }
VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) : VAbstractApplication::VApp()->IsPedantic()
qWarning() << VAbstractApplication::warningMessageSignature + errorMsg; ? throw VException(errorMsg)
: qWarning() << VAbstractApplication::warningMessageSignature + errorMsg;
} }
else if (length > maxLength) else if (length > maxLength)
{ {
@ -585,8 +584,9 @@ auto VEllipticalArc::CutArc(const qreal &length, VEllipticalArc &arc1, VElliptic
errorMsg = QObject::tr("Curve '%1'. Length of a cut segment is too big. Optimize it to maximal value.") errorMsg = QObject::tr("Curve '%1'. Length of a cut segment is too big. Optimize it to maximal value.")
.arg(name()); .arg(name());
} }
VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) : VAbstractApplication::VApp()->IsPedantic()
qWarning() << VAbstractApplication::warningMessageSignature + errorMsg; ? throw VException(errorMsg)
: qWarning() << VAbstractApplication::warningMessageSignature + errorMsg;
} }
else else
{ {
@ -594,18 +594,17 @@ auto VEllipticalArc::CutArc(const qreal &length, VEllipticalArc &arc1, VElliptic
} }
// the first arc has given length and startAngle just like in the origin arc // the first arc has given length and startAngle just like in the origin arc
arc1 = VEllipticalArc (len, QString().setNum(length), GetCenter(), d->radius1, d->radius2, arc1 = VEllipticalArc(len, QString().setNum(length), GetCenter(), d->radius1, d->radius2, d->formulaRadius1,
d->formulaRadius1, d->formulaRadius2, GetStartAngle(), GetFormulaF1(), d->rotationAngle, d->formulaRadius2, GetStartAngle(), GetFormulaF1(), d->rotationAngle,
GetFormulaRotationAngle(), getIdObject(), getMode()); GetFormulaRotationAngle(), getIdObject(), getMode());
// the second arc has startAngle just like endAngle of the first arc // the second arc has startAngle just like endAngle of the first arc
// and it has endAngle just like endAngle of the origin arc // and it has endAngle just like endAngle of the origin arc
arc2 = VEllipticalArc (GetCenter(), d->radius1, d->radius2, d->formulaRadius1, d->formulaRadius2, arc2 = VEllipticalArc(GetCenter(), d->radius1, d->radius2, d->formulaRadius1, d->formulaRadius2, arc1.GetEndAngle(),
arc1.GetEndAngle(), arc1.GetFormulaF2(), GetEndAngle(), GetFormulaF2(), d->rotationAngle, arc1.GetFormulaF2(), GetEndAngle(), GetFormulaF2(), d->rotationAngle,
GetFormulaRotationAngle(), getIdObject(), getMode()); GetFormulaRotationAngle(), getIdObject(), getMode());
return arc1.GetP1(); return arc1.GetP1();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VEllipticalArc::CutArc(const qreal &length, const QString &pointName) const -> QPointF auto VEllipticalArc::CutArc(const qreal &length, const QString &pointName) const -> QPointF
{ {
@ -681,7 +680,7 @@ void VEllipticalArc::FindF2(qreal length)
while (qAbs(lenBez - length) > eps) while (qAbs(lenBez - length) > eps)
{ {
gap = gap/2; gap = gap / 2;
if (gap < 0.0001) if (gap < 0.0001)
{ {
break; break;
@ -705,7 +704,7 @@ void VEllipticalArc::FindF2(qreal length)
auto VEllipticalArc::MaxLength() const -> qreal auto VEllipticalArc::MaxLength() const -> qreal
{ {
const qreal h = qPow(d->radius1 - d->radius2, 2) / qPow(d->radius1 + d->radius2, 2); const qreal h = qPow(d->radius1 - d->radius2, 2) / qPow(d->radius1 + d->radius2, 2);
const qreal ellipseLength = M_PI * (d->radius1 + d->radius2) * (1+3*h/(10+qSqrt(4-3*h))); const qreal ellipseLength = M_PI * (d->radius1 + d->radius2) * (1 + 3 * h / (10 + qSqrt(4 - 3 * h)));
return ellipseLength; return ellipseLength;
} }
@ -722,7 +721,7 @@ auto VEllipticalArc::GetP(qreal angle) const -> QPointF
const qreal a = not qFuzzyIsNull(GetRadius1()) ? line.p2().x() / GetRadius1() : 0; const qreal a = not qFuzzyIsNull(GetRadius1()) ? line.p2().x() / GetRadius1() : 0;
const qreal b = not qFuzzyIsNull(GetRadius2()) ? line.p2().y() / GetRadius2() : 0; const qreal b = not qFuzzyIsNull(GetRadius2()) ? line.p2().y() / GetRadius2() : 0;
const qreal k = qSqrt(a*a + b*b); const qreal k = qSqrt(a * a + b * b);
if (qFuzzyIsNull(k)) if (qFuzzyIsNull(k))
{ {
@ -755,22 +754,22 @@ auto VEllipticalArc::ArcPoints(QVector<QPointF> points) const -> QVector<QPointF
QLineF end(center.x(), center.y(), center.x() + radius, center.y()); QLineF end(center.x(), center.y(), center.x() + radius, center.y());
end.setAngle(VAbstractArc::GetEndAngle()); end.setAngle(VAbstractArc::GetEndAngle());
auto IsBoundedIntersection = [](QLineF::IntersectType type, QPointF p, const QLineF &segment1, auto IsBoundedIntersection =
const QLineF &segment2) [](QLineF::IntersectType type, QPointF p, const QLineF &segment1, const QLineF &segment2)
{ {
return type == QLineF::BoundedIntersection || return type == QLineF::BoundedIntersection ||
(type == QLineF::UnboundedIntersection && (type == QLineF::UnboundedIntersection &&
VGObject::IsPointOnLineSegment (p, segment1.p1(), segment2.p1()) && VGObject::IsPointOnLineSegment(p, segment1.p1(), segment2.p1()) &&
VGObject::IsPointOnLineSegment (p, segment2.p1(), segment2.p2())); VGObject::IsPointOnLineSegment(p, segment2.p1(), segment2.p2()));
}; };
bool begin = true; bool begin = true;
if (start.angle() >= end.angle()) if (start.angle() >= end.angle())
{ {
for (int i=0; i < points.size()-1; ++i) for (int i = 0; i < points.size() - 1; ++i)
{ {
QLineF edge(points.at(i), points.at(i+1)); QLineF edge(points.at(i), points.at(i + 1));
QPointF p; QPointF p;
QLineF::IntersectType type = Intersects(start, edge, &p); QLineF::IntersectType type = Intersects(start, edge, &p);
@ -778,8 +777,8 @@ auto VEllipticalArc::ArcPoints(QVector<QPointF> points) const -> QVector<QPointF
// QLineF::intersects not always accurate on edge cases // QLineF::intersects not always accurate on edge cases
if (IsBoundedIntersection(type, p, edge, start)) if (IsBoundedIntersection(type, p, edge, start))
{ {
QVector<QPointF> head = points.mid(0, i+1); QVector<QPointF> head = points.mid(0, i + 1);
QVector<QPointF> tail = points.mid(i+1, -1); QVector<QPointF> tail = points.mid(i + 1, -1);
tail = JoinVectors({p}, tail); tail = JoinVectors({p}, tail);
points = JoinVectors(tail, head); points = JoinVectors(tail, head);
@ -799,9 +798,9 @@ auto VEllipticalArc::ArcPoints(QVector<QPointF> points) const -> QVector<QPointF
QVector<QPointF> arc; QVector<QPointF> arc;
arc.reserve(points.size()); arc.reserve(points.size());
for (int i=0; i < points.size()-1; ++i) for (int i = 0; i < points.size() - 1; ++i)
{ {
QLineF edge(points.at(i), points.at(i+1)); QLineF edge(points.at(i), points.at(i + 1));
if (begin) if (begin)
{ {

View file

@ -107,14 +107,7 @@ VGObject::VGObject(const GOType &type, const quint32 &idObject, const Draw &mode
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** COPY_CONSTRUCTOR_IMPL(VGObject)
* @brief VGObject copy constructor.
* @param obj object.
*/
VGObject::VGObject(const VGObject &obj) // NOLINT(modernize-use-equals-default)
: d(obj.d)
{
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
@ -148,9 +141,7 @@ auto VGObject::operator=(VGObject &&obj) noexcept -> VGObject &
#endif #endif
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VGObject::~VGObject() // NOLINT(modernize-use-equals-default) VGObject::~VGObject() = default;
{
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**

View file

@ -26,30 +26,27 @@
** **
*************************************************************************/ *************************************************************************/
#include "vplacelabelitem.h" #include "vplacelabelitem.h"
#include "vplacelabelitem_p.h"
#include "../vpatterndb/vcontainer.h" #include "../vpatterndb/vcontainer.h"
#include "vplacelabelitem_p.h"
#include <qnumeric.h> #include <QPainterPath>
#include <QPolygonF> #include <QPolygonF>
#include <QTransform> #include <QTransform>
#include <QPainterPath> #include <qnumeric.h>
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPlaceLabelItem::VPlaceLabelItem() VPlaceLabelItem::VPlaceLabelItem()
: VPointF(), d(new VPlaceLabelItemData) : d(new VPlaceLabelItemData)
{ {
setType(GOType::PlaceLabel); setType(GOType::PlaceLabel);
setMode(Draw::Modeling); setMode(Draw::Modeling);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPlaceLabelItem::VPlaceLabelItem(const VPlaceLabelItem &item) COPY_CONSTRUCTOR_IMPL_2(VPlaceLabelItem, VPointF)
: VPointF(item), d(item.d)
{}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPlaceLabelItem::~VPlaceLabelItem() VPlaceLabelItem::~VPlaceLabelItem() = default;
{}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VPlaceLabelItem::GetWidthFormula() const -> QString auto VPlaceLabelItem::GetWidthFormula() const -> QString
@ -202,7 +199,7 @@ auto VPlaceLabelItem::RotationMatrix() const -> QTransform
{ {
QTransform t; QTransform t;
t.translate(x(), y()); t.translate(x(), y());
t.rotate(-d->aValue-d->correctionAngle); t.rotate(-d->aValue - d->correctionAngle);
t.translate(-x(), -y()); t.translate(-x(), -y());
return t; return t;
} }
@ -216,7 +213,7 @@ auto VPlaceLabelItem::Box() const -> QRectF
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VPlaceLabelItem::operator=(const VPlaceLabelItem &item) -> VPlaceLabelItem & auto VPlaceLabelItem::operator=(const VPlaceLabelItem &item) -> VPlaceLabelItem &
{ {
if ( &item == this ) if (&item == this)
{ {
return *this; return *this;
} }
@ -228,11 +225,13 @@ auto VPlaceLabelItem::operator=(const VPlaceLabelItem &item) -> VPlaceLabelItem
#ifdef Q_COMPILER_RVALUE_REFS #ifdef Q_COMPILER_RVALUE_REFS
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPlaceLabelItem::VPlaceLabelItem(VPlaceLabelItem &&item) noexcept VPlaceLabelItem::VPlaceLabelItem(VPlaceLabelItem &&item) noexcept
: VPointF(std::move(item)), d(std::move(item.d)) : VPointF(std::move(item)),
{} d(std::move(item.d))
{
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VPlaceLabelItem::operator=(VPlaceLabelItem &&item) noexcept->VPlaceLabelItem & auto VPlaceLabelItem::operator=(VPlaceLabelItem &&item) noexcept -> VPlaceLabelItem &
{ {
VPointF::operator=(item); VPointF::operator=(item);
std::swap(d, item.d); std::swap(d, item.d);

View file

@ -28,10 +28,10 @@
#ifndef VPLACELABELITEM_H #ifndef VPLACELABELITEM_H
#define VPLACELABELITEM_H #define VPLACELABELITEM_H
#include <QMetaType>
#include <QSharedDataPointer> #include <QSharedDataPointer>
#include <QTypeInfo> #include <QTypeInfo>
#include <QtGlobal> #include <QtGlobal>
#include <QMetaType>
#include "vpointf.h" #include "vpointf.h"
@ -44,42 +44,42 @@ class VPlaceLabelItem : public VPointF
public: public:
VPlaceLabelItem(); VPlaceLabelItem();
VPlaceLabelItem(const VPlaceLabelItem &item); VPlaceLabelItem(const VPlaceLabelItem &item);
virtual ~VPlaceLabelItem() override; ~VPlaceLabelItem() override;
auto operator=(const VPlaceLabelItem &item) -> VPlaceLabelItem &; auto operator=(const VPlaceLabelItem &item) -> VPlaceLabelItem &;
#ifdef Q_COMPILER_RVALUE_REFS #ifdef Q_COMPILER_RVALUE_REFS
VPlaceLabelItem(VPlaceLabelItem &&item) noexcept; VPlaceLabelItem(VPlaceLabelItem &&item) noexcept;
auto operator=(VPlaceLabelItem &&item) noexcept->VPlaceLabelItem &; auto operator=(VPlaceLabelItem &&item) noexcept -> VPlaceLabelItem &;
#endif #endif
auto GetWidthFormula() const -> QString; auto GetWidthFormula() const -> QString;
auto GetWidthFormula() -> QString &; auto GetWidthFormula() -> QString &;
auto GetWidth() const -> qreal; auto GetWidth() const -> qreal;
void SetWidth(qreal value, const QString &formula); void SetWidth(qreal value, const QString &formula);
auto GetHeightFormula() const -> QString; auto GetHeightFormula() const -> QString;
auto GetHeightFormula() -> QString &; auto GetHeightFormula() -> QString &;
auto GetHeight() const -> qreal; auto GetHeight() const -> qreal;
void SetHeight(qreal value, const QString &formula); void SetHeight(qreal value, const QString &formula);
auto GetAngleFormula() const -> QString; auto GetAngleFormula() const -> QString;
auto GetAngleFormula() -> QString &; auto GetAngleFormula() -> QString &;
auto GetAngle() const -> qreal; auto GetAngle() const -> qreal;
void SetAngle(qreal value, const QString &formula); void SetAngle(qreal value, const QString &formula);
auto GetVisibilityTrigger() const -> QString; auto GetVisibilityTrigger() const -> QString;
auto GetVisibilityTrigger() -> QString &; auto GetVisibilityTrigger() -> QString &;
auto IsVisible() const -> bool; auto IsVisible() const -> bool;
void SetVisibilityTrigger(qreal visible, const QString &formula); void SetVisibilityTrigger(qreal visible, const QString &formula);
auto GetCorrectionAngle() const -> qreal; auto GetCorrectionAngle() const -> qreal;
void SetCorrectionAngle(qreal value); void SetCorrectionAngle(qreal value);
auto GetCenterPoint() const -> quint32; auto GetCenterPoint() const -> quint32;
void SetCenterPoint(quint32 id); void SetCenterPoint(quint32 id);
auto GetLabelType() const -> PlaceLabelType; auto GetLabelType() const -> PlaceLabelType;
void SetLabelType(PlaceLabelType type); void SetLabelType(PlaceLabelType type);
auto RotationMatrix() const -> QTransform; auto RotationMatrix() const -> QTransform;
auto Box() const -> QRectF; auto Box() const -> QRectF;
@ -88,7 +88,7 @@ private:
QSharedDataPointer<VPlaceLabelItemData> d; QSharedDataPointer<VPlaceLabelItemData> d;
}; };
Q_DECLARE_METATYPE(VPlaceLabelItem) Q_DECLARE_METATYPE(VPlaceLabelItem) // NOLINT
Q_DECLARE_TYPEINFO(VPlaceLabelItem, Q_MOVABLE_TYPE); // NOLINT Q_DECLARE_TYPEINFO(VPlaceLabelItem, Q_MOVABLE_TYPE); // NOLINT
#endif // VPLACELABELITEM_H #endif // VPLACELABELITEM_H

View file

@ -39,18 +39,20 @@
* @brief VPointF creat empty point * @brief VPointF creat empty point
*/ */
VPointF::VPointF() VPointF::VPointF()
:VGObject(GOType::Point, 0, Draw::Calculation), d(new VPointFData) : VGObject(GOType::Point, 0, Draw::Calculation),
{} d(new VPointFData)
{
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPointF::VPointF(const VPointF &point) COPY_CONSTRUCTOR_IMPL_2(VPointF, VGObject)
:VGObject(point), d(point.d)
{}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPointF::VPointF(const QPointF &point) VPointF::VPointF(const QPointF &point)
:VGObject(VPointF()), d(new VPointFData(point)) : VGObject(VPointF()),
{} d(new VPointFData(point))
{
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
@ -62,7 +64,8 @@ VPointF::VPointF(const QPointF &point)
* @param my offset name respect to y * @param my offset name respect to y
*/ */
VPointF::VPointF(qreal x, qreal y, const QString &name, qreal mx, qreal my, quint32 idObject, const Draw &mode) VPointF::VPointF(qreal x, qreal y, const QString &name, qreal mx, qreal my, quint32 idObject, const Draw &mode)
:VGObject(GOType::Point, idObject, mode), d(new VPointFData(x, y, mx, my)) : VGObject(GOType::Point, idObject, mode),
d(new VPointFData(x, y, mx, my))
{ {
setName(name); setName(name);
} }
@ -76,14 +79,14 @@ VPointF::VPointF(qreal x, qreal y, const QString &name, qreal mx, qreal my, quin
* @param my offset name respect to y * @param my offset name respect to y
*/ */
VPointF::VPointF(const QPointF &point, const QString &name, qreal mx, qreal my, quint32 idObject, const Draw &mode) VPointF::VPointF(const QPointF &point, const QString &name, qreal mx, qreal my, quint32 idObject, const Draw &mode)
:VGObject(GOType::Point, idObject, mode), d(new VPointFData(point, mx, my)) : VGObject(GOType::Point, idObject, mode),
d(new VPointFData(point, mx, my))
{ {
setName(name); setName(name);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPointF::~VPointF() VPointF::~VPointF() = default;
{}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
@ -93,7 +96,7 @@ VPointF::~VPointF()
*/ */
auto VPointF::operator=(const VPointF &point) -> VPointF & auto VPointF::operator=(const VPointF &point) -> VPointF &
{ {
if ( &point == this ) if (&point == this)
{ {
return *this; return *this;
} }
@ -105,11 +108,13 @@ auto VPointF::operator=(const VPointF &point) -> VPointF &
#ifdef Q_COMPILER_RVALUE_REFS #ifdef Q_COMPILER_RVALUE_REFS
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPointF::VPointF(VPointF &&point) noexcept VPointF::VPointF(VPointF &&point) noexcept
:VGObject(std::move(point)), d(std::move(point.d)) : VGObject(std::move(point)),
{} d(std::move(point.d))
{
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VPointF::operator=(VPointF &&point) noexcept->VPointF & auto VPointF::operator=(VPointF &&point) noexcept -> VPointF &
{ {
VGObject::operator=(point); VGObject::operator=(point);
std::swap(d, point.d); std::swap(d, point.d);

View file

@ -29,7 +29,6 @@
#ifndef VPOINTF_H #ifndef VPOINTF_H
#define VPOINTF_H #define VPOINTF_H
#include <QMetaType> #include <QMetaType>
#include <QSharedDataPointer> #include <QSharedDataPointer>
#include <QString> #include <QString>
@ -39,7 +38,6 @@
#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 "vgeometrydef.h"
#include "vgobject.h" #include "vgobject.h"
class VPointFData; class VPointFData;
@ -51,22 +49,22 @@ QT_WARNING_DISABLE_GCC("-Wsuggest-final-types")
/** /**
* @brief The VPointF class keep data of point. * @brief The VPointF class keep data of point.
*/ */
class VPointF:public VGObject class VPointF : public VGObject
{ {
public: public:
VPointF (); VPointF();
VPointF (const VPointF &point ); VPointF(const VPointF &point);
explicit VPointF (const QPointF &point ); explicit VPointF(const QPointF &point);
VPointF (qreal x, qreal y, const QString &name, qreal mx, qreal my, quint32 idObject = 0, VPointF(qreal x, qreal y, const QString &name, qreal mx, qreal my, quint32 idObject = 0,
const Draw &mode = Draw::Calculation); const Draw &mode = Draw::Calculation);
VPointF (const QPointF &point, const QString &name, qreal mx, qreal my, quint32 idObject = 0, VPointF(const QPointF &point, const QString &name, qreal mx, qreal my, quint32 idObject = 0,
const Draw &mode = Draw::Calculation); const Draw &mode = Draw::Calculation);
virtual ~VPointF() override; ~VPointF() override;
auto operator=(const VPointF &point) -> VPointF &; auto operator=(const VPointF &point) -> VPointF &;
#ifdef Q_COMPILER_RVALUE_REFS #ifdef Q_COMPILER_RVALUE_REFS
VPointF(VPointF &&point) noexcept; VPointF(VPointF &&point) noexcept;
auto operator=(VPointF &&point) noexcept->VPointF &; auto operator=(VPointF &&point) noexcept -> VPointF &;
#endif #endif
explicit operator QPointF() const; explicit operator QPointF() const;
@ -75,21 +73,21 @@ public:
auto Move(qreal length, qreal angle, const QString &prefix = QString()) const -> VPointF; auto Move(qreal length, qreal angle, const QString &prefix = QString()) const -> VPointF;
auto mx() const -> qreal; auto mx() const -> qreal;
auto my() const -> qreal; auto my() const -> qreal;
void setMx(qreal mx); void setMx(qreal mx);
void setMy(qreal my); void setMy(qreal my);
auto toQPointF() const -> QPointF; auto toQPointF() const -> QPointF;
auto x() const -> qreal; auto x() const -> qreal;
void setX(const qreal &value); void setX(const qreal &value);
auto y() const -> qreal; auto y() const -> qreal;
void setY(const qreal &value); void setY(const qreal &value);
auto IsShowLabel() const -> bool; auto IsShowLabel() const -> bool;
void SetShowLabel(bool hide); void SetShowLabel(bool hide);
virtual auto ToJson() const -> QJsonObject override; auto ToJson() const -> QJsonObject override;
virtual void SetAlias(const QString &alias) override; void SetAlias(const QString &alias) override;
virtual void SetAliasSuffix(const QString &aliasSuffix) override; void SetAliasSuffix(const QString &aliasSuffix) override;
static auto RotatePF(const QPointF &originPoint, const QPointF &point, qreal degrees) -> QPointF; static auto RotatePF(const QPointF &originPoint, const QPointF &point, qreal degrees) -> QPointF;
static auto FlipPF(const QLineF &axis, const QPointF &point) -> QPointF; static auto FlipPF(const QLineF &axis, const QPointF &point) -> QPointF;
@ -99,7 +97,7 @@ private:
QSharedDataPointer<VPointFData> d; QSharedDataPointer<VPointFData> d;
}; };
Q_DECLARE_METATYPE(VPointF) Q_DECLARE_METATYPE(VPointF) // NOLINT
Q_DECLARE_TYPEINFO(VPointF, Q_MOVABLE_TYPE); // NOLINT Q_DECLARE_TYPEINFO(VPointF, Q_MOVABLE_TYPE); // NOLINT
QT_WARNING_POP QT_WARNING_POP

View file

@ -31,28 +31,22 @@
#include <QJsonObject> #include <QJsonObject>
#include <QLineF> #include <QLineF>
#include "../vmisc/vmath.h"
#include "vabstractcurve.h" #include "vabstractcurve.h"
#include "vspline_p.h" #include "vspline_p.h"
#include "../vmisc/vmath.h"
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief VSpline default constructor * @brief VSpline default constructor
*/ */
VSpline::VSpline() VSpline::VSpline()
: VAbstractCubicBezier(GOType::Spline), : VAbstractCubicBezier(GOType::Spline),
d(new VSplineData) d(new VSplineData)
{} {
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** COPY_CONSTRUCTOR_IMPL_2(VSpline, VAbstractCubicBezier)
* @brief VSpline constructor.
* @param spline spline from which the copy.
*/
VSpline::VSpline(const VSpline &spline) // NOLINT(modernize-use-equals-default)
: VAbstractCubicBezier(spline),
d(spline.d)
{}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
@ -65,10 +59,10 @@ VSpline::VSpline(const VSpline &spline) // NOLINT(modernize-use-equals-default)
* @param kAsm1 coefficient of length first control line. * @param kAsm1 coefficient of length first control line.
* @param kAsm2 coefficient of length second control line. * @param kAsm2 coefficient of length second control line.
*/ */
VSpline::VSpline (const VPointF &p1, const VPointF &p4, qreal angle1, qreal angle2, qreal kAsm1, qreal kAsm2, VSpline::VSpline(const VPointF &p1, const VPointF &p4, qreal angle1, qreal angle2, qreal kAsm1, qreal kAsm2,
qreal kCurve, quint32 idObject, Draw mode) qreal kCurve, quint32 idObject, Draw mode)
: VAbstractCubicBezier(GOType::Spline, idObject, mode), : VAbstractCubicBezier(GOType::Spline, idObject, mode),
d(new VSplineData(p1, p4, angle1, angle2, kAsm1, kAsm2, kCurve)) d(new VSplineData(p1, p4, angle1, angle2, kAsm1, kAsm2, kCurve))
{ {
CreateName(); CreateName();
} }
@ -81,14 +75,14 @@ VSpline::VSpline (const VPointF &p1, const VPointF &p4, qreal angle1, qreal angl
* @param p3 second control point. * @param p3 second control point.
* @param p4 second point spline. * @param p4 second point spline.
*/ */
VSpline::VSpline (const VPointF &p1, const QPointF &p2, const QPointF &p3, const VPointF &p4, quint32 idObject, VSpline::VSpline(const VPointF &p1, const QPointF &p2, const QPointF &p3, const VPointF &p4, quint32 idObject,
Draw mode) Draw mode)
:VAbstractCubicBezier(GOType::Spline, idObject, mode), d(new VSplineData(p1, p2, p3, p4)) : VAbstractCubicBezier(GOType::Spline, idObject, mode),
d(new VSplineData(p1, p2, p3, p4))
{ {
CreateName(); CreateName();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief VSpline constructor * @brief VSpline constructor
@ -106,9 +100,9 @@ VSpline::VSpline (const VPointF &p1, const QPointF &p2, const QPointF &p3, const
VSpline::VSpline(const VPointF &p1, const VPointF &p4, qreal angle1, const QString &angle1Formula, qreal angle2, VSpline::VSpline(const VPointF &p1, const VPointF &p4, qreal angle1, const QString &angle1Formula, qreal angle2,
const QString &angle2Formula, qreal c1Length, const QString &c1LengthFormula, qreal c2Length, const QString &angle2Formula, qreal c1Length, const QString &c1LengthFormula, qreal c2Length,
const QString &c2LengthFormula, quint32 idObject, Draw mode) const QString &c2LengthFormula, quint32 idObject, Draw mode)
: VAbstractCubicBezier(GOType::Spline, idObject, mode), : VAbstractCubicBezier(GOType::Spline, idObject, mode),
d(new VSplineData(p1, p4, angle1, angle1Formula, angle2, angle2Formula, c1Length, c1LengthFormula, c2Length, d(new VSplineData(p1, p4, angle1, angle1Formula, angle2, angle2Formula, c1Length, c1LengthFormula, c2Length,
c2LengthFormula)) c2LengthFormula))
{ {
CreateName(); CreateName();
} }
@ -183,18 +177,17 @@ auto VSpline::Move(qreal length, qreal angle, const QString &prefix) const -> VS
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VSpline::~VSpline() // NOLINT(hicpp-use-equals-default, modernize-use-equals-default) VSpline::~VSpline() = default;
{}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief GetLength return length of spline. * @brief GetLength return length of spline.
* @return length. * @return length.
*/ */
auto VSpline::GetLength () const -> qreal auto VSpline::GetLength() const -> qreal
{ {
return LengthBezier ( static_cast<QPointF>(GetP1()), static_cast<QPointF>(GetP2()), static_cast<QPointF>(GetP3()), return LengthBezier(static_cast<QPointF>(GetP1()), static_cast<QPointF>(GetP2()), static_cast<QPointF>(GetP3()),
static_cast<QPointF>(GetP4()), GetApproximationScale()); static_cast<QPointF>(GetP4()), GetApproximationScale());
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -219,7 +212,7 @@ auto VSpline::CutSpline(qreal length, VSpline &spl1, VSpline &spl2, const QStrin
* @brief GetPoints return list with spline points. * @brief GetPoints return list with spline points.
* @return list of points. * @return list of points.
*/ */
auto VSpline::GetPoints () const -> QVector<QPointF> auto VSpline::GetPoints() const -> QVector<QPointF>
{ {
return GetCubicBezierPoints(static_cast<QPointF>(GetP1()), static_cast<QPointF>(GetP2()), return GetCubicBezierPoints(static_cast<QPointF>(GetP1()), static_cast<QPointF>(GetP2()),
static_cast<QPointF>(GetP3()), static_cast<QPointF>(GetP4()), GetApproximationScale()); static_cast<QPointF>(GetP3()), static_cast<QPointF>(GetP4()), GetApproximationScale());
@ -238,14 +231,14 @@ auto VSpline::GetPoints () const -> QVector<QPointF>
* @return list with spline points. * @return list with spline points.
*/ */
// cppcheck-suppress unusedFunction // cppcheck-suppress unusedFunction
auto VSpline::SplinePoints(const QPointF &p1, const QPointF &p4, qreal angle1, qreal angle2, qreal kAsm1, auto VSpline::SplinePoints(const QPointF &p1, const QPointF &p4, qreal angle1, qreal angle2, qreal kAsm1, qreal kAsm2,
qreal kAsm2, qreal kCurve, qreal approximationScale) -> QVector<QPointF> qreal kCurve, qreal approximationScale) -> QVector<QPointF>
{ {
QLineF p1pX(p1.x(), p1.y(), p1.x() + 100, p1.y()); QLineF p1pX(p1.x(), p1.y(), p1.x() + 100, p1.y());
p1pX.setAngle( angle1 ); p1pX.setAngle(angle1);
qreal L = 0, radius = 0, angle = 90; qreal L = 0, radius = 0, angle = 90;
radius = QLineF(QPointF(p1.x(), p4.y()), p4).length(); radius = QLineF(QPointF(p1.x(), p4.y()), p4).length();
L = kCurve * radius * 4 / 3 * tan( angle * M_PI_4 / 180.0 ); L = kCurve * radius * 4 / 3 * tan(angle * M_PI_4 / 180.0);
QLineF p1p2(p1.x(), p1.y(), p1.x() + L * kAsm1, p1.y()); QLineF p1p2(p1.x(), p1.y(), p1.x() + L * kAsm1, p1.y());
p1p2.setAngle(angle1); p1p2.setAngle(angle1);
QLineF p4p3(p4.x(), p4.y(), p4.x() + L * kAsm2, p4.y()); QLineF p4p3(p4.x(), p4.y(), p4.x() + L * kAsm2, p4.y());
@ -256,9 +249,9 @@ auto VSpline::SplinePoints(const QPointF &p1, const QPointF &p4, qreal angle1, q
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VSpline::operator =(const VSpline &spline) -> VSpline & auto VSpline::operator=(const VSpline &spline) -> VSpline &
{ {
if ( &spline == this ) if (&spline == this)
{ {
return *this; return *this;
} }
@ -270,9 +263,10 @@ auto VSpline::operator =(const VSpline &spline) -> VSpline &
#ifdef Q_COMPILER_RVALUE_REFS #ifdef Q_COMPILER_RVALUE_REFS
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VSpline::VSpline(VSpline &&spline) noexcept VSpline::VSpline(VSpline &&spline) noexcept
: VAbstractCubicBezier(std::move(spline)), : VAbstractCubicBezier(std::move(spline)),
d(std::move(spline.d)) d(std::move(spline.d))
{} {
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VSpline::operator=(VSpline &&spline) noexcept -> VSpline & auto VSpline::operator=(VSpline &&spline) noexcept -> VSpline &
@ -431,7 +425,7 @@ void VSpline::SetC2Length(qreal length, const QString &formula)
auto VSpline::GetKasm1() const -> qreal auto VSpline::GetKasm1() const -> qreal
{ {
return QLineF(static_cast<QPointF>(d->p1), static_cast<QPointF>(GetP2())).length() / return QLineF(static_cast<QPointF>(d->p1), static_cast<QPointF>(GetP2())).length() /
VSplineData::GetL(static_cast<QPointF>(d->p1), static_cast<QPointF>(d->p4), d->kCurve); VSplineData::GetL(static_cast<QPointF>(d->p1), static_cast<QPointF>(d->p4), d->kCurve);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -442,7 +436,7 @@ auto VSpline::GetKasm1() const -> qreal
auto VSpline::GetKasm2() const -> qreal auto VSpline::GetKasm2() const -> qreal
{ {
return QLineF(static_cast<QPointF>(d->p4), static_cast<QPointF>(GetP3())).length() / return QLineF(static_cast<QPointF>(d->p4), static_cast<QPointF>(GetP3())).length() /
VSplineData::GetL(static_cast<QPointF>(d->p1), static_cast<QPointF>(d->p4), d->kCurve); VSplineData::GetL(static_cast<QPointF>(d->p1), static_cast<QPointF>(d->p4), d->kCurve);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -458,11 +452,11 @@ auto VSpline::GetKcurve() const -> qreal
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VSpline::Sign(long double ld) -> int auto VSpline::Sign(long double ld) -> int
{ {
if (qAbs(ld)<0.00000000001) if (qAbs(ld) < 0.00000000001)
{ {
return 0; return 0;
} }
return (ld>0) ? 1 : -1; return (ld > 0) ? 1 : -1;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -486,50 +480,50 @@ auto VSpline::Sign(long double ld) -> int
*/ */
auto VSpline::Cubic(QVector<qreal> &x, qreal a, qreal b, qreal c) -> qint32 auto VSpline::Cubic(QVector<qreal> &x, qreal a, qreal b, qreal c) -> qint32
{ {
//To find cubic equation roots in the case of real coefficients, calculated at the beginning // To find cubic equation roots in the case of real coefficients, calculated at the beginning
const qreal q = (pow(a, 2) - 3*b)/9.; const qreal q = (pow(a, 2) - 3 * b) / 9.;
const qreal r = (2*pow(a, 3) - 9*a*b + 27.*c)/54.; const qreal r = (2 * pow(a, 3) - 9 * a * b + 27. * c) / 54.;
if (pow(r, 2) < pow(q, 3)) if (pow(r, 2) < pow(q, 3))
{ // equation has three real roots, use formula Vieta { // equation has three real roots, use formula Vieta
const qreal t = acos(r/sqrt(pow(q, 3)))/3.; const qreal t = acos(r / sqrt(pow(q, 3))) / 3.;
x.insert(0, -2.*sqrt(q)*cos(t)-a/3); x.insert(0, -2. * sqrt(q) * cos(t) - a / 3);
x.insert(1, -2.*sqrt(q)*cos(t + (2*M_2PI/3.)) - a/3.); x.insert(1, -2. * sqrt(q) * cos(t + (2 * M_2PI / 3.)) - a / 3.);
x.insert(2, -2.*sqrt(q)*cos(t - (2*M_2PI/3.)) - a/3.); x.insert(2, -2. * sqrt(q) * cos(t - (2 * M_2PI / 3.)) - a / 3.);
return(3); return (3);
} }
// 1 real root + 2 complex // 1 real root + 2 complex
//Formula Cardano // Formula Cardano
const qreal aa = -Sign(r)*pow(fabs(r)+sqrt(pow(r, 2)-pow(q, 3)), 1./3.); const qreal aa = -Sign(r) * pow(fabs(r) + sqrt(pow(r, 2) - pow(q, 3)), 1. / 3.);
const qreal bb = Sign(aa) == 0 ? 0 : q/aa; const qreal bb = Sign(aa) == 0 ? 0 : q / aa;
x.insert(0, aa+bb-a/3.); // Real root x.insert(0, aa + bb - a / 3.); // Real root
x.insert(1, (-0.5)*(aa+bb)-a/3.); //Complex root x.insert(1, (-0.5) * (aa + bb) - a / 3.); // Complex root
x.insert(2, (sqrt(3.)*0.5)*fabs(aa-bb)); // Complex root x.insert(2, (sqrt(3.) * 0.5) * fabs(aa - bb)); // Complex root
if (qFuzzyIsNull(x.at(2))) if (qFuzzyIsNull(x.at(2)))
{ {
return(2); return (2);
} }
return(1); return (1);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VSpline::CalcT(qreal curveCoord1, qreal curveCoord2, qreal curveCoord3, qreal curveCoord4, auto VSpline::CalcT(qreal curveCoord1, qreal curveCoord2, qreal curveCoord3, qreal curveCoord4, qreal pointCoord)
qreal pointCoord) -> QVector<qreal> -> QVector<qreal>
{ {
const qreal a = -curveCoord1 + 3*curveCoord2 - 3*curveCoord3 + curveCoord4; const qreal a = -curveCoord1 + 3 * curveCoord2 - 3 * curveCoord3 + curveCoord4;
const qreal b = 3*curveCoord1 - 6*curveCoord2 + 3*curveCoord3; const qreal b = 3 * curveCoord1 - 6 * curveCoord2 + 3 * curveCoord3;
const qreal c = -3*curveCoord1 + 3*curveCoord2; const qreal c = -3 * curveCoord1 + 3 * curveCoord2;
const qreal d = -pointCoord + curveCoord1; const qreal d = -pointCoord + curveCoord1;
QVector<qreal> t = QVector<qreal>(3, -1); QVector<qreal> t = QVector<qreal>(3, -1);
Cubic(t, b/a, c/a, d/a); Cubic(t, b / a, c / a, d / a);
QVector<qreal> retT; QVector<qreal> retT;
retT.reserve(t.size()); retT.reserve(t.size());
for (auto i : qAsConst(t)) for (auto i : qAsConst(t))
{ {
if (i >= 0 && i <= 1 ) if (i >= 0 && i <= 1)
{ {
retT.append(i); retT.append(i);
} }
@ -547,12 +541,12 @@ auto VSpline::CalcT(qreal curveCoord1, qreal curveCoord2, qreal curveCoord3, qre
* @param pBt point on curve * @param pBt point on curve
* @return t coeffient that reprezent this point on curve. Return -1 if point doesn't belongs to curve. * @return t coeffient that reprezent this point on curve. Return -1 if point doesn't belongs to curve.
*/ */
auto VSpline::ParamT (const QPointF &pBt) const -> qreal auto VSpline::ParamT(const QPointF &pBt) const -> qreal
{ {
QVector<qreal> ts; QVector<qreal> ts;
// Calculate t coefficient for each axis // Calculate t coefficient for each axis
ts += CalcT (GetP1().x(), GetP2().x(), GetP3().x(), GetP4().x(), pBt.x()); ts += CalcT(GetP1().x(), GetP2().x(), GetP3().x(), GetP4().x(), pBt.x());
ts += CalcT (GetP1().y(), GetP2().y(), GetP3().y(), GetP4().y(), pBt.y()); ts += CalcT(GetP1().y(), GetP2().y(), GetP3().y(), GetP4().y(), pBt.y());
if (ts.isEmpty()) if (ts.isEmpty())
{ {
@ -570,15 +564,17 @@ auto VSpline::ParamT (const QPointF &pBt) const -> qreal
const QPointF p1 = static_cast<QPointF>(GetP2()); const QPointF p1 = static_cast<QPointF>(GetP2());
const QPointF p2 = static_cast<QPointF>(GetP3()); const QPointF p2 = static_cast<QPointF>(GetP3());
const QPointF p3 = static_cast<QPointF>(GetP4()); const QPointF p3 = static_cast<QPointF>(GetP4());
//The explicit form of the Cubic Bézier curve // The explicit form of the Cubic Bézier curve
const qreal pointX = pow(1-t, 3)*p0.x() + 3*pow(1-t, 2)*t*p1.x() + 3*(1-t)*pow(t, 2)*p2.x() + pow(t, 3)*p3.x(); const qreal pointX = pow(1 - t, 3) * p0.x() + 3 * pow(1 - t, 2) * t * p1.x() +
const qreal pointY = pow(1-t, 3)*p0.y() + 3*pow(1-t, 2)*t*p1.y() + 3*(1-t)*pow(t, 2)*p2.y() + pow(t, 3)*p3.y(); 3 * (1 - t) * pow(t, 2) * p2.x() + pow(t, 3) * p3.x();
const qreal pointY = pow(1 - t, 3) * p0.y() + 3 * pow(1 - t, 2) * t * p1.y() +
3 * (1 - t) * pow(t, 2) * p2.y() + pow(t, 3) * p3.y();
const QLineF line(pBt, QPointF(pointX, pointY)); const QLineF line(pBt, QPointF(pointX, pointY));
if (line.length() <= eps) if (line.length() <= eps)
{ {
tx = t; tx = t;
eps = line.length(); //Next point should be even closest eps = line.length(); // Next point should be even closest
} }
} }
@ -606,13 +602,13 @@ auto VSpline::ToJson() const -> QJsonObject
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VSpline::GetControlPoint1() const -> QPointF auto VSpline::GetControlPoint1() const -> QPointF
{ {
return static_cast<QPointF>(GetP2 ()); return static_cast<QPointF>(GetP2());
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VSpline::GetControlPoint2() const -> QPointF auto VSpline::GetControlPoint2() const -> QPointF
{ {
return static_cast<QPointF>(GetP3 ()); return static_cast<QPointF>(GetP3());
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View file

@ -44,14 +44,15 @@
* @param mode mode creation spline path. * @param mode mode creation spline path.
*/ */
VSplinePath::VSplinePath(quint32 idObject, Draw mode) VSplinePath::VSplinePath(quint32 idObject, Draw mode)
: VAbstractCubicBezierPath(GOType::SplinePath, idObject, mode), : VAbstractCubicBezierPath(GOType::SplinePath, idObject, mode),
d(new VSplinePathData()) d(new VSplinePathData())
{} {
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VSplinePath::VSplinePath(const QVector<VFSplinePoint> &points, qreal kCurve, quint32 idObject, Draw mode) VSplinePath::VSplinePath(const QVector<VFSplinePoint> &points, qreal kCurve, quint32 idObject, Draw mode)
: VAbstractCubicBezierPath(GOType::SplinePath, idObject, mode), : VAbstractCubicBezierPath(GOType::SplinePath, idObject, mode),
d(new VSplinePathData()) d(new VSplinePathData())
{ {
if (points.size() < 3) if (points.size() < 3)
{ {
@ -59,15 +60,15 @@ VSplinePath::VSplinePath(const QVector<VFSplinePoint> &points, qreal kCurve, qui
} }
QVector<VSplinePoint> newPoints(points.size()); QVector<VSplinePoint> newPoints(points.size());
for (qint32 i = 1; i <= points.size()-1; ++i) for (qint32 i = 1; i <= points.size() - 1; ++i)
{ {
const VFSplinePoint &p1 = points.at(i-1); const VFSplinePoint &p1 = points.at(i - 1);
const VFSplinePoint &p2 = points.at(i); const VFSplinePoint &p2 = points.at(i);
VSpline spl(p1.P(), p2.P(), p1.Angle2(), p2.Angle1(), p1.KAsm2(), p2.KAsm1(), kCurve); VSpline spl(p1.P(), p2.P(), p1.Angle2(), p2.Angle1(), p1.KAsm2(), p2.KAsm1(), kCurve);
newPoints[i-1].SetP(p1.P()); newPoints[i - 1].SetP(p1.P());
newPoints[i-1].SetAngle2(p1.Angle2(), spl.GetStartAngleFormula()); newPoints[i - 1].SetAngle2(p1.Angle2(), spl.GetStartAngleFormula());
newPoints[i-1].SetLength2(spl.GetC1Length(), spl.GetC1LengthFormula()); newPoints[i - 1].SetLength2(spl.GetC1Length(), spl.GetC1LengthFormula());
newPoints[i].SetP(p2.P()); newPoints[i].SetP(p2.P());
newPoints[i].SetAngle1(p2.Angle1(), spl.GetEndAngleFormula()); newPoints[i].SetAngle1(p2.Angle1(), spl.GetEndAngleFormula());
@ -80,8 +81,8 @@ VSplinePath::VSplinePath(const QVector<VFSplinePoint> &points, qreal kCurve, qui
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VSplinePath::VSplinePath(const QVector<VSplinePoint> &points, quint32 idObject, Draw mode) VSplinePath::VSplinePath(const QVector<VSplinePoint> &points, quint32 idObject, Draw mode)
: VAbstractCubicBezierPath(GOType::SplinePath, idObject, mode), : VAbstractCubicBezierPath(GOType::SplinePath, idObject, mode),
d(new VSplinePathData()) d(new VSplinePathData())
{ {
if (points.isEmpty()) if (points.isEmpty())
{ {
@ -93,14 +94,7 @@ VSplinePath::VSplinePath(const QVector<VSplinePoint> &points, quint32 idObject,
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** COPY_CONSTRUCTOR_IMPL_2(VSplinePath, VAbstractCubicBezierPath)
* @brief VSplinePath copy constructor.
* @param splPath spline path.
*/
VSplinePath::VSplinePath(const VSplinePath &splPath)
: VAbstractCubicBezierPath(splPath),
d(splPath.d)
{}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VSplinePath::Rotate(const QPointF &originPoint, qreal degrees, const QString &prefix) const -> VSplinePath auto VSplinePath::Rotate(const QPointF &originPoint, qreal degrees, const QString &prefix) const -> VSplinePath
@ -110,9 +104,9 @@ auto VSplinePath::Rotate(const QPointF &originPoint, qreal degrees, const QStrin
{ {
const VSpline spl = GetSpline(i).Rotate(originPoint, degrees); const VSpline spl = GetSpline(i).Rotate(originPoint, degrees);
newPoints[i-1].SetP(spl.GetP1()); newPoints[i - 1].SetP(spl.GetP1());
newPoints[i-1].SetAngle2(spl.GetStartAngle(), spl.GetStartAngleFormula()); newPoints[i - 1].SetAngle2(spl.GetStartAngle(), spl.GetStartAngleFormula());
newPoints[i-1].SetLength2(spl.GetC1Length(), spl.GetC1LengthFormula()); newPoints[i - 1].SetLength2(spl.GetC1Length(), spl.GetC1LengthFormula());
newPoints[i].SetP(spl.GetP4()); newPoints[i].SetP(spl.GetP4());
newPoints[i].SetAngle1(spl.GetEndAngle(), spl.GetEndAngleFormula()); newPoints[i].SetAngle1(spl.GetEndAngle(), spl.GetEndAngleFormula());
@ -141,9 +135,9 @@ auto VSplinePath::Flip(const QLineF &axis, const QString &prefix) const -> VSpli
{ {
const VSpline spl = GetSpline(i).Flip(axis); const VSpline spl = GetSpline(i).Flip(axis);
newPoints[i-1].SetP(spl.GetP1()); newPoints[i - 1].SetP(spl.GetP1());
newPoints[i-1].SetAngle2(spl.GetStartAngle(), spl.GetStartAngleFormula()); newPoints[i - 1].SetAngle2(spl.GetStartAngle(), spl.GetStartAngleFormula());
newPoints[i-1].SetLength2(spl.GetC1Length(), spl.GetC1LengthFormula()); newPoints[i - 1].SetLength2(spl.GetC1Length(), spl.GetC1LengthFormula());
newPoints[i].SetP(spl.GetP4()); newPoints[i].SetP(spl.GetP4());
newPoints[i].SetAngle1(spl.GetEndAngle(), spl.GetEndAngleFormula()); newPoints[i].SetAngle1(spl.GetEndAngle(), spl.GetEndAngleFormula());
@ -172,9 +166,9 @@ auto VSplinePath::Move(qreal length, qreal angle, const QString &prefix) const -
{ {
const VSpline spl = GetSpline(i).Move(length, angle); const VSpline spl = GetSpline(i).Move(length, angle);
newPoints[i-1].SetP(spl.GetP1()); newPoints[i - 1].SetP(spl.GetP1());
newPoints[i-1].SetAngle2(spl.GetStartAngle(), spl.GetStartAngleFormula()); newPoints[i - 1].SetAngle2(spl.GetStartAngle(), spl.GetStartAngleFormula());
newPoints[i-1].SetLength2(spl.GetC1Length(), spl.GetC1LengthFormula()); newPoints[i - 1].SetLength2(spl.GetC1Length(), spl.GetC1LengthFormula());
newPoints[i].SetP(spl.GetP4()); newPoints[i].SetP(spl.GetP4());
newPoints[i].SetAngle1(spl.GetEndAngle(), spl.GetEndAngleFormula()); newPoints[i].SetAngle1(spl.GetEndAngle(), spl.GetEndAngleFormula());
@ -196,8 +190,7 @@ auto VSplinePath::Move(qreal length, qreal angle, const QString &prefix) const -
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VSplinePath::~VSplinePath() VSplinePath::~VSplinePath() = default;
{}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
@ -233,7 +226,7 @@ auto VSplinePath::CountSubSpl() const -> vsizetype
*/ */
auto VSplinePath::GetSpline(vsizetype index) const -> VSpline auto VSplinePath::GetSpline(vsizetype index) const -> VSpline
{ {
if (CountPoints()<1) if (CountPoints() < 1)
{ {
throw VException(tr("Not enough points to create the spline.")); throw VException(tr("Not enough points to create the spline."));
} }
@ -243,7 +236,7 @@ auto VSplinePath::GetSpline(vsizetype index) const -> VSpline
throw VException(tr("This spline does not exist.")); throw VException(tr("This spline does not exist."));
} }
const VSplinePoint &p1 = d->path.at(index-1); const VSplinePoint &p1 = d->path.at(index - 1);
const VSplinePoint &p2 = d->path.at(index); const VSplinePoint &p2 = d->path.at(index);
VSpline spl(p1.P(), p2.P(), p1.Angle2(), p1.Angle2Formula(), p2.Angle1(), p2.Angle1Formula(), p1.Length2(), VSpline spl(p1.P(), p2.P(), p1.Angle2(), p1.Angle2Formula(), p2.Angle1(), p2.Angle1Formula(), p1.Length2(),
p1.Length2Formula(), p2.Length1(), p2.Length1Formula(), 1); p1.Length2Formula(), p2.Length1(), p2.Length1Formula(), 1);
@ -266,7 +259,7 @@ void VSplinePath::UpdatePoint(qint32 indexSpline, const SplinePointPosition &pos
} }
if (pos == SplinePointPosition::FirstPoint) if (pos == SplinePointPosition::FirstPoint)
{ {
d->path[indexSpline-1] = point; d->path[indexSpline - 1] = point;
} }
else else
{ {
@ -289,7 +282,7 @@ auto VSplinePath::GetSplinePoint(qint32 indexSpline, SplinePointPosition pos) co
} }
if (pos == SplinePointPosition::FirstPoint) if (pos == SplinePointPosition::FirstPoint)
{ {
return d->path.at(indexSpline-1); return d->path.at(indexSpline - 1);
} }
else else
{ {
@ -305,7 +298,7 @@ auto VSplinePath::GetSplinePoint(qint32 indexSpline, SplinePointPosition pos) co
*/ */
auto VSplinePath::operator=(const VSplinePath &path) -> VSplinePath & auto VSplinePath::operator=(const VSplinePath &path) -> VSplinePath &
{ {
if ( &path == this ) if (&path == this)
{ {
return *this; return *this;
} }
@ -317,12 +310,13 @@ auto VSplinePath::operator=(const VSplinePath &path) -> VSplinePath &
#ifdef Q_COMPILER_RVALUE_REFS #ifdef Q_COMPILER_RVALUE_REFS
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VSplinePath::VSplinePath(VSplinePath &&splPath) noexcept VSplinePath::VSplinePath(VSplinePath &&splPath) noexcept
: VAbstractCubicBezierPath(std::move(splPath)), : VAbstractCubicBezierPath(std::move(splPath)),
d(std::move(splPath.d)) d(std::move(splPath.d))
{} {
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VSplinePath::operator=(VSplinePath &&path) noexcept->VSplinePath & auto VSplinePath::operator=(VSplinePath &&path) noexcept -> VSplinePath &
{ {
VAbstractCubicBezierPath::operator=(path); VAbstractCubicBezierPath::operator=(path);
std::swap(d, path.d); std::swap(d, path.d);
@ -371,7 +365,7 @@ auto VSplinePath::ToJson() const -> QJsonObject
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VSplinePath::GetStartAngle() const -> qreal auto VSplinePath::GetStartAngle() const -> qreal
{ {
return CountPoints() > 0 ? ConstFirst (GetSplinePath()).Angle2() : 0; return CountPoints() > 0 ? ConstFirst(GetSplinePath()).Angle2() : 0;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -390,27 +384,27 @@ auto VSplinePath::GetEndAngle() const -> qreal
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VSplinePath::GetC1Length() const -> qreal auto VSplinePath::GetC1Length() const -> qreal
{ {
return CountPoints() > 0 ? ConstFirst (GetSplinePath()).Length2() : 0; return CountPoints() > 0 ? ConstFirst(GetSplinePath()).Length2() : 0;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VSplinePath::GetC2Length() const -> qreal auto VSplinePath::GetC2Length() const -> qreal
{ {
return CountPoints() > 0 ? ConstFirst (GetSplinePath()).Length1() : 0; return CountPoints() > 0 ? ConstFirst(GetSplinePath()).Length1() : 0;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VSplinePath::FirstPoint() const -> VPointF auto VSplinePath::FirstPoint() const -> VPointF
{ {
return not d->path.isEmpty() ? ConstFirst (d->path).P() : VPointF(); return not d->path.isEmpty() ? ConstFirst(d->path).P() : VPointF();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VSplinePath::LastPoint() const -> VPointF auto VSplinePath::LastPoint() const -> VPointF
{ {
const vsizetype count = CountSubSpl(); const vsizetype count = CountSubSpl();
return count >= 1 ? d->path.at(count).P() :// Take last point of the last real spline return count >= 1 ? d->path.at(count).P() : // Take last point of the last real spline
VPointF(); VPointF();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -441,14 +435,14 @@ auto VSplinePath::GetFSplinePath() const -> QVector<VFSplinePoint>
for (qint32 i = 1; i <= CountSubSpl(); ++i) for (qint32 i = 1; i <= CountSubSpl(); ++i)
{ {
const VSplinePoint &p1 = d->path.at(i-1); const VSplinePoint &p1 = d->path.at(i - 1);
const VSplinePoint &p2 = d->path.at(i); const VSplinePoint &p2 = d->path.at(i);
VSpline spl(p1.P(), p2.P(), p1.Angle2(), p1.Angle2Formula(), p2.Angle1(), p2.Angle1Formula(), p1.Length2(), VSpline spl(p1.P(), p2.P(), p1.Angle2(), p1.Angle2Formula(), p2.Angle1(), p2.Angle1Formula(), p1.Length2(),
p1.Length2Formula(), p2.Length1(), p2.Length1Formula(), 1); p1.Length2Formula(), p2.Length1(), p2.Length1Formula(), 1);
points[i-1].SetP(p1.P()); points[i - 1].SetP(p1.P());
points[i-1].SetAngle2(p1.Angle2()); points[i - 1].SetAngle2(p1.Angle2());
points[i-1].SetKAsm2(spl.GetKasm1()); points[i - 1].SetKAsm2(spl.GetKasm1());
points[i].SetP(p2.P()); points[i].SetP(p2.P());
points[i].SetAngle1(p2.Angle1()); points[i].SetAngle1(p2.Angle1());

View file

@ -39,8 +39,9 @@
* @brief VFSplinePoint default constructor. * @brief VFSplinePoint default constructor.
*/ */
VFSplinePoint::VFSplinePoint() VFSplinePoint::VFSplinePoint()
:d(new VFSplinePointData) : d(new VFSplinePointData)
{} {
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
@ -52,22 +53,17 @@ VFSplinePoint::VFSplinePoint()
* @param angle2 second angle control line. * @param angle2 second angle control line.
*/ */
VFSplinePoint::VFSplinePoint(const VPointF &pSpline, qreal kAsm1, qreal angle1, qreal kAsm2, qreal angle2) VFSplinePoint::VFSplinePoint(const VPointF &pSpline, qreal kAsm1, qreal angle1, qreal kAsm2, qreal angle2)
:d(new VFSplinePointData(pSpline, kAsm1, angle1, kAsm2, angle2)) : d(new VFSplinePointData(pSpline, kAsm1, angle1, kAsm2, angle2))
{} {
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** COPY_CONSTRUCTOR_IMPL(VFSplinePoint)
* @brief VFSplinePoint copy constructor
* @param point point
*/
VFSplinePoint::VFSplinePoint(const VFSplinePoint &point)
:d(point.d)
{}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VFSplinePoint::operator=(const VFSplinePoint &point) -> VFSplinePoint & auto VFSplinePoint::operator=(const VFSplinePoint &point) -> VFSplinePoint &
{ {
if ( &point == this ) if (&point == this)
{ {
return *this; return *this;
} }
@ -78,11 +74,12 @@ auto VFSplinePoint::operator=(const VFSplinePoint &point) -> VFSplinePoint &
#ifdef Q_COMPILER_RVALUE_REFS #ifdef Q_COMPILER_RVALUE_REFS
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VFSplinePoint::VFSplinePoint(VFSplinePoint &&point) noexcept VFSplinePoint::VFSplinePoint(VFSplinePoint &&point) noexcept
:d(std::move(point.d)) : d(std::move(point.d))
{} {
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VFSplinePoint::operator=(VFSplinePoint &&point) noexcept->VFSplinePoint & auto VFSplinePoint::operator=(VFSplinePoint &&point) noexcept -> VFSplinePoint &
{ {
std::swap(d, point.d); std::swap(d, point.d);
return *this; return *this;
@ -90,8 +87,7 @@ auto VFSplinePoint::operator=(VFSplinePoint &&point) noexcept->VFSplinePoint &
#endif #endif
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VFSplinePoint::~VFSplinePoint() VFSplinePoint::~VFSplinePoint() = default;
{}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
@ -104,7 +100,7 @@ void VFSplinePoint::SetAngle1(const qreal &value)
line.setAngle(value); line.setAngle(value);
d->angle1 = line.angle(); d->angle1 = line.angle();
line.setAngle(d->angle1+180); line.setAngle(d->angle1 + 180);
d->angle2 = line.angle(); d->angle2 = line.angle();
} }
@ -119,7 +115,7 @@ void VFSplinePoint::SetAngle2(const qreal &value)
line.setAngle(value); line.setAngle(value);
d->angle2 = line.angle(); d->angle2 = line.angle();
line.setAngle(d->angle2+180); line.setAngle(d->angle2 + 180);
d->angle1 = line.angle(); d->angle1 = line.angle();
} }
@ -205,7 +201,7 @@ void VFSplinePoint::SetKAsm2(const qreal &value)
//------------------------------------------VSplinePoint--------------------------------------------------------------- //------------------------------------------VSplinePoint---------------------------------------------------------------
VSplinePoint::VSplinePoint() VSplinePoint::VSplinePoint()
: d(new VSplinePointData) : d(new VSplinePointData)
{ {
} }
@ -213,20 +209,17 @@ VSplinePoint::VSplinePoint()
VSplinePoint::VSplinePoint(const VPointF &pSpline, qreal angle1, const QString &angle1F, qreal angle2, VSplinePoint::VSplinePoint(const VPointF &pSpline, qreal angle1, const QString &angle1F, qreal angle2,
const QString &angle2F, qreal length1, const QString &length1F, qreal length2, const QString &angle2F, qreal length1, const QString &length1F, qreal length2,
const QString &length2F) const QString &length2F)
: d(new VSplinePointData(pSpline, angle1, angle1F, angle2, angle2F, length1, length1F, length2, length2F)) : d(new VSplinePointData(pSpline, angle1, angle1F, angle2, angle2F, length1, length1F, length2, length2F))
{ {
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VSplinePoint::VSplinePoint(const VSplinePoint &point) COPY_CONSTRUCTOR_IMPL(VSplinePoint)
: d(point.d)
{
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VSplinePoint::operator=(const VSplinePoint &point) -> VSplinePoint & auto VSplinePoint::operator=(const VSplinePoint &point) -> VSplinePoint &
{ {
if ( &point == this ) if (&point == this)
{ {
return *this; return *this;
} }
@ -237,11 +230,12 @@ auto VSplinePoint::operator=(const VSplinePoint &point) -> VSplinePoint &
#ifdef Q_COMPILER_RVALUE_REFS #ifdef Q_COMPILER_RVALUE_REFS
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VSplinePoint::VSplinePoint(VSplinePoint &&point) noexcept VSplinePoint::VSplinePoint(VSplinePoint &&point) noexcept
: d(std::move(point.d)) : d(std::move(point.d))
{} {
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VSplinePoint::operator=(VSplinePoint &&point) noexcept->VSplinePoint & auto VSplinePoint::operator=(VSplinePoint &&point) noexcept -> VSplinePoint &
{ {
std::swap(d, point.d); std::swap(d, point.d);
return *this; return *this;
@ -249,9 +243,7 @@ auto VSplinePoint::operator=(VSplinePoint &&point) noexcept->VSplinePoint &
#endif #endif
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VSplinePoint::~VSplinePoint() VSplinePoint::~VSplinePoint() = default;
{
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VSplinePoint::P() const -> VPointF auto VSplinePoint::P() const -> VPointF
@ -286,7 +278,7 @@ void VSplinePoint::SetAngle1(const qreal &value, const QString &angle1F)
line.setAngle(value); line.setAngle(value);
d->angle1 = line.angle(); d->angle1 = line.angle();
line.setAngle(d->angle1+180); line.setAngle(d->angle1 + 180);
d->angle2 = line.angle(); d->angle2 = line.angle();
d->angle2F = QString::number(d->angle2); d->angle2F = QString::number(d->angle2);
} }
@ -312,7 +304,7 @@ void VSplinePoint::SetAngle2(const qreal &value, const QString &angle2F)
line.setAngle(value); line.setAngle(value);
d->angle2 = line.angle(); d->angle2 = line.angle();
line.setAngle(d->angle2+180); line.setAngle(d->angle2 + 180);
d->angle1 = line.angle(); d->angle1 = line.angle();
d->angle1F = QString::number(d->angle1); d->angle1F = QString::number(d->angle1);
} }
@ -365,17 +357,10 @@ auto VSplinePoint::IsMovable() const -> bool
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VSplinePoint::ToJson() const -> QJsonObject auto VSplinePoint::ToJson() const -> QJsonObject
{ {
QJsonObject object QJsonObject object{
{ {"point", d->pSpline.ToJson()}, {"angle1", d->angle1}, {"angle1Formula", d->angle1F},
{"point", d->pSpline.ToJson()}, {"angle2", d->angle2}, {"angle2Formula", d->angle2F}, {"length1", d->length1},
{"angle1", d->angle1}, {"length1Formula", d->length1F}, {"length2", d->length2}, {"length2Formula", d->length2F},
{"angle1Formula", d->angle1F},
{"angle2", d->angle2},
{"angle2Formula", d->angle2F},
{"length1", d->length1},
{"length1Formula", d->length1F},
{"length2", d->length2},
{"length2Formula", d->length2F},
}; };
return object; return object;
} }

View file

@ -54,24 +54,25 @@ public:
auto operator=(const VFSplinePoint &point) -> VFSplinePoint &; auto operator=(const VFSplinePoint &point) -> VFSplinePoint &;
#ifdef Q_COMPILER_RVALUE_REFS #ifdef Q_COMPILER_RVALUE_REFS
VFSplinePoint(VFSplinePoint &&point) noexcept; VFSplinePoint(VFSplinePoint &&point) noexcept;
auto operator=(VFSplinePoint &&point) noexcept->VFSplinePoint &; auto operator=(VFSplinePoint &&point) noexcept -> VFSplinePoint &;
#endif #endif
auto P() const -> VPointF; auto P() const -> VPointF;
void SetP(const VPointF &value); void SetP(const VPointF &value);
auto Angle1() const -> qreal; auto Angle1() const -> qreal;
void SetAngle1(const qreal &value); void SetAngle1(const qreal &value);
void SetAngle2(const qreal &value); void SetAngle2(const qreal &value);
auto Angle2() const -> qreal; auto Angle2() const -> qreal;
auto KAsm1() const -> qreal; auto KAsm1() const -> qreal;
void SetKAsm1(const qreal &value); void SetKAsm1(const qreal &value);
auto KAsm2() const -> qreal; auto KAsm2() const -> qreal;
void SetKAsm2(const qreal &value); void SetKAsm2(const qreal &value);
protected: protected:
QSharedDataPointer<VFSplinePointData> d; QSharedDataPointer<VFSplinePointData> d;
}; };
Q_DECLARE_METATYPE(VFSplinePoint) Q_DECLARE_METATYPE(VFSplinePoint) // NOLINT
Q_DECLARE_TYPEINFO(VFSplinePoint, Q_MOVABLE_TYPE); // NOLINT Q_DECLARE_TYPEINFO(VFSplinePoint, Q_MOVABLE_TYPE); // NOLINT
class VSplinePointData; class VSplinePointData;
@ -92,27 +93,27 @@ public:
auto operator=(const VSplinePoint &point) -> VSplinePoint &; auto operator=(const VSplinePoint &point) -> VSplinePoint &;
#ifdef Q_COMPILER_RVALUE_REFS #ifdef Q_COMPILER_RVALUE_REFS
VSplinePoint(VSplinePoint &&point) noexcept; VSplinePoint(VSplinePoint &&point) noexcept;
auto operator=(VSplinePoint &&point) noexcept->VSplinePoint &; auto operator=(VSplinePoint &&point) noexcept -> VSplinePoint &;
#endif #endif
auto P() const -> VPointF; auto P() const -> VPointF;
void SetP(const VPointF &value); void SetP(const VPointF &value);
auto Angle1() const -> qreal; auto Angle1() const -> qreal;
auto Angle1Formula() const -> QString; auto Angle1Formula() const -> QString;
void SetAngle1(const qreal &value, const QString &angle1F); void SetAngle1(const qreal &value, const QString &angle1F);
auto Angle2() const -> qreal; auto Angle2() const -> qreal;
auto Angle2Formula() const -> QString; auto Angle2Formula() const -> QString;
void SetAngle2(const qreal &value, const QString &angle2F); void SetAngle2(const qreal &value, const QString &angle2F);
auto Length1() const -> qreal; auto Length1() const -> qreal;
auto Length1Formula() const -> QString; auto Length1Formula() const -> QString;
void SetLength1(const qreal &value, const QString &length1F); void SetLength1(const qreal &value, const QString &length1F);
auto Length2() const -> qreal; auto Length2() const -> qreal;
auto Length2Formula() const -> QString; auto Length2Formula() const -> QString;
void SetLength2(const qreal &value, const QString &length2F); void SetLength2(const qreal &value, const QString &length2F);
auto IsMovable() const -> bool; auto IsMovable() const -> bool;
@ -122,7 +123,7 @@ protected:
QSharedDataPointer<VSplinePointData> d; QSharedDataPointer<VSplinePointData> d;
}; };
Q_DECLARE_METATYPE(VSplinePoint) Q_DECLARE_METATYPE(VSplinePoint) // NOLINT
Q_DECLARE_TYPEINFO(VSplinePoint, Q_MOVABLE_TYPE); // NOLINT Q_DECLARE_TYPEINFO(VSplinePoint, Q_MOVABLE_TYPE); // NOLINT
#endif // VSPLINEPOINT_H #endif // VSPLINEPOINT_H

View file

@ -308,6 +308,12 @@ auto NextPattern(int patternIndex, const QVector<int> &pattern) -> int
} }
} // namespace } // namespace
//---------------------------------------------------------------------------------------------------------------------
VHPGLEngine::VHPGLEngine()
: m_penWidthPx(qCeil(ToPixel(0.025, Unit::Mm)))
{
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VHPGLEngine::SortDetails(const QVector<VLayoutPiece> &details) -> QList<VLayoutPiece> auto VHPGLEngine::SortDetails(const QVector<VLayoutPiece> &details) -> QList<VLayoutPiece>
{ {

View file

@ -49,7 +49,7 @@ class VHPGLEngine
friend class VHPGLPaintDevice; friend class VHPGLPaintDevice;
public: public:
VHPGLEngine() = default; VHPGLEngine();
~VHPGLEngine() = default; ~VHPGLEngine() = default;
auto isActive() const -> bool; auto isActive() const -> bool;
@ -93,7 +93,7 @@ private:
QPoint m_currentPos{-1, -1}; QPoint m_currentPos{-1, -1};
bool m_singleLineFont{false}; bool m_singleLineFont{false};
bool m_singleStrokeOutlineFont{false}; bool m_singleStrokeOutlineFont{false};
int m_penWidthPx{qCeil(ToPixel(0.025, Unit::Mm))}; int m_penWidthPx;
qreal m_xscale{1}; qreal m_xscale{1};
qreal m_yscale{1}; qreal m_yscale{1};
bool m_showGrainline{true}; bool m_showGrainline{true};

File diff suppressed because it is too large Load diff

View file

@ -27,41 +27,40 @@
*************************************************************************/ *************************************************************************/
#include "vbestsquare.h" #include "vbestsquare.h"
#include "vbestsquare_p.h"
#include "../vgeometry/vgeometrydef.h" #include "../vgeometry/vgeometrydef.h"
#include "vbestsquare_p.h"
namespace namespace
{ {
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
Q_DECL_CONSTEXPR inline auto Square(QSizeF size) -> qint64 Q_DECL_CONSTEXPR inline auto Square(QSizeF size) -> qint64
{ {
return static_cast<qint64>(size.width()*size.height()); return static_cast<qint64>(size.width() * size.height());
} }
} // anonymous namespace } // anonymous namespace
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VBestSquare::VBestSquare() VBestSquare::VBestSquare()
: d(new VBestSquareData()) : d(new VBestSquareData())
{} {
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VBestSquare::VBestSquare(QSizeF sheetSize, bool saveLength, bool isPortrait) VBestSquare::VBestSquare(QSizeF sheetSize, bool saveLength, bool isPortrait)
: d(new VBestSquareData(sheetSize, saveLength, isPortrait)) : d(new VBestSquareData(sheetSize, saveLength, isPortrait))
{} {
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VBestSquare::VBestSquare(const VBestSquare &res) COPY_CONSTRUCTOR_IMPL(VBestSquare)
: d(res.d)
{}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VBestSquare::~VBestSquare() VBestSquare::~VBestSquare() = default;
{}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VBestSquare::operator=(const VBestSquare &res) -> VBestSquare & auto VBestSquare::operator=(const VBestSquare &res) -> VBestSquare &
{ {
if ( &res == this ) if (&res == this)
{ {
return *this; return *this;
} }
@ -72,11 +71,12 @@ auto VBestSquare::operator=(const VBestSquare &res) -> VBestSquare &
#ifdef Q_COMPILER_RVALUE_REFS #ifdef Q_COMPILER_RVALUE_REFS
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VBestSquare::VBestSquare(VBestSquare &&res) noexcept VBestSquare::VBestSquare(VBestSquare &&res) noexcept
: d(std::move(res.d)) : d(std::move(res.d))
{} {
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VBestSquare::operator=(VBestSquare &&res) noexcept->VBestSquare & auto VBestSquare::operator=(VBestSquare &&res) noexcept -> VBestSquare &
{ {
std::swap(d, res.d); std::swap(d, res.d);
return *this; return *this;
@ -104,12 +104,9 @@ void VBestSquare::NewResult(const VBestSquareResData &data)
{ {
if (d->saveLength) if (d->saveLength)
{ {
if (VFuzzyOnAxis(data.depthPosition, d->data.depthPosition) if ((VFuzzyOnAxis(data.depthPosition, d->data.depthPosition) &&
&& IsImprovedSidePosition(data.sidePosition)) IsImprovedSidePosition(data.sidePosition)) ||
{ data.depthPosition < d->data.depthPosition)
SaveResult();
}
else if (data.depthPosition < d->data.depthPosition)
{ {
SaveResult(); SaveResult();
} }
@ -214,7 +211,7 @@ auto VBestSquare::IsImprovedSidePosition(qreal sidePosition) const -> bool
const bool lessThan = d->data.sidePosition < sidePosition; const bool lessThan = d->data.sidePosition < sidePosition;
const bool greaterThan = d->data.sidePosition > sidePosition; const bool greaterThan = d->data.sidePosition > sidePosition;
return IsPortrait() ? greaterThan : lessThan; return IsPortrait() ? greaterThan : lessThan;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View file

@ -29,11 +29,11 @@
#ifndef VBESTSQUARE_H #ifndef VBESTSQUARE_H
#define VBESTSQUARE_H #define VBESTSQUARE_H
#include <QSharedDataPointer>
#include <QSizeF> #include <QSizeF>
#include <QTransform> #include <QTransform>
#include <QtGlobal>
#include <QSharedDataPointer>
#include <QTypeInfo> #include <QTypeInfo>
#include <QtGlobal>
#include "vlayoutdef.h" #include "vlayoutdef.h"
@ -50,7 +50,7 @@ public:
auto operator=(const VBestSquare &res) -> VBestSquare &; auto operator=(const VBestSquare &res) -> VBestSquare &;
#ifdef Q_COMPILER_RVALUE_REFS #ifdef Q_COMPILER_RVALUE_REFS
VBestSquare(VBestSquare &&res) noexcept; VBestSquare(VBestSquare &&res) noexcept;
auto operator=(VBestSquare &&res) noexcept->VBestSquare &; auto operator=(VBestSquare &&res) noexcept -> VBestSquare &;
#endif #endif
void NewResult(const VBestSquareResData &data); void NewResult(const VBestSquareResData &data);
@ -65,7 +65,7 @@ public:
auto Type() const -> BestFrom; auto Type() const -> BestFrom;
auto IsTerminatedByException() const -> bool; auto IsTerminatedByException() const -> bool;
auto ReasonTerminatedByException() const -> QString; auto ReasonTerminatedByException() const -> QString;
void TerminatedByException(const QString &reason); void TerminatedByException(const QString &reason);
auto BestResultData() const -> VBestSquareResData; auto BestResultData() const -> VBestSquareResData;
@ -75,7 +75,6 @@ public:
private: private:
QSharedDataPointer<VBestSquareData> d; QSharedDataPointer<VBestSquareData> d;
}; };
Q_DECLARE_TYPEINFO(VBestSquare, Q_MOVABLE_TYPE); // NOLINT Q_DECLARE_TYPEINFO(VBestSquare, Q_MOVABLE_TYPE); // NOLINT

View file

@ -106,7 +106,7 @@ VContour::VContour(int height, int width, qreal layoutWidth)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VContour::VContour(const VContour &contour) = default; COPY_CONSTRUCTOR_IMPL(VContour)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VContour::operator=(const VContour &contour) -> VContour & auto VContour::operator=(const VContour &contour) -> VContour &

View file

@ -35,8 +35,8 @@
#include <QVector> #include <QVector>
#include <QtGlobal> #include <QtGlobal>
#include "vlayoutdef.h"
#include "../vmisc/defglobal.h" #include "../vmisc/defglobal.h"
#include "vlayoutdef.h"
class VContourData; class VContourData;
class QPointF; class QPointF;
@ -57,16 +57,16 @@ public:
auto operator=(const VContour &contour) -> VContour &; auto operator=(const VContour &contour) -> VContour &;
#ifdef Q_COMPILER_RVALUE_REFS #ifdef Q_COMPILER_RVALUE_REFS
VContour(VContour &&contour) noexcept; VContour(VContour &&contour) noexcept;
auto operator=(VContour &&contour) noexcept->VContour &; auto operator=(VContour &&contour) noexcept -> VContour &;
#endif #endif
void CeateEmptySheetContour(); void CeateEmptySheetContour();
void SetContour(const QVector<QPointF> &contour); void SetContour(const QVector<QPointF> &contour);
auto GetContour() const -> QVector<QPointF>; auto GetContour() const -> QVector<QPointF>;
auto GetShift() const -> qreal; auto GetShift() const -> qreal;
void SetShift(qreal shift); void SetShift(qreal shift);
auto GetHeight() const -> int; auto GetHeight() const -> int;
void SetHeight(int height); void SetHeight(int height);

View file

@ -48,7 +48,6 @@
#endif #endif
#include "../ifc/exception/vexceptionterminatedposition.h" #include "../ifc/exception/vexceptionterminatedposition.h"
#include "../vmisc/compatibility.h"
#include "vbestsquare.h" #include "vbestsquare.h"
#include "vcontour.h" #include "vcontour.h"
#include "vlayoutpaper_p.h" #include "vlayoutpaper_p.h"
@ -68,10 +67,7 @@ VLayoutPaper::VLayoutPaper(int height, int width, qreal layoutWidth)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VLayoutPaper::VLayoutPaper(const VLayoutPaper &paper) COPY_CONSTRUCTOR_IMPL(VLayoutPaper)
: d(paper.d)
{
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VLayoutPaper::operator=(const VLayoutPaper &paper) -> VLayoutPaper & auto VLayoutPaper::operator=(const VLayoutPaper &paper) -> VLayoutPaper &
@ -100,9 +96,7 @@ auto VLayoutPaper::operator=(VLayoutPaper &&paper) noexcept -> VLayoutPaper &
#endif #endif
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VLayoutPaper::~VLayoutPaper() VLayoutPaper::~VLayoutPaper() = default;
{
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VLayoutPaper::GetHeight() const -> int auto VLayoutPaper::GetHeight() const -> int
@ -382,7 +376,7 @@ auto VLayoutPaper::GetGlobalContour() const -> QGraphicsPathItem *
const QVector<QPointF> points = d->globalContour.GetContour(); const QVector<QPointF> points = d->globalContour.GetContour();
QPainterPath path; QPainterPath path;
if (points.size() > 0) if (!points.isEmpty())
{ {
path.moveTo(points.at(0)); path.moveTo(points.at(0));
for (auto point : points) for (auto point : points)

View file

@ -29,13 +29,12 @@
#ifndef VLAYOUTPAPER_H #ifndef VLAYOUTPAPER_H
#define VLAYOUTPAPER_H #define VLAYOUTPAPER_H
#include <QGraphicsPathItem>
#include <QSharedDataPointer> #include <QSharedDataPointer>
#include <QTypeInfo> #include <QTypeInfo>
#include <QtCore/qcontainerfwd.h>
#include <QtGlobal> #include <QtGlobal>
#include <atomic> #include <atomic>
#include <QGraphicsPathItem>
#include <QtCore/qcontainerfwd.h>
#include "../vmisc/defglobal.h" #include "../vmisc/defglobal.h"
@ -59,7 +58,7 @@ public:
auto operator=(const VLayoutPaper &paper) -> VLayoutPaper &; auto operator=(const VLayoutPaper &paper) -> VLayoutPaper &;
#ifdef Q_COMPILER_RVALUE_REFS #ifdef Q_COMPILER_RVALUE_REFS
VLayoutPaper(VLayoutPaper &&paper) noexcept; VLayoutPaper(VLayoutPaper &&paper) noexcept;
auto operator=(VLayoutPaper &&paper) noexcept->VLayoutPaper &; auto operator=(VLayoutPaper &&paper) noexcept -> VLayoutPaper &;
#endif #endif
auto GetHeight() const -> int; auto GetHeight() const -> int;
@ -69,10 +68,10 @@ public:
void SetWidth(int width); void SetWidth(int width);
auto GetLayoutWidth() const -> qreal; auto GetLayoutWidth() const -> qreal;
void SetLayoutWidth(qreal width); void SetLayoutWidth(qreal width);
auto GetShift() const -> qreal; auto GetShift() const -> qreal;
void SetShift(qreal shift); void SetShift(qreal shift);
auto GetRotate() const -> bool; auto GetRotate() const -> bool;
void SetRotate(bool value); void SetRotate(bool value);
@ -99,9 +98,9 @@ public:
Q_REQUIRED_RESULT auto GetItemDetails(bool textAsPaths) const -> QList<QGraphicsItem *>; Q_REQUIRED_RESULT auto GetItemDetails(bool textAsPaths) const -> QList<QGraphicsItem *>;
auto GetDetails() const -> QVector<VLayoutPiece>; auto GetDetails() const -> QVector<VLayoutPiece>;
void SetDetails(const QVector<VLayoutPiece>& details); void SetDetails(const QVector<VLayoutPiece> &details);
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
void SetDetails(const QList<VLayoutPiece>& details); void SetDetails(const QList<VLayoutPiece> &details);
#endif #endif
auto DetailsBoundingRect() const -> QRectF; auto DetailsBoundingRect() const -> QRectF;

View file

@ -595,11 +595,7 @@ VLayoutPiece::VLayoutPiece()
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VLayoutPiece::VLayoutPiece(const VLayoutPiece &detail) // NOLINT(modernize-use-equals-default) COPY_CONSTRUCTOR_IMPL_2(VLayoutPiece, VAbstractPiece)
: VAbstractPiece(detail),
d(detail.d)
{
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VLayoutPiece::operator=(const VLayoutPiece &detail) -> VLayoutPiece & auto VLayoutPiece::operator=(const VLayoutPiece &detail) -> VLayoutPiece &
@ -615,14 +611,14 @@ auto VLayoutPiece::operator=(const VLayoutPiece &detail) -> VLayoutPiece &
#ifdef Q_COMPILER_RVALUE_REFS #ifdef Q_COMPILER_RVALUE_REFS
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VLayoutPiece::VLayoutPiece(VLayoutPiece &&detail) noexcept : VAbstractPiece(std::move(detail)), VLayoutPiece::VLayoutPiece(VLayoutPiece &&detail) noexcept
d(std::move(detail.d)) : VAbstractPiece(std::move(detail)),
d(std::move(detail.d))
{ {
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VLayoutPiece::operator=(VLayoutPiece &&detail) noexcept auto VLayoutPiece::operator=(VLayoutPiece &&detail) noexcept -> VLayoutPiece &
->VLayoutPiece &
{ {
VAbstractPiece::operator=(detail); VAbstractPiece::operator=(detail);
std::swap(d, detail.d); std::swap(d, detail.d);
@ -631,9 +627,7 @@ auto VLayoutPiece::operator=(VLayoutPiece &&detail) noexcept
#endif #endif
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VLayoutPiece::~VLayoutPiece() // NOLINT(modernize-use-equals-default) VLayoutPiece::~VLayoutPiece() = default;
{
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VLayoutPiece::Create(const VPiece &piece, vidtype id, const VContainer *pattern) -> VLayoutPiece auto VLayoutPiece::Create(const VPiece &piece, vidtype id, const VContainer *pattern) -> VLayoutPiece

View file

@ -91,8 +91,7 @@ public:
auto operator=(const VLayoutPiece &detail) -> VLayoutPiece &; auto operator=(const VLayoutPiece &detail) -> VLayoutPiece &;
#ifdef Q_COMPILER_RVALUE_REFS #ifdef Q_COMPILER_RVALUE_REFS
VLayoutPiece(VLayoutPiece &&detail) noexcept; VLayoutPiece(VLayoutPiece &&detail) noexcept;
auto operator=(VLayoutPiece &&detail) noexcept auto operator=(VLayoutPiece &&detail) noexcept -> VLayoutPiece &;
->VLayoutPiece &;
#endif #endif
static auto Create(const VPiece &piece, vidtype id, const VContainer *pattern) -> VLayoutPiece; static auto Create(const VPiece &piece, vidtype id, const VContainer *pattern) -> VLayoutPiece;
@ -265,7 +264,7 @@ Q_DECLARE_TYPEINFO(VLayoutPiece, Q_MOVABLE_TYPE); // NOLINT
template <class T> inline auto VLayoutPiece::Map(QVector<T> points, const QTransform &matrix, bool mirror) -> QVector<T> template <class T> inline auto VLayoutPiece::Map(QVector<T> points, const QTransform &matrix, bool mirror) -> QVector<T>
{ {
std::transform(points.begin(), points.end(), points.begin(), std::transform(points.begin(), points.end(), points.begin(),
[matrix](const T &point) { return Map(point, matrix); }); [matrix](const T &point) { return VLayoutPiece::Map(point, matrix); });
if (mirror) if (mirror)
{ {
std::reverse(points.begin(), points.end()); std::reverse(points.begin(), points.end());

View file

@ -48,26 +48,23 @@ auto operator>>(QDataStream &dataStream, VLayoutPiecePath &path) -> QDataStream
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VLayoutPiecePath::VLayoutPiecePath() VLayoutPiecePath::VLayoutPiecePath()
: d(new VLayoutPiecePathData) : d(new VLayoutPiecePathData)
{ {
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VLayoutPiecePath::VLayoutPiecePath(const QVector<VLayoutPoint> &points) VLayoutPiecePath::VLayoutPiecePath(const QVector<VLayoutPoint> &points)
: d(new VLayoutPiecePathData(points)) : d(new VLayoutPiecePathData(points))
{ {
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VLayoutPiecePath::VLayoutPiecePath(const VLayoutPiecePath &path) COPY_CONSTRUCTOR_IMPL(VLayoutPiecePath)
: d(path.d)
{
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VLayoutPiecePath::operator=(const VLayoutPiecePath &path) -> VLayoutPiecePath & auto VLayoutPiecePath::operator=(const VLayoutPiecePath &path) -> VLayoutPiecePath &
{ {
if ( &path == this ) if (&path == this)
{ {
return *this; return *this;
} }
@ -78,11 +75,12 @@ auto VLayoutPiecePath::operator=(const VLayoutPiecePath &path) -> VLayoutPiecePa
#ifdef Q_COMPILER_RVALUE_REFS #ifdef Q_COMPILER_RVALUE_REFS
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VLayoutPiecePath::VLayoutPiecePath(VLayoutPiecePath &&path) noexcept VLayoutPiecePath::VLayoutPiecePath(VLayoutPiecePath &&path) noexcept
: d(std::move(path.d)) : d(std::move(path.d))
{} {
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VLayoutPiecePath::operator=(VLayoutPiecePath &&path) noexcept->VLayoutPiecePath & auto VLayoutPiecePath::operator=(VLayoutPiecePath &&path) noexcept -> VLayoutPiecePath &
{ {
std::swap(d, path.d); std::swap(d, path.d);
return *this; return *this;
@ -90,9 +88,7 @@ auto VLayoutPiecePath::operator=(VLayoutPiecePath &&path) noexcept->VLayoutPiece
#endif #endif
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VLayoutPiecePath::~VLayoutPiecePath() VLayoutPiecePath::~VLayoutPiecePath() = default;
{
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VLayoutPiecePath::GetPainterPath() const -> QPainterPath auto VLayoutPiecePath::GetPainterPath() const -> QPainterPath

View file

@ -68,6 +68,28 @@ template <class T> class QSharedPointer;
#endif #endif
#endif #endif
#if defined(Q_COMPILER_GCC) && defined(Q_CC_GNU) && defined(Q_CC_GNU_VERSION) && (Q_CC_GNU_VERSION <= 40900)
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
#define COPY_CONSTRUCTOR_IMPL(className) \
className::className(const className &item) \
: d(item.d) \
{ \
}
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
#define COPY_CONSTRUCTOR_IMPL_2(className, baseClassName) \
className::className(const className &item) \
: baseClassName(item), \
d(item.d) \
{ \
}
#else
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
#define COPY_CONSTRUCTOR_IMPL(className) className::className(const className &) = default;
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
#define COPY_CONSTRUCTOR_IMPL_2(className, baseClassName) className::className(const className &) = default;
#endif
class QComboBox; class QComboBox;
class QMarginsF; class QMarginsF;
class VTranslateMeasurements; class VTranslateMeasurements;
@ -501,7 +523,7 @@ template <typename T> constexpr inline auto InchToPixel(T val) noexcept -> T
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
Q_DECL_RELAXED_CONSTEXPR inline auto ToPixel(double val, const Unit &unit) -> double Q_DECL_RELAXED_CONSTEXPR inline auto ToPixel(double val, const Unit &unit) noexcept -> double
{ {
switch (unit) switch (unit)
{ {

View file

@ -26,6 +26,7 @@
** **
*************************************************************************/ *************************************************************************/
#include "vsvgfont.h" #include "vsvgfont.h"
#include "../def.h"
#include "svgdef.h" #include "svgdef.h"
#include "vsvgfont_p.h" #include "vsvgfont_p.h"
@ -47,15 +48,10 @@ VSvgFont::VSvgFont(qreal horizAdvX)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VSvgFont::VSvgFont(const VSvgFont &font) // NOLINT(modernize-use-equals-default) COPY_CONSTRUCTOR_IMPL(VSvgFont)
: d(font.d)
{
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VSvgFont::~VSvgFont() // NOLINT(modernize-use-equals-default) VSvgFont::~VSvgFont() = default;
{
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VSvgFont::operator=(const VSvgFont &font) -> VSvgFont & auto VSvgFont::operator=(const VSvgFont &font) -> VSvgFont &

View file

@ -53,15 +53,10 @@ VSvgFontEngine::VSvgFontEngine(const VSvgFont &font)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VSvgFontEngine::VSvgFontEngine(const VSvgFontEngine &engine) // NOLINT(modernize-use-equals-default) COPY_CONSTRUCTOR_IMPL(VSvgFontEngine)
: d(engine.d)
{
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VSvgFontEngine::~VSvgFontEngine() // NOLINT(modernize-use-equals-default) VSvgFontEngine::~VSvgFontEngine() = default;
{
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VSvgFontEngine::operator=(const VSvgFontEngine &engine) -> VSvgFontEngine & auto VSvgFontEngine::operator=(const VSvgFontEngine &engine) -> VSvgFontEngine &

View file

@ -26,6 +26,7 @@
** **
*************************************************************************/ *************************************************************************/
#include "vsvgglyph.h" #include "vsvgglyph.h"
#include "../def.h"
#include "vsvgglyph_p.h" #include "vsvgglyph_p.h"
#include <QChar> #include <QChar>
@ -44,15 +45,10 @@ VSvgGlyph::VSvgGlyph(QChar unicode, const QPainterPath &path, qreal horizAdvX)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VSvgGlyph::VSvgGlyph(const VSvgGlyph &font) // NOLINT(modernize-use-equals-default) COPY_CONSTRUCTOR_IMPL(VSvgGlyph)
: d(font.d)
{
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VSvgGlyph::~VSvgGlyph() // NOLINT(modernize-use-equals-default) VSvgGlyph::~VSvgGlyph() = default;
{
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VSvgGlyph::operator=(const VSvgGlyph &glyph) -> VSvgGlyph & auto VSvgGlyph::operator=(const VSvgGlyph &glyph) -> VSvgGlyph &

View file

@ -27,22 +27,22 @@
*************************************************************************/ *************************************************************************/
#include "vabstractfloatitemdata.h" #include "vabstractfloatitemdata.h"
#include "../vmisc/def.h"
#include "vabstractfloatitemdata_p.h" #include "vabstractfloatitemdata_p.h"
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VAbstractFloatItemData::VAbstractFloatItemData() VAbstractFloatItemData::VAbstractFloatItemData()
: d(new VAbstractFloatItemDataPrivate()) : d(new VAbstractFloatItemDataPrivate())
{} {
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VAbstractFloatItemData::VAbstractFloatItemData(const VAbstractFloatItemData &data) COPY_CONSTRUCTOR_IMPL(VAbstractFloatItemData)
: d (data.d)
{}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VAbstractFloatItemData::operator=(const VAbstractFloatItemData &data) -> VAbstractFloatItemData & auto VAbstractFloatItemData::operator=(const VAbstractFloatItemData &data) -> VAbstractFloatItemData &
{ {
if ( &data == this ) if (&data == this)
{ {
return *this; return *this;
} }
@ -53,11 +53,12 @@ auto VAbstractFloatItemData::operator=(const VAbstractFloatItemData &data) -> VA
#ifdef Q_COMPILER_RVALUE_REFS #ifdef Q_COMPILER_RVALUE_REFS
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VAbstractFloatItemData::VAbstractFloatItemData(VAbstractFloatItemData &&data) noexcept VAbstractFloatItemData::VAbstractFloatItemData(VAbstractFloatItemData &&data) noexcept
: d (std::move(data.d)) : d(std::move(data.d))
{} {
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VAbstractFloatItemData::operator=(VAbstractFloatItemData &&data) noexcept->VAbstractFloatItemData & auto VAbstractFloatItemData::operator=(VAbstractFloatItemData &&data) noexcept -> VAbstractFloatItemData &
{ {
std::swap(d, data.d); std::swap(d, data.d);
return *this; return *this;
@ -65,8 +66,7 @@ auto VAbstractFloatItemData::operator=(VAbstractFloatItemData &&data) noexcept->
#endif #endif
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VAbstractFloatItemData::~VAbstractFloatItemData() VAbstractFloatItemData::~VAbstractFloatItemData() = default;
{}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VAbstractFloatItemData::GetPos() const -> QPointF auto VAbstractFloatItemData::GetPos() const -> QPointF

View file

@ -28,25 +28,24 @@
#include <QPointF> #include <QPointF>
#include "../vmisc/def.h"
#include "vgrainlinedata.h" #include "vgrainlinedata.h"
#include "vgrainlinedata_p.h" #include "vgrainlinedata_p.h"
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VGrainlineData::VGrainlineData() VGrainlineData::VGrainlineData()
: VAbstractFloatItemData(), : VAbstractFloatItemData(),
d(new VGrainlineDataPrivate()) d(new VGrainlineDataPrivate())
{} {
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VGrainlineData::VGrainlineData(const VGrainlineData &data) COPY_CONSTRUCTOR_IMPL_2(VGrainlineData, VAbstractFloatItemData)
: VAbstractFloatItemData(data),
d (data.d)
{}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VGrainlineData::operator=(const VGrainlineData &data) -> VGrainlineData & auto VGrainlineData::operator=(const VGrainlineData &data) -> VGrainlineData &
{ {
if ( &data == this ) if (&data == this)
{ {
return *this; return *this;
} }
@ -58,12 +57,13 @@ auto VGrainlineData::operator=(const VGrainlineData &data) -> VGrainlineData &
#ifdef Q_COMPILER_RVALUE_REFS #ifdef Q_COMPILER_RVALUE_REFS
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VGrainlineData::VGrainlineData(VGrainlineData &&data) noexcept VGrainlineData::VGrainlineData(VGrainlineData &&data) noexcept
: VAbstractFloatItemData(std::move(data)), : VAbstractFloatItemData(std::move(data)),
d (std::move(data.d)) d(std::move(data.d))
{} {
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VGrainlineData::operator=(VGrainlineData &&data) noexcept->VGrainlineData & auto VGrainlineData::operator=(VGrainlineData &&data) noexcept -> VGrainlineData &
{ {
VAbstractFloatItemData::operator=(data); VAbstractFloatItemData::operator=(data);
std::swap(d, data.d); std::swap(d, data.d);
@ -72,8 +72,7 @@ auto VGrainlineData::operator=(VGrainlineData &&data) noexcept->VGrainlineData &
#endif #endif
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VGrainlineData::~VGrainlineData() VGrainlineData::~VGrainlineData() = default;
{}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VGrainlineData::GetLength() const -> QString auto VGrainlineData::GetLength() const -> QString
@ -82,7 +81,7 @@ auto VGrainlineData::GetLength() const -> QString
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VGrainlineData::SetLength(const QString& qsLen) void VGrainlineData::SetLength(const QString &qsLen)
{ {
d->m_qsLength = qsLen; d->m_qsLength = qsLen;
} }
@ -94,7 +93,7 @@ auto VGrainlineData::GetRotation() const -> QString
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VGrainlineData::SetRotation(const QString& qsRot) void VGrainlineData::SetRotation(const QString &qsRot)
{ {
d->m_dRotation = qsRot; d->m_dRotation = qsRot;
} }

View file

@ -29,11 +29,11 @@
#ifndef VGRAINLINEGEOMETRY_H #ifndef VGRAINLINEGEOMETRY_H
#define VGRAINLINEGEOMETRY_H #define VGRAINLINEGEOMETRY_H
#include <QString>
#include <QPointF> #include <QPointF>
#include <QString>
#include "vabstractfloatitemdata.h"
#include "floatitemdef.h" #include "floatitemdef.h"
#include "vabstractfloatitemdata.h"
class VGrainlineDataPrivate; class VGrainlineDataPrivate;
@ -47,36 +47,35 @@ public:
VGrainlineData(); VGrainlineData();
VGrainlineData(const VGrainlineData &data); VGrainlineData(const VGrainlineData &data);
virtual ~VGrainlineData(); ~VGrainlineData() override;
auto operator=(const VGrainlineData &data) -> VGrainlineData &; auto operator=(const VGrainlineData &data) -> VGrainlineData &;
#ifdef Q_COMPILER_RVALUE_REFS #ifdef Q_COMPILER_RVALUE_REFS
VGrainlineData(VGrainlineData &&data) noexcept; VGrainlineData(VGrainlineData &&data) noexcept;
auto operator=(VGrainlineData &&data) noexcept->VGrainlineData &; auto operator=(VGrainlineData &&data) noexcept -> VGrainlineData &;
#endif #endif
// methods, which set and return values of different parameters // methods, which set and return values of different parameters
auto GetLength() const -> QString; auto GetLength() const -> QString;
void SetLength(const QString& qsLen); void SetLength(const QString &qsLen);
auto GetRotation() const -> QString; auto GetRotation() const -> QString;
void SetRotation(const QString& qsRot); void SetRotation(const QString &qsRot);
auto GetArrowType() const -> GrainlineArrowDirection; auto GetArrowType() const -> GrainlineArrowDirection;
void SetArrowType(GrainlineArrowDirection eAT); void SetArrowType(GrainlineArrowDirection eAT);
auto CenterPin() const -> quint32; auto CenterPin() const -> quint32;
void SetCenterPin(quint32 centerPin); void SetCenterPin(quint32 centerPin);
auto TopPin() const -> quint32; auto TopPin() const -> quint32;
void SetTopPin(quint32 topPin); void SetTopPin(quint32 topPin);
auto BottomPin() const -> quint32; auto BottomPin() const -> quint32;
void SetBottomPin(quint32 bottomPin); void SetBottomPin(quint32 bottomPin);
private: private:
QSharedDataPointer<VGrainlineDataPrivate> d; QSharedDataPointer<VGrainlineDataPrivate> d;
}; };
#endif // VGRAINLINEGEOMETRY_H #endif // VGRAINLINEGEOMETRY_H

View file

@ -27,25 +27,23 @@
*************************************************************************/ *************************************************************************/
#include "vpatternlabeldata.h" #include "vpatternlabeldata.h"
#include "../vmisc/def.h"
#include "vpatternlabeldata_p.h" #include "vpatternlabeldata_p.h"
#include "../ifc/ifcdef.h"
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPatternLabelData::VPatternLabelData() VPatternLabelData::VPatternLabelData()
: VAbstractFloatItemData(), : VAbstractFloatItemData(),
d(new VPatternLabelDataPrivate()) d(new VPatternLabelDataPrivate())
{} {
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPatternLabelData::VPatternLabelData(const VPatternLabelData &data) COPY_CONSTRUCTOR_IMPL_2(VPatternLabelData, VAbstractFloatItemData)
: VAbstractFloatItemData(data),
d (data.d)
{}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VPatternLabelData::operator=(const VPatternLabelData &data) -> VPatternLabelData & auto VPatternLabelData::operator=(const VPatternLabelData &data) -> VPatternLabelData &
{ {
if ( &data == this ) if (&data == this)
{ {
return *this; return *this;
} }
@ -57,12 +55,13 @@ auto VPatternLabelData::operator=(const VPatternLabelData &data) -> VPatternLabe
#ifdef Q_COMPILER_RVALUE_REFS #ifdef Q_COMPILER_RVALUE_REFS
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPatternLabelData::VPatternLabelData(VPatternLabelData &&data) noexcept VPatternLabelData::VPatternLabelData(VPatternLabelData &&data) noexcept
: VAbstractFloatItemData(std::move(data)), : VAbstractFloatItemData(std::move(data)),
d (std::move(data.d)) d(std::move(data.d))
{} {
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VPatternLabelData::operator=(VPatternLabelData &&data) noexcept->VPatternLabelData & auto VPatternLabelData::operator=(VPatternLabelData &&data) noexcept -> VPatternLabelData &
{ {
VAbstractFloatItemData::operator=(data); VAbstractFloatItemData::operator=(data);
std::swap(d, data.d); std::swap(d, data.d);
@ -71,8 +70,7 @@ auto VPatternLabelData::operator=(VPatternLabelData &&data) noexcept->VPatternLa
#endif #endif
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPatternLabelData::~VPatternLabelData() VPatternLabelData::~VPatternLabelData() = default;
{}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VPatternLabelData::GetLabelWidth() const -> QString auto VPatternLabelData::GetLabelWidth() const -> QString

View file

@ -44,35 +44,35 @@ public:
VPatternLabelData(); VPatternLabelData();
VPatternLabelData(const VPatternLabelData &data); VPatternLabelData(const VPatternLabelData &data);
virtual ~VPatternLabelData(); ~VPatternLabelData() override;
auto operator=(const VPatternLabelData &data) -> VPatternLabelData &; auto operator=(const VPatternLabelData &data) -> VPatternLabelData &;
#ifdef Q_COMPILER_RVALUE_REFS #ifdef Q_COMPILER_RVALUE_REFS
VPatternLabelData(VPatternLabelData &&data) noexcept; VPatternLabelData(VPatternLabelData &&data) noexcept;
auto operator=(VPatternLabelData &&data) noexcept->VPatternLabelData &; auto operator=(VPatternLabelData &&data) noexcept -> VPatternLabelData &;
#endif #endif
// methods, which set up label parameters // methods, which set up label parameters
auto GetLabelWidth() const -> QString; auto GetLabelWidth() const -> QString;
void SetLabelWidth(const QString &dLabelW); void SetLabelWidth(const QString &dLabelW);
auto GetLabelHeight() const -> QString; auto GetLabelHeight() const -> QString;
void SetLabelHeight(const QString &dLabelH); void SetLabelHeight(const QString &dLabelH);
auto GetFontSize() const -> int; auto GetFontSize() const -> int;
void SetFontSize(int iSize); void SetFontSize(int iSize);
auto GetRotation() const -> QString; auto GetRotation() const -> QString;
void SetRotation(const QString &dRot); void SetRotation(const QString &dRot);
auto CenterPin() const -> quint32; auto CenterPin() const -> quint32;
void SetCenterPin(const quint32 &centerPin); void SetCenterPin(const quint32 &centerPin);
auto TopLeftPin() const -> quint32; auto TopLeftPin() const -> quint32;
void SetTopLeftPin(const quint32 &topLeftPin); void SetTopLeftPin(const quint32 &topLeftPin);
auto BottomRightPin() const -> quint32; auto BottomRightPin() const -> quint32;
void SetBottomRightPin(const quint32 &bottomRightPin); void SetBottomRightPin(const quint32 &bottomRightPin);
private: private:
QSharedDataPointer<VPatternLabelDataPrivate> d; QSharedDataPointer<VPatternLabelDataPrivate> d;

View file

@ -33,20 +33,18 @@
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPieceLabelData::VPieceLabelData() VPieceLabelData::VPieceLabelData()
: VPatternLabelData(), : VPatternLabelData(),
d(new VPieceLabelDataPrivate()) d(new VPieceLabelDataPrivate())
{} {
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPieceLabelData::VPieceLabelData(const VPieceLabelData &data) COPY_CONSTRUCTOR_IMPL_2(VPieceLabelData, VPatternLabelData)
: VPatternLabelData(data),
d (data.d)
{}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VPieceLabelData::operator=(const VPieceLabelData &data) -> VPieceLabelData & auto VPieceLabelData::operator=(const VPieceLabelData &data) -> VPieceLabelData &
{ {
if ( &data == this ) if (&data == this)
{ {
return *this; return *this;
} }
@ -58,12 +56,13 @@ auto VPieceLabelData::operator=(const VPieceLabelData &data) -> VPieceLabelData
#ifdef Q_COMPILER_RVALUE_REFS #ifdef Q_COMPILER_RVALUE_REFS
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPieceLabelData::VPieceLabelData(VPieceLabelData &&data) noexcept VPieceLabelData::VPieceLabelData(VPieceLabelData &&data) noexcept
: VPatternLabelData(std::move(data)), : VPatternLabelData(std::move(data)),
d (std::move(data.d)) d(std::move(data.d))
{} {
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VPieceLabelData::operator=(VPieceLabelData &&data) noexcept->VPieceLabelData & auto VPieceLabelData::operator=(VPieceLabelData &&data) noexcept -> VPieceLabelData &
{ {
VPatternLabelData::operator=(data); VPatternLabelData::operator=(data);
std::swap(d, data.d); std::swap(d, data.d);
@ -72,8 +71,7 @@ auto VPieceLabelData::operator=(VPieceLabelData &&data) noexcept->VPieceLabelDat
#endif #endif
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPieceLabelData::~VPieceLabelData() VPieceLabelData::~VPieceLabelData() = default;
{}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPieceLabelData::Clear() void VPieceLabelData::Clear()

View file

@ -47,7 +47,7 @@ VCurveVariable::VCurveVariable(const quint32 &id, const quint32 &parentId)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VCurveVariable::VCurveVariable(const VCurveVariable &var) = default; COPY_CONSTRUCTOR_IMPL(VCurveVariable)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VCurveVariable::operator=(const VCurveVariable &var) -> VCurveVariable & auto VCurveVariable::operator=(const VCurveVariable &var) -> VCurveVariable &

View file

@ -29,15 +29,16 @@
#include "vincrement.h" #include "vincrement.h"
#include "../vmisc/def.h" #include "../vmisc/def.h"
#include "vvariable.h"
#include "vincrement_p.h" #include "vincrement_p.h"
#include "vvariable.h"
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief VIncrement create enpty increment * @brief VIncrement create enpty increment
*/ */
VIncrement::VIncrement() VIncrement::VIncrement()
:VVariable(), d(new VIncrementData) : VVariable(),
d(new VIncrementData)
{ {
SetType(VarType::Increment); SetType(VarType::Increment);
} }
@ -48,20 +49,19 @@ VIncrement::VIncrement()
* @param name increment's name * @param name increment's name
*/ */
VIncrement::VIncrement(VContainer *data, const QString &name, IncrementType incrType) VIncrement::VIncrement(VContainer *data, const QString &name, IncrementType incrType)
:VVariable(name, QString()), d(new VIncrementData(data, incrType)) : VVariable(name, QString()),
d(new VIncrementData(data, incrType))
{ {
incrType == IncrementType::Separator ? SetType(VarType::IncrementSeparator) : SetType(VarType::Increment); incrType == IncrementType::Separator ? SetType(VarType::IncrementSeparator) : SetType(VarType::Increment);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VIncrement::VIncrement(const VIncrement &incr) COPY_CONSTRUCTOR_IMPL_2(VIncrement, VVariable)
:VVariable(incr), d(incr.d)
{}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VIncrement::operator=(const VIncrement &incr) -> VIncrement & auto VIncrement::operator=(const VIncrement &incr) -> VIncrement &
{ {
if ( &incr == this ) if (&incr == this)
{ {
return *this; return *this;
} }
@ -73,11 +73,13 @@ auto VIncrement::operator=(const VIncrement &incr) -> VIncrement &
#ifdef Q_COMPILER_RVALUE_REFS #ifdef Q_COMPILER_RVALUE_REFS
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VIncrement::VIncrement(VIncrement &&incr) noexcept VIncrement::VIncrement(VIncrement &&incr) noexcept
:VVariable(std::move(incr)), d(std::move(incr.d)) : VVariable(std::move(incr)),
{} d(std::move(incr.d))
{
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VIncrement::operator=(VIncrement &&incr) noexcept->VIncrement & auto VIncrement::operator=(VIncrement &&incr) noexcept -> VIncrement &
{ {
VVariable::operator=(incr); VVariable::operator=(incr);
std::swap(d, incr.d); std::swap(d, incr.d);
@ -86,8 +88,7 @@ auto VIncrement::operator=(VIncrement &&incr) noexcept->VIncrement &
#endif #endif
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VIncrement::~VIncrement() VIncrement::~VIncrement() = default;
{}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**

View file

@ -49,7 +49,7 @@ public:
VIncrement(VContainer *data, const QString &name, IncrementType incrType = IncrementType::Increment); VIncrement(VContainer *data, const QString &name, IncrementType incrType = IncrementType::Increment);
VIncrement(const VIncrement &incr); VIncrement(const VIncrement &incr);
virtual ~VIncrement() override; ~VIncrement() override;
auto operator=(const VIncrement &incr) -> VIncrement &; auto operator=(const VIncrement &incr) -> VIncrement &;
#ifdef Q_COMPILER_RVALUE_REFS #ifdef Q_COMPILER_RVALUE_REFS

View file

@ -36,7 +36,7 @@ VInternalVariable::VInternalVariable()
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VInternalVariable::VInternalVariable(const VInternalVariable &var) = default; COPY_CONSTRUCTOR_IMPL(VInternalVariable)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VInternalVariable::operator=(const VInternalVariable &var) -> VInternalVariable & auto VInternalVariable::operator=(const VInternalVariable &var) -> VInternalVariable &

View file

@ -34,22 +34,24 @@
#include <QString> #include <QString>
#include <QtMath> #include <QtMath>
#include "../vmisc/def.h"
#include "../ifc/ifcdef.h" #include "../ifc/ifcdef.h"
#include "../vgeometry/vpointf.h" #include "../vgeometry/vpointf.h"
#include "../vmisc/def.h"
#include "vinternalvariable.h" #include "vinternalvariable.h"
#include "vlineangle_p.h" #include "vlineangle_p.h"
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VLineAngle::VLineAngle() VLineAngle::VLineAngle()
:VInternalVariable(), d(new VLineAngleData) : VInternalVariable(),
d(new VLineAngleData)
{ {
SetType(VarType::LineAngle); SetType(VarType::LineAngle);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VLineAngle::VLineAngle(const VPointF *p1, const quint32 &p1Id, const VPointF *p2, const quint32 &p2Id) VLineAngle::VLineAngle(const VPointF *p1, const quint32 &p1Id, const VPointF *p2, const quint32 &p2Id)
:VInternalVariable(), d(new VLineAngleData(p1Id, p2Id)) : VInternalVariable(),
d(new VLineAngleData(p1Id, p2Id))
{ {
SetType(VarType::LineAngle); SetType(VarType::LineAngle);
@ -57,19 +59,17 @@ VLineAngle::VLineAngle(const VPointF *p1, const quint32 &p1Id, const VPointF *p2
SCASSERT(p1 != nullptr) SCASSERT(p1 != nullptr)
SCASSERT(p2 != nullptr) SCASSERT(p2 != nullptr)
SetName(QString(angleLine_+"%1_%2").arg(p1->name(), p2->name())); SetName(QString(angleLine_ + "%1_%2").arg(p1->name(), p2->name()));
SetValue(p1, p2); SetValue(p1, p2);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VLineAngle::VLineAngle(const VLineAngle &var) COPY_CONSTRUCTOR_IMPL_2(VLineAngle, VInternalVariable)
:VInternalVariable(var), d(var.d)
{}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VLineAngle::operator=(const VLineAngle &var) -> VLineAngle & auto VLineAngle::operator=(const VLineAngle &var) -> VLineAngle &
{ {
if ( &var == this ) if (&var == this)
{ {
return *this; return *this;
} }
@ -81,11 +81,13 @@ auto VLineAngle::operator=(const VLineAngle &var) -> VLineAngle &
#ifdef Q_COMPILER_RVALUE_REFS #ifdef Q_COMPILER_RVALUE_REFS
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VLineAngle::VLineAngle(VLineAngle &&var) noexcept VLineAngle::VLineAngle(VLineAngle &&var) noexcept
:VInternalVariable(std::move(var)), d(std::move(var.d)) : VInternalVariable(std::move(var)),
{} d(std::move(var.d))
{
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VLineAngle::operator=(VLineAngle &&var) noexcept->VLineAngle & auto VLineAngle::operator=(VLineAngle &&var) noexcept -> VLineAngle &
{ {
VInternalVariable::operator=(var); VInternalVariable::operator=(var);
std::swap(d, var.d); std::swap(d, var.d);
@ -94,8 +96,7 @@ auto VLineAngle::operator=(VLineAngle &&var) noexcept->VLineAngle &
#endif #endif
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VLineAngle::~VLineAngle() VLineAngle::~VLineAngle() = default;
{}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VLineAngle::Filter(quint32 id) -> bool auto VLineAngle::Filter(quint32 id) -> bool
@ -108,9 +109,9 @@ void VLineAngle::SetValue(const VPointF *p1, const VPointF *p2)
{ {
SCASSERT(p1 != nullptr) SCASSERT(p1 != nullptr)
SCASSERT(p2 != nullptr) SCASSERT(p2 != nullptr)
//Correct angle. Try avoid results like 6,7563e-15. // Correct angle. Try avoid results like 6,7563e-15.
const qreal angle = qFloor(QLineF(static_cast<QPointF>(*p1), const qreal angle =
static_cast<QPointF>(*p2)).angle() * 100000.) / 100000.; qFloor(QLineF(static_cast<QPointF>(*p1), static_cast<QPointF>(*p2)).angle() * 100000.) / 100000.;
VInternalVariable::SetValue(angle); VInternalVariable::SetValue(angle);
} }

View file

@ -52,7 +52,7 @@ public:
auto operator=(VLineAngle &&var) noexcept -> VLineAngle &; auto operator=(VLineAngle &&var) noexcept -> VLineAngle &;
#endif #endif
virtual auto Filter(quint32 id) -> bool override; auto Filter(quint32 id) -> bool override;
void SetValue(const VPointF *p1, const VPointF *p2); void SetValue(const VPointF *p1, const VPointF *p2);

View file

@ -40,7 +40,8 @@
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VLengthLine::VLengthLine() VLengthLine::VLengthLine()
:VInternalVariable(), d(new VLengthLineData) : VInternalVariable(),
d(new VLengthLineData)
{ {
SetType(VarType::LineLength); SetType(VarType::LineLength);
} }
@ -48,26 +49,25 @@ VLengthLine::VLengthLine()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VLengthLine::VLengthLine(const VPointF *p1, const quint32 &p1Id, const VPointF *p2, const quint32 &p2Id, VLengthLine::VLengthLine(const VPointF *p1, const quint32 &p1Id, const VPointF *p2, const quint32 &p2Id,
Unit patternUnit) Unit patternUnit)
:VInternalVariable(), d(new VLengthLineData(p1Id, p2Id, patternUnit)) : VInternalVariable(),
d(new VLengthLineData(p1Id, p2Id, patternUnit))
{ {
// cppcheck-suppress unknownMacro // cppcheck-suppress unknownMacro
SCASSERT(p1 != nullptr) SCASSERT(p1 != nullptr)
SCASSERT(p2 != nullptr) SCASSERT(p2 != nullptr)
SetType(VarType::LineLength); SetType(VarType::LineLength);
SetName(QString(line_+"%1_%2").arg(p1->name(), p2->name())); SetName(QString(line_ + "%1_%2").arg(p1->name(), p2->name()));
SetValue(p1, p2); SetValue(p1, p2);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VLengthLine::VLengthLine(const VLengthLine &var) COPY_CONSTRUCTOR_IMPL_2(VLengthLine, VInternalVariable)
:VInternalVariable(var), d(var.d)
{}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VLengthLine::operator=(const VLengthLine &var) -> VLengthLine & auto VLengthLine::operator=(const VLengthLine &var) -> VLengthLine &
{ {
if ( &var == this ) if (&var == this)
{ {
return *this; return *this;
} }
@ -78,12 +78,14 @@ auto VLengthLine::operator=(const VLengthLine &var) -> VLengthLine &
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VLengthLine::VLengthLine(VLengthLine &&var) noexcept VLengthLine::VLengthLine(VLengthLine &&var) noexcept
:VInternalVariable(std::move(var)), d(std::move(var.d)) : VInternalVariable(std::move(var)),
{} d(std::move(var.d))
{
}
#ifdef Q_COMPILER_RVALUE_REFS #ifdef Q_COMPILER_RVALUE_REFS
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VLengthLine::operator=(VLengthLine &&var) noexcept->VLengthLine & auto VLengthLine::operator=(VLengthLine &&var) noexcept -> VLengthLine &
{ {
VInternalVariable::operator=(var); VInternalVariable::operator=(var);
std::swap(d, var.d); std::swap(d, var.d);
@ -92,8 +94,7 @@ auto VLengthLine::operator=(VLengthLine &&var) noexcept->VLengthLine &
#endif #endif
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VLengthLine::~VLengthLine() VLengthLine::~VLengthLine() = default;
{}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VLengthLine::Filter(quint32 id) -> bool auto VLengthLine::Filter(quint32 id) -> bool
@ -107,8 +108,8 @@ void VLengthLine::SetValue(const VPointF *p1, const VPointF *p2)
SCASSERT(p1 != nullptr) SCASSERT(p1 != nullptr)
SCASSERT(p2 != nullptr) SCASSERT(p2 != nullptr)
VInternalVariable::SetValue(FromPixel(QLineF(static_cast<QPointF>(*p1), static_cast<QPointF>(*p2)).length(), VInternalVariable::SetValue(
d->patternUnit)); FromPixel(QLineF(static_cast<QPointF>(*p1), static_cast<QPointF>(*p2)).length(), d->patternUnit));
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View file

@ -53,7 +53,7 @@ public:
auto operator=(VLengthLine &&var) noexcept -> VLengthLine &; auto operator=(VLengthLine &&var) noexcept -> VLengthLine &;
#endif #endif
virtual auto Filter(quint32 id) -> bool override; auto Filter(quint32 id) -> bool override;
void SetValue(const VPointF *p1, const VPointF *p2); void SetValue(const VPointF *p1, const VPointF *p2);

View file

@ -33,13 +33,13 @@
#include <QtDebug> #include <QtDebug>
#include "../ifc/ifcdef.h" #include "../ifc/ifcdef.h"
#include "vvariable.h"
#include "vmeasurement_p.h" #include "vmeasurement_p.h"
#include "vvariable.h"
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VMeasurement::VMeasurement(quint32 index, const QString &name) VMeasurement::VMeasurement(quint32 index, const QString &name)
:VVariable(name), : VVariable(name),
d(new VMeasurementData(index, MeasurementType::Separator)) d(new VMeasurementData(index, MeasurementType::Separator))
{ {
SetType(VarType::MeasurementSeparator); SetType(VarType::MeasurementSeparator);
VInternalVariable::SetValue(0); VInternalVariable::SetValue(0);
@ -52,8 +52,8 @@ VMeasurement::VMeasurement(quint32 index, const QString &name)
* @param base measurement's base value * @param base measurement's base value
*/ */
VMeasurement::VMeasurement(quint32 index, const QString &name, qreal baseA, qreal baseB, qreal baseC, qreal base) VMeasurement::VMeasurement(quint32 index, const QString &name, qreal baseA, qreal baseB, qreal baseC, qreal base)
:VVariable(name), : VVariable(name),
d(new VMeasurementData(index, baseA, baseB, baseC, base)) d(new VMeasurementData(index, baseA, baseB, baseC, base))
{ {
SetType(VarType::Measurement); SetType(VarType::Measurement);
VInternalVariable::SetValue(d->shiftBase); VInternalVariable::SetValue(d->shiftBase);
@ -67,21 +67,20 @@ VMeasurement::VMeasurement(quint32 index, const QString &name, qreal baseA, qrea
*/ */
VMeasurement::VMeasurement(VContainer *data, quint32 index, const QString &name, const qreal &base, VMeasurement::VMeasurement(VContainer *data, quint32 index, const QString &name, const qreal &base,
const QString &formula, bool ok) const QString &formula, bool ok)
:VVariable(name), d(new VMeasurementData(data, index, formula, ok, base)) : VVariable(name),
d(new VMeasurementData(data, index, formula, ok, base))
{ {
SetType(VarType::Measurement); SetType(VarType::Measurement);
VInternalVariable::SetValue(base); VInternalVariable::SetValue(base);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VMeasurement::VMeasurement(const VMeasurement &m) COPY_CONSTRUCTOR_IMPL_2(VMeasurement, VVariable)
:VVariable(m), d(m.d)
{}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VMeasurement::operator=(const VMeasurement &m) -> VMeasurement & auto VMeasurement::operator=(const VMeasurement &m) -> VMeasurement &
{ {
if ( &m == this ) if (&m == this)
{ {
return *this; return *this;
} }
@ -93,11 +92,13 @@ auto VMeasurement::operator=(const VMeasurement &m) -> VMeasurement &
#ifdef Q_COMPILER_RVALUE_REFS #ifdef Q_COMPILER_RVALUE_REFS
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VMeasurement::VMeasurement(VMeasurement &&m) noexcept VMeasurement::VMeasurement(VMeasurement &&m) noexcept
:VVariable(std::move(m)), d(std::move(m.d)) : VVariable(std::move(m)),
{} d(std::move(m.d))
{
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VMeasurement::operator=(VMeasurement &&m) noexcept->VMeasurement & auto VMeasurement::operator=(VMeasurement &&m) noexcept -> VMeasurement &
{ {
VVariable::operator=(m); VVariable::operator=(m);
std::swap(d, m.d); std::swap(d, m.d);
@ -106,8 +107,7 @@ auto VMeasurement::operator=(VMeasurement &&m) noexcept->VMeasurement &
#endif #endif
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VMeasurement::~VMeasurement() VMeasurement::~VMeasurement() = default;
{}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VMeasurement::CorrectionHash(qreal baseA, qreal baseB, qreal baseC) -> QString auto VMeasurement::CorrectionHash(qreal baseA, qreal baseB, qreal baseC) -> QString

View file

@ -26,23 +26,23 @@
** **
*************************************************************************/ *************************************************************************/
#include "vpiecearea.h" #include "vpiecearea.h"
#include "vpiecearea_p.h"
#include "../vpiece.h"
#include "../vcontainer.h" #include "../vcontainer.h"
#include "../vpiece.h"
#include "vincrement.h" #include "vincrement.h"
#include "vpiecearea_p.h"
#include <QRegularExpression> #include <QRegularExpression>
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPieceArea::VPieceArea() VPieceArea::VPieceArea()
:d(new VPieceAreaData) : d(new VPieceAreaData)
{ {
SetType(VarType::PieceExternalArea); SetType(VarType::PieceExternalArea);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPieceArea::VPieceArea(PieceAreaType type, quint32 pieceId, const VPiece &piece, const VContainer *data, Unit unit) VPieceArea::VPieceArea(PieceAreaType type, quint32 pieceId, const VPiece &piece, const VContainer *data, Unit unit)
:d(new VPieceAreaData(pieceId)) : d(new VPieceAreaData(pieceId))
{ {
// cppcheck-suppress unknownMacro // cppcheck-suppress unknownMacro
SCASSERT(data != nullptr) SCASSERT(data != nullptr)
@ -72,7 +72,7 @@ VPieceArea::VPieceArea(PieceAreaType type, quint32 pieceId, const VPiece &piece,
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VPieceArea::operator=(const VPieceArea &var) -> VPieceArea & auto VPieceArea::operator=(const VPieceArea &var) -> VPieceArea &
{ {
if ( &var == this ) if (&var == this)
{ {
return *this; return *this;
} }
@ -81,15 +81,16 @@ auto VPieceArea::operator=(const VPieceArea &var) -> VPieceArea &
return *this; return *this;
} }
//---------------------------------------------------------------------------------------------------------------------
VPieceArea::~VPieceArea() = default;
#ifdef Q_COMPILER_RVALUE_REFS #ifdef Q_COMPILER_RVALUE_REFS
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPieceArea::VPieceArea(VPieceArea &&var) noexcept VPieceArea::VPieceArea(VPieceArea &&var) noexcept
:VInternalVariable(std::move(var)), d(std::move(var.d)) : VInternalVariable(std::move(var)),
{} d(std::move(var.d))
{
//--------------------------------------------------------------------------------------------------------------------- }
VPieceArea::~VPieceArea() // NOLINT(modernize-use-equals-default)
{}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VPieceArea::operator=(VPieceArea &&var) noexcept -> VPieceArea & auto VPieceArea::operator=(VPieceArea &&var) noexcept -> VPieceArea &
@ -106,8 +107,8 @@ void VPieceArea::SetValue(quint32 pieceId, const VPiece &piece, const VContainer
// cppcheck-suppress unknownMacro // cppcheck-suppress unknownMacro
SCASSERT(data != nullptr) SCASSERT(data != nullptr)
d->m_pieceId = pieceId; d->m_pieceId = pieceId;
VInternalVariable::SetValue(FromPixel2(GetType() == VarType::PieceExternalArea ? piece.ExternalArea(data) VInternalVariable::SetValue(FromPixel2(
: piece.SeamLineArea(data), unit)); GetType() == VarType::PieceExternalArea ? piece.ExternalArea(data) : piece.SeamLineArea(data), unit));
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View file

@ -48,11 +48,7 @@ VVariable::VVariable(const QString &name, const QString &description)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VVariable::VVariable(const VVariable &var) // NOLINT(modernize-use-equals-default) COPY_CONSTRUCTOR_IMPL_2(VVariable, VInternalVariable)
: VInternalVariable(var),
d(var.d)
{
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VVariable::operator=(const VVariable &var) -> VVariable & auto VVariable::operator=(const VVariable &var) -> VVariable &
@ -84,9 +80,7 @@ auto VVariable::operator=(VVariable &&var) noexcept -> VVariable &
#endif #endif
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VVariable::~VVariable() // NOLINT(modernize-use-equals-default) VVariable::~VVariable() = default;
{
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VVariable::GetDescription() const -> QString auto VVariable::GetDescription() const -> QString

View file

@ -144,9 +144,7 @@ VContainer::VContainer(const VContainer &data)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VContainer::~VContainer() VContainer::~VContainer() = default;
{
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VContainer::UniqueNamespace() -> QString auto VContainer::UniqueNamespace() -> QString

View file

@ -67,7 +67,7 @@ auto VFormula::operator=(const VFormula &formula) -> VFormula &
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VFormula::VFormula(const VFormula &formula) = default; COPY_CONSTRUCTOR_IMPL(VFormula)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VFormula::~VFormula() = default; VFormula::~VFormula() = default;

View file

@ -30,10 +30,10 @@
#define VFORMULA_H #define VFORMULA_H
#include <QCoreApplication> #include <QCoreApplication>
#include <QSharedDataPointer>
#include <QMetaType> #include <QMetaType>
#include <QTypeInfo> #include <QSharedDataPointer>
#include <QString> #include <QString>
#include <QTypeInfo>
#include <QtGlobal> #include <QtGlobal>
enum class FormulaType : qint8 enum class FormulaType : qint8
@ -50,6 +50,7 @@ class VFormulaData;
class VFormula class VFormula
{ {
Q_DECLARE_TR_FUNCTIONS(VFormula) // NOLINT Q_DECLARE_TR_FUNCTIONS(VFormula) // NOLINT
public: public:
VFormula(); VFormula();
VFormula(const QString &formula, const VContainer *container); VFormula(const QString &formula, const VContainer *container);
@ -87,12 +88,13 @@ public:
static auto FormulaTypeId() -> int; static auto FormulaTypeId() -> int;
void Eval(); void Eval();
private: private:
QSharedDataPointer<VFormulaData> d; QSharedDataPointer<VFormulaData> d;
void ResetState(); void ResetState();
}; };
Q_DECLARE_METATYPE(VFormula) Q_DECLARE_METATYPE(VFormula) // NOLINT
Q_DECLARE_TYPEINFO(VFormula, Q_MOVABLE_TYPE); // NOLINT Q_DECLARE_TYPEINFO(VFormula, Q_MOVABLE_TYPE); // NOLINT
#endif // VFORMULA_H #endif // VFORMULA_H

View file

@ -27,11 +27,11 @@
*************************************************************************/ *************************************************************************/
#include "vnodedetail.h" #include "vnodedetail.h"
#include "../vgeometry/vpointf.h"
#include "../vpatterndb/vcontainer.h"
#include "vnodedetail_p.h" #include "vnodedetail_p.h"
#include "vpiecenode.h" #include "vpiecenode.h"
#include "vpiecepath.h" #include "vpiecepath.h"
#include "../vgeometry/vpointf.h"
#include "../vpatterndb/vcontainer.h"
#include <QLineF> #include <QLineF>
#include <QVector> #include <QVector>
@ -41,9 +41,8 @@ namespace
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto IsOX(const QLineF &line) -> bool auto IsOX(const QLineF &line) -> bool
{ {
return VFuzzyComparePossibleNulls(line.angle(), 0) return VFuzzyComparePossibleNulls(line.angle(), 0) || VFuzzyComparePossibleNulls(line.angle(), 360) ||
|| VFuzzyComparePossibleNulls(line.angle(), 360) VFuzzyComparePossibleNulls(line.angle(), 180);
|| VFuzzyComparePossibleNulls(line.angle(), 180);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -92,27 +91,27 @@ void ConvertAfter(VPieceNode &node, const QLineF &line, qreal mX, qreal mY)
node.SetFormulaSAAfter(LocalWidth(line, movedLine)); node.SetFormulaSAAfter(LocalWidth(line, movedLine));
} }
} }
}//static functions } // namespace
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VNodeDetail::VNodeDetail() VNodeDetail::VNodeDetail()
:d(new VNodeDetailData) : d(new VNodeDetailData)
{} {
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VNodeDetail::VNodeDetail(quint32 id, Tool typeTool, NodeDetail typeNode, qreal mx, qreal my, bool reverse) VNodeDetail::VNodeDetail(quint32 id, Tool typeTool, NodeDetail typeNode, qreal mx, qreal my, bool reverse)
:d(new VNodeDetailData(id, typeTool, typeNode, mx, my, reverse)) : d(new VNodeDetailData(id, typeTool, typeNode, mx, my, reverse))
{} {
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VNodeDetail::VNodeDetail(const VNodeDetail &node) COPY_CONSTRUCTOR_IMPL(VNodeDetail)
:d (node.d)
{}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VNodeDetail::operator=(const VNodeDetail &node) -> VNodeDetail & auto VNodeDetail::operator=(const VNodeDetail &node) -> VNodeDetail &
{ {
if ( &node == this ) if (&node == this)
{ {
return *this; return *this;
} }
@ -123,11 +122,12 @@ auto VNodeDetail::operator=(const VNodeDetail &node) -> VNodeDetail &
#ifdef Q_COMPILER_RVALUE_REFS #ifdef Q_COMPILER_RVALUE_REFS
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VNodeDetail::VNodeDetail(VNodeDetail &&node) noexcept VNodeDetail::VNodeDetail(VNodeDetail &&node) noexcept
:d (std::move(node.d)) : d(std::move(node.d))
{} {
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VNodeDetail::operator=(VNodeDetail &&node) noexcept->VNodeDetail & auto VNodeDetail::operator=(VNodeDetail &&node) noexcept -> VNodeDetail &
{ {
std::swap(d, node.d); std::swap(d, node.d);
return *this; return *this;
@ -135,8 +135,7 @@ auto VNodeDetail::operator=(VNodeDetail &&node) noexcept->VNodeDetail &
#endif #endif
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VNodeDetail::~VNodeDetail() VNodeDetail::~VNodeDetail() = default;
{}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VNodeDetail::getId() const -> quint32 auto VNodeDetail::getId() const -> quint32
@ -253,13 +252,13 @@ auto VNodeDetail::Convert(const VContainer *data, const QVector<VNodeDetail> &no
const QPointF point = data->GeometricObject<VPointF>(node.getId())->toQPointF(); const QPointF point = data->GeometricObject<VPointF>(node.getId())->toQPointF();
QLineF lineBefore(point, previosPoint); QLineF lineBefore(point, previosPoint);
lineBefore.setAngle(lineBefore.angle()-90); lineBefore.setAngle(lineBefore.angle() - 90);
lineBefore.setLength(width); lineBefore.setLength(width);
ConvertBefore(path[i], lineBefore, node.getMx(), node.getMy()); ConvertBefore(path[i], lineBefore, node.getMx(), node.getMy());
QLineF lineAfter(point, nextPoint); QLineF lineAfter(point, nextPoint);
lineAfter.setAngle(lineAfter.angle()+90); lineAfter.setAngle(lineAfter.angle() + 90);
lineAfter.setLength(width); lineAfter.setLength(width);
ConvertAfter(path[i], lineAfter, node.getMx(), node.getMy()); ConvertAfter(path[i], lineAfter, node.getMx(), node.getMy());
@ -271,7 +270,7 @@ auto VNodeDetail::Convert(const VContainer *data, const QVector<VNodeDetail> &no
if (not closed && path.CountNodes() > 1) if (not closed && path.CountNodes() > 1)
{ {
path[0].SetFormulaSABefore(QChar('0')); path[0].SetFormulaSABefore(QChar('0'));
path[path.CountNodes()-1].SetFormulaSAAfter(QChar('0')); path[path.CountNodes() - 1].SetFormulaSAAfter(QChar('0'));
} }
return path.GetNodes(); return path.GetNodes();

View file

@ -75,7 +75,7 @@ public:
auto operator=(const VNodeDetail &node) -> VNodeDetail &; auto operator=(const VNodeDetail &node) -> VNodeDetail &;
#ifdef Q_COMPILER_RVALUE_REFS #ifdef Q_COMPILER_RVALUE_REFS
VNodeDetail(VNodeDetail &&node) noexcept; VNodeDetail(VNodeDetail &&node) noexcept;
auto operator=(VNodeDetail &&node) noexcept->VNodeDetail &; auto operator=(VNodeDetail &&node) noexcept -> VNodeDetail &;
#endif #endif
/** /**
@ -87,7 +87,7 @@ public:
* @brief setId set object id. * @brief setId set object id.
* @param value object id. * @param value object id.
*/ */
void setId(const quint32 &value); void setId(const quint32 &value);
/** /**
* @brief getTypeTool return tool type. * @brief getTypeTool return tool type.
* @return tool type. * @return tool type.
@ -97,7 +97,7 @@ public:
* @brief setTypeTool set tool type. * @brief setTypeTool set tool type.
* @param value tool type. * @param value tool type.
*/ */
void setTypeTool(const Tool &value); void setTypeTool(const Tool &value);
/** /**
* @brief getTypeNode return node type. * @brief getTypeNode return node type.
* @return node type. * @return node type.
@ -107,7 +107,7 @@ public:
* @brief setTypeNode set node type. * @brief setTypeNode set node type.
* @param value node type. * @param value node type.
*/ */
void setTypeNode(const NodeDetail &value); void setTypeNode(const NodeDetail &value);
/** /**
* @brief getMx return object bias x axis. * @brief getMx return object bias x axis.
* @return bias x axis. * @return bias x axis.
@ -117,7 +117,7 @@ public:
* @brief setMx set object bias x axis. * @brief setMx set object bias x axis.
* @param value bias x axis. * @param value bias x axis.
*/ */
void setMx(const qreal &value); void setMx(const qreal &value);
/** /**
* @brief getMy return object bias y axis. * @brief getMy return object bias y axis.
* @return bias y axis. * @return bias y axis.
@ -127,10 +127,10 @@ public:
* @brief setMy set object bias y axis. * @brief setMy set object bias y axis.
* @param value bias y axis. * @param value bias y axis.
*/ */
void setMy(const qreal &value); void setMy(const qreal &value);
auto getReverse() const -> bool; auto getReverse() const -> bool;
void setReverse(bool reverse); void setReverse(bool reverse);
static auto Convert(const VContainer *data, const QVector<VNodeDetail> &nodes, qreal width, bool closed) static auto Convert(const VContainer *data, const QVector<VNodeDetail> &nodes, qreal width, bool closed)
-> QVector<VPieceNode>; -> QVector<VPieceNode>;
@ -139,7 +139,7 @@ private:
QSharedDataPointer<VNodeDetailData> d; QSharedDataPointer<VNodeDetailData> d;
}; };
Q_DECLARE_METATYPE(VNodeDetail) Q_DECLARE_METATYPE(VNodeDetail) // NOLINT
Q_DECLARE_TYPEINFO(VNodeDetail, Q_MOVABLE_TYPE); // NOLINT Q_DECLARE_TYPEINFO(VNodeDetail, Q_MOVABLE_TYPE); // NOLINT
#endif // VNODEDETAIL_H #endif // VNODEDETAIL_H

View file

@ -27,29 +27,29 @@
*************************************************************************/ *************************************************************************/
#include "vpiece.h" #include "vpiece.h"
#include "vpiece_p.h"
#include "vpassmark.h"
#include "../vgeometry/vpointf.h"
#include "../vgeometry/vabstractcurve.h"
#include "../vgeometry/vplacelabelitem.h"
#include "../vgeometry/vlayoutplacelabel.h"
#include "vcontainer.h"
#include "../vmisc/vabstractvalapplication.h"
#include "../vmisc/compatibility.h"
#include "../ifc/exception/vexceptioninvalidnotch.h" #include "../ifc/exception/vexceptioninvalidnotch.h"
#include "../ifc/exception/vexceptionobjecterror.h" #include "../ifc/exception/vexceptionobjecterror.h"
#include "../vmisc/testpath.h"
#include "../ifc/xml/vabstractpattern.h" #include "../ifc/xml/vabstractpattern.h"
#include "../vpatterndb/vpiecenode.h" #include "../vgeometry/vabstractcurve.h"
#include "../vgeometry/vlayoutplacelabel.h"
#include "../vgeometry/vplacelabelitem.h"
#include "../vgeometry/vpointf.h"
#include "../vmisc/compatibility.h"
#include "../vmisc/testpath.h"
#include "../vmisc/vabstractvalapplication.h"
#include "../vpatterndb/variables/vpiecearea.h" #include "../vpatterndb/variables/vpiecearea.h"
#include "../vpatterndb/vpiecenode.h"
#include "vcontainer.h"
#include "vpassmark.h"
#include "vpiece_p.h"
#include <QSharedPointer>
#include <QDebug> #include <QDebug>
#include <QPainterPath>
#include <QTemporaryFile>
#include <QJsonObject>
#include <QJsonDocument>
#include <QJsonArray> #include <QJsonArray>
#include <QJsonDocument>
#include <QJsonObject>
#include <QPainterPath>
#include <QSharedPointer>
#include <QTemporaryFile>
namespace namespace
{ {
@ -93,7 +93,7 @@ auto IsPassmarksPossible(const QVector<VPieceNode> &path) -> bool
{ {
if (node.IsExcluded()) if (node.IsExcluded())
{ {
continue;// skip node continue; // skip node
} }
node.GetTypeTool() == Tool::NodePoint ? ++countPointNodes : ++countOthers; node.GetTypeTool() == Tool::NodePoint ? ++countPointNodes : ++countOthers;
@ -116,18 +116,18 @@ auto RotatePath(const QVector<VPieceNode> &path, vsizetype index) -> QVector<VPi
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPiece::VPiece() VPiece::VPiece()
: VAbstractPiece(), d(new VPieceData(PiecePathType::PiecePath)) : VAbstractPiece(),
{} d(new VPieceData(PiecePathType::PiecePath))
{
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPiece::VPiece(const VPiece &piece) COPY_CONSTRUCTOR_IMPL_2(VPiece, VAbstractPiece)
: VAbstractPiece(piece), d (piece.d)
{}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VPiece::operator=(const VPiece &piece) -> VPiece & auto VPiece::operator=(const VPiece &piece) -> VPiece &
{ {
if ( &piece == this ) if (&piece == this)
{ {
return *this; return *this;
} }
@ -139,11 +139,13 @@ auto VPiece::operator=(const VPiece &piece) -> VPiece &
#ifdef Q_COMPILER_RVALUE_REFS #ifdef Q_COMPILER_RVALUE_REFS
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPiece::VPiece(VPiece &&piece) noexcept VPiece::VPiece(VPiece &&piece) noexcept
: VAbstractPiece(std::move(piece)), d (std::move(piece.d)) : VAbstractPiece(std::move(piece)),
{} d(std::move(piece.d))
{
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VPiece::operator=(VPiece &&piece) noexcept->VPiece & auto VPiece::operator=(VPiece &&piece) noexcept -> VPiece &
{ {
VAbstractPiece::operator=(piece); VAbstractPiece::operator=(piece);
std::swap(d, piece.d); std::swap(d, piece.d);
@ -152,8 +154,7 @@ auto VPiece::operator=(VPiece &&piece) noexcept->VPiece &
#endif #endif
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPiece::~VPiece() VPiece::~VPiece() = default;
{}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VPiece::GetPath() const -> VPiecePath auto VPiece::GetPath() const -> VPiecePath
@ -176,15 +177,15 @@ void VPiece::SetPath(const VPiecePath &path)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VPiece::MainPathPoints(const VContainer *data) const -> QVector<VLayoutPoint> auto VPiece::MainPathPoints(const VContainer *data) const -> QVector<VLayoutPoint>
{ {
// DumpPiece(*this, data, QStringLiteral("input.json.XXXXXX")); // Uncomment for dumping test data // DumpPiece(*this, data, QStringLiteral("input.json.XXXXXX")); // Uncomment for dumping test data
VPiecePath mainPath = GetPath(); VPiecePath mainPath = GetPath();
mainPath.SetName(QCoreApplication::translate("VPiece", "Main path of piece %1").arg(GetName())); mainPath.SetName(QCoreApplication::translate("VPiece", "Main path of piece %1").arg(GetName()));
QVector<VLayoutPoint> points = mainPath.PathPoints(data); QVector<VLayoutPoint> points = mainPath.PathPoints(data);
points = CheckLoops(CorrectEquidistantPoints(points));//A path can contains loops points = CheckLoops(CorrectEquidistantPoints(points)); // A path can contains loops
// DumpVector(points, QStringLiteral("output.json.XXXXXX")); // Uncomment for dumping test data // DumpVector(points, QStringLiteral("output.json.XXXXXX")); // Uncomment for dumping test data
return points; return points;
} }
@ -192,7 +193,7 @@ auto VPiece::MainPathPoints(const VContainer *data) const -> QVector<VLayoutPoin
auto VPiece::UniteMainPathPoints(const VContainer *data) const -> QVector<VLayoutPoint> auto VPiece::UniteMainPathPoints(const VContainer *data) const -> QVector<VLayoutPoint>
{ {
QVector<VLayoutPoint> points = VPiecePath::NodesToPoints(data, GetUnitedPath(data), GetName()); QVector<VLayoutPoint> points = VPiecePath::NodesToPoints(data, GetUnitedPath(data), GetName());
points = CheckLoops(CorrectEquidistantPoints(points));//A path can contains loops points = CheckLoops(CorrectEquidistantPoints(points)); // A path can contains loops
return points; return points;
} }
@ -227,7 +228,7 @@ auto VPiece::PassmarksLines(const VContainer *data) const -> QVector<QLineF>
{ {
QVector<VPassmark> passmarks = Passmarks(data); QVector<VPassmark> passmarks = Passmarks(data);
QVector<QLineF> lines; QVector<QLineF> lines;
for(auto &passmark : passmarks) for (auto &passmark : passmarks)
{ {
if (not passmark.IsNull()) if (not passmark.IsNull())
{ {
@ -249,12 +250,12 @@ auto VPiece::Passmarks(const VContainer *data) const -> QVector<VPassmark>
QVector<VPassmark> passmarks; QVector<VPassmark> passmarks;
for (int i = 0; i< unitedPath.size(); ++i) for (int i = 0; i < unitedPath.size(); ++i)
{ {
const VPieceNode &node = unitedPath.at(i); const VPieceNode &node = unitedPath.at(i);
if (node.IsExcluded() || not node.IsPassmark()) if (node.IsExcluded() || not node.IsPassmark())
{ {
continue;// skip node continue; // skip node
} }
const vsizetype previousIndex = VPiecePath::FindInLoopNotExcludedUp(i, unitedPath); const vsizetype previousIndex = VPiecePath::FindInLoopNotExcludedUp(i, unitedPath);
@ -333,7 +334,7 @@ auto VPiece::PassmarksPath(const VContainer *data) const -> QPainterPath
auto VPiece::PlaceLabelPath(const VContainer *data) const -> QPainterPath auto VPiece::PlaceLabelPath(const VContainer *data) const -> QPainterPath
{ {
QPainterPath path; QPainterPath path;
for(auto placeLabel : d->m_placeLabels) for (auto placeLabel : d->m_placeLabels)
{ {
try try
{ {
@ -662,16 +663,16 @@ auto VPiece::SeamAllowancePointsWithRotation(const VContainer *data, vsizetype m
int recordIndex = -1; int recordIndex = -1;
bool insertingCSA = false; bool insertingCSA = false;
const qreal width = ToPixel(GetSAWidth(), *data->GetPatternUnit()); const qreal width = ToPixel(GetSAWidth(), *data->GetPatternUnit());
const QVector<VPieceNode> unitedPath = makeFirst > 0 ? RotatePath(GetUnitedPath(data), makeFirst) const QVector<VPieceNode> unitedPath =
: GetUnitedPath(data); makeFirst > 0 ? RotatePath(GetUnitedPath(data), makeFirst) : GetUnitedPath(data);
QVector<VSAPoint> pointsEkv; QVector<VSAPoint> pointsEkv;
for (int i = 0; i< unitedPath.size(); ++i) for (int i = 0; i < unitedPath.size(); ++i)
{ {
const VPieceNode &node = unitedPath.at(i); const VPieceNode &node = unitedPath.at(i);
if (node.IsExcluded()) if (node.IsExcluded())
{ {
continue;// skip excluded node continue; // skip excluded node
} }
switch (node.GetTypeTool()) switch (node.GetTypeTool())
@ -727,7 +728,7 @@ auto VPiece::SeamAllowancePointsWithRotation(const VContainer *data, vsizetype m
} }
break; break;
default: default:
qDebug()<<"Get wrong tool type. Ignore."<< static_cast<char>(node.GetTypeTool()); qDebug() << "Get wrong tool type. Ignore." << static_cast<char>(node.GetTypeTool());
break; break;
} }
} }
@ -777,12 +778,12 @@ auto VPiece::GetUnitedPath(const VContainer *data) const -> QVector<VPieceNode>
QVector<VPieceNode> midAfter; QVector<VPieceNode> midAfter;
if (indexStartPoint <= indexEndPoint) if (indexStartPoint <= indexEndPoint)
{ {
midBefore = united.mid(0, indexStartPoint+1); midBefore = united.mid(0, indexStartPoint + 1);
midAfter = united.mid(indexEndPoint, united.size() - midBefore.size()); midAfter = united.mid(indexEndPoint, united.size() - midBefore.size());
} }
else else
{ {
midBefore = united.mid(indexEndPoint, indexStartPoint+1); midBefore = united.mid(indexEndPoint, indexStartPoint + 1);
} }
QVector<VPieceNode> customNodes = data->GetPiecePath(records.at(i).path).GetNodes(); QVector<VPieceNode> customNodes = data->GetPiecePath(records.at(i).path).GetNodes();
@ -827,13 +828,9 @@ auto VPiece::GetValidRecords() const -> QVector<CustomSARecord>
const int indexStartPoint = d->m_path.indexOfNode(record.startPoint); const int indexStartPoint = d->m_path.indexOfNode(record.startPoint);
const int indexEndPoint = d->m_path.indexOfNode(record.endPoint); const int indexEndPoint = d->m_path.indexOfNode(record.endPoint);
if (record.startPoint > NULL_ID if (record.startPoint > NULL_ID && record.path > NULL_ID && record.endPoint > NULL_ID &&
&& record.path > NULL_ID indexStartPoint != -1 && not d->m_path.at(indexStartPoint).IsExcluded() && indexEndPoint != -1 &&
&& record.endPoint > NULL_ID not d->m_path.at(indexEndPoint).IsExcluded())
&& indexStartPoint != -1
&& not d->m_path.at(indexStartPoint).IsExcluded()
&& indexEndPoint != -1
&& not d->m_path.at(indexEndPoint).IsExcluded())
{ {
records.append(record); records.append(record);
} }
@ -865,12 +862,12 @@ auto VPiece::FilterRecords(QVector<CustomSARecord> records) const -> QVector<Cus
QVector<VPieceNode> midAfter; QVector<VPieceNode> midAfter;
if (indexStartPoint <= indexEndPoint) if (indexStartPoint <= indexEndPoint)
{ {
midBefore = path.mid(0, indexStartPoint+1); midBefore = path.mid(0, indexStartPoint + 1);
midAfter = path.mid(indexEndPoint, path.size() - midBefore.size()); midAfter = path.mid(indexEndPoint, path.size() - midBefore.size());
} }
else else
{ {
midBefore = path.mid(indexEndPoint, indexStartPoint+1); midBefore = path.mid(indexEndPoint, indexStartPoint + 1);
} }
path = midBefore + midAfter; path = midBefore + midAfter;
@ -937,14 +934,15 @@ auto VPiece::GetPassmarkPreviousSAPoints(const QVector<VPieceNode> &path, vsizet
if (points.isEmpty()) if (points.isEmpty())
{ {
const QString errorMsg = tr("Cannot calculate a notch for point '%1' in piece '%2'.") const QString errorMsg = tr("Cannot calculate a notch for point '%1' in piece '%2'.")
.arg(VPiecePath::NodeName(path, passmarkIndex, data), GetName()); .arg(VPiecePath::NodeName(path, passmarkIndex, data), GetName());
VAbstractApplication::VApp()->IsPedantic() ? throw VExceptionInvalidNotch(errorMsg) : VAbstractApplication::VApp()->IsPedantic()
qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; ? throw VExceptionInvalidNotch(errorMsg)
: qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
return false; // Something wrong return false; // Something wrong
} }
bool found = false; bool found = false;
auto nodeIndex = points.size()-1; auto nodeIndex = points.size() - 1;
do do
{ {
const VSAPoint previous = points.at(nodeIndex); const VSAPoint previous = points.at(nodeIndex);
@ -976,9 +974,10 @@ auto VPiece::GetPassmarkNextSAPoints(const QVector<VPieceNode> &path, vsizetype
if (points.isEmpty()) if (points.isEmpty())
{ {
const QString errorMsg = tr("Cannot calculate a notch for point '%1' in piece '%2'.") const QString errorMsg = tr("Cannot calculate a notch for point '%1' in piece '%2'.")
.arg(VPiecePath::NodeName(path, passmarkIndex, data), GetName()); .arg(VPiecePath::NodeName(path, passmarkIndex, data), GetName());
VAbstractApplication::VApp()->IsPedantic() ? throw VExceptionInvalidNotch(errorMsg) : VAbstractApplication::VApp()->IsPedantic()
qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; ? throw VExceptionInvalidNotch(errorMsg)
: qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
return false; // Something wrong return false; // Something wrong
} }
@ -1060,9 +1059,10 @@ auto VPiece::CreatePassmark(const QVector<VPieceNode> &path, vsizetype previousI
if (not GetPassmarkSAPoint(path, passmarkIndex, data, passmarkSAPoint)) if (not GetPassmarkSAPoint(path, passmarkIndex, data, passmarkSAPoint))
{ {
const QString errorMsg = tr("Cannot calculate a notch for point '%1' in piece '%2'.") const QString errorMsg = tr("Cannot calculate a notch for point '%1' in piece '%2'.")
.arg(VPiecePath::NodeName(path, passmarkIndex, data), GetName()); .arg(VPiecePath::NodeName(path, passmarkIndex, data), GetName());
VAbstractApplication::VApp()->IsPedantic() ? throw VExceptionInvalidNotch(errorMsg) : VAbstractApplication::VApp()->IsPedantic()
qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; ? throw VExceptionInvalidNotch(errorMsg)
: qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
return {}; return {};
} }
@ -1085,12 +1085,11 @@ auto VPiece::CreatePassmark(const QVector<VPieceNode> &path, vsizetype previousI
return {}; return {};
} }
if (passmarkSAPoint.IsManualPasskmarkLength() if (passmarkSAPoint.IsManualPasskmarkLength() && passmarkSAPoint.GetPasskmarkLength() <= accuracyPointOnLine)
&& passmarkSAPoint.GetPasskmarkLength() <= accuracyPointOnLine)
{ {
const QString infoMsg = tr("Notch for point '%1' in piece '%2' will be disabled. Manual length is less than " const QString infoMsg = tr("Notch for point '%1' in piece '%2' will be disabled. Manual length is less than "
"allowed value.") "allowed value.")
.arg(VPiecePath::NodeName(path, passmarkIndex, data), GetName()); .arg(VPiecePath::NodeName(path, passmarkIndex, data), GetName());
#if QT_VERSION >= QT_VERSION_CHECK(5, 5, 0) #if QT_VERSION >= QT_VERSION_CHECK(5, 5, 0)
qInfo() << VAbstractValApplication::warningMessageSignature + infoMsg; qInfo() << VAbstractValApplication::warningMessageSignature + infoMsg;
#else #else
@ -1143,7 +1142,7 @@ auto VPiece::Area(const QVector<QPointF> &shape, const VContainer *data) const -
{ {
SCASSERT(data != nullptr) SCASSERT(data != nullptr)
const qreal mainArea = qAbs(VAbstractPiece::SumTrapezoids(shape))/2.0; const qreal mainArea = qAbs(VAbstractPiece::SumTrapezoids(shape)) / 2.0;
qreal internalPathArea = 0; qreal internalPathArea = 0;
const QVector<quint32> pathsId = GetInternalPaths(); const QVector<quint32> pathsId = GetInternalPaths();
@ -1163,7 +1162,7 @@ auto VPiece::Area(const QVector<QPointF> &shape, const VContainer *data) const -
continue; continue;
} }
internalPathArea += qAbs(VAbstractPiece::SumTrapezoids(points))/2.0; internalPathArea += qAbs(VAbstractPiece::SumTrapezoids(points)) / 2.0;
} }
return mainArea - internalPathArea; return mainArea - internalPathArea;
@ -1243,8 +1242,7 @@ qreal VPiece::GlobalPassmarkWidth(const VContainer *data) const
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VPiece::MainPathToJson() const -> QJsonObject auto VPiece::MainPathToJson() const -> QJsonObject
{ {
QJsonObject pieceObject QJsonObject pieceObject{
{
{"seamAllowance", IsSeamAllowance()}, {"seamAllowance", IsSeamAllowance()},
{"saWidth", GetSAWidth()}, {"saWidth", GetSAWidth()},
}; };
@ -1252,8 +1250,7 @@ auto VPiece::MainPathToJson() const -> QJsonObject
QJsonArray nodesArray; QJsonArray nodesArray;
for (qint32 i = 0; i < d->m_path.CountNodes(); ++i) for (qint32 i = 0; i < d->m_path.CountNodes(); ++i)
{ {
QJsonObject nodeObject QJsonObject nodeObject{
{
{"id", static_cast<qint64>(d->m_path.at(i).GetId())}, {"id", static_cast<qint64>(d->m_path.at(i).GetId())},
{"type", static_cast<int>(d->m_path.at(i).GetTypeTool())}, {"type", static_cast<int>(d->m_path.at(i).GetTypeTool())},
{"reverse", d->m_path.at(i).GetReverse()}, {"reverse", d->m_path.at(i).GetReverse()},
@ -1275,10 +1272,7 @@ auto VPiece::DBToJson(const VContainer *data) const -> QJsonObject
itemsArray.append(data->GetGObject(d->m_path.at(i).GetId())->ToJson()); itemsArray.append(data->GetGObject(d->m_path.at(i).GetId())->ToJson());
} }
QJsonObject dbObject QJsonObject dbObject{{"items", itemsArray}};
{
{"items", itemsArray}
};
return dbObject; return dbObject;
} }
@ -1287,7 +1281,7 @@ auto VPiece::DBToJson(const VContainer *data) const -> QJsonObject
void VPiece::DumpPiece(const VPiece &piece, const VContainer *data, const QString &templateName) void VPiece::DumpPiece(const VPiece &piece, const VContainer *data, const QString &templateName)
{ {
SCASSERT(data != nullptr) SCASSERT(data != nullptr)
QTemporaryFile temp; // Go to tmp folder to find dump QTemporaryFile temp; // Go to tmp folder to find dump
temp.setAutoRemove(false); // Remove dump manually temp.setAutoRemove(false); // Remove dump manually
if (not templateName.isEmpty()) if (not templateName.isEmpty())
@ -1298,23 +1292,21 @@ void VPiece::DumpPiece(const VPiece &piece, const VContainer *data, const QStrin
if (temp.open()) if (temp.open())
{ {
#if defined(Q_OS_LINUX) #if defined(Q_OS_LINUX)
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) #if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
// On Linux, QTemporaryFile will attempt to create unnamed temporary // On Linux, QTemporaryFile will attempt to create unnamed temporary
// files. If that succeeds, open() will return true but exists() will be // files. If that succeeds, open() will return true but exists() will be
// false. If you call fileName() or any function that calls it, // false. If you call fileName() or any function that calls it,
// QTemporaryFile will give the file a name, so most applications will // QTemporaryFile will give the file a name, so most applications will
// not see a difference. // not see a difference.
temp.fileName(); // call to create a file on disk temp.fileName(); // call to create a file on disk
#endif
#endif #endif
QJsonObject testCase #endif
{ QJsonObject testCase{
{"bd", piece.DBToJson(data)}, {"bd", piece.DBToJson(data)},
{"piece", piece.MainPathToJson()}, {"piece", piece.MainPathToJson()},
}; };
QJsonObject json QJsonObject json{
{
{"testCase", testCase}, {"testCase", testCase},
}; };
@ -1358,18 +1350,22 @@ void VPiece::TestInternalPathCuttingPathIntersection(const VContainer *data) con
if (internalPath.intersects(contourPath)) if (internalPath.intersects(contourPath))
{ {
const QString errorMsg = QObject::tr("Piece '%1'. Internal path '%2' intersects with cutting " const QString errorMsg = QObject::tr("Piece '%1'. Internal path '%2' intersects with cutting "
"contour.").arg(GetName(), path.GetName()); "contour.")
VAbstractApplication::VApp()->IsPedantic() ? throw VExceptionObjectError(errorMsg) : .arg(GetName(), path.GetName());
qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; VAbstractApplication::VApp()->IsPedantic()
? throw VExceptionObjectError(errorMsg)
: qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
continue; continue;
} }
if (not contourPath.contains(internalPath)) if (not contourPath.contains(internalPath))
{ {
const QString errorMsg = QObject::tr("Piece '%1'. Internal path '%2' not inside of cutting " const QString errorMsg = QObject::tr("Piece '%1'. Internal path '%2' not inside of cutting "
"contour.").arg(GetName(), path.GetName()); "contour.")
VAbstractApplication::VApp()->IsPedantic() ? throw VExceptionObjectError(errorMsg) : .arg(GetName(), path.GetName());
qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; VAbstractApplication::VApp()->IsPedantic()
? throw VExceptionObjectError(errorMsg)
: qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
} }
} }
} }
@ -1390,7 +1386,7 @@ void VPiece::TestInternalPathsIntersections(const VContainer *data) const
// Internal pieces for cutting must not intersect // Internal pieces for cutting must not intersect
QSet<QPair<int, int>> pairs; QSet<QPair<int, int>> pairs;
for (int k=0; k < pathsId.size(); ++k) for (int k = 0; k < pathsId.size(); ++k)
{ {
const VPiecePath path1 = data->GetPiecePath(pathsId.at(k)); const VPiecePath path1 = data->GetPiecePath(pathsId.at(k));
@ -1409,7 +1405,7 @@ void VPiece::TestInternalPathsIntersections(const VContainer *data) const
const QPainterPath painterPath1 = VGObject::PainterPath(pointsPath1); const QPainterPath painterPath1 = VGObject::PainterPath(pointsPath1);
for (int i=0; i < pathsId.size(); ++i) for (int i = 0; i < pathsId.size(); ++i)
{ {
if (k == i || pairs.contains(qMakePair(k, i)) || pairs.contains(qMakePair(i, k))) if (k == i || pairs.contains(qMakePair(k, i)) || pairs.contains(qMakePair(i, k)))
{ {
@ -1439,9 +1435,11 @@ void VPiece::TestInternalPathsIntersections(const VContainer *data) const
if (painterPath1.intersects(painterPath2)) if (painterPath1.intersects(painterPath2))
{ {
const QString errorMsg = QObject::tr("Piece '%1'. Internal path '%2' intersects with internal path " const QString errorMsg = QObject::tr("Piece '%1'. Internal path '%2' intersects with internal path "
"'%3'.").arg(GetName(), path1.GetName(), path2.GetName()); "'%3'.")
VAbstractApplication::VApp()->IsPedantic() ? throw VExceptionObjectError(errorMsg) : .arg(GetName(), path1.GetName(), path2.GetName());
qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; VAbstractApplication::VApp()->IsPedantic()
? throw VExceptionObjectError(errorMsg)
: qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
} }
} }
} }
@ -1483,7 +1481,7 @@ auto VPiece::ShortNameRegExp() -> QString
QString decimalPoints; QString decimalPoints;
QString groupSeparators; QString groupSeparators;
for(const auto &locale : allLocales) for (const auto &locale : allLocales)
{ {
if (not positiveSigns.contains(LocalePositiveSign(locale))) if (not positiveSigns.contains(LocalePositiveSign(locale)))
{ {
@ -1509,11 +1507,11 @@ auto VPiece::ShortNameRegExp() -> QString
negativeSigns.replace('-', QLatin1String("\\-")); negativeSigns.replace('-', QLatin1String("\\-"));
groupSeparators.remove('\''); groupSeparators.remove('\'');
//Same regexp in pattern.xsd shema file. Don't forget to synchronize. // Same regexp in pattern.xsd shema file. Don't forget to synchronize.
// \p{Zs} - \p{Space_Separator} // \p{Zs} - \p{Space_Separator}
// Here we use permanent start of string and end of string anchors \A and \z to match whole pattern as one // Here we use permanent start of string and end of string anchors \A and \z to match whole pattern as one
// string. In some cases, a user may pass multiline or line that ends with a new line. To cover case with a new // string. In some cases, a user may pass multiline or line that ends with a new line. To cover case with a new
// line at the end of string use /z anchor. // line at the end of string use /z anchor.
regex = QStringLiteral("\\A([^\\p{Zs}*\\/&|!<>^\\n\\()%1%2%3%4=?:;\"]){0,}\\z") regex = QStringLiteral("\\A([^\\p{Zs}*\\/&|!<>^\\n\\()%1%2%3%4=?:;\"]){0,}\\z")
.arg(negativeSigns, positiveSigns, decimalPoints, groupSeparators); .arg(negativeSigns, positiveSigns, decimalPoints, groupSeparators);
} }

View file

@ -29,8 +29,8 @@
#ifndef VPIECE_H #ifndef VPIECE_H
#define VPIECE_H #define VPIECE_H
#include <QtGlobal>
#include <QSharedDataPointer> #include <QSharedDataPointer>
#include <QtGlobal>
#include "../vlayout/vabstractpiece.h" #include "../vlayout/vabstractpiece.h"
@ -48,21 +48,22 @@ class VPassmark;
class VPiece : public VAbstractPiece class VPiece : public VAbstractPiece
{ {
Q_DECLARE_TR_FUNCTIONS(VPiece) // NOLINT Q_DECLARE_TR_FUNCTIONS(VPiece) // NOLINT
public: public:
VPiece(); VPiece();
VPiece(const VPiece &piece); VPiece(const VPiece &piece);
virtual ~VPiece(); ~VPiece() override;
auto operator=(const VPiece &piece) -> VPiece &; auto operator=(const VPiece &piece) -> VPiece &;
#ifdef Q_COMPILER_RVALUE_REFS #ifdef Q_COMPILER_RVALUE_REFS
VPiece(VPiece &&piece) noexcept; VPiece(VPiece &&piece) noexcept;
auto operator=(VPiece &&piece) noexcept->VPiece &; auto operator=(VPiece &&piece) noexcept -> VPiece &;
#endif #endif
auto GetPath() const -> VPiecePath; auto GetPath() const -> VPiecePath;
auto GetPath() -> VPiecePath &; auto GetPath() -> VPiecePath &;
void SetPath(const VPiecePath &path); void SetPath(const VPiecePath &path);
auto MainPathPoints(const VContainer *data) const -> QVector<VLayoutPoint>; auto MainPathPoints(const VContainer *data) const -> QVector<VLayoutPoint>;
auto UniteMainPathPoints(const VContainer *data) const -> QVector<VLayoutPoint>; auto UniteMainPathPoints(const VContainer *data) const -> QVector<VLayoutPoint>;
@ -95,23 +96,23 @@ public:
void SetShortName(const QString &value); void SetShortName(const QString &value);
auto GetFormulaSAWidth() const -> QString; auto GetFormulaSAWidth() const -> QString;
void SetFormulaSAWidth(const QString &formula, qreal value); void SetFormulaSAWidth(const QString &formula, qreal value);
auto GetInternalPaths() const -> QVector<quint32>; auto GetInternalPaths() const -> QVector<quint32>;
auto GetInternalPaths() -> QVector<quint32> &; auto GetInternalPaths() -> QVector<quint32> &;
void SetInternalPaths(const QVector<quint32> &iPaths); void SetInternalPaths(const QVector<quint32> &iPaths);
auto GetCustomSARecords() const -> QVector<CustomSARecord>; auto GetCustomSARecords() const -> QVector<CustomSARecord>;
auto GetCustomSARecords() -> QVector<CustomSARecord> &; auto GetCustomSARecords() -> QVector<CustomSARecord> &;
void SetCustomSARecords(const QVector<CustomSARecord> &records); void SetCustomSARecords(const QVector<CustomSARecord> &records);
auto GetPins() const -> QVector<quint32>; auto GetPins() const -> QVector<quint32>;
auto GetPins() -> QVector<quint32> &; auto GetPins() -> QVector<quint32> &;
void SetPins(const QVector<quint32> &pins); void SetPins(const QVector<quint32> &pins);
auto GetPlaceLabels() const -> QVector<quint32>; auto GetPlaceLabels() const -> QVector<quint32>;
auto GetPlaceLabels() -> QVector<quint32> &; auto GetPlaceLabels() -> QVector<quint32> &;
void SetPlaceLabels(const QVector<quint32> &labels); void SetPlaceLabels(const QVector<quint32> &labels);
auto Dependencies() const -> QList<quint32>; auto Dependencies() const -> QList<quint32>;
auto MissingNodes(const VPiece &det) const -> QVector<quint32>; auto MissingNodes(const VPiece &det) const -> QVector<quint32>;
@ -120,15 +121,15 @@ public:
auto MissingPins(const VPiece &det) const -> QVector<quint32>; auto MissingPins(const VPiece &det) const -> QVector<quint32>;
auto MissingPlaceLabels(const VPiece &det) const -> QVector<quint32>; auto MissingPlaceLabels(const VPiece &det) const -> QVector<quint32>;
void SetPieceLabelData(const VPieceLabelData &data); void SetPieceLabelData(const VPieceLabelData &data);
auto GetPieceLabelData() -> VPieceLabelData &; auto GetPieceLabelData() -> VPieceLabelData &;
auto GetPieceLabelData() const -> const VPieceLabelData &; auto GetPieceLabelData() const -> const VPieceLabelData &;
void SetPatternLabelData(const VPatternLabelData &info); void SetPatternLabelData(const VPatternLabelData &info);
auto GetPatternLabelData() -> VPatternLabelData &; auto GetPatternLabelData() -> VPatternLabelData &;
auto GetPatternLabelData() const -> const VPatternLabelData &; auto GetPatternLabelData() const -> const VPatternLabelData &;
void SetGrainlineGeometry(const VGrainlineData &data); void SetGrainlineGeometry(const VGrainlineData &data);
auto GetGrainlineGeometry() -> VGrainlineData &; auto GetGrainlineGeometry() -> VGrainlineData &;
auto GetGrainlineGeometry() const -> const VGrainlineData &; auto GetGrainlineGeometry() const -> const VGrainlineData &;
@ -139,13 +140,14 @@ public:
void SetGradationLabel(const QString &label); void SetGradationLabel(const QString &label);
auto GetGradationLabel() const -> QString; auto GetGradationLabel() const -> QString;
static void DumpPiece(const VPiece &piece, const VContainer *data, const QString &templateName=QString()); static void DumpPiece(const VPiece &piece, const VContainer *data, const QString &templateName = QString());
void TestInternalPaths(const VContainer *data) const; void TestInternalPaths(const VContainer *data) const;
static auto ShortNameRegExp() -> QString; static auto ShortNameRegExp() -> QString;
auto ExternalArea(const VContainer *data) const -> qreal; auto ExternalArea(const VContainer *data) const -> qreal;
auto SeamLineArea(const VContainer *data) const -> qreal; auto SeamLineArea(const VContainer *data) const -> qreal;
private: private:
QSharedDataPointer<VPieceData> d; QSharedDataPointer<VPieceData> d;

View file

@ -27,34 +27,34 @@
*************************************************************************/ *************************************************************************/
#include "vpiecenode.h" #include "vpiecenode.h"
#include "vpiecenode_p.h"
#include "vcontainer.h"
#include "calculator.h"
#include "vformula.h"
#include "../vmisc/vabstractvalapplication.h" #include "../vmisc/vabstractvalapplication.h"
#include "calculator.h"
#include "vcontainer.h"
#include "vformula.h"
#include "vpiecenode_p.h"
#include <QDataStream> #include <QDataStream>
#include <QtNumeric> #include <QtNumeric>
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPieceNode::VPieceNode() VPieceNode::VPieceNode()
: d(new VPieceNodeData) : d(new VPieceNodeData)
{} {
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPieceNode::VPieceNode(quint32 id, Tool typeTool, bool reverse) VPieceNode::VPieceNode(quint32 id, Tool typeTool, bool reverse)
: d(new VPieceNodeData(id, typeTool, reverse)) : d(new VPieceNodeData(id, typeTool, reverse))
{} {
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPieceNode::VPieceNode(const VPieceNode &node) COPY_CONSTRUCTOR_IMPL(VPieceNode)
: d (node.d)
{}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VPieceNode::operator=(const VPieceNode &node) -> VPieceNode & auto VPieceNode::operator=(const VPieceNode &node) -> VPieceNode &
{ {
if ( &node == this ) if (&node == this)
{ {
return *this; return *this;
} }
@ -65,11 +65,12 @@ auto VPieceNode::operator=(const VPieceNode &node) -> VPieceNode &
#ifdef Q_COMPILER_RVALUE_REFS #ifdef Q_COMPILER_RVALUE_REFS
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPieceNode::VPieceNode(VPieceNode &&node) noexcept VPieceNode::VPieceNode(VPieceNode &&node) noexcept
: d (std::move(node.d)) : d(std::move(node.d))
{} {
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VPieceNode::operator=(VPieceNode &&node) noexcept->VPieceNode & auto VPieceNode::operator=(VPieceNode &&node) noexcept -> VPieceNode &
{ {
std::swap(d, node.d); std::swap(d, node.d);
return *this; return *this;
@ -77,8 +78,7 @@ auto VPieceNode::operator=(VPieceNode &&node) noexcept->VPieceNode &
#endif #endif
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPieceNode::~VPieceNode() VPieceNode::~VPieceNode() = default;
{}
// Friend functions // Friend functions
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -154,12 +154,14 @@ auto VPieceNode::GetSABefore(const VContainer *data) const -> qreal
nodeName = data->GetGObject(d->m_id)->name(); nodeName = data->GetGObject(d->m_id)->name();
} }
catch (const VExceptionBadId &) catch (const VExceptionBadId &)
{} {
}
const QString errorMsg = QObject::tr("Cannot calculate seam allowance before for point '%1'. Reason: %2.") const QString errorMsg = QObject::tr("Cannot calculate seam allowance before for point '%1'. Reason: %2.")
.arg(nodeName, formula.Reason()); .arg(nodeName, formula.Reason());
VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) : VAbstractApplication::VApp()->IsPedantic()
qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; ? throw VException(errorMsg)
: qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
return -1; return -1;
} }
return formula.getDoubleValue(); return formula.getDoubleValue();
@ -185,12 +187,14 @@ auto VPieceNode::GetSABefore(const VContainer *data, Unit unit) const -> qreal
nodeName = data->GetGObject(d->m_id)->name(); nodeName = data->GetGObject(d->m_id)->name();
} }
catch (const VExceptionBadId &) catch (const VExceptionBadId &)
{} {
}
const QString errorMsg = QObject::tr("Cannot calculate seam allowance before for point '%1'. Reason: %2.") const QString errorMsg = QObject::tr("Cannot calculate seam allowance before for point '%1'. Reason: %2.")
.arg(nodeName, formula.Reason()); .arg(nodeName, formula.Reason());
VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) : VAbstractApplication::VApp()->IsPedantic()
qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; ? throw VException(errorMsg)
: qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
return -1; return -1;
} }
@ -237,12 +241,14 @@ auto VPieceNode::GetSAAfter(const VContainer *data) const -> qreal
nodeName = data->GetGObject(d->m_id)->name(); nodeName = data->GetGObject(d->m_id)->name();
} }
catch (const VExceptionBadId &) catch (const VExceptionBadId &)
{} {
}
const QString errorMsg = QObject::tr("Cannot calculate seam allowance after for point '%1'. Reason: %2.") const QString errorMsg = QObject::tr("Cannot calculate seam allowance after for point '%1'. Reason: %2.")
.arg(nodeName, formula.Reason()); .arg(nodeName, formula.Reason());
VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) : VAbstractApplication::VApp()->IsPedantic()
qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; ? throw VException(errorMsg)
: qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
return -1; return -1;
} }
@ -269,12 +275,14 @@ auto VPieceNode::GetSAAfter(const VContainer *data, Unit unit) const -> qreal
nodeName = data->GetGObject(d->m_id)->name(); nodeName = data->GetGObject(d->m_id)->name();
} }
catch (const VExceptionBadId &) catch (const VExceptionBadId &)
{} {
}
const QString errorMsg = QObject::tr("Cannot calculate seam allowance after for point '%1'. Reason: %2.") const QString errorMsg = QObject::tr("Cannot calculate seam allowance after for point '%1'. Reason: %2.")
.arg(nodeName, formula.Reason()); .arg(nodeName, formula.Reason());
VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) : VAbstractApplication::VApp()->IsPedantic()
qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; ? throw VException(errorMsg)
: qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
return -1; return -1;
} }
@ -365,12 +373,14 @@ auto VPieceNode::GetPassmarkLength(const VContainer *data, Unit unit) const -> q
nodeName = data->GetGObject(d->m_id)->name(); nodeName = data->GetGObject(d->m_id)->name();
} }
catch (const VExceptionBadId &) catch (const VExceptionBadId &)
{} {
}
const QString errorMsg = QObject::tr("Cannot calculate passmark length for point '%1'. Reason: %2.") const QString errorMsg = QObject::tr("Cannot calculate passmark length for point '%1'. Reason: %2.")
.arg(nodeName, formula.Reason()); .arg(nodeName, formula.Reason());
VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) : VAbstractApplication::VApp()->IsPedantic()
qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; ? throw VException(errorMsg)
: qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
return VSAPoint::maxPassmarkLength; return VSAPoint::maxPassmarkLength;
} }

View file

@ -29,9 +29,9 @@
#ifndef VPIECENODE_H #ifndef VPIECENODE_H
#define VPIECENODE_H #define VPIECENODE_H
#include <QtGlobal>
#include <QSharedDataPointer>
#include <QMetaType> #include <QMetaType>
#include <QSharedDataPointer>
#include <QtGlobal>
#include "../vmisc/def.h" #include "../vmisc/def.h"
@ -50,7 +50,7 @@ public:
auto operator=(const VPieceNode &node) -> VPieceNode &; auto operator=(const VPieceNode &node) -> VPieceNode &;
#ifdef Q_COMPILER_RVALUE_REFS #ifdef Q_COMPILER_RVALUE_REFS
VPieceNode(VPieceNode &&node) noexcept; VPieceNode(VPieceNode &&node) noexcept;
auto operator=(VPieceNode &&node) noexcept->VPieceNode &; auto operator=(VPieceNode &&node) noexcept -> VPieceNode &;
#endif #endif
friend auto operator<<(QDataStream &out, const VPieceNode &p) -> QDataStream &; friend auto operator<<(QDataStream &out, const VPieceNode &p) -> QDataStream &;
@ -128,11 +128,12 @@ public:
auto IsTurnPoint() const -> bool; auto IsTurnPoint() const -> bool;
void SetTurnPoint(bool value); void SetTurnPoint(bool value);
private: private:
QSharedDataPointer<VPieceNodeData> d; QSharedDataPointer<VPieceNodeData> d;
}; };
Q_DECLARE_METATYPE(VPieceNode) Q_DECLARE_METATYPE(VPieceNode) // NOLINT
Q_DECLARE_TYPEINFO(VPieceNode, Q_MOVABLE_TYPE); // NOLINT Q_DECLARE_TYPEINFO(VPieceNode, Q_MOVABLE_TYPE); // NOLINT
#endif // VPIECENODE_H #endif // VPIECENODE_H

View file

@ -27,16 +27,16 @@
*************************************************************************/ *************************************************************************/
#include "vpiecepath.h" #include "vpiecepath.h"
#include "vpiecepath_p.h"
#include "vcontainer.h"
#include "../vgeometry/vpointf.h"
#include "calculator.h"
#include "../vmisc/vabstractvalapplication.h"
#include "../vmisc/compatibility.h"
#include "../ifc/exception/vexceptionobjecterror.h" #include "../ifc/exception/vexceptionobjecterror.h"
#include "../vgeometry/vpointf.h"
#include "../vmisc/compatibility.h"
#include "../vmisc/vabstractvalapplication.h"
#include "calculator.h"
#include "vcontainer.h"
#include "vpiecepath_p.h"
#include <qnumeric.h>
#include <QPainterPath> #include <QPainterPath>
#include <qnumeric.h>
namespace namespace
{ {
@ -78,13 +78,13 @@ auto CurveStartPoint(VSAPoint candidate, const VContainer *data, const VPieceNod
} }
QVector<QPointF> intersections; QVector<QPointF> intersections;
for (auto i = 0; i < curvePoints.count()-1; ++i) for (auto i = 0; i < curvePoints.count() - 1; ++i)
{ {
QLineF segment(curvePoints.at(i), curvePoints.at(i+1)); QLineF segment(curvePoints.at(i), curvePoints.at(i + 1));
intersections << VAbstractCurve::CurveIntersectLine(points, segment); intersections << VAbstractCurve::CurveIntersectLine(points, segment);
} }
for(auto &p : intersections) for (auto &p : intersections)
{ {
if (VFuzzyComparePoints(p, ConstFirst(curvePoints)) || VFuzzyComparePoints(p, ConstLast(curvePoints))) if (VFuzzyComparePoints(p, ConstFirst(curvePoints)) || VFuzzyComparePoints(p, ConstLast(curvePoints)))
{ {
@ -118,13 +118,13 @@ auto CurveEndPoint(VSAPoint candidate, const VContainer *data, const VPieceNode
} }
QVector<QPointF> intersections; QVector<QPointF> intersections;
for (auto i = 0; i < curvePoints.count()-1; ++i) for (auto i = 0; i < curvePoints.count() - 1; ++i)
{ {
QLineF segment(curvePoints.at(i), curvePoints.at(i+1)); QLineF segment(curvePoints.at(i), curvePoints.at(i + 1));
intersections << VAbstractCurve::CurveIntersectLine(points, segment); intersections << VAbstractCurve::CurveIntersectLine(points, segment);
} }
for(auto &p : intersections) for (auto &p : intersections)
{ {
if (VFuzzyComparePoints(p, ConstFirst(curvePoints)) || VFuzzyComparePoints(p, ConstLast(curvePoints))) if (VFuzzyComparePoints(p, ConstFirst(curvePoints)) || VFuzzyComparePoints(p, ConstLast(curvePoints)))
{ {
@ -155,7 +155,7 @@ auto IndexOfNode(const QVector<VPieceNode> &list, quint32 id) -> int
return i; return i;
} }
} }
qDebug()<<"Can't find node."; qDebug() << "Can't find node.";
return -1; return -1;
} }
@ -183,7 +183,7 @@ template <class T> auto FindTipDirection(const QVector<T> &points) -> qreal
const T &first = ConstFirst(points); const T &first = ConstFirst(points);
for(int i = 1; i < points.size(); ++i) for (int i = 1; i < points.size(); ++i)
{ {
if (first != points.at(i)) if (first != points.at(i))
{ {
@ -222,7 +222,7 @@ void AppendCurveSegment(QVector<T> &points, QVector<QPointF> &segment, const VSA
{ {
points.reserve(points.size() + segment.size()); points.reserve(points.size() + segment.size());
for(int i=0; i < segment.size(); ++i) for (int i = 0; i < segment.size(); ++i)
{ {
VLayoutPoint lp(segment.at(i)); VLayoutPoint lp(segment.at(i));
if (i == 0) if (i == 0)
@ -238,27 +238,27 @@ void AppendCurveSegment(QVector<T> &points, QVector<QPointF> &segment, const VSA
points.append(lp); points.append(lp);
} }
} }
} } // namespace
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPiecePath::VPiecePath() VPiecePath::VPiecePath()
: d(new VPiecePathData) : d(new VPiecePathData)
{} {
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPiecePath::VPiecePath(PiecePathType type) VPiecePath::VPiecePath(PiecePathType type)
: d(new VPiecePathData(type)) : d(new VPiecePathData(type))
{} {
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPiecePath::VPiecePath(const VPiecePath &path) COPY_CONSTRUCTOR_IMPL(VPiecePath)
: d (path.d)
{}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VPiecePath::operator=(const VPiecePath &path) -> VPiecePath & auto VPiecePath::operator=(const VPiecePath &path) -> VPiecePath &
{ {
if ( &path == this ) if (&path == this)
{ {
return *this; return *this;
} }
@ -269,11 +269,12 @@ auto VPiecePath::operator=(const VPiecePath &path) -> VPiecePath &
#ifdef Q_COMPILER_RVALUE_REFS #ifdef Q_COMPILER_RVALUE_REFS
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPiecePath::VPiecePath(VPiecePath &&path) noexcept VPiecePath::VPiecePath(VPiecePath &&path) noexcept
: d (std::move(path.d)) : d(std::move(path.d))
{} {
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VPiecePath::operator=(VPiecePath &&path) noexcept->VPiecePath & auto VPiecePath::operator=(VPiecePath &&path) noexcept -> VPiecePath &
{ {
std::swap(d, path.d); std::swap(d, path.d);
return *this; return *this;
@ -281,8 +282,7 @@ auto VPiecePath::operator=(VPiecePath &&path) noexcept->VPiecePath &
#endif #endif
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPiecePath::~VPiecePath() VPiecePath::~VPiecePath() = default;
{}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPiecePath::Append(const VPieceNode &node) void VPiecePath::Append(const VPieceNode &node)
@ -431,9 +431,10 @@ auto VPiecePath::PathPoints(const VContainer *data, const QVector<QPointF> &cutt
{ {
const QString errorMsg = QObject::tr("Error in internal path '%1'. There is no intersection of first " const QString errorMsg = QObject::tr("Error in internal path '%1'. There is no intersection of first "
"point with cutting contour") "point with cutting contour")
.arg(GetName()); .arg(GetName());
VAbstractApplication::VApp()->IsPedantic() ? throw VExceptionObjectError(errorMsg) : VAbstractApplication::VApp()->IsPedantic()
qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; ? throw VExceptionObjectError(errorMsg)
: qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
} }
} }
@ -449,9 +450,10 @@ auto VPiecePath::PathPoints(const VContainer *data, const QVector<QPointF> &cutt
{ {
const QString errorMsg = QObject::tr("Error in internal path '%1'. There is no intersection of last " const QString errorMsg = QObject::tr("Error in internal path '%1'. There is no intersection of last "
"point with cutting contour") "point with cutting contour")
.arg(GetName()); .arg(GetName());
VAbstractApplication::VApp()->IsPedantic() ? throw VExceptionObjectError(errorMsg) : VAbstractApplication::VApp()->IsPedantic()
qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; ? throw VExceptionObjectError(errorMsg)
: qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
} }
} }
@ -493,12 +495,12 @@ auto VPiecePath::PathNodePoints(const VContainer *data, bool showExcluded) const
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VPiecePath::PathCurvePoints(const VContainer *data) const -> QVector<QVector<QPointF>> auto VPiecePath::PathCurvePoints(const VContainer *data) const -> QVector<QVector<QPointF>>
{ {
QVector<QVector<QPointF> > curves; QVector<QVector<QPointF>> curves;
for (int i = 0; i < CountNodes(); ++i) for (int i = 0; i < CountNodes(); ++i)
{ {
if (at(i).IsExcluded()) if (at(i).IsExcluded())
{ {
continue;// skip excluded node continue; // skip excluded node
} }
switch (at(i).GetTypeTool()) switch (at(i).GetTypeTool())
@ -531,12 +533,12 @@ auto VPiecePath::SeamAllowancePoints(const VContainer *data, qreal width, bool r
SCASSERT(data != nullptr); SCASSERT(data != nullptr);
QVector<VSAPoint> pointsEkv; QVector<VSAPoint> pointsEkv;
for (int i = 0; i< d->m_nodes.size(); ++i) for (int i = 0; i < d->m_nodes.size(); ++i)
{ {
const VPieceNode &node = d->m_nodes.at(i); const VPieceNode &node = d->m_nodes.at(i);
if (node.IsExcluded()) if (node.IsExcluded())
{ {
continue;// skip excluded node continue; // skip excluded node
} }
switch (node.GetTypeTool()) switch (node.GetTypeTool())
@ -556,7 +558,7 @@ auto VPiecePath::SeamAllowancePoints(const VContainer *data, qreal width, bool r
} }
break; break;
default: default:
qDebug()<<"Get wrong tool type. Ignore."<< static_cast<char>(node.GetTypeTool()); qDebug() << "Get wrong tool type. Ignore." << static_cast<char>(node.GetTypeTool());
break; break;
} }
} }
@ -581,11 +583,11 @@ auto VPiecePath::PainterPath(const VContainer *data, const QVector<QPointF> &cut
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VPiecePath::CurvesPainterPath(const VContainer *data) const -> QVector<QPainterPath> auto VPiecePath::CurvesPainterPath(const VContainer *data) const -> QVector<QPainterPath>
{ {
const QVector<QVector<QPointF> > curves = PathCurvePoints(data); const QVector<QVector<QPointF>> curves = PathCurvePoints(data);
QVector<QPainterPath> paths; QVector<QPainterPath> paths;
paths.reserve(curves.size()); paths.reserve(curves.size());
for(const auto &curve : curves) for (const auto &curve : curves)
{ {
paths.append(MakePainterPath(curve)); paths.append(MakePainterPath(curve));
} }
@ -595,7 +597,7 @@ auto VPiecePath::CurvesPainterPath(const VContainer *data) const -> QVector<QPai
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VPiecePath::StartSegment(const VContainer *data, const QVector<VPieceNode> &nodes, vsizetype i) -> VSAPoint auto VPiecePath::StartSegment(const VContainer *data, const QVector<VPieceNode> &nodes, vsizetype i) -> VSAPoint
{ {
if (i < 0 || i > nodes.size()-1) if (i < 0 || i > nodes.size() - 1)
{ {
return {}; return {};
} }
@ -630,7 +632,7 @@ auto VPiecePath::StartSegment(const VContainer *data, const QVector<VPieceNode>
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VPiecePath::EndSegment(const VContainer *data, const QVector<VPieceNode> &nodes, vsizetype i) -> VSAPoint auto VPiecePath::EndSegment(const VContainer *data, const QVector<VPieceNode> &nodes, vsizetype i) -> VSAPoint
{ {
if (i < 0 || i > nodes.size()-1) if (i < 0 || i > nodes.size() - 1)
{ {
return {}; return {};
} }
@ -733,7 +735,7 @@ void VPiecePath::NodeOnEdge(quint32 index, VPieceNode &p1, VPieceNode &p2) const
const QVector<VPieceNode> list = ListNodePoint(); const QVector<VPieceNode> list = ListNodePoint();
if (index > static_cast<quint32>(list.size())) if (index > static_cast<quint32>(list.size()))
{ {
qDebug()<<"Wrong edge index index ="<<index; qDebug() << "Wrong edge index index =" << index;
return; return;
} }
p1 = list.at(static_cast<int>(index)); p1 = list.at(static_cast<int>(index));
@ -743,7 +745,7 @@ void VPiecePath::NodeOnEdge(quint32 index, VPieceNode &p1, VPieceNode &p2) const
} }
else else
{ {
p2 = list.at(static_cast<int>(index+1)); p2 = list.at(static_cast<int>(index + 1));
} }
} }
@ -773,7 +775,7 @@ auto VPiecePath::OnEdge(quint32 p1, quint32 p2) const -> bool
const QVector<VPieceNode> list = ListNodePoint(); const QVector<VPieceNode> list = ListNodePoint();
if (list.size() < 2) if (list.size() < 2)
{ {
qDebug()<<"Not enough points."; qDebug() << "Not enough points.";
return false; return false;
} }
int i = IndexOfNode(list, p1); int i = IndexOfNode(list, p1);
@ -781,7 +783,7 @@ auto VPiecePath::OnEdge(quint32 p1, quint32 p2) const -> bool
if (i == list.size() - 1) if (i == list.size() - 1)
{ {
j1 = i-1; j1 = i - 1;
j2 = 0; j2 = 0;
} }
else if (i == 0) else if (i == 0)
@ -817,7 +819,7 @@ auto VPiecePath::Edge(quint32 p1, quint32 p2) const -> vsizetype
{ {
if (OnEdge(p1, p2) == false) if (OnEdge(p1, p2) == false)
{ {
qDebug()<<"Points don't on edge."; qDebug() << "Points don't on edge.";
return -1; return -1;
} }
@ -866,7 +868,7 @@ auto VPiecePath::RemoveEdge(quint32 index) const -> VPiecePath
// Edge can be only segment. We ignore all curves inside segments. // Edge can be only segment. We ignore all curves inside segments.
const quint32 edges = static_cast<quint32>(ListNodePoint().size()); const quint32 edges = static_cast<quint32>(ListNodePoint().size());
for (quint32 i=0; i<edges; ++i) for (quint32 i = 0; i < edges; ++i)
{ {
VPieceNode p1; VPieceNode p1;
VPieceNode p2; VPieceNode p2;
@ -891,8 +893,7 @@ auto VPiecePath::RemoveEdge(quint32 index) const -> VPiecePath
{ {
j = 0; j = 0;
} }
} } while (j != j2);
while (j != j2);
} }
} }
return path; return path;
@ -913,7 +914,7 @@ auto VPiecePath::EndSegment(const VContainer *data, int i) const -> VSAPoint
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VPiecePath::NodePreviousPoint(const VContainer *data, int i) const -> QPointF auto VPiecePath::NodePreviousPoint(const VContainer *data, int i) const -> QPointF
{ {
if (i < 0 || i > d->m_nodes.size()-1) if (i < 0 || i > d->m_nodes.size() - 1)
{ {
return {}; return {};
} }
@ -923,11 +924,11 @@ auto VPiecePath::NodePreviousPoint(const VContainer *data, int i) const -> QPoin
vsizetype index = 0; vsizetype index = 0;
if (i == 0) if (i == 0)
{ {
index = d->m_nodes.size()-1; index = d->m_nodes.size() - 1;
} }
else else
{ {
index = i-1; index = i - 1;
} }
const VPieceNode &node = d->m_nodes.at(index); const VPieceNode &node = d->m_nodes.at(index);
@ -948,12 +949,12 @@ auto VPiecePath::NodePreviousPoint(const VContainer *data, int i) const -> QPoin
const QVector<QPointF> points = curve->GetSegmentPoints(begin, end, node.GetReverse(), GetName()); const QVector<QPointF> points = curve->GetSegmentPoints(begin, end, node.GetReverse(), GetName());
if (points.size() > 1) if (points.size() > 1)
{ {
return points.at(points.size()-2); return points.at(points.size() - 2);
} }
} }
break; break;
default: default:
qDebug()<<"Get wrong tool type. Ignore."<< static_cast<char>(node.GetTypeTool()); qDebug() << "Get wrong tool type. Ignore." << static_cast<char>(node.GetTypeTool());
break; break;
} }
} }
@ -965,7 +966,7 @@ auto VPiecePath::NodePreviousPoint(const VContainer *data, int i) const -> QPoin
auto VPiecePath::NodeNextPoint(const VContainer *data, int i) const -> QPointF auto VPiecePath::NodeNextPoint(const VContainer *data, int i) const -> QPointF
{ {
QPointF point; QPointF point;
if (i < 0 || i > d->m_nodes.size()-1) if (i < 0 || i > d->m_nodes.size() - 1)
{ {
return point; return point;
} }
@ -979,7 +980,7 @@ auto VPiecePath::NodeNextPoint(const VContainer *data, int i) const -> QPointF
} }
else else
{ {
index = i+1; index = i + 1;
} }
const VPieceNode &node = d->m_nodes.at(index); const VPieceNode &node = d->m_nodes.at(index);
@ -1003,9 +1004,9 @@ auto VPiecePath::NodeNextPoint(const VContainer *data, int i) const -> QPointF
return points.at(1); return points.at(1);
} }
} }
break; break;
default: default:
qDebug()<<"Get wrong tool type. Ignore."<< static_cast<char>(node.GetTypeTool()); qDebug() << "Get wrong tool type. Ignore." << static_cast<char>(node.GetTypeTool());
break; break;
} }
} }
@ -1051,7 +1052,7 @@ auto VPiecePath::indexOfNode(const QVector<VPieceNode> &nodes, quint32 id) -> in
return i; return i;
} }
} }
qDebug()<<"Can't find node."; qDebug() << "Can't find node.";
return -1; return -1;
} }
@ -1063,7 +1064,7 @@ auto VPiecePath::FindInLoopNotExcludedUp(vsizetype start, const QVector<VPieceNo
return -1; return -1;
} }
vsizetype i = (start == 0) ? nodes.size()-1 : start-1; vsizetype i = (start == 0) ? nodes.size() - 1 : start - 1;
if (i < 0 || i >= nodes.size()) if (i < 0 || i >= nodes.size())
{ {
@ -1099,7 +1100,7 @@ auto VPiecePath::FindInLoopNotExcludedDown(vsizetype start, const QVector<VPiece
return -1; return -1;
} }
vsizetype i = (start == nodes.size()-1) ? 0 : start+1; vsizetype i = (start == nodes.size() - 1) ? 0 : start + 1;
if (i < 0 || i >= nodes.size()) if (i < 0 || i >= nodes.size())
{ {
@ -1130,7 +1131,7 @@ auto VPiecePath::FindInLoopNotExcludedDown(vsizetype start, const QVector<VPiece
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VPiecePath::PreparePointEkv(const VPieceNode &node, const VContainer *data) -> VSAPoint auto VPiecePath::PreparePointEkv(const VPieceNode &node, const VContainer *data) -> VSAPoint
{ {
SCASSERT(data !=nullptr) SCASSERT(data != nullptr)
const QSharedPointer<VPointF> point = data->GeometricObject<VPointF>(node.GetId()); const QSharedPointer<VPointF> point = data->GeometricObject<VPointF>(node.GetId());
VSAPoint p(point->toQPointF()); VSAPoint p(point->toQPointF());
@ -1170,8 +1171,8 @@ auto VPiecePath::CurveSeamAllowanceSegment(const VContainer *data, const QVector
qreal w1 = begin.GetSAAfter(); qreal w1 = begin.GetSAAfter();
qreal w2 = end.GetSABefore(); qreal w2 = end.GetSABefore();
if (w1 < 0 && w2 < 0) if (w1 < 0 && w2 < 0)
{// no local widths { // no local widths
for(int i = 0; i < points.size(); ++i) for (int i = 0; i < points.size(); ++i)
{ {
VSAPoint p(points.at(i)); VSAPoint p(points.at(i));
p.SetAngleType(PieceNodeAngle::ByLengthCurve); p.SetAngleType(PieceNodeAngle::ByLengthCurve);
@ -1207,10 +1208,10 @@ auto VPiecePath::CurveSeamAllowanceSegment(const VContainer *data, const QVector
w2 = width; w2 = width;
} }
const qreal wDiff = w2 - w1;// Difference between two local widths const qreal wDiff = w2 - w1; // Difference between two local widths
const qreal fullLength = VAbstractCurve::PathLength(points); const qreal fullLength = VAbstractCurve::PathLength(points);
VSAPoint p(points.at(0));//First point in the list VSAPoint p(points.at(0)); // First point in the list
p.SetSAAfter(begin.GetSAAfter()); p.SetSAAfter(begin.GetSAAfter());
p.SetSABefore(begin.GetSABefore()); p.SetSABefore(begin.GetSABefore());
p.SetAngleType(begin.GetAngleType()); p.SetAngleType(begin.GetAngleType());
@ -1220,13 +1221,13 @@ auto VPiecePath::CurveSeamAllowanceSegment(const VContainer *data, const QVector
qreal length = 0; // how much we handle qreal length = 0; // how much we handle
for(int i = 1; i < points.size(); ++i) for (int i = 1; i < points.size(); ++i)
{ {
p = VSAPoint(points.at(i)); p = VSAPoint(points.at(i));
p.SetCurvePoint(true); p.SetCurvePoint(true);
if (i == points.size() - 1) if (i == points.size() - 1)
{// last point { // last point
p.SetSAAfter(end.GetSAAfter()); p.SetSAAfter(end.GetSAAfter());
p.SetSABefore(end.GetSABefore()); p.SetSABefore(end.GetSABefore());
p.SetAngleType(end.GetAngleType()); p.SetAngleType(end.GetAngleType());
@ -1234,8 +1235,8 @@ auto VPiecePath::CurveSeamAllowanceSegment(const VContainer *data, const QVector
} }
else else
{ {
length += QLineF(points.at(i-1), points.at(i)).length(); length += QLineF(points.at(i - 1), points.at(i)).length();
const qreal localWidth = w1 + wDiff*(length/fullLength); const qreal localWidth = w1 + wDiff * (length / fullLength);
p.SetSAAfter(localWidth); p.SetSAAfter(localWidth);
p.SetSABefore(localWidth); p.SetSABefore(localWidth);
@ -1262,7 +1263,7 @@ auto VPiecePath::NodeName(const QVector<VPieceNode> &nodes, vsizetype nodeIndex,
QSharedPointer<VGObject> obj = data->GetGObject(nodes.at(nodeIndex).GetId()); QSharedPointer<VGObject> obj = data->GetGObject(nodes.at(nodeIndex).GetId());
return obj->name(); return obj->name();
} }
catch (const VExceptionBadId& ) catch (const VExceptionBadId &)
{ {
// ignore // ignore
} }
@ -1279,7 +1280,7 @@ auto VPiecePath::NodesToPoints(const VContainer *data, const QVector<VPieceNode>
const VPieceNode &node = nodes.at(i); const VPieceNode &node = nodes.at(i);
if (node.IsExcluded()) if (node.IsExcluded())
{ {
continue;// skip excluded node continue; // skip excluded node
} }
switch (node.GetTypeTool()) switch (node.GetTypeTool())
@ -1307,7 +1308,7 @@ auto VPiecePath::NodesToPoints(const VContainer *data, const QVector<VPieceNode>
} }
break; break;
default: default:
qDebug()<<"Get wrong tool type. Ignore."<< static_cast<char>(node.GetTypeTool()); qDebug() << "Get wrong tool type. Ignore." << static_cast<char>(node.GetTypeTool());
break; break;
} }
} }

View file

@ -29,11 +29,11 @@
#ifndef VPIECEPATH_H #ifndef VPIECEPATH_H
#define VPIECEPATH_H #define VPIECEPATH_H
#include <QtGlobal>
#include <QSharedDataPointer> #include <QSharedDataPointer>
#include <QtGlobal>
#include "../vmisc/def.h"
#include "../vgeometry/vabstractcurve.h" #include "../vgeometry/vabstractcurve.h"
#include "../vmisc/def.h"
class VPiecePathData; class VPiecePathData;
class VSAPoint; class VSAPoint;
@ -56,33 +56,33 @@ public:
auto operator=(const VPiecePath &path) -> VPiecePath &; auto operator=(const VPiecePath &path) -> VPiecePath &;
#ifdef Q_COMPILER_RVALUE_REFS #ifdef Q_COMPILER_RVALUE_REFS
VPiecePath(VPiecePath &&path) noexcept; VPiecePath(VPiecePath &&path) noexcept;
auto operator=(VPiecePath &&path) noexcept->VPiecePath &; auto operator=(VPiecePath &&path) noexcept -> VPiecePath &;
#endif #endif
void Append(const VPieceNode &node); void Append(const VPieceNode &node);
void Clear(); void Clear();
auto CountNodes() const -> vsizetype; auto CountNodes() const -> vsizetype;
auto operator[](vsizetype indx) -> VPieceNode &; auto operator[](vsizetype indx) -> VPieceNode &;
auto at(vsizetype indx) const -> const VPieceNode &; auto at(vsizetype indx) const -> const VPieceNode &;
auto GetNodes() const -> QVector<VPieceNode>; auto GetNodes() const -> QVector<VPieceNode>;
void SetNodes(const QVector<VPieceNode> &nodes); void SetNodes(const QVector<VPieceNode> &nodes);
auto GetType() const -> PiecePathType; auto GetType() const -> PiecePathType;
void SetType(PiecePathType type); void SetType(PiecePathType type);
auto GetName() const -> QString; auto GetName() const -> QString;
void SetName(const QString &name); void SetName(const QString &name);
auto GetPenType() const -> Qt::PenStyle; auto GetPenType() const -> Qt::PenStyle;
void SetPenType(const Qt::PenStyle &type); void SetPenType(const Qt::PenStyle &type);
auto IsCutPath() const -> bool; auto IsCutPath() const -> bool;
void SetCutPath(bool cut); void SetCutPath(bool cut);
auto GetVisibilityTrigger() const -> QString; auto GetVisibilityTrigger() const -> QString;
void SetVisibilityTrigger(const QString &formula); void SetVisibilityTrigger(const QString &formula);
void SetFirstToCuttingContour(bool value); void SetFirstToCuttingContour(bool value);
auto IsFirstToCuttingContour() const -> bool; auto IsFirstToCuttingContour() const -> bool;
@ -146,6 +146,6 @@ private:
}; };
Q_DECLARE_TYPEINFO(VPiecePath, Q_MOVABLE_TYPE); // NOLINT Q_DECLARE_TYPEINFO(VPiecePath, Q_MOVABLE_TYPE); // NOLINT
Q_DECLARE_METATYPE(VPiecePath) Q_DECLARE_METATYPE(VPiecePath) // NOLINT
#endif // VPIECEPATH_H #endif // VPIECEPATH_H

View file

@ -37,9 +37,9 @@
namespace namespace
{ {
constexpr qreal arrowAngle = M_PI/9; constexpr qreal arrowAngle = M_PI / 9;
constexpr int arrowLength = 15; constexpr int arrowLength = 15;
} } // namespace
// VPieceGrainlinePrivate // VPieceGrainlinePrivate
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -52,32 +52,32 @@ auto VPieceGrainlinePrivate::MainLine(const QPointF &p1, qreal length, qreal ang
// VPieceGrainline // VPieceGrainline
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPieceGrainline::VPieceGrainline() VPieceGrainline::VPieceGrainline()
:d(new VPieceGrainlinePrivate) : d(new VPieceGrainlinePrivate)
{} {
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPieceGrainline::~VPieceGrainline() //NOLINT(modernize-use-equals-default) VPieceGrainline::~VPieceGrainline() = default;
{}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPieceGrainline::VPieceGrainline(const QLineF &mainLine, GrainlineArrowDirection arrowType) VPieceGrainline::VPieceGrainline(const QLineF &mainLine, GrainlineArrowDirection arrowType)
:d (new VPieceGrainlinePrivate(mainLine, arrowType)) : d(new VPieceGrainlinePrivate(mainLine, arrowType))
{} {
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPieceGrainline::VPieceGrainline(const QPointF &p1, qreal length, qreal angle, GrainlineArrowDirection arrowType) VPieceGrainline::VPieceGrainline(const QPointF &p1, qreal length, qreal angle, GrainlineArrowDirection arrowType)
:d (new VPieceGrainlinePrivate(VPieceGrainlinePrivate::MainLine(p1, length, angle), arrowType)) : d(new VPieceGrainlinePrivate(VPieceGrainlinePrivate::MainLine(p1, length, angle), arrowType))
{} {
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPieceGrainline::VPieceGrainline(const VPieceGrainline &other) //NOLINT(modernize-use-equals-default) COPY_CONSTRUCTOR_IMPL(VPieceGrainline)
:d (other.d)
{}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VPieceGrainline::operator=(const VPieceGrainline &grainline) -> VPieceGrainline & auto VPieceGrainline::operator=(const VPieceGrainline &grainline) -> VPieceGrainline &
{ {
if ( &grainline == this ) if (&grainline == this)
{ {
return *this; return *this;
} }
@ -88,8 +88,9 @@ auto VPieceGrainline::operator=(const VPieceGrainline &grainline) -> VPieceGrain
#ifdef Q_COMPILER_RVALUE_REFS #ifdef Q_COMPILER_RVALUE_REFS
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPieceGrainline::VPieceGrainline(VPieceGrainline &&grainline) noexcept VPieceGrainline::VPieceGrainline(VPieceGrainline &&grainline) noexcept
: d(std::move(grainline.d)) : d(std::move(grainline.d))
{} {
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VPieceGrainline::operator=(VPieceGrainline &&grainline) noexcept -> VPieceGrainline & auto VPieceGrainline::operator=(VPieceGrainline &&grainline) noexcept -> VPieceGrainline &
@ -397,7 +398,7 @@ auto VPieceGrainline::IsPositionValid(const QVector<QPointF> &contourPoints) con
{ {
QVector<QLineF> grainLine; QVector<QLineF> grainLine;
QLineF mainLine = GetMainLine(); QLineF mainLine = GetMainLine();
if (IsFourWays ()) if (IsFourWays())
{ {
grainLine = {mainLine, SecondaryLine()}; grainLine = {mainLine, SecondaryLine()};
} }
@ -409,7 +410,7 @@ auto VPieceGrainline::IsPositionValid(const QVector<QPointF> &contourPoints) con
QVector<QPointF> points = VAbstractCurve::CurveIntersectLine(contourPoints, line); QVector<QPointF> points = VAbstractCurve::CurveIntersectLine(contourPoints, line);
for (auto &point : points) for (auto &point : points)
{ {
if (not VFuzzyComparePoints (line.p1 (), point) && not VFuzzyComparePoints (line.p2 (), point)) if (not VFuzzyComparePoints(line.p1(), point) && not VFuzzyComparePoints(line.p2(), point))
{ {
return false; return false;
} }

View file

@ -28,9 +28,9 @@
#ifndef VPIECEGRAINLINE_H #ifndef VPIECEGRAINLINE_H
#define VPIECEGRAINLINE_H #define VPIECEGRAINLINE_H
#include <QSharedDataPointer>
#include <QMetaType>
#include "../vpatterndb/floatItemData/floatitemdef.h" #include "../vpatterndb/floatItemData/floatitemdef.h"
#include <QMetaType>
#include <QSharedDataPointer>
class QPointF; class QPointF;
class VPieceGrainlinePrivate; class VPieceGrainlinePrivate;
@ -86,13 +86,14 @@ public:
auto IsShapeValid() const -> bool; auto IsShapeValid() const -> bool;
friend auto operator<< (QDataStream& dataStream, const VPieceGrainline& grainline) -> QDataStream&; friend auto operator<<(QDataStream &dataStream, const VPieceGrainline &grainline) -> QDataStream &;
friend auto operator>> (QDataStream& dataStream, VPieceGrainline& grainline) -> QDataStream&; friend auto operator>>(QDataStream &dataStream, VPieceGrainline &grainline) -> QDataStream &;
private: private:
QSharedDataPointer<VPieceGrainlinePrivate> d; QSharedDataPointer<VPieceGrainlinePrivate> d;
}; };
Q_DECLARE_METATYPE(VPieceGrainline) Q_DECLARE_METATYPE(VPieceGrainline) // NOLINT
Q_DECLARE_TYPEINFO(VPieceGrainline, Q_MOVABLE_TYPE); // NOLINT Q_DECLARE_TYPEINFO(VPieceGrainline, Q_MOVABLE_TYPE); // NOLINT
#endif // VPIECEGRAINLINE_H #endif // VPIECEGRAINLINE_H