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 &

View File

@ -35,10 +35,10 @@
#include <QPoint>
#include <QtDebug>
#include "vabstractcurve_p.h"
#include "../vmisc/vabstractvalapplication.h"
#include "../vmisc/compatibility.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
#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)
:VGObject(type, idObject, mode), d (new VAbstractCurveData())
{}
: VGObject(type, idObject, mode),
d(new VAbstractCurveData())
{
}
//---------------------------------------------------------------------------------------------------------------------
VAbstractCurve::VAbstractCurve(const VAbstractCurve &curve) // NOLINT(modernize-use-equals-default)
:VGObject(curve), d (curve.d)
{}
COPY_CONSTRUCTOR_IMPL_2(VAbstractCurve, VGObject)
//---------------------------------------------------------------------------------------------------------------------
auto VAbstractCurve::operator=(const VAbstractCurve &curve) -> VAbstractCurve &
{
if ( &curve == this )
if (&curve == this)
{
return *this;
}
@ -70,8 +70,10 @@ auto VAbstractCurve::operator=(const VAbstractCurve &curve) -> VAbstractCurve &
#ifdef Q_COMPILER_RVALUE_REFS
//---------------------------------------------------------------------------------------------------------------------
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 &
@ -83,8 +85,7 @@ auto VAbstractCurve::operator=(VAbstractCurve &&curve) noexcept -> VAbstractCurv
#endif
//---------------------------------------------------------------------------------------------------------------------
VAbstractCurve::~VAbstractCurve() // NOLINT(modernize-use-equals-default)
{}
VAbstractCurve::~VAbstractCurve() = default;
//---------------------------------------------------------------------------------------------------------------------
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;
if (piece.isEmpty())
{
errorMsg = QObject::tr("Error calculating segment for curve '%1'. %2")
.arg(name(), error);
errorMsg = QObject::tr("Error calculating segment for curve '%1'. %2").arg(name(), error);
}
else
{
errorMsg = QObject::tr("Error in path '%1'. Calculating segment for curve '%2' has failed. %3")
.arg(piece, name(), error);
}
VAbstractApplication::VApp()->IsPedantic() ? throw VExceptionObjectError(errorMsg) :
qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
VAbstractApplication::VApp()->IsPedantic()
? throw VExceptionObjectError(errorMsg)
: qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
}
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>
{
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)
{
*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;
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();
if (length < bestDistance)
@ -290,7 +287,7 @@ auto VAbstractCurve::GetPath() const -> QPainterPath
}
else
{
qDebug()<<"points.count() < 2"<<Q_FUNC_INFO;
qDebug() << "points.count() < 2" << Q_FUNC_INFO;
}
return path;
}
@ -349,9 +346,9 @@ auto VAbstractCurve::IsPointOnCurve(const QVector<QPointF> &points, const QPoint
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;
}
@ -379,11 +376,11 @@ auto VAbstractCurve::SubdividePath(const QVector<QPointF> &points, QPointF p, QV
sub1.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 (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))
{
@ -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);
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));
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>
{
QVector<QPointF> intersections;
intersections.reserve(points.count()-1);
for ( auto i = 0; i < points.count()-1; ++i )
intersections.reserve(points.count() - 1);
for (auto i = 0; i < points.count() - 1; ++i)
{
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
if (type == QLineF::BoundedIntersection ||
(VGObject::IsPointOnLineSegment (crosPoint, points.at(i), points.at(i+1)) &&
VGObject::IsPointOnLineSegment (crosPoint, line.p1(), line.p2())))
(VGObject::IsPointOnLineSegment(crosPoint, points.at(i), points.at(i + 1)) &&
VGObject::IsPointOnLineSegment(crosPoint, line.p1(), line.p2())))
{
intersections.append(crosPoint);
}
@ -512,13 +509,13 @@ auto VAbstractCurve::CurveIntersectAxis(const QPointF &point, qreal angle, const
// Normalize an angle
{
QLineF line(QPointF(10,10), QPointF(100, 10));
QLineF line(QPointF(10, 10), QPointF(100, 10));
line.setAngle(angle);
angle = line.angle();
}
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.
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> backward;
for ( qint32 i = 0; i < points.size(); ++i )
for (qint32 i = 0; i < points.size(); ++i)
{
if (VFuzzyComparePoints(points.at(i), point))
{ // Always seek unique intersection
@ -546,7 +543,7 @@ auto VAbstractCurve::CurveIntersectAxis(const QPointF &point, qreal angle, const
}
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);
}
@ -597,33 +594,33 @@ auto VAbstractCurve::DirectionArrows() const -> QVector<DirectionArrow>
{
/*Need find coordinate midle of curve.
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;
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));
found_length += arrow.length();//Length that we aready find
arrow = QLineF(points.at(i - 1), points.at(i));
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));
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());
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());
DirectionArrow dArrow;
arrow.setAngle(angle-35);
arrow.setAngle(angle - 35);
dArrow.first = arrow;
arrow.setAngle(angle+35);
arrow.setAngle(angle + 35);
dArrow.second = arrow;
arrows.append(dArrow);

View File

@ -32,24 +32,25 @@
#include <QPointF>
#include <QtDebug>
#include "../vmisc/def.h"
#include "../vmisc/vmath.h"
#include "../vmisc/compatibility.h"
#include "../vmisc/vabstractapplication.h"
#include "../ifc/exception/vexception.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 "varc_p.h"
#include "vspline.h"
#include "../ifc/exception/vexception.h"
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief VArc default constructor.
*/
VArc::VArc ()
: VAbstractArc(GOType::Arc),
d (new VArcData)
{}
VArc::VArc()
: VAbstractArc(GOType::Arc),
d(new VArcData)
{
}
//---------------------------------------------------------------------------------------------------------------------
/**
@ -59,18 +60,18 @@ VArc::VArc ()
* @param f1 start angle (degree).
* @param f2 end angle (degree).
*/
VArc::VArc (const VPointF &center, qreal radius, const QString &formulaRadius, qreal f1, const QString &formulaF1,
qreal f2, const QString &formulaF2, quint32 idObject, Draw mode)
: VAbstractArc(GOType::Arc, center, f1, formulaF1, f2, formulaF2, idObject, mode),
d (new VArcData(radius, formulaRadius))
VArc::VArc(const VPointF &center, qreal radius, const QString &formulaRadius, qreal f1, const QString &formulaF1,
qreal f2, const QString &formulaF2, quint32 idObject, Draw mode)
: VAbstractArc(GOType::Arc, center, f1, formulaF1, f2, formulaF2, idObject, mode),
d(new VArcData(radius, formulaRadius))
{
CreateName();
}
//---------------------------------------------------------------------------------------------------------------------
VArc::VArc(const VPointF &center, qreal radius, qreal f1, qreal f2)
: VAbstractArc(GOType::Arc, center, f1, f2, NULL_ID, Draw::Calculation),
d (new VArcData(radius))
: VAbstractArc(GOType::Arc, center, f1, f2, NULL_ID, Draw::Calculation),
d(new VArcData(radius))
{
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,
const QString &formulaRadius, qreal f1, const QString &formulaF1, quint32 idObject, Draw mode)
: VAbstractArc(GOType::Arc, formulaLength, center, f1, formulaF1, idObject, mode),
d (new VArcData(radius, formulaRadius))
: VAbstractArc(GOType::Arc, formulaLength, center, f1, formulaF1, idObject, mode),
d(new VArcData(radius, formulaRadius))
{
CreateName();
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)
: VAbstractArc(GOType::Arc, center, f1, NULL_ID, Draw::Calculation),
d (new VArcData(radius))
: VAbstractArc(GOType::Arc, center, f1, NULL_ID, Draw::Calculation),
d(new VArcData(radius))
{
CreateName();
FindF2(length);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief VArc copy constructor
* @param arc arc
*/
VArc::VArc(const VArc &arc)
: VAbstractArc(arc), d (arc.d)
{}
COPY_CONSTRUCTOR_IMPL_2(VArc, VAbstractArc)
//---------------------------------------------------------------------------------------------------------------------
/**
@ -109,9 +104,9 @@ VArc::VArc(const VArc &arc)
* @param arc 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;
}
@ -123,8 +118,10 @@ auto VArc::operator =(const VArc &arc) -> VArc &
#ifdef Q_COMPILER_RVALUE_REFS
//---------------------------------------------------------------------------------------------------------------------
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 &
@ -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
{
QPointF p1 ( GetCenter().x () + d->radius, GetCenter().y () );
QPointF p1(GetCenter().x() + d->radius, GetCenter().y());
QLineF centerP1(static_cast<QPointF>(GetCenter()), p1);
centerP1.setAngle(GetStartAngle());
return centerP1.p2();
@ -251,9 +247,9 @@ auto VArc::GetP1() const -> QPointF
* @brief GetP2 return point associated with end angle.
* @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);
centerP2.setAngle(GetEndAngle());
return centerP2.p2();
@ -286,15 +282,15 @@ auto VArc::GetPoints() const -> QVector<QPointF>
}
if (angle > 360 || angle < 0)
{// Filter incorect value
QLineF dummy(0,0, 100, 0);
{ // Filter incorect value
QLineF dummy(0, 0, 100, 0);
dummy.setAngle(angle);
angle = dummy.angle();
}
const qreal angleInterpolation = 45; //degree
const qreal angleInterpolation = 45; // degree
const int sections = qFloor(angle / angleInterpolation);
sectionAngle.reserve(sections+1);
sectionAngle.reserve(sections + 1);
for (int i = 0; i < sections; ++i)
{
sectionAngle.append(angleInterpolation);
@ -309,7 +305,7 @@ auto VArc::GetPoints() const -> QVector<QPointF>
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());
@ -319,7 +315,7 @@ auto VArc::GetPoints() const -> QVector<QPointF>
QLineF lineP4P3(center, pStart);
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.setAngle(lineP4P3.angle() + 90.0);
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
{
//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();
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();
const QString errorMsg = tr("Unable to cut curve '%1'. The curve is too short.").arg(name());
VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) :
qWarning() << VAbstractApplication::warningMessageSignature + errorMsg;
VAbstractApplication::VApp()->IsPedantic()
? throw VException(errorMsg)
: qWarning() << VAbstractApplication::warningMessageSignature + errorMsg;
return {};
}
QLineF line = not IsFlipped() ? CutPoint(length, fullLength, pointName)
: CutPointFlipped(length, fullLength, pointName);
QLineF line =
not IsFlipped() ? CutPoint(length, fullLength, pointName) : CutPointFlipped(length, fullLength, pointName);
arc1 = VArc(GetCenter(), d->radius, d->formulaRadius, GetStartAngle(), GetFormulaF1(), line.angle(),
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();
}
//---------------------------------------------------------------------------------------------------------------------
auto VArc::CutArc(qreal length, const QString &pointName) const -> QPointF
{
@ -434,7 +430,7 @@ void VArc::FindF2(qreal length)
length = MaxLength();
}
qreal arcAngle = qAbs(qRadiansToDegrees(length/d->radius));
qreal arcAngle = qAbs(qRadiansToDegrees(length / d->radius));
if (IsFlipped())
{
@ -442,7 +438,7 @@ void VArc::FindF2(qreal length)
}
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());
}
@ -450,7 +446,7 @@ void VArc::FindF2(qreal length)
//---------------------------------------------------------------------------------------------------------------------
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())
{
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
{
errorMsg = tr("Curve '%1'. Length of a cut segment is too small. Optimize it to minimal value.")
.arg(name());
errorMsg =
tr("Curve '%1'. Length of a cut segment is too small. Optimize it to minimal value.").arg(name());
}
VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) :
qWarning() << VAbstractApplication::warningMessageSignature + errorMsg;
VAbstractApplication::VApp()->IsPedantic()
? throw VException(errorMsg)
: qWarning() << VAbstractApplication::warningMessageSignature + errorMsg;
}
else if (length > maxLength)
{
@ -485,22 +482,22 @@ auto VArc::CutPoint(qreal length, qreal fullLength, const QString &pointName) co
if (not pointName.isEmpty())
{
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
{
errorMsg = tr("Curve '%1'. Length of a cut segment is too big. Optimize it to maximal value.")
.arg(name());
errorMsg = tr("Curve '%1'. Length of a cut segment is too big. Optimize it to maximal value.").arg(name());
}
VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) :
qWarning() << VAbstractApplication::warningMessageSignature + errorMsg;
VAbstractApplication::VApp()->IsPedantic()
? throw VException(errorMsg)
: qWarning() << VAbstractApplication::warningMessageSignature + errorMsg;
}
length = qBound(minLength, length, maxLength);
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;
}
@ -521,15 +518,16 @@ auto VArc::CutPointFlipped(qreal length, qreal fullLength, const QString &pointN
if (not pointName.isEmpty())
{
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
{
errorMsg = tr("Curve '%1'. Length of a cut segment is too small. Optimize it to minimal value.")
.arg(name());
errorMsg =
tr("Curve '%1'. Length of a cut segment is too small. Optimize it to minimal value.").arg(name());
}
VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) :
qWarning() << VAbstractApplication::warningMessageSignature + errorMsg;
VAbstractApplication::VApp()->IsPedantic()
? throw VException(errorMsg)
: qWarning() << VAbstractApplication::warningMessageSignature + errorMsg;
}
else if (length > maxLengthFlipped)
{
@ -537,21 +535,21 @@ auto VArc::CutPointFlipped(qreal length, qreal fullLength, const QString &pointN
if (not pointName.isEmpty())
{
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
{
errorMsg = tr("Curve '%1'. Length of a cut segment is too big. Optimize it to maximal value.")
.arg(name());
errorMsg = tr("Curve '%1'. Length of a cut segment is too big. Optimize it to maximal value.").arg(name());
}
VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) :
qWarning() << VAbstractApplication::warningMessageSignature + errorMsg;
VAbstractApplication::VApp()->IsPedantic()
? throw VException(errorMsg)
: qWarning() << VAbstractApplication::warningMessageSignature + errorMsg;
}
length = qBound(minLengthFlipped, length, maxLengthFlipped);
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;
}

View File

@ -34,20 +34,19 @@
//---------------------------------------------------------------------------------------------------------------------
VCubicBezier::VCubicBezier()
: VAbstractCubicBezier(GOType::CubicBezier), d(new VCubicBezierData)
: VAbstractCubicBezier(GOType::CubicBezier),
d(new VCubicBezierData)
{
}
//---------------------------------------------------------------------------------------------------------------------
VCubicBezier::VCubicBezier(const VCubicBezier &curve)
: VAbstractCubicBezier(curve), d(curve.d)
{
}
COPY_CONSTRUCTOR_IMPL_2(VCubicBezier, VAbstractCubicBezier)
//---------------------------------------------------------------------------------------------------------------------
VCubicBezier::VCubicBezier(const VPointF &p1, const VPointF &p2, const VPointF &p3, const VPointF &p4, quint32 idObject,
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();
}
@ -55,7 +54,7 @@ VCubicBezier::VCubicBezier(const VPointF &p1, const VPointF &p2, const VPointF &
//---------------------------------------------------------------------------------------------------------------------
auto VCubicBezier::operator=(const VCubicBezier &curve) -> VCubicBezier &
{
if ( &curve == this )
if (&curve == this)
{
return *this;
}
@ -67,11 +66,13 @@ auto VCubicBezier::operator=(const VCubicBezier &curve) -> VCubicBezier &
#ifdef Q_COMPILER_RVALUE_REFS
//---------------------------------------------------------------------------------------------------------------------
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);
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
@ -214,8 +213,8 @@ auto VCubicBezier::GetEndAngle() const -> qreal
*/
auto VCubicBezier::GetLength() const -> qreal
{
return LengthBezier (static_cast<QPointF>(GetP1()), static_cast<QPointF>(GetP2()),
static_cast<QPointF>(GetP3()), static_cast<QPointF>(GetP4()), GetApproximationScale());
return LengthBezier(static_cast<QPointF>(GetP1()), static_cast<QPointF>(GetP2()), static_cast<QPointF>(GetP3()),
static_cast<QPointF>(GetP4()), GetApproximationScale());
}
//---------------------------------------------------------------------------------------------------------------------
@ -256,6 +255,6 @@ auto VCubicBezier::GetControlPoint2() const -> QPointF
//---------------------------------------------------------------------------------------------------------------------
auto VCubicBezier::GetRealLength() const -> qreal
{
return LengthBezier (static_cast<QPointF>(GetP1()), static_cast<QPointF>(GetP2()),
static_cast<QPointF>(GetP3()), static_cast<QPointF>(GetP4()), maxCurveApproximationScale);
return LengthBezier(static_cast<QPointF>(GetP1()), static_cast<QPointF>(GetP2()), static_cast<QPointF>(GetP3()),
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 Flip(const QLineF &axis, 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 &;
#ifdef Q_COMPILER_RVALUE_REFS
@ -59,29 +59,29 @@ public:
auto operator=(VCubicBezier &&curve) noexcept -> VCubicBezier &;
#endif
virtual auto GetP1() const -> VPointF override;
auto GetP1() const -> VPointF override;
void SetP1(const VPointF &p);
virtual auto GetP2() const -> VPointF override;
auto GetP2() const -> VPointF override;
void SetP2(const VPointF &p);
virtual auto GetP3() const -> VPointF override;
auto GetP3() const -> VPointF override;
void SetP3(const VPointF &p);
virtual auto GetP4() const -> VPointF override;
auto GetP4() const -> VPointF override;
void SetP4(const VPointF &p);
virtual auto GetStartAngle() const -> qreal override;
virtual auto GetEndAngle() const -> qreal override;
virtual auto GetLength() const -> qreal override;
virtual auto GetPoints() const -> QVector<QPointF> override;
auto GetStartAngle() const -> qreal override;
auto GetEndAngle() const -> qreal override;
auto GetLength() const -> qreal override;
auto GetPoints() const -> QVector<QPointF> override;
virtual auto GetC1Length() const -> qreal override;
virtual auto GetC2Length() const -> qreal override;
auto GetC1Length() const -> qreal override;
auto GetC2Length() const -> qreal override;
protected:
virtual auto GetControlPoint1() const -> QPointF override;
virtual auto GetControlPoint2() const -> QPointF override;
auto GetControlPoint1() const -> QPointF override;
auto GetControlPoint2() const -> QPointF override;
auto GetRealLength() const -> qreal override;
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)

View File

@ -49,11 +49,11 @@ class VCubicBezierPath final : public VAbstractCubicBezierPath
public:
explicit VCubicBezierPath(quint32 idObject = 0, Draw mode = Draw::Calculation);
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 Flip(const QLineF &axis, 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 &;
#ifdef Q_COMPILER_RVALUE_REFS
@ -67,17 +67,17 @@ public:
void append(const VPointF &point);
virtual auto CountSubSpl() const -> vsizetype override;
virtual auto CountPoints() const -> vsizetype override;
virtual void Clear() override;
virtual auto GetSpline(vsizetype index) const -> VSpline override;
virtual auto GetStartAngle() const -> qreal override;
virtual auto GetEndAngle() const -> qreal override;
auto CountSubSpl() const -> vsizetype override;
auto CountPoints() const -> vsizetype override;
void Clear() override;
auto GetSpline(vsizetype index) const -> VSpline override;
auto GetStartAngle() const -> qreal override;
auto GetEndAngle() const -> qreal override;
virtual auto GetC1Length() const -> qreal override;
virtual auto GetC2Length() const -> qreal override;
auto GetC1Length() 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>;
static auto CountSubSpl(vsizetype size) -> vsizetype;
@ -85,8 +85,8 @@ public:
static auto SubSplPointsCount(vsizetype countSubSpl) -> vsizetype;
protected:
virtual auto FirstPoint() const -> VPointF override;
virtual auto LastPoint() const -> VPointF override;
auto FirstPoint() const -> VPointF override;
auto LastPoint() const -> VPointF override;
private:
QSharedDataPointer<VCubicBezierPathData> d;

View File

@ -29,24 +29,24 @@
#include "vellipticalarc.h"
#include <QLineF>
#include <QPoint>
#include <QPainterPath>
#include <QPoint>
#include <QtDebug>
#include "../vmisc/def.h"
#include "../ifc/ifcdef.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/math.hpp"
#include "../vmisc/compatibility.h"
#include "../vmisc/vabstractapplication.h"
#include "../vmisc/vmath.h"
#include "vabstractcurve.h"
#include "vellipticalarc_p.h"
#include "../vmisc/vmath.h"
namespace
{
constexpr qreal tolerance = accuracyPointOnLine/8;
constexpr qreal tolerance = accuracyPointOnLine / 8;
// Because of overflow we cannot generate arcs more than maxRadius
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);
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 r1 = qMax(dP, dQ);
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;
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
{
uint shift = 2*k + 3;
fpm::fixed_16_16 w {u0 >> shift};
uint shift = 2 * k + 3;
fpm::fixed_16_16 w{u0 >> shift};
fpm::fixed_16_16 U0 = u0 - w + (v0 >> (k + 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,
fpm::fixed_16_16 xQ, fpm::fixed_16_16 yQ, fpm::fixed_16_16 sweep,
fpm::fixed_16_16 flatness) -> QVector<QPointF>
fpm::fixed_16_16 xQ, fpm::fixed_16_16 yQ, fpm::fixed_16_16 sweep, fpm::fixed_16_16 flatness)
-> QVector<QPointF>
{
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);
@ -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,
qreal approximationScale) -> QVector<QPointF>
auto EllipticArcPoints(QPointF c, qreal radius1, qreal radius2, qreal astart, qreal asweep, qreal approximationScale)
-> QVector<QPointF>
{
fpm::fixed_16_16 xC{c.x()};
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))
{
// Set new conjugate diameter end points P and Q
fpm::fixed_16_16 cosa {cos(astart)};
fpm::fixed_16_16 sina {sin(astart)};
fpm::fixed_16_16 x {xP * cosa + xQ * sina};
fpm::fixed_16_16 y {yP * cosa + yQ * sina};
fpm::fixed_16_16 cosa{cos(astart)};
fpm::fixed_16_16 sina{sin(astart)};
fpm::fixed_16_16 x{xP * cosa + xQ * sina};
fpm::fixed_16_16 y{yP * cosa + yQ * sina};
xQ = xQ * cosa - xP * sina;
yQ = yQ * cosa - yP * sina;
@ -187,21 +187,21 @@ auto EllipticArcPoints(QPointF c, qreal radius1, qreal radius2, qreal astart, qr
asweep = -asweep;
}
if(approximationScale < minCurveApproximationScale || approximationScale > maxCurveApproximationScale)
if (approximationScale < minCurveApproximationScale || approximationScale > maxCurveApproximationScale)
{
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};
QVector<QPointF> arc = EllipseCore(xC, yC, xP, yP, xQ, yQ, swangle, flatness);
// Arc end point
fpm::fixed_16_16 cosb {qCos(asweep)};
fpm::fixed_16_16 sinb {qSin(asweep)};
xP = xP*cosb + xQ*sinb;
yP = yP*cosb + yQ*sinb;
arc.append({static_cast<qreal>(xP+xC), static_cast<qreal>(yP+yC)});
fpm::fixed_16_16 cosb{qCos(asweep)};
fpm::fixed_16_16 sinb{qSin(asweep)};
xP = xP * cosb + xQ * sinb;
yP = yP * cosb + yQ * sinb;
arc.append({static_cast<qreal>(xP + xC), static_cast<qreal>(yP + yC)});
return arc;
}
@ -226,15 +226,17 @@ auto JoinVectors(const QVector<QPointF> &v1, const QVector<QPointF> &v2) -> QVec
return v;
}
} // namespace
} // namespace
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief VEllipticalArc default constructor.
*/
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 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 &formulaF2, qreal rotationAngle, const QString &formulaRotationAngle,
quint32 idObject, Draw mode)
: VAbstractArc(GOType::EllipticalArc, center, f1, formulaF1, f2, formulaF2, idObject, mode),
d (new VEllipticalArcData(radius1, radius2, formulaRadius1, formulaRadius2, rotationAngle, formulaRotationAngle))
: VAbstractArc(GOType::EllipticalArc, center, f1, formulaF1, f2, formulaF2, idObject, mode),
d(new VEllipticalArcData(radius1, radius2, formulaRadius1, formulaRadius2, rotationAngle, formulaRotationAngle))
{
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,
qreal rotationAngle)
: VAbstractArc(GOType::EllipticalArc, center, f1, f2, NULL_ID, Draw::Calculation),
d (new VEllipticalArcData(radius1, radius2, rotationAngle))
: VAbstractArc(GOType::EllipticalArc, center, f1, f2, NULL_ID, Draw::Calculation),
d(new VEllipticalArcData(radius1, radius2, rotationAngle))
{
CreateName();
}
@ -269,8 +271,8 @@ VEllipticalArc::VEllipticalArc(qreal length, const QString &formulaLength, const
qreal radius2, const QString &formulaRadius1, const QString &formulaRadius2, qreal f1,
const QString &formulaF1, qreal rotationAngle, const QString &formulaRotationAngle,
quint32 idObject, Draw mode)
: VAbstractArc(GOType::EllipticalArc, formulaLength, center, f1, formulaF1, idObject, mode),
d (new VEllipticalArcData(radius1, radius2, formulaRadius1, formulaRadius2, rotationAngle, formulaRotationAngle))
: VAbstractArc(GOType::EllipticalArc, formulaLength, center, f1, formulaF1, idObject, mode),
d(new VEllipticalArcData(radius1, radius2, formulaRadius1, formulaRadius2, rotationAngle, formulaRotationAngle))
{
CreateName();
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,
qreal rotationAngle)
: VAbstractArc(GOType::EllipticalArc, center, f1, NULL_ID, Draw::Calculation),
d (new VEllipticalArcData(radius1, radius2, rotationAngle))
: VAbstractArc(GOType::EllipticalArc, center, f1, NULL_ID, Draw::Calculation),
d(new VEllipticalArcData(radius1, radius2, rotationAngle))
{
CreateName();
FindF2(length);
@ -288,13 +290,7 @@ VEllipticalArc::VEllipticalArc(qreal length, const VPointF &center, qreal radius
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief VEllipticalArc copy constructor
* @param arc arc
*/
VEllipticalArc::VEllipticalArc(const VEllipticalArc &arc)
: VAbstractArc(arc), d (arc.d)
{}
COPY_CONSTRUCTOR_IMPL_2(VEllipticalArc, VAbstractArc)
//---------------------------------------------------------------------------------------------------------------------
/**
@ -302,9 +298,9 @@ VEllipticalArc::VEllipticalArc(const VEllipticalArc &arc)
* @param arc 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;
}
@ -316,9 +312,10 @@ auto VEllipticalArc::operator =(const VEllipticalArc &arc) -> VEllipticalArc &
#ifdef Q_COMPILER_RVALUE_REFS
//---------------------------------------------------------------------------------------------------------------------
VEllipticalArc::VEllipticalArc(VEllipticalArc &&arc) noexcept
: VAbstractArc(std::move(arc)),
d(std::move(arc.d))
{}
: VAbstractArc(std::move(arc)),
d(std::move(arc.d))
{
}
//---------------------------------------------------------------------------------------------------------------------
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 center = oldCenter.Move(length, angle);
const QPointF position = d->m_transform.inverted().map(center.toQPointF()) -
d->m_transform.inverted().map(oldCenter.toQPointF());
const QPointF position =
d->m_transform.inverted().map(center.toQPointF()) - d->m_transform.inverted().map(oldCenter.toQPointF());
QTransform t = d->m_transform;
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.
* @return point.
*/
auto VEllipticalArc::GetP2 () const -> QPointF
auto VEllipticalArc::GetP2() const -> QPointF
{
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,
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;
const qreal fullLength = GetLength();
@ -544,8 +540,9 @@ auto VEllipticalArc::CutArc(const qreal &length, VEllipticalArc &arc1, VElliptic
arc2 = VEllipticalArc();
const QString errorMsg = QObject::tr("Unable to cut curve '%1'. The curve is too short.").arg(name());
VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) :
qWarning() << VAbstractApplication::warningMessageSignature + errorMsg;
VAbstractApplication::VApp()->IsPedantic()
? throw VException(errorMsg)
: qWarning() << VAbstractApplication::warningMessageSignature + errorMsg;
return {};
}
@ -560,15 +557,17 @@ auto VEllipticalArc::CutArc(const qreal &length, VEllipticalArc &arc1, VElliptic
if (not pointName.isEmpty())
{
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
{
errorMsg = QObject::tr("Curve '%1'. Length of a cut segment is too small. Optimize it to minimal value.")
.arg(name());
}
VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) :
qWarning() << VAbstractApplication::warningMessageSignature + errorMsg;
VAbstractApplication::VApp()->IsPedantic()
? throw VException(errorMsg)
: qWarning() << VAbstractApplication::warningMessageSignature + errorMsg;
}
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.")
.arg(name());
}
VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) :
qWarning() << VAbstractApplication::warningMessageSignature + errorMsg;
VAbstractApplication::VApp()->IsPedantic()
? throw VException(errorMsg)
: qWarning() << VAbstractApplication::warningMessageSignature + errorMsg;
}
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
arc1 = VEllipticalArc (len, QString().setNum(length), GetCenter(), d->radius1, d->radius2,
d->formulaRadius1, d->formulaRadius2, GetStartAngle(), GetFormulaF1(), d->rotationAngle,
arc1 = VEllipticalArc(len, QString().setNum(length), GetCenter(), d->radius1, d->radius2, d->formulaRadius1,
d->formulaRadius2, GetStartAngle(), GetFormulaF1(), d->rotationAngle,
GetFormulaRotationAngle(), getIdObject(), getMode());
// the second arc has startAngle just like endAngle of the first arc
// and it has endAngle just like endAngle of the origin arc
arc2 = VEllipticalArc (GetCenter(), d->radius1, d->radius2, d->formulaRadius1, d->formulaRadius2,
arc1.GetEndAngle(), arc1.GetFormulaF2(), GetEndAngle(), GetFormulaF2(), d->rotationAngle,
arc2 = VEllipticalArc(GetCenter(), d->radius1, d->radius2, d->formulaRadius1, d->formulaRadius2, arc1.GetEndAngle(),
arc1.GetFormulaF2(), GetEndAngle(), GetFormulaF2(), d->rotationAngle,
GetFormulaRotationAngle(), getIdObject(), getMode());
return arc1.GetP1();
}
//---------------------------------------------------------------------------------------------------------------------
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)
{
gap = gap/2;
gap = gap / 2;
if (gap < 0.0001)
{
break;
@ -705,7 +704,7 @@ void VEllipticalArc::FindF2(qreal length)
auto VEllipticalArc::MaxLength() const -> qreal
{
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;
}
@ -722,7 +721,7 @@ auto VEllipticalArc::GetP(qreal angle) const -> QPointF
const qreal a = not qFuzzyIsNull(GetRadius1()) ? line.p2().x() / GetRadius1() : 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))
{
@ -755,22 +754,22 @@ auto VEllipticalArc::ArcPoints(QVector<QPointF> points) const -> QVector<QPointF
QLineF end(center.x(), center.y(), center.x() + radius, center.y());
end.setAngle(VAbstractArc::GetEndAngle());
auto IsBoundedIntersection = [](QLineF::IntersectType type, QPointF p, const QLineF &segment1,
const QLineF &segment2)
auto IsBoundedIntersection =
[](QLineF::IntersectType type, QPointF p, const QLineF &segment1, const QLineF &segment2)
{
return type == QLineF::BoundedIntersection ||
(type == QLineF::UnboundedIntersection &&
VGObject::IsPointOnLineSegment (p, segment1.p1(), segment2.p1()) &&
VGObject::IsPointOnLineSegment (p, segment2.p1(), segment2.p2()));
VGObject::IsPointOnLineSegment(p, segment1.p1(), segment2.p1()) &&
VGObject::IsPointOnLineSegment(p, segment2.p1(), segment2.p2()));
};
bool begin = true;
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;
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
if (IsBoundedIntersection(type, p, edge, start))
{
QVector<QPointF> head = points.mid(0, i+1);
QVector<QPointF> tail = points.mid(i+1, -1);
QVector<QPointF> head = points.mid(0, i + 1);
QVector<QPointF> tail = points.mid(i + 1, -1);
tail = JoinVectors({p}, tail);
points = JoinVectors(tail, head);
@ -799,9 +798,9 @@ auto VEllipticalArc::ArcPoints(QVector<QPointF> points) const -> QVector<QPointF
QVector<QPointF> arc;
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)
{

View File

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

View File

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

View File

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

View File

@ -39,18 +39,20 @@
* @brief VPointF creat empty point
*/
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)
:VGObject(point), d(point.d)
{}
COPY_CONSTRUCTOR_IMPL_2(VPointF, VGObject)
//---------------------------------------------------------------------------------------------------------------------
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
*/
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);
}
@ -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
*/
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);
}
//---------------------------------------------------------------------------------------------------------------------
VPointF::~VPointF()
{}
VPointF::~VPointF() = default;
//---------------------------------------------------------------------------------------------------------------------
/**
@ -93,7 +96,7 @@ VPointF::~VPointF()
*/
auto VPointF::operator=(const VPointF &point) -> VPointF &
{
if ( &point == this )
if (&point == this)
{
return *this;
}
@ -105,11 +108,13 @@ auto VPointF::operator=(const VPointF &point) -> VPointF &
#ifdef Q_COMPILER_RVALUE_REFS
//---------------------------------------------------------------------------------------------------------------------
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);
std::swap(d, point.d);

