Code smell and performance : capture various variables by reference
This commit is contained in:
parent
0400b4fc72
commit
a1cf176331
|
@ -516,7 +516,7 @@ auto VEllipticalArc::GetPoints() const -> QVector<QPointF>
|
||||||
t.rotate(-d->rotationAngle);
|
t.rotate(-d->rotationAngle);
|
||||||
t.translate(-center.x(), -center.y());
|
t.translate(-center.x(), -center.y());
|
||||||
|
|
||||||
std::transform(points.begin(), points.end(), points.begin(), [t](const QPointF &point) { return t.map(point); });
|
std::transform(points.begin(), points.end(), points.begin(), [&t](const QPointF &point) { return t.map(point); });
|
||||||
|
|
||||||
return IsFlipped() ? Reverse(points) : points;
|
return IsFlipped() ? Reverse(points) : points;
|
||||||
}
|
}
|
||||||
|
|
|
@ -502,7 +502,7 @@ void VHPGLEngine::PlotInternalPaths(QTextStream &out, const VLayoutPiece &detail
|
||||||
{
|
{
|
||||||
const QTransform matrix = VGObject::FlippingMatrix(detail.GetMappedSeamMirrorLine());
|
const QTransform matrix = VGObject::FlippingMatrix(detail.GetMappedSeamMirrorLine());
|
||||||
std::transform(points.begin(), points.end(), points.begin(),
|
std::transform(points.begin(), points.end(), points.begin(),
|
||||||
[matrix](const VLayoutPoint &point) { return VAbstractPiece::MapPoint(point, matrix); });
|
[&matrix](const VLayoutPoint &point) { return VAbstractPiece::MapPoint(point, matrix); });
|
||||||
PlotPath(out, CastToPoint(ConvertPath(points)), path.PenStyle());
|
PlotPath(out, CastToPoint(ConvertPath(points)), path.PenStyle());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -531,7 +531,7 @@ void VHPGLEngine::PlotPlaceLabels(QTextStream &out, const VLayoutPiece &detail)
|
||||||
for (auto &points : shape)
|
for (auto &points : shape)
|
||||||
{
|
{
|
||||||
std::transform(points.begin(), points.end(), points.begin(),
|
std::transform(points.begin(), points.end(), points.begin(),
|
||||||
[matrix](const VLayoutPoint &point) { return VAbstractPiece::MapPoint(point, matrix); });
|
[&matrix](const VLayoutPoint &point) { return VAbstractPiece::MapPoint(point, matrix); });
|
||||||
}
|
}
|
||||||
|
|
||||||
PlotShape(shape);
|
PlotShape(shape);
|
||||||
|
|
|
@ -1906,7 +1906,7 @@ auto VAbstractPiece::GrainlineMainLine(const VGrainlineData &geom, const VContai
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
auto VAbstractPiece::PlaceLabelShape(const VLayoutPlaceLabel &label) -> PlaceLabelImg
|
auto VAbstractPiece::PlaceLabelShape(const VLayoutPlaceLabel &label) -> PlaceLabelImg
|
||||||
{
|
{
|
||||||
auto LayoutPoint = [label](QPointF p, bool turnPoint = false, bool curvePoint = false)
|
auto LayoutPoint = [&label](QPointF p, bool turnPoint = false, bool curvePoint = false)
|
||||||
{
|
{
|
||||||
VLayoutPoint point(label.RotationMatrix().map(p));
|
VLayoutPoint point(label.RotationMatrix().map(p));
|
||||||
point.SetTurnPoint(turnPoint);
|
point.SetTurnPoint(turnPoint);
|
||||||
|
@ -1917,7 +1917,7 @@ auto VAbstractPiece::PlaceLabelShape(const VLayoutPlaceLabel &label) -> PlaceLab
|
||||||
const QPointF pos = label.Center();
|
const QPointF pos = label.Center();
|
||||||
const QRectF box = label.Box();
|
const QRectF box = label.Box();
|
||||||
|
|
||||||
auto SegmentShape = [pos, box, LayoutPoint]()
|
auto SegmentShape = [pos, &box, &LayoutPoint]()
|
||||||
{
|
{
|
||||||
QVector<VLayoutPoint> const shape{LayoutPoint(QPointF(pos.x(), pos.y() - box.height() / 2.0), true),
|
QVector<VLayoutPoint> const shape{LayoutPoint(QPointF(pos.x(), pos.y() - box.height() / 2.0), true),
|
||||||
LayoutPoint(QPointF(pos.x(), pos.y() + box.height() / 2.0), true)};
|
LayoutPoint(QPointF(pos.x(), pos.y() + box.height() / 2.0), true)};
|
||||||
|
@ -1925,7 +1925,7 @@ auto VAbstractPiece::PlaceLabelShape(const VLayoutPlaceLabel &label) -> PlaceLab
|
||||||
return PlaceLabelImg{shape};
|
return PlaceLabelImg{shape};
|
||||||
};
|
};
|
||||||
|
|
||||||
auto RectangleShape = [pos, box, LayoutPoint]()
|
auto RectangleShape = [pos, &box, &LayoutPoint]()
|
||||||
{
|
{
|
||||||
QRectF const rect(QPointF(pos.x() - box.width() / 2.0, pos.y() - box.height() / 2.0),
|
QRectF const rect(QPointF(pos.x() - box.width() / 2.0, pos.y() - box.height() / 2.0),
|
||||||
QPointF(pos.x() + box.width() / 2.0, pos.y() + box.height() / 2.0));
|
QPointF(pos.x() + box.width() / 2.0, pos.y() + box.height() / 2.0));
|
||||||
|
@ -1937,7 +1937,7 @@ auto VAbstractPiece::PlaceLabelShape(const VLayoutPlaceLabel &label) -> PlaceLab
|
||||||
return PlaceLabelImg{shape};
|
return PlaceLabelImg{shape};
|
||||||
};
|
};
|
||||||
|
|
||||||
auto CrossShape = [pos, box, LayoutPoint]()
|
auto CrossShape = [pos, &box, &LayoutPoint]()
|
||||||
{
|
{
|
||||||
QVector<VLayoutPoint> const shape1{LayoutPoint(QPointF(pos.x(), pos.y() - box.height() / 2.0), true),
|
QVector<VLayoutPoint> const shape1{LayoutPoint(QPointF(pos.x(), pos.y() - box.height() / 2.0), true),
|
||||||
LayoutPoint(QPointF(pos.x(), pos.y() + box.height() / 2.0), true)};
|
LayoutPoint(QPointF(pos.x(), pos.y() + box.height() / 2.0), true)};
|
||||||
|
@ -1948,7 +1948,7 @@ auto VAbstractPiece::PlaceLabelShape(const VLayoutPlaceLabel &label) -> PlaceLab
|
||||||
return PlaceLabelImg{shape1, shape2};
|
return PlaceLabelImg{shape1, shape2};
|
||||||
};
|
};
|
||||||
|
|
||||||
auto TshapedShape = [pos, box, LayoutPoint]()
|
auto TshapedShape = [pos, &box, &LayoutPoint]()
|
||||||
{
|
{
|
||||||
QPointF const center2(pos.x(), pos.y() + box.height() / 2.0);
|
QPointF const center2(pos.x(), pos.y() + box.height() / 2.0);
|
||||||
|
|
||||||
|
@ -1960,7 +1960,7 @@ auto VAbstractPiece::PlaceLabelShape(const VLayoutPlaceLabel &label) -> PlaceLab
|
||||||
return PlaceLabelImg{shape1, shape2};
|
return PlaceLabelImg{shape1, shape2};
|
||||||
};
|
};
|
||||||
|
|
||||||
auto DoubletreeShape = [pos, box, LayoutPoint]()
|
auto DoubletreeShape = [pos, &box, &LayoutPoint]()
|
||||||
{
|
{
|
||||||
QRectF const rect(QPointF(pos.x() - box.width() / 2.0, pos.y() - box.height() / 2.0),
|
QRectF const rect(QPointF(pos.x() - box.width() / 2.0, pos.y() - box.height() / 2.0),
|
||||||
QPointF(pos.x() + box.width() / 2.0, pos.y() + box.height() / 2.0));
|
QPointF(pos.x() + box.width() / 2.0, pos.y() + box.height() / 2.0));
|
||||||
|
@ -1972,7 +1972,7 @@ auto VAbstractPiece::PlaceLabelShape(const VLayoutPlaceLabel &label) -> PlaceLab
|
||||||
return PlaceLabelImg{shape1, shape2};
|
return PlaceLabelImg{shape1, shape2};
|
||||||
};
|
};
|
||||||
|
|
||||||
auto CornerShape = [pos, box, LayoutPoint]()
|
auto CornerShape = [pos, &box, &LayoutPoint]()
|
||||||
{
|
{
|
||||||
QVector<VLayoutPoint> const shape1{LayoutPoint(QPointF(pos.x(), pos.y()), true),
|
QVector<VLayoutPoint> const shape1{LayoutPoint(QPointF(pos.x(), pos.y()), true),
|
||||||
LayoutPoint(QPointF(pos.x(), pos.y() + box.height() / 2.0), true)};
|
LayoutPoint(QPointF(pos.x(), pos.y() + box.height() / 2.0), true)};
|
||||||
|
@ -1983,7 +1983,7 @@ auto VAbstractPiece::PlaceLabelShape(const VLayoutPlaceLabel &label) -> PlaceLab
|
||||||
return PlaceLabelImg{shape1, shape2};
|
return PlaceLabelImg{shape1, shape2};
|
||||||
};
|
};
|
||||||
|
|
||||||
auto TriangleShape = [pos, box, LayoutPoint]()
|
auto TriangleShape = [pos, &box, &LayoutPoint]()
|
||||||
{
|
{
|
||||||
QRectF const rect(QPointF(pos.x() - box.width() / 2.0, pos.y() - box.height() / 2.0),
|
QRectF const rect(QPointF(pos.x() - box.width() / 2.0, pos.y() - box.height() / 2.0),
|
||||||
QPointF(pos.x() + box.width() / 2.0, pos.y() + box.height() / 2.0));
|
QPointF(pos.x() + box.width() / 2.0, pos.y() + box.height() / 2.0));
|
||||||
|
@ -1994,7 +1994,7 @@ auto VAbstractPiece::PlaceLabelShape(const VLayoutPlaceLabel &label) -> PlaceLab
|
||||||
return PlaceLabelImg{shape};
|
return PlaceLabelImg{shape};
|
||||||
};
|
};
|
||||||
|
|
||||||
auto HshapedShape = [pos, box, LayoutPoint]()
|
auto HshapedShape = [pos, &box, &LayoutPoint]()
|
||||||
{
|
{
|
||||||
const QPointF center1(pos.x(), pos.y() - box.height() / 2.0);
|
const QPointF center1(pos.x(), pos.y() - box.height() / 2.0);
|
||||||
const QPointF center2(pos.x(), pos.y() + box.height() / 2.0);
|
const QPointF center2(pos.x(), pos.y() + box.height() / 2.0);
|
||||||
|
@ -2010,7 +2010,7 @@ auto VAbstractPiece::PlaceLabelShape(const VLayoutPlaceLabel &label) -> PlaceLab
|
||||||
return PlaceLabelImg{shape1, shape2, shape3};
|
return PlaceLabelImg{shape1, shape2, shape3};
|
||||||
};
|
};
|
||||||
|
|
||||||
auto ButtonShape = [pos, box, LayoutPoint]()
|
auto ButtonShape = [pos, &box, &LayoutPoint]()
|
||||||
{
|
{
|
||||||
const qreal radius = qMin(box.width() / 2.0, box.height() / 2.0);
|
const qreal radius = qMin(box.width() / 2.0, box.height() / 2.0);
|
||||||
QVector<VLayoutPoint> const shape1{LayoutPoint(QPointF(pos.x(), pos.y() - radius), true),
|
QVector<VLayoutPoint> const shape1{LayoutPoint(QPointF(pos.x(), pos.y() - radius), true),
|
||||||
|
@ -2044,7 +2044,7 @@ auto VAbstractPiece::PlaceLabelShape(const VLayoutPlaceLabel &label) -> PlaceLab
|
||||||
return PlaceLabelImg{shape1, shape2, shape3};
|
return PlaceLabelImg{shape1, shape2, shape3};
|
||||||
};
|
};
|
||||||
|
|
||||||
auto CircleShape = [pos, box, LayoutPoint]()
|
auto CircleShape = [pos, &box, &LayoutPoint]()
|
||||||
{
|
{
|
||||||
const qreal radius = qMin(box.width() / 2.0, box.height() / 2.0);
|
const qreal radius = qMin(box.width() / 2.0, box.height() / 2.0);
|
||||||
VArc arc(VPointF(pos), radius, 0, 360);
|
VArc arc(VPointF(pos), radius, 0, 360);
|
||||||
|
|
|
@ -940,7 +940,7 @@ template <class T>
|
||||||
inline auto VAbstractPiece::MapVector(QVector<T> points, const QTransform &matrix, bool mirror) -> QVector<T>
|
inline auto VAbstractPiece::MapVector(QVector<T> points, const QTransform &matrix, bool mirror) -> QVector<T>
|
||||||
{
|
{
|
||||||
std::transform(points.begin(), points.end(), points.begin(),
|
std::transform(points.begin(), points.end(), points.begin(),
|
||||||
[matrix](const T &point) { return MapPoint(point, matrix); });
|
[&matrix](const T &point) { return MapPoint(point, matrix); });
|
||||||
if (mirror)
|
if (mirror)
|
||||||
{
|
{
|
||||||
std::reverse(points.begin(), points.end());
|
std::reverse(points.begin(), points.end());
|
||||||
|
|
Loading…
Reference in New Issue
Block a user