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))
|
||||
{
|
||||
point = boundary.constFirst();
|
||||
point = boundary.constFirst().ToQPointF();
|
||||
return true;
|
||||
}
|
||||
|
||||
if (VFuzzyComparePoints(boundary.constLast(), notchBase))
|
||||
{
|
||||
point = boundary.constLast();
|
||||
point = boundary.constLast().ToQPointF();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -2016,7 +2016,7 @@ auto VDxfEngine::NotchPrecedingPoint(const QVector<VLayoutPoint> &boundary, QPoi
|
|||
const qreal length = QLineF(notchBase, cPoint).length();
|
||||
if (length < bestDistance)
|
||||
{
|
||||
candidatePoint = boundary.at(i);
|
||||
candidatePoint = boundary.at(i).ToQPointF();
|
||||
bestDistance = length;
|
||||
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
|
||||
{
|
||||
qreal x1, y1, x2, y2;
|
||||
qreal x1 = 0;
|
||||
qreal y1 = 0;
|
||||
qreal x2 = 0;
|
||||
qreal y2 = 0;
|
||||
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;
|
||||
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;
|
||||
}
|
||||
|
||||
type = line.intersects(QLineF(QPointF(x1, y1), QPointF(x2, y1)), &point);
|
||||
|
||||
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;
|
||||
// Return the point (which would be (0,0) if no intersection is found)
|
||||
return {};
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -55,7 +55,7 @@ COPY_CONSTRUCTOR_IMPL_2(VPointF, VGObject)
|
|||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VPointF::VPointF(const QPointF &point)
|
||||
: VGObject(VPointF()),
|
||||
: VGObject(GOType::Point, 0, Draw::Calculation),
|
||||
d(new VPointFData(point))
|
||||
{
|
||||
}
|
||||
|
|
|
@ -609,7 +609,7 @@ auto AngleBySecondRightAngle(QVector<VRawSAPoint> points, QPointF p1, QPointF p2
|
|||
if (success)
|
||||
{
|
||||
points = temp;
|
||||
px = points.constLast();
|
||||
px = points.constLast().ToQPointF();
|
||||
}
|
||||
|
||||
if (countBefore > 0)
|
||||
|
@ -852,7 +852,7 @@ void RollbackBySecondEdgeRightAngle(QVector<VRawSAPoint> &ekvPoints, const QVect
|
|||
if (success)
|
||||
{
|
||||
ekvPoints = temp;
|
||||
px = ekvPoints.constLast();
|
||||
px = ekvPoints.constLast().ToQPointF();
|
||||
}
|
||||
|
||||
QLineF seam(px, points.at(1));
|
||||
|
@ -1322,23 +1322,28 @@ auto VAbstractPiece::EkvPoint(QVector<VRawSAPoint> points, const VSAPoint &p1Lin
|
|||
break;
|
||||
case PieceNodeAngle::ByLength:
|
||||
case PieceNodeAngle::ByLengthCurve:
|
||||
return AngleByLength(points, p1Line1, p2Line1, p1Line2, bigLine1, crosPoint, bigLine2, p2Line1,
|
||||
width, needRollback);
|
||||
return AngleByLength(points, p1Line1.ToQPointF(), p2Line1.ToQPointF(), p1Line2.ToQPointF(),
|
||||
bigLine1, crosPoint, bigLine2, p2Line1, width, needRollback);
|
||||
case PieceNodeAngle::ByPointsIntersection:
|
||||
return AngleByIntersection(points, p1Line1, p2Line1, p1Line2, bigLine1, crosPoint, bigLine2,
|
||||
p2Line1, width, needRollback);
|
||||
return AngleByIntersection(points, p1Line1.ToQPointF(), p2Line1.ToQPointF(),
|
||||
p1Line2.ToQPointF(), bigLine1, crosPoint, bigLine2, p2Line1, width,
|
||||
needRollback);
|
||||
case PieceNodeAngle::ByFirstEdgeSymmetry:
|
||||
return AngleByFirstSymmetry(points, p1Line1, p2Line1, p1Line2, bigLine1, crosPoint, bigLine2,
|
||||
p2Line1, width, needRollback);
|
||||
return AngleByFirstSymmetry(points, p1Line1.ToQPointF(), p2Line1.ToQPointF(),
|
||||
p1Line2.ToQPointF(), bigLine1, crosPoint, bigLine2, p2Line1, width,
|
||||
needRollback);
|
||||
case PieceNodeAngle::BySecondEdgeSymmetry:
|
||||
return AngleBySecondSymmetry(points, p1Line1, p2Line1, p1Line2, bigLine1, crosPoint, bigLine2,
|
||||
p2Line1, width, needRollback);
|
||||
return AngleBySecondSymmetry(points, p1Line1.ToQPointF(), p2Line1.ToQPointF(),
|
||||
p1Line2.ToQPointF(), bigLine1, crosPoint, bigLine2, p2Line1, width,
|
||||
needRollback);
|
||||
case PieceNodeAngle::ByFirstEdgeRightAngle:
|
||||
return AngleByFirstRightAngle(points, p1Line1, p2Line1, p1Line2, bigLine1, crosPoint, bigLine2,
|
||||
p2Line1, width, needRollback);
|
||||
return AngleByFirstRightAngle(points, p1Line1.ToQPointF(), p2Line1.ToQPointF(),
|
||||
p1Line2.ToQPointF(), bigLine1, crosPoint, bigLine2, p2Line1,
|
||||
width, needRollback);
|
||||
case PieceNodeAngle::BySecondEdgeRightAngle:
|
||||
return AngleBySecondRightAngle(points, p1Line1, p2Line1, p1Line2, bigLine1, crosPoint, bigLine2,
|
||||
p2Line1, width, needRollback);
|
||||
return AngleBySecondRightAngle(points, p1Line1.ToQPointF(), p2Line1.ToQPointF(),
|
||||
p1Line2.ToQPointF(), bigLine1, crosPoint, bigLine2, p2Line1,
|
||||
width, needRollback);
|
||||
}
|
||||
|
||||
QT_WARNING_POP
|
||||
|
|
|
@ -797,8 +797,7 @@ inline auto VAbstractPiece::SubdividePath(const QVector<T> &boundary, const QPoi
|
|||
continue;
|
||||
}
|
||||
|
||||
if (!VGObject::IsPointOnLineSegment(p, static_cast<QPointF>(boundary.at(i)),
|
||||
static_cast<QPointF>(boundary.at(i + 1))))
|
||||
if (!VGObject::IsPointOnLineSegment(p, boundary.at(i).ToQPointF(), boundary.at(i + 1).ToQPointF()))
|
||||
{
|
||||
sub1.append(boundary.at(i));
|
||||
continue;
|
||||
|
@ -858,7 +857,7 @@ inline auto VAbstractPiece::MirrorPath<VLayoutPoint>(const QVector<VLayoutPoint>
|
|||
for (const auto &p : points)
|
||||
{
|
||||
VLayoutPoint tmp = p;
|
||||
QPointF const flippedPoint = matrix.map(static_cast<QPointF>(p));
|
||||
QPointF const flippedPoint = matrix.map(p.ToQPointF());
|
||||
tmp.setX(flippedPoint.x());
|
||||
tmp.setY(flippedPoint.y());
|
||||
flipped.append(tmp);
|
||||
|
|
|
@ -225,54 +225,54 @@ auto VFoldLine::LabelPosition(bool &ok) const -> FoldLabelPosData
|
|||
{
|
||||
FoldLabelPosData posData;
|
||||
|
||||
TextPosData data;
|
||||
std::unique_ptr<TextPosData> data;
|
||||
if (m_type == FoldLineType::Text)
|
||||
{
|
||||
data = TextData();
|
||||
data = std::make_unique<TextPosData>(TextData());
|
||||
}
|
||||
else if (m_type == FoldLineType::TwoArrowsTextAbove)
|
||||
{
|
||||
data = TwoArrowsTextAboveData();
|
||||
data = std::make_unique<ArrowsTextPosData>(TwoArrowsTextAboveData());
|
||||
}
|
||||
else
|
||||
{
|
||||
data = TwoArrowsTextUnderData();
|
||||
data = std::make_unique<ArrowsTextPosData>(TwoArrowsTextUnderData());
|
||||
}
|
||||
|
||||
if (data.base.isNull())
|
||||
if (data->base.isNull())
|
||||
{
|
||||
ok = false;
|
||||
return {};
|
||||
}
|
||||
|
||||
qreal const height = data.labelHeight + (qFuzzyIsNull(m_height) ? defLabelMargin : m_height);
|
||||
qreal const margin = qMax(0., height - data.labelHeight);
|
||||
qreal const height = data->labelHeight + (qFuzzyIsNull(m_height) ? defLabelMargin : m_height);
|
||||
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());
|
||||
baseLine.setLength(data.labelWidth / 2);
|
||||
QLineF baseLine(center, data->base.p1());
|
||||
baseLine.setLength(data->labelWidth / 2);
|
||||
Swap(baseLine);
|
||||
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();
|
||||
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)
|
||||
{
|
||||
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);
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
posData.pos = baseLine.p2();
|
||||
posData.angle = QLineF(center, data.base.p1()).angle();
|
||||
posData.angle = QLineF(center, data->base.p1()).angle();
|
||||
ok = true;
|
||||
|
||||
return posData;
|
||||
|
|
|
@ -544,7 +544,7 @@ void InitFoldLine(VLayoutPiece &det, const VPiece &piece, const VContainer *patt
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
auto operator<<(QDataStream &dataStream, const VLayoutPoint &p) -> QDataStream &
|
||||
{
|
||||
dataStream << static_cast<QPointF>(p); // NOLINT(cppcoreguidelines-slicing)
|
||||
dataStream << p.ToQPointF();
|
||||
dataStream << p.TurnPoint();
|
||||
dataStream << p.CurvePoint();
|
||||
return dataStream;
|
||||
|
@ -570,7 +570,8 @@ auto operator>>(QDataStream &dataStream, VLayoutPoint &p) -> 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;
|
||||
return dataStream;
|
||||
}
|
||||
|
|
|
@ -56,3 +56,9 @@ auto VLayoutPoint::toJson() const -> QJsonObject
|
|||
|
||||
return pointObject;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
auto VLayoutPoint::ToQPointF() const -> QPointF
|
||||
{
|
||||
return {x(), y()};
|
||||
}
|
||||
|
|
|
@ -52,6 +52,7 @@ public:
|
|||
Q_DECL_RELAXED_CONSTEXPR void SetCurvePoint(bool newCurvePoint);
|
||||
|
||||
auto toJson() const -> QJsonObject;
|
||||
auto ToQPointF() const -> QPointF;
|
||||
|
||||
private:
|
||||
bool m_turnPoint{false};
|
||||
|
|
|
@ -69,7 +69,7 @@ auto GetSeamPassmarkSAPoint(const VPiecePassmarkData &passmarkData, const QVecto
|
|||
return PassmarkStatus::Error; // Something wrong
|
||||
}
|
||||
|
||||
point = ekvPoints.constFirst(); // NOLINT(cppcoreguidelines-slicing)
|
||||
point = ekvPoints.constFirst().ToQPointF();
|
||||
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 QPointF begin = StartSegment(data, i);
|
||||
const QPointF end = EndSegment(data, i);
|
||||
const QPointF begin = StartSegment(data, i).ToQPointF();
|
||||
const QPointF end = EndSegment(data, i).ToQPointF();
|
||||
|
||||
curves.append(curve->GetSegmentPoints(begin, end, at(i).GetReverse(), GetName()));
|
||||
break;
|
||||
|
|
|
@ -686,7 +686,7 @@ auto VTranslateVars::VarFromUser(const QString &var) const -> QString
|
|||
{
|
||||
return newVar;
|
||||
}
|
||||
return newVar;
|
||||
return var;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -743,25 +743,13 @@ auto DialogSeamAllowance::GetMirrorLineEndPoint() const -> quint32
|
|||
nextIndex = 0;
|
||||
}
|
||||
|
||||
int prevIndex = index - 1;
|
||||
if (prevIndex < 0)
|
||||
{
|
||||
prevIndex = uiTabPaths->listWidgetMainPath->count() - 1;
|
||||
}
|
||||
|
||||
const int next = FindNotExcludedNeighborNodeDown(uiTabPaths->listWidgetMainPath, nextIndex);
|
||||
const int prev = FindNotExcludedNeighborNodeUp(uiTabPaths->listWidgetMainPath, prevIndex);
|
||||
|
||||
if (next >= 0 && RowNode(uiTabPaths->listWidgetMainPath, next).GetId() == startPoint)
|
||||
{
|
||||
return startPoint;
|
||||
}
|
||||
|
||||
if (prev >= 0 && RowNode(uiTabPaths->listWidgetMainPath, prev).GetId() == startPoint)
|
||||
{
|
||||
return endPoint;
|
||||
}
|
||||
|
||||
return endPoint;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user