View File

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

View File

@ -31,28 +31,22 @@
#include <QJsonObject>
#include <QLineF>
#include "../vmisc/vmath.h"
#include "vabstractcurve.h"
#include "vspline_p.h"
#include "../vmisc/vmath.h"
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief VSpline default constructor
*/
VSpline::VSpline()
: VAbstractCubicBezier(GOType::Spline),
d(new VSplineData)
{}
: VAbstractCubicBezier(GOType::Spline),
d(new VSplineData)
{
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @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)
{}
COPY_CONSTRUCTOR_IMPL_2(VSpline, VAbstractCubicBezier)
//---------------------------------------------------------------------------------------------------------------------
/**
@ -65,10 +59,10 @@ VSpline::VSpline(const VSpline &spline) // NOLINT(modernize-use-equals-default)
* @param kAsm1 coefficient of length first 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,
qreal kCurve, quint32 idObject, Draw mode)
: VAbstractCubicBezier(GOType::Spline, idObject, mode),
d(new VSplineData(p1, p4, angle1, angle2, kAsm1, kAsm2, kCurve))
VSpline::VSpline(const VPointF &p1, const VPointF &p4, qreal angle1, qreal angle2, qreal kAsm1, qreal kAsm2,
qreal kCurve, quint32 idObject, Draw mode)
: VAbstractCubicBezier(GOType::Spline, idObject, mode),
d(new VSplineData(p1, p4, angle1, angle2, kAsm1, kAsm2, kCurve))
{
CreateName();
}
@ -81,14 +75,14 @@ VSpline::VSpline (const VPointF &p1, const VPointF &p4, qreal angle1, qreal angl
* @param p3 second control point.
* @param p4 second point spline.
*/
VSpline::VSpline (const VPointF &p1, const QPointF &p2, const QPointF &p3, const VPointF &p4, quint32 idObject,
Draw mode)
:VAbstractCubicBezier(GOType::Spline, idObject, mode), d(new VSplineData(p1, p2, p3, p4))
VSpline::VSpline(const VPointF &p1, const QPointF &p2, const QPointF &p3, const VPointF &p4, quint32 idObject,
Draw mode)
: VAbstractCubicBezier(GOType::Spline, idObject, mode),
d(new VSplineData(p1, p2, p3, p4))
{
CreateName();
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @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,
const QString &angle2Formula, qreal c1Length, const QString &c1LengthFormula, qreal c2Length,
const QString &c2LengthFormula, quint32 idObject, Draw mode)
: VAbstractCubicBezier(GOType::Spline, idObject, mode),
d(new VSplineData(p1, p4, angle1, angle1Formula, angle2, angle2Formula, c1Length, c1LengthFormula, c2Length,
c2LengthFormula))
: VAbstractCubicBezier(GOType::Spline, idObject, mode),
d(new VSplineData(p1, p4, angle1, angle1Formula, angle2, angle2Formula, c1Length, c1LengthFormula, c2Length,
c2LengthFormula))
{
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.
* @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()),
static_cast<QPointF>(GetP4()), GetApproximationScale());
return LengthBezier(static_cast<QPointF>(GetP1()), static_cast<QPointF>(GetP2()), static_cast<QPointF>(GetP3()),
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.
* @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()),
static_cast<QPointF>(GetP3()), static_cast<QPointF>(GetP4()), GetApproximationScale());
@ -238,14 +231,14 @@ auto VSpline::GetPoints () const -> QVector<QPointF>
* @return list with spline points.
*/
// cppcheck-suppress unusedFunction
auto VSpline::SplinePoints(const QPointF &p1, const QPointF &p4, qreal angle1, qreal angle2, qreal kAsm1,
qreal kAsm2, qreal kCurve, qreal approximationScale) -> QVector<QPointF>
auto VSpline::SplinePoints(const QPointF &p1, const QPointF &p4, qreal angle1, qreal angle2, qreal kAsm1, qreal kAsm2,
qreal kCurve, qreal approximationScale) -> QVector<QPointF>
{
QLineF p1pX(p1.x(), p1.y(), p1.x() + 100, p1.y());
p1pX.setAngle( angle1 );
p1pX.setAngle(angle1);
qreal L = 0, radius = 0, angle = 90;
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());
p1p2.setAngle(angle1);
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;
}
@ -270,9 +263,10 @@ auto VSpline::operator =(const VSpline &spline) -> VSpline &
#ifdef Q_COMPILER_RVALUE_REFS
//---------------------------------------------------------------------------------------------------------------------
VSpline::VSpline(VSpline &&spline) noexcept
: VAbstractCubicBezier(std::move(spline)),
d(std::move(spline.d))
{}
: VAbstractCubicBezier(std::move(spline)),
d(std::move(spline.d))
{
}
//---------------------------------------------------------------------------------------------------------------------
auto VSpline::operator=(VSpline &&spline) noexcept -> VSpline &
@ -431,7 +425,7 @@ void VSpline::SetC2Length(qreal length, const QString &formula)
auto VSpline::GetKasm1() const -> qreal
{
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
{
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
{
if (qAbs(ld)<0.00000000001)
if (qAbs(ld) < 0.00000000001)
{
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
{
//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 r = (2*pow(a, 3) - 9*a*b + 27.*c)/54.;
// 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 r = (2 * pow(a, 3) - 9 * a * b + 27. * c) / 54.;
if (pow(r, 2) < pow(q, 3))
{ // equation has three real roots, use formula Vieta
const qreal t = acos(r/sqrt(pow(q, 3)))/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(2, -2.*sqrt(q)*cos(t - (2*M_2PI/3.)) - a/3.);
return(3);
const qreal t = acos(r / sqrt(pow(q, 3))) / 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(2, -2. * sqrt(q) * cos(t - (2 * M_2PI / 3.)) - a / 3.);
return (3);
}
// 1 real root + 2 complex
//Formula Cardano
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;
// Formula Cardano
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;
x.insert(0, aa+bb-a/3.); // Real 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(0, aa + bb - a / 3.); // Real root
x.insert(1, (-0.5) * (aa + bb) - a / 3.); // Complex root
x.insert(2, (sqrt(3.) * 0.5) * fabs(aa - bb)); // Complex root
if (qFuzzyIsNull(x.at(2)))
{
return(2);
return (2);
}
return(1);
return (1);
}
//---------------------------------------------------------------------------------------------------------------------
auto VSpline::CalcT(qreal curveCoord1, qreal curveCoord2, qreal curveCoord3, qreal curveCoord4,
qreal pointCoord) -> QVector<qreal>
auto VSpline::CalcT(qreal curveCoord1, qreal curveCoord2, qreal curveCoord3, qreal curveCoord4, qreal pointCoord)
-> QVector<qreal>
{
const qreal a = -curveCoord1 + 3*curveCoord2 - 3*curveCoord3 + curveCoord4;
const qreal b = 3*curveCoord1 - 6*curveCoord2 + 3*curveCoord3;
const qreal c = -3*curveCoord1 + 3*curveCoord2;
const qreal a = -curveCoord1 + 3 * curveCoord2 - 3 * curveCoord3 + curveCoord4;
const qreal b = 3 * curveCoord1 - 6 * curveCoord2 + 3 * curveCoord3;
const qreal c = -3 * curveCoord1 + 3 * curveCoord2;
const qreal d = -pointCoord + curveCoord1;
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;
retT.reserve(t.size());
for (auto i : qAsConst(t))
{
if (i >= 0 && i <= 1 )
if (i >= 0 && i <= 1)
{
retT.append(i);
}
@ -547,12 +541,12 @@ auto VSpline::CalcT(qreal curveCoord1, qreal curveCoord2, qreal curveCoord3, qre
* @param pBt point on 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;
// Calculate t coefficient for each axis
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().x(), GetP2().x(), GetP3().x(), GetP4().x(), pBt.x());
ts += CalcT(GetP1().y(), GetP2().y(), GetP3().y(), GetP4().y(), pBt.y());
if (ts.isEmpty())
{
@ -570,15 +564,17 @@ auto VSpline::ParamT (const QPointF &pBt) const -> qreal
const QPointF p1 = static_cast<QPointF>(GetP2());
const QPointF p2 = static_cast<QPointF>(GetP3());
const QPointF p3 = static_cast<QPointF>(GetP4());
//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 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();
// 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 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));
if (line.length() <= eps)
{
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
{
return static_cast<QPointF>(GetP2 ());
return static_cast<QPointF>(GetP2());
}
//---------------------------------------------------------------------------------------------------------------------
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.
*/
VSplinePath::VSplinePath(quint32 idObject, Draw mode)
: VAbstractCubicBezierPath(GOType::SplinePath, idObject, mode),
d(new VSplinePathData())
{}
: VAbstractCubicBezierPath(GOType::SplinePath, idObject, mode),
d(new VSplinePathData())
{
}
//---------------------------------------------------------------------------------------------------------------------
VSplinePath::VSplinePath(const QVector<VFSplinePoint> &points, qreal kCurve, quint32 idObject, Draw mode)
: VAbstractCubicBezierPath(GOType::SplinePath, idObject, mode),
d(new VSplinePathData())
: VAbstractCubicBezierPath(GOType::SplinePath, idObject, mode),
d(new VSplinePathData())
{
if (points.size() < 3)
{
@ -59,15 +60,15 @@ VSplinePath::VSplinePath(const QVector<VFSplinePoint> &points, qreal kCurve, qui
}
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);
VSpline spl(p1.P(), p2.P(), p1.Angle2(), p2.Angle1(), p1.KAsm2(), p2.KAsm1(), kCurve);
newPoints[i-1].SetP(p1.P());
newPoints[i-1].SetAngle2(p1.Angle2(), spl.GetStartAngleFormula());
newPoints[i-1].SetLength2(spl.GetC1Length(), spl.GetC1LengthFormula());
newPoints[i - 1].SetP(p1.P());
newPoints[i - 1].SetAngle2(p1.Angle2(), spl.GetStartAngleFormula());
newPoints[i - 1].SetLength2(spl.GetC1Length(), spl.GetC1LengthFormula());
newPoints[i].SetP(p2.P());
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)
: VAbstractCubicBezierPath(GOType::SplinePath, idObject, mode),
d(new VSplinePathData())
: VAbstractCubicBezierPath(GOType::SplinePath, idObject, mode),
d(new VSplinePathData())
{
if (points.isEmpty())
{
@ -93,14 +94,7 @@ VSplinePath::VSplinePath(const QVector<VSplinePoint> &points, quint32 idObject,
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief VSplinePath copy constructor.
* @param splPath spline path.
*/
VSplinePath::VSplinePath(const VSplinePath &splPath)
: VAbstractCubicBezierPath(splPath),
d(splPath.d)
{}
COPY_CONSTRUCTOR_IMPL_2(VSplinePath, VAbstractCubicBezierPath)
//---------------------------------------------------------------------------------------------------------------------
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);
newPoints[i-1].SetP(spl.GetP1());
newPoints[i-1].SetAngle2(spl.GetStartAngle(), spl.GetStartAngleFormula());
newPoints[i-1].SetLength2(spl.GetC1Length(), spl.GetC1LengthFormula());
newPoints[i - 1].SetP(spl.GetP1());
newPoints[i - 1].SetAngle2(spl.GetStartAngle(), spl.GetStartAngleFormula());
newPoints[i - 1].SetLength2(spl.GetC1Length(), spl.GetC1LengthFormula());
newPoints[i].SetP(spl.GetP4());
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);
newPoints[i-1].SetP(spl.GetP1());
newPoints[i-1].SetAngle2(spl.GetStartAngle(), spl.GetStartAngleFormula());
newPoints[i-1].SetLength2(spl.GetC1Length(), spl.GetC1LengthFormula());
newPoints[i - 1].SetP(spl.GetP1());
newPoints[i - 1].SetAngle2(spl.GetStartAngle(), spl.GetStartAngleFormula());
newPoints[i - 1].SetLength2(spl.GetC1Length(), spl.GetC1LengthFormula());
newPoints[i].SetP(spl.GetP4());
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);
newPoints[i-1].SetP(spl.GetP1());
newPoints[i-1].SetAngle2(spl.GetStartAngle(), spl.GetStartAngleFormula());
newPoints[i-1].SetLength2(spl.GetC1Length(), spl.GetC1LengthFormula());
newPoints[i - 1].SetP(spl.GetP1());
newPoints[i - 1].SetAngle2(spl.GetStartAngle(), spl.GetStartAngleFormula());
newPoints[i - 1].SetLength2(spl.GetC1Length(), spl.GetC1LengthFormula());
newPoints[i].SetP(spl.GetP4());
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
{
if (CountPoints()<1)
if (CountPoints() < 1)
{
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."));
}
const VSplinePoint &p1 = d->path.at(index-1);
const VSplinePoint &p1 = d->path.at(index - 1);
const VSplinePoint &p2 = d->path.at(index);
VSpline spl(p1.P(), p2.P(), p1.Angle2(), p1.Angle2Formula(), p2.Angle1(), p2.Angle1Formula(), p1.Length2(),
p1.Length2Formula(), p2.Length1(), p2.Length1Formula(), 1);
@ -266,7 +259,7 @@ void VSplinePath::UpdatePoint(qint32 indexSpline, const SplinePointPosition &pos
}
if (pos == SplinePointPosition::FirstPoint)
{
d->path[indexSpline-1] = point;
d->path[indexSpline - 1] = point;
}
else
{
@ -289,7 +282,7 @@ auto VSplinePath::GetSplinePoint(qint32 indexSpline, SplinePointPosition pos) co
}
if (pos == SplinePointPosition::FirstPoint)
{
return d->path.at(indexSpline-1);
return d->path.at(indexSpline - 1);
}
else
{
@ -305,7 +298,7 @@ auto VSplinePath::GetSplinePoint(qint32 indexSpline, SplinePointPosition pos) co
*/
auto VSplinePath::operator=(const VSplinePath &path) -> VSplinePath &
{
if ( &path == this )
if (&path == this)
{
return *this;
}
@ -317,12 +310,13 @@ auto VSplinePath::operator=(const VSplinePath &path) -> VSplinePath &
#ifdef Q_COMPILER_RVALUE_REFS
//---------------------------------------------------------------------------------------------------------------------
VSplinePath::VSplinePath(VSplinePath &&splPath) noexcept
: VAbstractCubicBezierPath(std::move(splPath)),
d(std::move(splPath.d))
{}
: VAbstractCubicBezierPath(std::move(splPath)),
d(std::move(splPath.d))
{
}
//---------------------------------------------------------------------------------------------------------------------
auto VSplinePath::operator=(VSplinePath &&path) noexcept->VSplinePath &
auto VSplinePath::operator=(VSplinePath &&path) noexcept -> VSplinePath &
{
VAbstractCubicBezierPath::operator=(path);
std::swap(d, path.d);
@ -371,7 +365,7 @@ auto VSplinePath::ToJson() const -> QJsonObject
//---------------------------------------------------------------------------------------------------------------------
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
{
return CountPoints() > 0 ? ConstFirst (GetSplinePath()).Length2() : 0;
return CountPoints() > 0 ? ConstFirst(GetSplinePath()).Length2() : 0;
}
//---------------------------------------------------------------------------------------------------------------------
auto VSplinePath::GetC2Length() const -> qreal
{
return CountPoints() > 0 ? ConstFirst (GetSplinePath()).Length1() : 0;
return CountPoints() > 0 ? ConstFirst(GetSplinePath()).Length1() : 0;
}
//---------------------------------------------------------------------------------------------------------------------
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
{
const vsizetype count = CountSubSpl();
return count >= 1 ? d->path.at(count).P() :// Take last point of the last real spline
VPointF();
return count >= 1 ? d->path.at(count).P() : // Take last point of the last real spline
VPointF();
}
//---------------------------------------------------------------------------------------------------------------------
@ -441,14 +435,14 @@ auto VSplinePath::GetFSplinePath() const -> QVector<VFSplinePoint>
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);
VSpline spl(p1.P(), p2.P(), p1.Angle2(), p1.Angle2Formula(), p2.Angle1(), p2.Angle1Formula(), p1.Length2(),
p1.Length2Formula(), p2.Length1(), p2.Length1Formula(), 1);
points[i-1].SetP(p1.P());
points[i-1].SetAngle2(p1.Angle2());
points[i-1].SetKAsm2(spl.GetKasm1());
points[i - 1].SetP(p1.P());
points[i - 1].SetAngle2(p1.Angle2());
points[i - 1].SetKAsm2(spl.GetKasm1());
points[i].SetP(p2.P());
points[i].SetAngle1(p2.Angle1());

View File

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

View File

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

View File

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

View File

@ -49,7 +49,7 @@ class VHPGLEngine
friend class VHPGLPaintDevice;
public:
VHPGLEngine() = default;
VHPGLEngine();
~VHPGLEngine() = default;
auto isActive() const -> bool;
@ -93,7 +93,7 @@ private:
QPoint m_currentPos{-1, -1};
bool m_singleLineFont{false};
bool m_singleStrokeOutlineFont{false};
int m_penWidthPx{qCeil(ToPixel(0.025, Unit::Mm))};
int m_penWidthPx;
qreal m_xscale{1};
qreal m_yscale{1};
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_p.h"
#include "../vgeometry/vgeometrydef.h"
#include "vbestsquare_p.h"
namespace
{
//---------------------------------------------------------------------------------------------------------------------
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
//---------------------------------------------------------------------------------------------------------------------
VBestSquare::VBestSquare()
: d(new VBestSquareData())
{}
: d(new VBestSquareData())
{
}
//---------------------------------------------------------------------------------------------------------------------
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)
: d(res.d)
{}
COPY_CONSTRUCTOR_IMPL(VBestSquare)
//---------------------------------------------------------------------------------------------------------------------
VBestSquare::~VBestSquare()
{}
VBestSquare::~VBestSquare() = default;
//---------------------------------------------------------------------------------------------------------------------
auto VBestSquare::operator=(const VBestSquare &res) -> VBestSquare &
{
if ( &res == this )
if (&res == this)
{
return *this;
}
@ -72,11 +71,12 @@ auto VBestSquare::operator=(const VBestSquare &res) -> VBestSquare &
#ifdef Q_COMPILER_RVALUE_REFS
//---------------------------------------------------------------------------------------------------------------------
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);
return *this;
@ -104,12 +104,9 @@ void VBestSquare::NewResult(const VBestSquareResData &data)
{
if (d->saveLength)
{
if (VFuzzyOnAxis(data.depthPosition, d->data.depthPosition)
&& IsImprovedSidePosition(data.sidePosition))
{
SaveResult();
}
else if (data.depthPosition < d->data.depthPosition)
if ((VFuzzyOnAxis(data.depthPosition, d->data.depthPosition) &&
IsImprovedSidePosition(data.sidePosition)) ||
data.depthPosition < d->data.depthPosition)
{
SaveResult();
}
@ -214,7 +211,7 @@ auto VBestSquare::IsImprovedSidePosition(qreal sidePosition) const -> bool
const bool lessThan = 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
#define VBESTSQUARE_H
#include <QSharedDataPointer>
#include <QSizeF>
#include <QTransform>
#include <QtGlobal>
#include <QSharedDataPointer>
#include <QTypeInfo>
#include <QtGlobal>
#include "vlayoutdef.h"
@ -50,7 +50,7 @@ public:
auto operator=(const VBestSquare &res) -> VBestSquare &;
#ifdef Q_COMPILER_RVALUE_REFS
VBestSquare(VBestSquare &&res) noexcept;
auto operator=(VBestSquare &&res) noexcept->VBestSquare &;
auto operator=(VBestSquare &&res) noexcept -> VBestSquare &;
#endif
void NewResult(const VBestSquareResData &data);
@ -65,7 +65,7 @@ public:
auto Type() const -> BestFrom;
auto IsTerminatedByException() const -> bool;
auto ReasonTerminatedByException() const -> QString;
void TerminatedByException(const QString &reason);
void TerminatedByException(const QString &reason);
auto BestResultData() const -> VBestSquareResData;
@ -75,7 +75,6 @@ public:
private:
QSharedDataPointer<VBestSquareData> d;
};
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 &

View File

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

View File

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

View File

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

View File

@ -595,11 +595,7 @@ VLayoutPiece::VLayoutPiece()
}
//---------------------------------------------------------------------------------------------------------------------
VLayoutPiece::VLayoutPiece(const VLayoutPiece &detail) // NOLINT(modernize-use-equals-default)
: VAbstractPiece(detail),
d(detail.d)
{
}
COPY_CONSTRUCTOR_IMPL_2(VLayoutPiece, VAbstractPiece)
//---------------------------------------------------------------------------------------------------------------------
auto VLayoutPiece::operator=(const VLayoutPiece &detail) -> VLayoutPiece &
@ -615,14 +611,14 @@ auto VLayoutPiece::operator=(const VLayoutPiece &detail) -> VLayoutPiece &
#ifdef Q_COMPILER_RVALUE_REFS
//---------------------------------------------------------------------------------------------------------------------
VLayoutPiece::VLayoutPiece(VLayoutPiece &&detail) noexcept : VAbstractPiece(std::move(detail)),
d(std::move(detail.d))
VLayoutPiece::VLayoutPiece(VLayoutPiece &&detail) noexcept
: VAbstractPiece(std::move(detail)),
d(std::move(detail.d))
{
}
//---------------------------------------------------------------------------------------------------------------------
auto VLayoutPiece::operator=(VLayoutPiece &&detail) noexcept
->VLayoutPiece &
auto VLayoutPiece::operator=(VLayoutPiece &&detail) noexcept -> VLayoutPiece &
{
VAbstractPiece::operator=(detail);
std::swap(d, detail.d);
@ -631,9 +627,7 @@ auto VLayoutPiece::operator=(VLayoutPiece &&detail) noexcept
#endif
//---------------------------------------------------------------------------------------------------------------------
VLayoutPiece::~VLayoutPiece() // NOLINT(modernize-use-equals-default)
{
}
VLayoutPiece::~VLayoutPiece() = default;
//---------------------------------------------------------------------------------------------------------------------
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 &;
#ifdef Q_COMPILER_RVALUE_REFS
VLayoutPiece(VLayoutPiece &&detail) noexcept;
auto operator=(VLayoutPiece &&detail) noexcept
->VLayoutPiece &;
auto operator=(VLayoutPiece &&detail) noexcept -> VLayoutPiece &;
#endif
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>
{
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)
{
std::reverse(points.begin(), points.end());

View File

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

View File

@ -68,6 +68,28 @@ template <class T> class QSharedPointer;
#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 QMarginsF;
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)
{

View File

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

View File

@ -26,6 +26,7 @@
**
*************************************************************************/
#include "vsvgglyph.h"
#include "../def.h"
#include "vsvgglyph_p.h"
#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)
: d(font.d)
{
}
COPY_CONSTRUCTOR_IMPL(VSvgGlyph)
//---------------------------------------------------------------------------------------------------------------------
VSvgGlyph::~VSvgGlyph() // NOLINT(modernize-use-equals-default)
{
}
VSvgGlyph::~VSvgGlyph() = default;
//---------------------------------------------------------------------------------------------------------------------
auto VSvgGlyph::operator=(const VSvgGlyph &glyph) -> VSvgGlyph &

View File

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

View File

@ -28,25 +28,24 @@
#include <QPointF>
#include "../vmisc/def.h"
#include "vgrainlinedata.h"
#include "vgrainlinedata_p.h"
//---------------------------------------------------------------------------------------------------------------------
VGrainlineData::VGrainlineData()
: VAbstractFloatItemData(),
d(new VGrainlineDataPrivate())
{}
: VAbstractFloatItemData(),
d(new VGrainlineDataPrivate())
{
}
//---------------------------------------------------------------------------------------------------------------------
VGrainlineData::VGrainlineData(const VGrainlineData &data)
: VAbstractFloatItemData(data),
d (data.d)
{}
COPY_CONSTRUCTOR_IMPL_2(VGrainlineData, VAbstractFloatItemData)
//---------------------------------------------------------------------------------------------------------------------
auto VGrainlineData::operator=(const VGrainlineData &data) -> VGrainlineData &
{
if ( &data == this )
if (&data == this)
{
return *this;
}
@ -58,12 +57,13 @@ auto VGrainlineData::operator=(const VGrainlineData &data) -> VGrainlineData &
#ifdef Q_COMPILER_RVALUE_REFS
//---------------------------------------------------------------------------------------------------------------------
VGrainlineData::VGrainlineData(VGrainlineData &&data) noexcept
: VAbstractFloatItemData(std::move(data)),
d (std::move(data.d))
{}
: VAbstractFloatItemData(std::move(data)),
d(std::move(data.d))
{
}
//---------------------------------------------------------------------------------------------------------------------
auto VGrainlineData::operator=(VGrainlineData &&data) noexcept->VGrainlineData &
auto VGrainlineData::operator=(VGrainlineData &&data) noexcept -> VGrainlineData &
{
VAbstractFloatItemData::operator=(data);
std::swap(d, data.d);
@ -72,8 +72,7 @@ auto VGrainlineData::operator=(VGrainlineData &&data) noexcept->VGrainlineData &
#endif
//---------------------------------------------------------------------------------------------------------------------
VGrainlineData::~VGrainlineData()
{}
VGrainlineData::~VGrainlineData() = default;
//---------------------------------------------------------------------------------------------------------------------
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;
}
@ -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;
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

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;

View File

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

View File

@ -27,11 +27,11 @@
*************************************************************************/
#include "vnodedetail.h"
#include "../vgeometry/vpointf.h"
#include "../vpatterndb/vcontainer.h"
#include "vnodedetail_p.h"
#include "vpiecenode.h"
#include "vpiecepath.h"
#include "../vgeometry/vpointf.h"
#include "../vpatterndb/vcontainer.h"
#include <QLineF>
#include <QVector>
@ -41,9 +41,8 @@ namespace
//---------------------------------------------------------------------------------------------------------------------
auto IsOX(const QLineF &line) -> bool
{
return VFuzzyComparePossibleNulls(line.angle(), 0)
|| VFuzzyComparePossibleNulls(line.angle(), 360)
|| VFuzzyComparePossibleNulls(line.angle(), 180);
return VFuzzyComparePossibleNulls(line.angle(), 0) || VFuzzyComparePossibleNulls(line.angle(), 360) ||
VFuzzyComparePossibleNulls(line.angle(), 180);
}
//---------------------------------------------------------------------------------------------------------------------
@ -92,27 +91,27 @@ void ConvertAfter(VPieceNode &node, const QLineF &line, qreal mX, qreal mY)
node.SetFormulaSAAfter(LocalWidth(line, movedLine));
}
}
}//static functions
} // namespace
//---------------------------------------------------------------------------------------------------------------------
VNodeDetail::VNodeDetail()
:d(new VNodeDetailData)
{}
: d(new VNodeDetailData)
{
}
//---------------------------------------------------------------------------------------------------------------------
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)
:d (node.d)
{}
COPY_CONSTRUCTOR_IMPL(VNodeDetail)
//---------------------------------------------------------------------------------------------------------------------
auto VNodeDetail::operator=(const VNodeDetail &node) -> VNodeDetail &
{
if ( &node == this )
if (&node == this)
{
return *this;
}
@ -123,11 +122,12 @@ auto VNodeDetail::operator=(const VNodeDetail &node) -> VNodeDetail &
#ifdef Q_COMPILER_RVALUE_REFS
//---------------------------------------------------------------------------------------------------------------------
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);
return *this;
@ -135,8 +135,7 @@ auto VNodeDetail::operator=(VNodeDetail &&node) noexcept->VNodeDetail &
#endif
//---------------------------------------------------------------------------------------------------------------------
VNodeDetail::~VNodeDetail()
{}
VNodeDetail::~VNodeDetail() = default;
//---------------------------------------------------------------------------------------------------------------------
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();
QLineF lineBefore(point, previosPoint);
lineBefore.setAngle(lineBefore.angle()-90);
lineBefore.setAngle(lineBefore.angle() - 90);
lineBefore.setLength(width);
ConvertBefore(path[i], lineBefore, node.getMx(), node.getMy());
QLineF lineAfter(point, nextPoint);
lineAfter.setAngle(lineAfter.angle()+90);
lineAfter.setAngle(lineAfter.angle() + 90);
lineAfter.setLength(width);
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)
{
path[0].SetFormulaSABefore(QChar('0'));
path[path.CountNodes()-1].SetFormulaSAAfter(QChar('0'));
path[path.CountNodes() - 1].SetFormulaSAAfter(QChar('0'));
}
return path.GetNodes();

View File

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

View File

@ -27,29 +27,29 @@
*************************************************************************/
#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/vexceptionobjecterror.h"
#include "../vmisc/testpath.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/vpiecenode.h"
#include "vcontainer.h"
#include "vpassmark.h"
#include "vpiece_p.h"
#include <QSharedPointer>
#include <QDebug>
#include <QPainterPath>
#include <QTemporaryFile>
#include <QJsonObject>
#include <QJsonDocument>
#include <QJsonArray>
#include <QJsonDocument>
#include <QJsonObject>
#include <QPainterPath>
#include <QSharedPointer>
#include <QTemporaryFile>
namespace
{
@ -93,7 +93,7 @@ auto IsPassmarksPossible(const QVector<VPieceNode> &path) -> bool
{
if (node.IsExcluded())
{
continue;// skip node
continue; // skip node
}
node.GetTypeTool() == Tool::NodePoint ? ++countPointNodes : ++countOthers;
@ -116,18 +116,18 @@ auto RotatePath(const QVector<VPieceNode> &path, vsizetype index) -> QVector<VPi
//---------------------------------------------------------------------------------------------------------------------
VPiece::VPiece()
: VAbstractPiece(), d(new VPieceData(PiecePathType::PiecePath))
{}
: VAbstractPiece(),
d(new VPieceData(PiecePathType::PiecePath))
{
}
//---------------------------------------------------------------------------------------------------------------------
VPiece::VPiece(const VPiece &piece)
: VAbstractPiece(piece), d (piece.d)
{}
COPY_CONSTRUCTOR_IMPL_2(VPiece, VAbstractPiece)
//---------------------------------------------------------------------------------------------------------------------
auto VPiece::operator=(const VPiece &piece) -> VPiece &
{
if ( &piece == this )
if (&piece == this)
{
return *this;
}
@ -139,11 +139,13 @@ auto VPiece::operator=(const VPiece &piece) -> VPiece &
#ifdef Q_COMPILER_RVALUE_REFS
//---------------------------------------------------------------------------------------------------------------------
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);
std::swap(d, piece.d);
@ -152,8 +154,7 @@ auto VPiece::operator=(VPiece &&piece) noexcept->VPiece &
#endif
//---------------------------------------------------------------------------------------------------------------------
VPiece::~VPiece()
{}
VPiece::~VPiece() = default;
//---------------------------------------------------------------------------------------------------------------------
auto VPiece::GetPath() const -> VPiecePath
@ -176,15 +177,15 @@ void VPiece::SetPath(const VPiecePath &path)
//---------------------------------------------------------------------------------------------------------------------
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();
mainPath.SetName(QCoreApplication::translate("VPiece", "Main path of piece %1").arg(GetName()));
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;
}
@ -192,7 +193,7 @@ auto VPiece::MainPathPoints(const VContainer *data) const -> QVector<VLayoutPoin
auto VPiece::UniteMainPathPoints(const VContainer *data) const -> QVector<VLayoutPoint>
{
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;
}
@ -227,7 +228,7 @@ auto VPiece::PassmarksLines(const VContainer *data) const -> QVector<QLineF>
{
QVector<VPassmark> passmarks = Passmarks(data);
QVector<QLineF> lines;
for(auto &passmark : passmarks)
for (auto &passmark : passmarks)
{
if (not passmark.IsNull())
{
@ -249,12 +250,12 @@ auto VPiece::Passmarks(const VContainer *data) const -> QVector<VPassmark>
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);
if (node.IsExcluded() || not node.IsPassmark())
{
continue;// skip node
continue; // skip node
}
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
{
QPainterPath path;
for(auto placeLabel : d->m_placeLabels)
for (auto placeLabel : d->m_placeLabels)
{
try
{
@ -662,16 +663,16 @@ auto VPiece::SeamAllowancePointsWithRotation(const VContainer *data, vsizetype m
int recordIndex = -1;
bool insertingCSA = false;
const qreal width = ToPixel(GetSAWidth(), *data->GetPatternUnit());
const QVector<VPieceNode> unitedPath = makeFirst > 0 ? RotatePath(GetUnitedPath(data), makeFirst)
: GetUnitedPath(data);
const QVector<VPieceNode> unitedPath =
makeFirst > 0 ? RotatePath(GetUnitedPath(data), makeFirst) : GetUnitedPath(data);
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);
if (node.IsExcluded())
{
continue;// skip excluded node
continue; // skip excluded node
}
switch (node.GetTypeTool())
@ -727,7 +728,7 @@ auto VPiece::SeamAllowancePointsWithRotation(const VContainer *data, vsizetype m
}
break;
default:
qDebug()<<"Get wrong tool type. Ignore."<< static_cast<char>(node.GetTypeTool());
qDebug() << "Get wrong tool type. Ignore." << static_cast<char>(node.GetTypeTool());
break;
}
}
@ -777,12 +778,12 @@ auto VPiece::GetUnitedPath(const VContainer *data) const -> QVector<VPieceNode>
QVector<VPieceNode> midAfter;
if (indexStartPoint <= indexEndPoint)
{
midBefore = united.mid(0, indexStartPoint+1);
midBefore = united.mid(0, indexStartPoint + 1);
midAfter = united.mid(indexEndPoint, united.size() - midBefore.size());
}
else
{
midBefore = united.mid(indexEndPoint, indexStartPoint+1);
midBefore = united.mid(indexEndPoint, indexStartPoint + 1);
}
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 indexEndPoint = d->m_path.indexOfNode(record.endPoint);
if (record.startPoint > NULL_ID
&& record.path > NULL_ID
&& record.endPoint > NULL_ID
&& indexStartPoint != -1
&& not d->m_path.at(indexStartPoint).IsExcluded()
&& indexEndPoint != -1
&& not d->m_path.at(indexEndPoint).IsExcluded())
if (record.startPoint > NULL_ID && record.path > NULL_ID && record.endPoint > NULL_ID &&
indexStartPoint != -1 && not d->m_path.at(indexStartPoint).IsExcluded() && indexEndPoint != -1 &&
not d->m_path.at(indexEndPoint).IsExcluded())
{
records.append(record);
}
@ -865,12 +862,12 @@ auto VPiece::FilterRecords(QVector<CustomSARecord> records) const -> QVector<Cus
QVector<VPieceNode> midAfter;
if (indexStartPoint <= indexEndPoint)
{
midBefore = path.mid(0, indexStartPoint+1);
midBefore = path.mid(0, indexStartPoint + 1);
midAfter = path.mid(indexEndPoint, path.size() - midBefore.size());
}
else
{
midBefore = path.mid(indexEndPoint, indexStartPoint+1);
midBefore = path.mid(indexEndPoint, indexStartPoint + 1);
}
path = midBefore + midAfter;
@ -937,14 +934,15 @@ auto VPiece::GetPassmarkPreviousSAPoints(const QVector<VPieceNode> &path, vsizet
if (points.isEmpty())
{
const QString errorMsg = tr("Cannot calculate a notch for point '%1' in piece '%2'.")
.arg(VPiecePath::NodeName(path, passmarkIndex, data), GetName());
VAbstractApplication::VApp()->IsPedantic() ? throw VExceptionInvalidNotch(errorMsg) :
qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
.arg(VPiecePath::NodeName(path, passmarkIndex, data), GetName());
VAbstractApplication::VApp()->IsPedantic()
? throw VExceptionInvalidNotch(errorMsg)
: qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
return false; // Something wrong
}
bool found = false;
auto nodeIndex = points.size()-1;
auto nodeIndex = points.size() - 1;
do
{
const VSAPoint previous = points.at(nodeIndex);
@ -976,9 +974,10 @@ auto VPiece::GetPassmarkNextSAPoints(const QVector<VPieceNode> &path, vsizetype
if (points.isEmpty())
{
const QString errorMsg = tr("Cannot calculate a notch for point '%1' in piece '%2'.")
.arg(VPiecePath::NodeName(path, passmarkIndex, data), GetName());
VAbstractApplication::VApp()->IsPedantic() ? throw VExceptionInvalidNotch(errorMsg) :
qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
.arg(VPiecePath::NodeName(path, passmarkIndex, data), GetName());
VAbstractApplication::VApp()->IsPedantic()
? throw VExceptionInvalidNotch(errorMsg)
: qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
return false; // Something wrong
}
@ -1060,9 +1059,10 @@ auto VPiece::CreatePassmark(const QVector<VPieceNode> &path, vsizetype previousI
if (not GetPassmarkSAPoint(path, passmarkIndex, data, passmarkSAPoint))
{
const QString errorMsg = tr("Cannot calculate a notch for point '%1' in piece '%2'.")
.arg(VPiecePath::NodeName(path, passmarkIndex, data), GetName());
VAbstractApplication::VApp()->IsPedantic() ? throw VExceptionInvalidNotch(errorMsg) :
qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
.arg(VPiecePath::NodeName(path, passmarkIndex, data), GetName());
VAbstractApplication::VApp()->IsPedantic()
? throw VExceptionInvalidNotch(errorMsg)
: qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
return {};
}
@ -1085,12 +1085,11 @@ auto VPiece::CreatePassmark(const QVector<VPieceNode> &path, vsizetype previousI
return {};
}
if (passmarkSAPoint.IsManualPasskmarkLength()
&& passmarkSAPoint.GetPasskmarkLength() <= accuracyPointOnLine)
if (passmarkSAPoint.IsManualPasskmarkLength() && passmarkSAPoint.GetPasskmarkLength() <= accuracyPointOnLine)
{
const QString infoMsg = tr("Notch for point '%1' in piece '%2' will be disabled. Manual length is less than "
"allowed value.")
.arg(VPiecePath::NodeName(path, passmarkIndex, data), GetName());
"allowed value.")
.arg(VPiecePath::NodeName(path, passmarkIndex, data), GetName());
#if QT_VERSION >= QT_VERSION_CHECK(5, 5, 0)
qInfo() << VAbstractValApplication::warningMessageSignature + infoMsg;
#else
@ -1143,7 +1142,7 @@ auto VPiece::Area(const QVector<QPointF> &shape, const VContainer *data) const -
{
SCASSERT(data != nullptr)
const qreal mainArea = qAbs(VAbstractPiece::SumTrapezoids(shape))/2.0;
const qreal mainArea = qAbs(VAbstractPiece::SumTrapezoids(shape)) / 2.0;
qreal internalPathArea = 0;
const QVector<quint32> pathsId = GetInternalPaths();
@ -1163,7 +1162,7 @@ auto VPiece::Area(const QVector<QPointF> &shape, const VContainer *data) const -
continue;
}
internalPathArea += qAbs(VAbstractPiece::SumTrapezoids(points))/2.0;
internalPathArea += qAbs(VAbstractPiece::SumTrapezoids(points)) / 2.0;
}
return mainArea - internalPathArea;
@ -1243,8 +1242,7 @@ qreal VPiece::GlobalPassmarkWidth(const VContainer *data) const
//---------------------------------------------------------------------------------------------------------------------
auto VPiece::MainPathToJson() const -> QJsonObject
{
QJsonObject pieceObject
{
QJsonObject pieceObject{
{"seamAllowance", IsSeamAllowance()},
{"saWidth", GetSAWidth()},
};
@ -1252,8 +1250,7 @@ auto VPiece::MainPathToJson() const -> QJsonObject
QJsonArray nodesArray;
for (qint32 i = 0; i < d->m_path.CountNodes(); ++i)
{
QJsonObject nodeObject
{
QJsonObject nodeObject{
{"id", static_cast<qint64>(d->m_path.at(i).GetId())},
{"type", static_cast<int>(d->m_path.at(i).GetTypeTool())},
{"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());
}
QJsonObject dbObject
{
{"items", itemsArray}
};
QJsonObject dbObject{{"items", itemsArray}};
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)
{
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
if (not templateName.isEmpty())
@ -1298,23 +1292,21 @@ void VPiece::DumpPiece(const VPiece &piece, const VContainer *data, const QStrin
if (temp.open())
{
#if defined(Q_OS_LINUX)
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
// On Linux, QTemporaryFile will attempt to create unnamed temporary
// files. If that succeeds, open() will return true but exists() will be
// false. If you call fileName() or any function that calls it,
// QTemporaryFile will give the file a name, so most applications will
// not see a difference.
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
// On Linux, QTemporaryFile will attempt to create unnamed temporary
// files. If that succeeds, open() will return true but exists() will be
// false. If you call fileName() or any function that calls it,
// QTemporaryFile will give the file a name, so most applications will
// not see a difference.
temp.fileName(); // call to create a file on disk
#endif
#endif
QJsonObject testCase
{
#endif
QJsonObject testCase{
{"bd", piece.DBToJson(data)},
{"piece", piece.MainPathToJson()},
};
QJsonObject json
{
QJsonObject json{
{"testCase", testCase},
};
@ -1358,18 +1350,22 @@ void VPiece::TestInternalPathCuttingPathIntersection(const VContainer *data) con
if (internalPath.intersects(contourPath))
{
const QString errorMsg = QObject::tr("Piece '%1'. Internal path '%2' intersects with cutting "
"contour.").arg(GetName(), path.GetName());
VAbstractApplication::VApp()->IsPedantic() ? throw VExceptionObjectError(errorMsg) :
qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
"contour.")
.arg(GetName(), path.GetName());
VAbstractApplication::VApp()->IsPedantic()
? throw VExceptionObjectError(errorMsg)
: qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
continue;
}
if (not contourPath.contains(internalPath))
{
const QString errorMsg = QObject::tr("Piece '%1'. Internal path '%2' not inside of cutting "
"contour.").arg(GetName(), path.GetName());
VAbstractApplication::VApp()->IsPedantic() ? throw VExceptionObjectError(errorMsg) :
qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
"contour.")
.arg(GetName(), path.GetName());
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
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));
@ -1409,7 +1405,7 @@ void VPiece::TestInternalPathsIntersections(const VContainer *data) const
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)))
{
@ -1439,9 +1435,11 @@ void VPiece::TestInternalPathsIntersections(const VContainer *data) const
if (painterPath1.intersects(painterPath2))
{
const QString errorMsg = QObject::tr("Piece '%1'. Internal path '%2' intersects with internal path "
"'%3'.").arg(GetName(), path1.GetName(), path2.GetName());
VAbstractApplication::VApp()->IsPedantic() ? throw VExceptionObjectError(errorMsg) :
qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
"'%3'.")
.arg(GetName(), path1.GetName(), path2.GetName());
VAbstractApplication::VApp()->IsPedantic()
? throw VExceptionObjectError(errorMsg)
: qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
}
}
}
@ -1483,7 +1481,7 @@ auto VPiece::ShortNameRegExp() -> QString
QString decimalPoints;
QString groupSeparators;
for(const auto &locale : allLocales)
for (const auto &locale : allLocales)
{
if (not positiveSigns.contains(LocalePositiveSign(locale)))
{
@ -1509,11 +1507,11 @@ auto VPiece::ShortNameRegExp() -> QString
negativeSigns.replace('-', QLatin1String("\\-"));
groupSeparators.remove('\'');
//Same regexp in pattern.xsd shema file. Don't forget to synchronize.
// \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
// 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.
// Same regexp in pattern.xsd shema file. Don't forget to synchronize.
// \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
// 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.
regex = QStringLiteral("\\A([^\\p{Zs}*\\/&|!<>^\\n\\()%1%2%3%4=?:;\"]){0,}\\z")
.arg(negativeSigns, positiveSigns, decimalPoints, groupSeparators);
}

View File

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

View File

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

View File

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

View File

@ -27,16 +27,16 @@
*************************************************************************/
#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 "../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 <qnumeric.h>
namespace
{
@ -78,13 +78,13 @@ auto CurveStartPoint(VSAPoint candidate, const VContainer *data, const VPieceNod
}
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);
}
for(auto &p : intersections)
for (auto &p : intersections)
{
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;
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);
}
for(auto &p : intersections)
for (auto &p : intersections)
{
if (VFuzzyComparePoints(p, ConstFirst(curvePoints)) || VFuzzyComparePoints(p, ConstLast(curvePoints)))
{
@ -155,7 +155,7 @@ auto IndexOfNode(const QVector<VPieceNode> &list, quint32 id) -> int
return i;
}
}
qDebug()<<"Can't find node.";
qDebug() << "Can't find node.";
return -1;
}
@ -183,7 +183,7 @@ template <class T> auto FindTipDirection(const QVector<T> &points) -> qreal
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))
{
@ -222,7 +222,7 @@ void AppendCurveSegment(QVector<T> &points, QVector<QPointF> &segment, const VSA
{
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));
if (i == 0)
@ -238,27 +238,27 @@ void AppendCurveSegment(QVector<T> &points, QVector<QPointF> &segment, const VSA
points.append(lp);
}
}
}
} // namespace
//---------------------------------------------------------------------------------------------------------------------
VPiecePath::VPiecePath()
: d(new VPiecePathData)
{}
: d(new VPiecePathData)
{
}
//---------------------------------------------------------------------------------------------------------------------
VPiecePath::VPiecePath(PiecePathType type)
: d(new VPiecePathData(type))
{}
: d(new VPiecePathData(type))
{
}
//---------------------------------------------------------------------------------------------------------------------
VPiecePath::VPiecePath(const VPiecePath &path)
: d (path.d)
{}
COPY_CONSTRUCTOR_IMPL(VPiecePath)
//---------------------------------------------------------------------------------------------------------------------
auto VPiecePath::operator=(const VPiecePath &path) -> VPiecePath &
{
if ( &path == this )
if (&path == this)
{
return *this;
}
@ -269,11 +269,12 @@ auto VPiecePath::operator=(const VPiecePath &path) -> VPiecePath &
#ifdef Q_COMPILER_RVALUE_REFS
//---------------------------------------------------------------------------------------------------------------------
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);
return *this;
@ -281,8 +282,7 @@ auto VPiecePath::operator=(VPiecePath &&path) noexcept->VPiecePath &
#endif
//---------------------------------------------------------------------------------------------------------------------
VPiecePath::~VPiecePath()
{}
VPiecePath::~VPiecePath() = default;
//---------------------------------------------------------------------------------------------------------------------
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 "
"point with cutting contour")
.arg(GetName());
VAbstractApplication::VApp()->IsPedantic() ? throw VExceptionObjectError(errorMsg) :
qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
.arg(GetName());
VAbstractApplication::VApp()->IsPedantic()
? 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 "
"point with cutting contour")
.arg(GetName());
VAbstractApplication::VApp()->IsPedantic() ? throw VExceptionObjectError(errorMsg) :
qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
.arg(GetName());
VAbstractApplication::VApp()->IsPedantic()
? 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>>
{
QVector<QVector<QPointF> > curves;
QVector<QVector<QPointF>> curves;
for (int i = 0; i < CountNodes(); ++i)
{
if (at(i).IsExcluded())
{
continue;// skip excluded node
continue; // skip excluded node
}
switch (at(i).GetTypeTool())
@ -531,12 +533,12 @@ auto VPiecePath::SeamAllowancePoints(const VContainer *data, qreal width, bool r
SCASSERT(data != nullptr);
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);
if (node.IsExcluded())
{
continue;// skip excluded node
continue; // skip excluded node
}
switch (node.GetTypeTool())
@ -556,7 +558,7 @@ auto VPiecePath::SeamAllowancePoints(const VContainer *data, qreal width, bool r
}
break;
default:
qDebug()<<"Get wrong tool type. Ignore."<< static_cast<char>(node.GetTypeTool());
qDebug() << "Get wrong tool type. Ignore." << static_cast<char>(node.GetTypeTool());
break;
}
}
@ -581,11 +583,11 @@ auto VPiecePath::PainterPath(const VContainer *data, const QVector<QPointF> &cut
//---------------------------------------------------------------------------------------------------------------------
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;
paths.reserve(curves.size());
for(const auto &curve : curves)
for (const auto &curve : curves)
{
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
{
if (i < 0 || i > nodes.size()-1)
if (i < 0 || i > nodes.size() - 1)
{
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
{
if (i < 0 || i > nodes.size()-1)
if (i < 0 || i > nodes.size() - 1)
{
return {};
}
@ -733,7 +735,7 @@ void VPiecePath::NodeOnEdge(quint32 index, VPieceNode &p1, VPieceNode &p2) const
const QVector<VPieceNode> list = ListNodePoint();
if (index > static_cast<quint32>(list.size()))
{
qDebug()<<"Wrong edge index index ="<<index;
qDebug() << "Wrong edge index index =" << index;
return;
}
p1 = list.at(static_cast<int>(index));
@ -743,7 +745,7 @@ void VPiecePath::NodeOnEdge(quint32 index, VPieceNode &p1, VPieceNode &p2) const
}
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();
if (list.size() < 2)
{
qDebug()<<"Not enough points.";
qDebug() << "Not enough points.";
return false;
}
int i = IndexOfNode(list, p1);
@ -781,7 +783,7 @@ auto VPiecePath::OnEdge(quint32 p1, quint32 p2) const -> bool
if (i == list.size() - 1)
{
j1 = i-1;
j1 = i - 1;
j2 = 0;
}
else if (i == 0)
@ -817,7 +819,7 @@ auto VPiecePath::Edge(quint32 p1, quint32 p2) const -> vsizetype
{
if (OnEdge(p1, p2) == false)
{
qDebug()<<"Points don't on edge.";
qDebug() << "Points don't on edge.";
return -1;
}
@ -866,7 +868,7 @@ auto VPiecePath::RemoveEdge(quint32 index) const -> VPiecePath
// Edge can be only segment. We ignore all curves inside segments.
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 p2;
@ -891,8 +893,7 @@ auto VPiecePath::RemoveEdge(quint32 index) const -> VPiecePath
{
j = 0;
}
}
while (j != j2);
} while (j != j2);
}
}
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
{
if (i < 0 || i > d->m_nodes.size()-1)
if (i < 0 || i > d->m_nodes.size() - 1)
{
return {};
}
@ -923,11 +924,11 @@ auto VPiecePath::NodePreviousPoint(const VContainer *data, int i) const -> QPoin
vsizetype index = 0;
if (i == 0)
{
index = d->m_nodes.size()-1;
index = d->m_nodes.size() - 1;
}
else
{
index = i-1;
index = i - 1;
}
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());
if (points.size() > 1)
{
return points.at(points.size()-2);
return points.at(points.size() - 2);
}
}
break;
break;
default:
qDebug()<<"Get wrong tool type. Ignore."<< static_cast<char>(node.GetTypeTool());
qDebug() << "Get wrong tool type. Ignore." << static_cast<char>(node.GetTypeTool());
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
{
QPointF point;
if (i < 0 || i > d->m_nodes.size()-1)
if (i < 0 || i > d->m_nodes.size() - 1)
{
return point;
}
@ -979,7 +980,7 @@ auto VPiecePath::NodeNextPoint(const VContainer *data, int i) const -> QPointF
}
else
{
index = i+1;
index = i + 1;
}
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);
}
}
break;
break;
default:
qDebug()<<"Get wrong tool type. Ignore."<< static_cast<char>(node.GetTypeTool());
qDebug() << "Get wrong tool type. Ignore." << static_cast<char>(node.GetTypeTool());
break;
}
}
@ -1051,7 +1052,7 @@ auto VPiecePath::indexOfNode(const QVector<VPieceNode> &nodes, quint32 id) -> in
return i;
}
}
qDebug()<<"Can't find node.";
qDebug() << "Can't find node.";
return -1;
}
@ -1063,7 +1064,7 @@ auto VPiecePath::FindInLoopNotExcludedUp(vsizetype start, const QVector<VPieceNo
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())
{
@ -1099,7 +1100,7 @@ auto VPiecePath::FindInLoopNotExcludedDown(vsizetype start, const QVector<VPiece
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())
{
@ -1130,7 +1131,7 @@ auto VPiecePath::FindInLoopNotExcludedDown(vsizetype start, const QVector<VPiece
//---------------------------------------------------------------------------------------------------------------------
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());
VSAPoint p(point->toQPointF());
@ -1170,8 +1171,8 @@ auto VPiecePath::CurveSeamAllowanceSegment(const VContainer *data, const QVector
qreal w1 = begin.GetSAAfter();
qreal w2 = end.GetSABefore();
if (w1 < 0 && w2 < 0)
{// no local widths
for(int i = 0; i < points.size(); ++i)
{ // no local widths
for (int i = 0; i < points.size(); ++i)
{
VSAPoint p(points.at(i));
p.SetAngleType(PieceNodeAngle::ByLengthCurve);
@ -1207,10 +1208,10 @@ auto VPiecePath::CurveSeamAllowanceSegment(const VContainer *data, const QVector
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);
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.SetSABefore(begin.GetSABefore());
p.SetAngleType(begin.GetAngleType());
@ -1220,13 +1221,13 @@ auto VPiecePath::CurveSeamAllowanceSegment(const VContainer *data, const QVector
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.SetCurvePoint(true);
if (i == points.size() - 1)
{// last point
{ // last point
p.SetSAAfter(end.GetSAAfter());
p.SetSABefore(end.GetSABefore());
p.SetAngleType(end.GetAngleType());
@ -1234,8 +1235,8 @@ auto VPiecePath::CurveSeamAllowanceSegment(const VContainer *data, const QVector
}
else
{
length += QLineF(points.at(i-1), points.at(i)).length();
const qreal localWidth = w1 + wDiff*(length/fullLength);
length += QLineF(points.at(i - 1), points.at(i)).length();
const qreal localWidth = w1 + wDiff * (length / fullLength);
p.SetSAAfter(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());
return obj->name();
}
catch (const VExceptionBadId& )
catch (const VExceptionBadId &)
{
// ignore
}
@ -1279,7 +1280,7 @@ auto VPiecePath::NodesToPoints(const VContainer *data, const QVector<VPieceNode>
const VPieceNode &node = nodes.at(i);
if (node.IsExcluded())
{
continue;// skip excluded node
continue; // skip excluded node
}
switch (node.GetTypeTool())
@ -1307,7 +1308,7 @@ auto VPiecePath::NodesToPoints(const VContainer *data, const QVector<VPieceNode>
}
break;
default:
qDebug()<<"Get wrong tool type. Ignore."<< static_cast<char>(node.GetTypeTool());
qDebug() << "Get wrong tool type. Ignore." << static_cast<char>(node.GetTypeTool());
break;
}
}

View File

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

View File

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

View File

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