Sonar warnings.
This commit is contained in:
parent
91611cedfe
commit
63292fa235
|
@ -1993,13 +1993,13 @@ auto VDxfEngine::NotchPrecedingPoint(const QVector<VLayoutPoint> &boundary, QPoi
|
||||||
|
|
||||||
if (VFuzzyComparePoints(boundary.constFirst(), notchBase))
|
if (VFuzzyComparePoints(boundary.constFirst(), notchBase))
|
||||||
{
|
{
|
||||||
point = boundary.constFirst();
|
point = boundary.constFirst().ToQPointF();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (VFuzzyComparePoints(boundary.constLast(), notchBase))
|
if (VFuzzyComparePoints(boundary.constLast(), notchBase))
|
||||||
{
|
{
|
||||||
point = boundary.constLast();
|
point = boundary.constLast().ToQPointF();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2016,7 +2016,7 @@ auto VDxfEngine::NotchPrecedingPoint(const QVector<VLayoutPoint> &boundary, QPoi
|
||||||
const qreal length = QLineF(notchBase, cPoint).length();
|
const qreal length = QLineF(notchBase, cPoint).length();
|
||||||
if (length < bestDistance)
|
if (length < bestDistance)
|
||||||
{
|
{
|
||||||
candidatePoint = boundary.at(i);
|
candidatePoint = boundary.at(i).ToQPointF();
|
||||||
bestDistance = length;
|
bestDistance = length;
|
||||||
found = true;
|
found = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -374,37 +374,31 @@ auto VGObject::ContactPoints(const QPointF &p, const QPointF ¢er, qreal radi
|
||||||
*/
|
*/
|
||||||
auto VGObject::LineIntersectRect(const QRectF &rec, const QLineF &line) -> QPointF
|
auto VGObject::LineIntersectRect(const QRectF &rec, const QLineF &line) -> QPointF
|
||||||
{
|
{
|
||||||
qreal x1, y1, x2, y2;
|
qreal x1 = 0;
|
||||||
|
qreal y1 = 0;
|
||||||
|
qreal x2 = 0;
|
||||||
|
qreal y2 = 0;
|
||||||
rec.getCoords(&x1, &y1, &x2, &y2);
|
rec.getCoords(&x1, &y1, &x2, &y2);
|
||||||
|
|
||||||
|
// Define lines representing each side of the rectangle
|
||||||
|
QLineF const topLine(QPointF(x1, y1), QPointF(x2, y1));
|
||||||
|
QLineF const bottomLine(QPointF(x1, y2), QPointF(x2, y2));
|
||||||
|
QLineF const leftLine(QPointF(x1, y1), QPointF(x1, y2));
|
||||||
|
QLineF const rightLine(QPointF(x2, y1), QPointF(x2, y2));
|
||||||
|
|
||||||
QPointF point;
|
QPointF point;
|
||||||
QLineF::IntersectType type = line.intersects(QLineF(QPointF(x1, y1), QPointF(x1, y2)), &point);
|
|
||||||
|
|
||||||
if (type == QLineF::BoundedIntersection)
|
// Check intersections with each side of the rectangle
|
||||||
|
if (line.intersects(topLine, &point) == QLineF::BoundedIntersection ||
|
||||||
|
line.intersects(bottomLine, &point) == QLineF::BoundedIntersection ||
|
||||||
|
line.intersects(leftLine, &point) == QLineF::BoundedIntersection ||
|
||||||
|
line.intersects(rightLine, &point) == QLineF::BoundedIntersection)
|
||||||
{
|
{
|
||||||
return point;
|
return point;
|
||||||
}
|
}
|
||||||
|
|
||||||
type = line.intersects(QLineF(QPointF(x1, y1), QPointF(x2, y1)), &point);
|
// Return the point (which would be (0,0) if no intersection is found)
|
||||||
|
return {};
|
||||||
if (type == QLineF::BoundedIntersection)
|
|
||||||
{
|
|
||||||
return point;
|
|
||||||
}
|
|
||||||
|
|
||||||
type = line.intersects(QLineF(QPointF(x1, y2), QPointF(x2, y2)), &point);
|
|
||||||
|
|
||||||
if (type == QLineF::BoundedIntersection)
|
|
||||||
{
|
|
||||||
return point;
|
|
||||||
}
|
|
||||||
|
|
||||||
type = line.intersects(QLineF(QPointF(x2, y1), QPointF(x2, y2)), &point);
|
|
||||||
|
|
||||||
if (type == QLineF::BoundedIntersection)
|
|
||||||
{
|
|
||||||
return point;
|
|
||||||
}
|
|
||||||
return point;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -55,7 +55,7 @@ COPY_CONSTRUCTOR_IMPL_2(VPointF, VGObject)
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VPointF::VPointF(const QPointF &point)
|
VPointF::VPointF(const QPointF &point)
|
||||||
: VGObject(VPointF()),
|
: VGObject(GOType::Point, 0, Draw::Calculation),
|
||||||
d(new VPointFData(point))
|
d(new VPointFData(point))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -609,7 +609,7 @@ auto AngleBySecondRightAngle(QVector<VRawSAPoint> points, QPointF p1, QPointF p2
|
||||||
if (success)
|
if (success)
|
||||||
{
|
{
|
||||||
points = temp;
|
points = temp;
|
||||||
px = points.constLast();
|
px = points.constLast().ToQPointF();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (countBefore > 0)
|
if (countBefore > 0)
|
||||||
|
@ -852,7 +852,7 @@ void RollbackBySecondEdgeRightAngle(QVector<VRawSAPoint> &ekvPoints, const QVect
|
||||||
if (success)
|
if (success)
|
||||||
{
|
{
|
||||||
ekvPoints = temp;
|
ekvPoints = temp;
|
||||||
px = ekvPoints.constLast();
|
px = ekvPoints.constLast().ToQPointF();
|
||||||
}
|
}
|
||||||
|
|
||||||
QLineF seam(px, points.at(1));
|
QLineF seam(px, points.at(1));
|
||||||
|
@ -1322,23 +1322,28 @@ auto VAbstractPiece::EkvPoint(QVector<VRawSAPoint> points, const VSAPoint &p1Lin
|
||||||
break;
|
break;
|
||||||
case PieceNodeAngle::ByLength:
|
case PieceNodeAngle::ByLength:
|
||||||
case PieceNodeAngle::ByLengthCurve:
|
case PieceNodeAngle::ByLengthCurve:
|
||||||
return AngleByLength(points, p1Line1, p2Line1, p1Line2, bigLine1, crosPoint, bigLine2, p2Line1,
|
return AngleByLength(points, p1Line1.ToQPointF(), p2Line1.ToQPointF(), p1Line2.ToQPointF(),
|
||||||
width, needRollback);
|
bigLine1, crosPoint, bigLine2, p2Line1, width, needRollback);
|
||||||
case PieceNodeAngle::ByPointsIntersection:
|
case PieceNodeAngle::ByPointsIntersection:
|
||||||
return AngleByIntersection(points, p1Line1, p2Line1, p1Line2, bigLine1, crosPoint, bigLine2,
|
return AngleByIntersection(points, p1Line1.ToQPointF(), p2Line1.ToQPointF(),
|
||||||
p2Line1, width, needRollback);
|
p1Line2.ToQPointF(), bigLine1, crosPoint, bigLine2, p2Line1, width,
|
||||||
|
needRollback);
|
||||||
case PieceNodeAngle::ByFirstEdgeSymmetry:
|
case PieceNodeAngle::ByFirstEdgeSymmetry:
|
||||||
return AngleByFirstSymmetry(points, p1Line1, p2Line1, p1Line2, bigLine1, crosPoint, bigLine2,
|
return AngleByFirstSymmetry(points, p1Line1.ToQPointF(), p2Line1.ToQPointF(),
|
||||||
p2Line1, width, needRollback);
|
p1Line2.ToQPointF(), bigLine1, crosPoint, bigLine2, p2Line1, width,
|
||||||
|
needRollback);
|
||||||
case PieceNodeAngle::BySecondEdgeSymmetry:
|
case PieceNodeAngle::BySecondEdgeSymmetry:
|
||||||
return AngleBySecondSymmetry(points, p1Line1, p2Line1, p1Line2, bigLine1, crosPoint, bigLine2,
|
return AngleBySecondSymmetry(points, p1Line1.ToQPointF(), p2Line1.ToQPointF(),
|
||||||
p2Line1, width, needRollback);
|
p1Line2.ToQPointF(), bigLine1, crosPoint, bigLine2, p2Line1, width,
|
||||||
|
needRollback);
|
||||||
case PieceNodeAngle::ByFirstEdgeRightAngle:
|
case PieceNodeAngle::ByFirstEdgeRightAngle:
|
||||||
return AngleByFirstRightAngle(points, p1Line1, p2Line1, p1Line2, bigLine1, crosPoint, bigLine2,
|
return AngleByFirstRightAngle(points, p1Line1.ToQPointF(), p2Line1.ToQPointF(),
|
||||||
p2Line1, width, needRollback);
|
p1Line2.ToQPointF(), bigLine1, crosPoint, bigLine2, p2Line1,
|
||||||
|
width, needRollback);
|
||||||
case PieceNodeAngle::BySecondEdgeRightAngle:
|
case PieceNodeAngle::BySecondEdgeRightAngle:
|
||||||
return AngleBySecondRightAngle(points, p1Line1, p2Line1, p1Line2, bigLine1, crosPoint, bigLine2,
|
return AngleBySecondRightAngle(points, p1Line1.ToQPointF(), p2Line1.ToQPointF(),
|
||||||
p2Line1, width, needRollback);
|
p1Line2.ToQPointF(), bigLine1, crosPoint, bigLine2, p2Line1,
|
||||||
|
width, needRollback);
|
||||||
}
|
}
|
||||||
|
|
||||||
QT_WARNING_POP
|
QT_WARNING_POP
|
||||||
|
|
|
@ -797,8 +797,7 @@ inline auto VAbstractPiece::SubdividePath(const QVector<T> &boundary, const QPoi
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!VGObject::IsPointOnLineSegment(p, static_cast<QPointF>(boundary.at(i)),
|
if (!VGObject::IsPointOnLineSegment(p, boundary.at(i).ToQPointF(), boundary.at(i + 1).ToQPointF()))
|
||||||
static_cast<QPointF>(boundary.at(i + 1))))
|
|
||||||
{
|
{
|
||||||
sub1.append(boundary.at(i));
|
sub1.append(boundary.at(i));
|
||||||
continue;
|
continue;
|
||||||
|
@ -858,7 +857,7 @@ inline auto VAbstractPiece::MirrorPath<VLayoutPoint>(const QVector<VLayoutPoint>
|
||||||
for (const auto &p : points)
|
for (const auto &p : points)
|
||||||
{
|
{
|
||||||
VLayoutPoint tmp = p;
|
VLayoutPoint tmp = p;
|
||||||
QPointF const flippedPoint = matrix.map(static_cast<QPointF>(p));
|
QPointF const flippedPoint = matrix.map(p.ToQPointF());
|
||||||
tmp.setX(flippedPoint.x());
|
tmp.setX(flippedPoint.x());
|
||||||
tmp.setY(flippedPoint.y());
|
tmp.setY(flippedPoint.y());
|
||||||
flipped.append(tmp);
|
flipped.append(tmp);
|
||||||
|
|
|
@ -225,54 +225,54 @@ auto VFoldLine::LabelPosition(bool &ok) const -> FoldLabelPosData
|
||||||
{
|
{
|
||||||
FoldLabelPosData posData;
|
FoldLabelPosData posData;
|
||||||
|
|
||||||
TextPosData data;
|
std::unique_ptr<TextPosData> data;
|
||||||
if (m_type == FoldLineType::Text)
|
if (m_type == FoldLineType::Text)
|
||||||
{
|
{
|
||||||
data = TextData();
|
data = std::make_unique<TextPosData>(TextData());
|
||||||
}
|
}
|
||||||
else if (m_type == FoldLineType::TwoArrowsTextAbove)
|
else if (m_type == FoldLineType::TwoArrowsTextAbove)
|
||||||
{
|
{
|
||||||
data = TwoArrowsTextAboveData();
|
data = std::make_unique<ArrowsTextPosData>(TwoArrowsTextAboveData());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
data = TwoArrowsTextUnderData();
|
data = std::make_unique<ArrowsTextPosData>(TwoArrowsTextUnderData());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.base.isNull())
|
if (data->base.isNull())
|
||||||
{
|
{
|
||||||
ok = false;
|
ok = false;
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
qreal const height = data.labelHeight + (qFuzzyIsNull(m_height) ? defLabelMargin : m_height);
|
qreal const height = data->labelHeight + (qFuzzyIsNull(m_height) ? defLabelMargin : m_height);
|
||||||
qreal const margin = qMax(0., height - data.labelHeight);
|
qreal const margin = qMax(0., height - data->labelHeight);
|
||||||
|
|
||||||
QPointF const center = TrueCenter(data.base, data.labelWidth);
|
QPointF const center = TrueCenter(data->base, data->labelWidth);
|
||||||
|
|
||||||
QLineF baseLine(center, data.base.p1());
|
QLineF baseLine(center, data->base.p1());
|
||||||
baseLine.setLength(data.labelWidth / 2);
|
baseLine.setLength(data->labelWidth / 2);
|
||||||
Swap(baseLine);
|
Swap(baseLine);
|
||||||
baseLine.setLength(baseLine.length() * 2);
|
baseLine.setLength(baseLine.length() * 2);
|
||||||
baseLine = SimpleParallelLine(baseLine.p1(), baseLine.p2(), -(margin + data.labelHeight));
|
baseLine = SimpleParallelLine(baseLine.p1(), baseLine.p2(), -(margin + data->labelHeight));
|
||||||
|
|
||||||
posData.font = LabelOutlineFont();
|
posData.font = LabelOutlineFont();
|
||||||
QFontMetrics const fm(posData.font);
|
QFontMetrics const fm(posData.font);
|
||||||
posData.label = fm.elidedText(FoldLineLabel(), Qt::ElideRight, qFloor(data.labelWidth));
|
posData.label = fm.elidedText(FoldLineLabel(), Qt::ElideRight, qFloor(data->labelWidth));
|
||||||
|
|
||||||
if (m_alignment & Qt::AlignHCenter) // NOLINT(readability-implicit-bool-conversion)
|
if (m_alignment & Qt::AlignHCenter) // NOLINT(readability-implicit-bool-conversion)
|
||||||
{
|
{
|
||||||
qreal const shift = (data.labelWidth - fm.horizontalAdvance(posData.label)) / 2;
|
qreal const shift = (data->labelWidth - fm.horizontalAdvance(posData.label)) / 2;
|
||||||
baseLine.setLength(baseLine.length() - shift);
|
baseLine.setLength(baseLine.length() - shift);
|
||||||
}
|
}
|
||||||
else if (m_alignment & Qt::AlignRight) // NOLINT(readability-implicit-bool-conversion)
|
else if (m_alignment & Qt::AlignRight) // NOLINT(readability-implicit-bool-conversion)
|
||||||
{
|
{
|
||||||
qreal const shift = data.labelWidth - fm.horizontalAdvance(posData.label);
|
qreal const shift = data->labelWidth - fm.horizontalAdvance(posData.label);
|
||||||
baseLine.setLength(baseLine.length() - shift);
|
baseLine.setLength(baseLine.length() - shift);
|
||||||
}
|
}
|
||||||
|
|
||||||
posData.pos = baseLine.p2();
|
posData.pos = baseLine.p2();
|
||||||
posData.angle = QLineF(center, data.base.p1()).angle();
|
posData.angle = QLineF(center, data->base.p1()).angle();
|
||||||
ok = true;
|
ok = true;
|
||||||
|
|
||||||
return posData;
|
return posData;
|
||||||
|
|
|
@ -544,7 +544,7 @@ void InitFoldLine(VLayoutPiece &det, const VPiece &piece, const VContainer *patt
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
auto operator<<(QDataStream &dataStream, const VLayoutPoint &p) -> QDataStream &
|
auto operator<<(QDataStream &dataStream, const VLayoutPoint &p) -> QDataStream &
|
||||||
{
|
{
|
||||||
dataStream << static_cast<QPointF>(p); // NOLINT(cppcoreguidelines-slicing)
|
dataStream << p.ToQPointF();
|
||||||
dataStream << p.TurnPoint();
|
dataStream << p.TurnPoint();
|
||||||
dataStream << p.CurvePoint();
|
dataStream << p.CurvePoint();
|
||||||
return dataStream;
|
return dataStream;
|
||||||
|
@ -570,7 +570,8 @@ auto operator>>(QDataStream &dataStream, VLayoutPoint &p) -> QDataStream &
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
auto operator<<(QDataStream &dataStream, const VLayoutPiece &piece) -> QDataStream &
|
auto operator<<(QDataStream &dataStream, const VLayoutPiece &piece) -> QDataStream &
|
||||||
{
|
{
|
||||||
dataStream << static_cast<VAbstractPiece>(piece); // NOLINT(cppcoreguidelines-slicing)
|
const VAbstractPiece &abstractPiece = piece;
|
||||||
|
dataStream << abstractPiece;
|
||||||
dataStream << *piece.d;
|
dataStream << *piece.d;
|
||||||
return dataStream;
|
return dataStream;
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,3 +56,9 @@ auto VLayoutPoint::toJson() const -> QJsonObject
|
||||||
|
|
||||||
return pointObject;
|
return pointObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
auto VLayoutPoint::ToQPointF() const -> QPointF
|
||||||
|
{
|
||||||
|
return {x(), y()};
|
||||||
|
}
|
||||||
|
|
|
@ -52,6 +52,7 @@ public:
|
||||||
Q_DECL_RELAXED_CONSTEXPR void SetCurvePoint(bool newCurvePoint);
|
Q_DECL_RELAXED_CONSTEXPR void SetCurvePoint(bool newCurvePoint);
|
||||||
|
|
||||||
auto toJson() const -> QJsonObject;
|
auto toJson() const -> QJsonObject;
|
||||||
|
auto ToQPointF() const -> QPointF;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool m_turnPoint{false};
|
bool m_turnPoint{false};
|
||||||
|
|
|
@ -69,7 +69,7 @@ auto GetSeamPassmarkSAPoint(const VPiecePassmarkData &passmarkData, const QVecto
|
||||||
return PassmarkStatus::Error; // Something wrong
|
return PassmarkStatus::Error; // Something wrong
|
||||||
}
|
}
|
||||||
|
|
||||||
point = ekvPoints.constFirst(); // NOLINT(cppcoreguidelines-slicing)
|
point = ekvPoints.constFirst().ToQPointF();
|
||||||
return needRollback ? PassmarkStatus::Rollback : PassmarkStatus::Common;
|
return needRollback ? PassmarkStatus::Rollback : PassmarkStatus::Common;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -510,8 +510,8 @@ auto VPiecePath::PathCurvePoints(const VContainer *data) const -> QVector<QVecto
|
||||||
{
|
{
|
||||||
const QSharedPointer<VAbstractCurve> curve = data->GeometricObject<VAbstractCurve>(at(i).GetId());
|
const QSharedPointer<VAbstractCurve> curve = data->GeometricObject<VAbstractCurve>(at(i).GetId());
|
||||||
|
|
||||||
const QPointF begin = StartSegment(data, i);
|
const QPointF begin = StartSegment(data, i).ToQPointF();
|
||||||
const QPointF end = EndSegment(data, i);
|
const QPointF end = EndSegment(data, i).ToQPointF();
|
||||||
|
|
||||||
curves.append(curve->GetSegmentPoints(begin, end, at(i).GetReverse(), GetName()));
|
curves.append(curve->GetSegmentPoints(begin, end, at(i).GetReverse(), GetName()));
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -686,7 +686,7 @@ auto VTranslateVars::VarFromUser(const QString &var) const -> QString
|
||||||
{
|
{
|
||||||
return newVar;
|
return newVar;
|
||||||
}
|
}
|
||||||
return newVar;
|
return var;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -743,25 +743,13 @@ auto DialogSeamAllowance::GetMirrorLineEndPoint() const -> quint32
|
||||||
nextIndex = 0;
|
nextIndex = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int prevIndex = index - 1;
|
|
||||||
if (prevIndex < 0)
|
|
||||||
{
|
|
||||||
prevIndex = uiTabPaths->listWidgetMainPath->count() - 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
const int next = FindNotExcludedNeighborNodeDown(uiTabPaths->listWidgetMainPath, nextIndex);
|
const int next = FindNotExcludedNeighborNodeDown(uiTabPaths->listWidgetMainPath, nextIndex);
|
||||||
const int prev = FindNotExcludedNeighborNodeUp(uiTabPaths->listWidgetMainPath, prevIndex);
|
|
||||||
|
|
||||||
if (next >= 0 && RowNode(uiTabPaths->listWidgetMainPath, next).GetId() == startPoint)
|
if (next >= 0 && RowNode(uiTabPaths->listWidgetMainPath, next).GetId() == startPoint)
|
||||||
{
|
{
|
||||||
return startPoint;
|
return startPoint;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (prev >= 0 && RowNode(uiTabPaths->listWidgetMainPath, prev).GetId() == startPoint)
|
|
||||||
{
|
|
||||||
return endPoint;
|
|
||||||
}
|
|
||||||
|
|
||||||
return endPoint;
|
return endPoint;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user