Refactoring.

Replace the redundant type with "auto".
This commit is contained in:
Roman Telezhynskyi 2024-05-02 13:47:29 +03:00
parent 5e56f30fb1
commit 9600364c05
30 changed files with 64 additions and 65 deletions

View File

@ -799,8 +799,7 @@ auto VAbstractPattern::ParseSANode(const QDomElement &domElement) -> VPieceNode
VDomDocument::GetParametrString(domElement, VAbstractPattern::AttrSABefore, currentSeamAllowance); VDomDocument::GetParametrString(domElement, VAbstractPattern::AttrSABefore, currentSeamAllowance);
const QString saAfter = const QString saAfter =
VDomDocument::GetParametrString(domElement, VAbstractPattern::AttrSAAfter, currentSeamAllowance); VDomDocument::GetParametrString(domElement, VAbstractPattern::AttrSAAfter, currentSeamAllowance);
const PieceNodeAngle angle = const auto angle = static_cast<PieceNodeAngle>(VDomDocument::GetParametrUInt(domElement, AttrAngle, QChar('0')));
static_cast<PieceNodeAngle>(VDomDocument::GetParametrUInt(domElement, AttrAngle, QChar('0')));
const bool passmark = VDomDocument::GetParametrBool(domElement, VAbstractPattern::AttrNodePassmark, falseStr); const bool passmark = VDomDocument::GetParametrBool(domElement, VAbstractPattern::AttrNodePassmark, falseStr);
const PassmarkLineType passmarkLine = StringToPassmarkLineType( const PassmarkLineType passmarkLine = StringToPassmarkLineType(
@ -1510,7 +1509,7 @@ void VAbstractPattern::DeleteBackgroundImage(const QUuid &id)
const QDomElement imageElement = imageNode.toElement(); const QDomElement imageElement = imageNode.toElement();
if (not imageElement.isNull()) if (not imageElement.isNull())
{ {
QUuid const imageId = QUuid(GetParametrEmptyString(imageElement, AttrImageId)); auto const imageId = QUuid(GetParametrEmptyString(imageElement, AttrImageId));
if (imageId == id) if (imageId == id)
{ {
imagesTag.removeChild(imageElement); imagesTag.removeChild(imageElement);
@ -2272,7 +2271,7 @@ auto VAbstractPattern::GetBackgroundImageElement(const QUuid &id) const -> QDomE
const QDomElement imageElement = imageNode.toElement(); const QDomElement imageElement = imageNode.toElement();
if (not imageElement.isNull()) if (not imageElement.isNull())
{ {
QUuid const imageId = QUuid(GetParametrEmptyString(imageElement, AttrImageId)); auto const imageId = QUuid(GetParametrEmptyString(imageElement, AttrImageId));
if (imageId == id) if (imageId == id)
{ {
return imageElement; return imageElement;

View File

@ -504,7 +504,7 @@ auto QmuParserTester::TestVarConst() -> int
// 4 used variables // 4 used variables
p.SetExpr("a+b+c+d"); p.SetExpr("a+b+c+d");
qmu::varmap_type UsedVar = p.GetUsedVar(); qmu::varmap_type UsedVar = p.GetUsedVar();
int iCount = static_cast<int>(UsedVar.size()); auto iCount = static_cast<int>(UsedVar.size());
if (iCount != 4) if (iCount != 4)
{ {
throw false; throw false;

View File

@ -1017,7 +1017,7 @@ auto VMeasurements::DimensionTypeToStr(const MeasurementDimension &type) -> QStr
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VMeasurements::StrToDimensionType(const QString &type) -> MeasurementDimension auto VMeasurements::StrToDimensionType(const QString &type) -> MeasurementDimension
{ {
const QStringList dimensions = QStringList{DimensionX, DimensionY, DimensionW, DimensionZ}; const auto dimensions = QStringList{DimensionX, DimensionY, DimensionW, DimensionZ};
switch (dimensions.indexOf(type)) switch (dimensions.indexOf(type))
{ {
case 1: // DimensionY case 1: // DimensionY

View File

@ -496,7 +496,7 @@ auto VAbstractCurve::CurveIntersectAxis(const QPointF &point, qreal angle, const
rec.translate(-INT_MAX / 2.0, -INT_MAX / 2.0); rec.translate(-INT_MAX / 2.0, -INT_MAX / 2.0);
// Instead of using axis compare two rays. See issue #963. // Instead of using axis compare two rays. See issue #963.
QLineF axis = QLineF(point, VGObject::BuildRay(point, angle, rec)); auto axis = QLineF(point, VGObject::BuildRay(point, angle, rec));
QVector<QPointF> points = VAbstractCurve::CurveIntersectLine(curvePoints, axis); QVector<QPointF> points = VAbstractCurve::CurveIntersectLine(curvePoints, axis);
axis = QLineF(point, VGObject::BuildRay(point, angle + 180, rec)); axis = QLineF(point, VGObject::BuildRay(point, angle + 180, rec));

View File

@ -299,7 +299,7 @@ auto VGObject::ToJson() const -> QJsonObject
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VGObject::BuildLine(const QPointF &p1, const qreal &length, const qreal &angle) -> QLineF auto VGObject::BuildLine(const QPointF &p1, const qreal &length, const qreal &angle) -> QLineF
{ {
QLineF line = QLineF(); QLineF line;
line.setP1(p1); line.setP1(p1);
line.setAngle(angle); // First set angle then length. Length can have negative value. line.setAngle(angle); // First set angle then length. Length can have negative value.
line.setLength(length); line.setLength(length);
@ -696,7 +696,7 @@ auto VGObject::FlippingMatrix(const QLineF &axis) -> QTransform
return matrix; return matrix;
} }
const QLineF axisOX = QLineF(axis.x2(), axis.y2(), axis.x2() + 100, axis.y2()); // Ox axis const auto axisOX = QLineF(axis.x2(), axis.y2(), axis.x2() + 100, axis.y2()); // Ox axis
const qreal angle = axis.angleTo(axisOX); const qreal angle = axis.angleTo(axisOX);
const QPointF p2 = axis.p2(); const QPointF p2 = axis.p2();

View File

@ -327,7 +327,7 @@ auto AngleByFirstSymmetry(const QVector<VRawSAPoint> &points, QPointF p1, QPoint
*needRollback = false; *needRollback = false;
} }
const QLineF axis = QLineF(p1, p2); const auto axis = QLineF(p1, p2);
QLineF const sEdge(VPointF::FlipPF(axis, bigLine2.p1()), VPointF::FlipPF(axis, bigLine2.p2())); QLineF const sEdge(VPointF::FlipPF(axis, bigLine2.p1()), VPointF::FlipPF(axis, bigLine2.p2()));
@ -408,7 +408,7 @@ auto AngleBySecondSymmetry(const QVector<VRawSAPoint> &points, QPointF p1, QPoin
*needRollback = false; *needRollback = false;
} }
const QLineF axis = QLineF(p3, p2); const auto axis = QLineF(p3, p2);
QLineF const sEdge(VPointF::FlipPF(axis, bigLine1.p1()), VPointF::FlipPF(axis, bigLine1.p2())); QLineF const sEdge(VPointF::FlipPF(axis, bigLine1.p1()), VPointF::FlipPF(axis, bigLine1.p2()));
@ -755,7 +755,7 @@ void RollbackByLength(QVector<VRawSAPoint> &ekvPoints, const QVector<VSAPoint> &
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void RollbackBySecondEdgeSymmetry(QVector<VRawSAPoint> &ekvPoints, const QVector<VSAPoint> &points, qreal width) void RollbackBySecondEdgeSymmetry(QVector<VRawSAPoint> &ekvPoints, const QVector<VSAPoint> &points, qreal width)
{ {
const QLineF axis = QLineF(points.at(points.size() - 1), points.at(1)); const auto axis = QLineF(points.at(points.size() - 1), points.at(1));
const QLineF bigLine1 = VAbstractPiece::ParallelLine(points.at(points.size() - 2), points.at(0), width); const QLineF bigLine1 = VAbstractPiece::ParallelLine(points.at(points.size() - 2), points.at(0), width);
QLineF const sEdge(VPointF::FlipPF(axis, bigLine1.p1()), VPointF::FlipPF(axis, bigLine1.p2())); QLineF const sEdge(VPointF::FlipPF(axis, bigLine1.p1()), VPointF::FlipPF(axis, bigLine1.p2()));
@ -772,7 +772,7 @@ void RollbackBySecondEdgeSymmetry(QVector<VRawSAPoint> &ekvPoints, const QVector
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void RollbackByFirstEdgeSymmetry(QVector<VRawSAPoint> &ekvPoints, const QVector<VSAPoint> &points, qreal width) void RollbackByFirstEdgeSymmetry(QVector<VRawSAPoint> &ekvPoints, const QVector<VSAPoint> &points, qreal width)
{ {
const QLineF axis = QLineF(points.at(points.size() - 2), points.at(points.size() - 1)); const auto axis = QLineF(points.at(points.size() - 2), points.at(points.size() - 1));
const QLineF bigLine2 = VAbstractPiece::ParallelLine(points.at(points.size() - 1), points.at(1), width); const QLineF bigLine2 = VAbstractPiece::ParallelLine(points.at(points.size() - 1), points.at(1), width);
QLineF const sEdge(VPointF::FlipPF(axis, bigLine2.p1()), VPointF::FlipPF(axis, bigLine2.p2())); QLineF const sEdge(VPointF::FlipPF(axis, bigLine2.p1()), VPointF::FlipPF(axis, bigLine2.p2()));
const QLineF bigLine1 = VAbstractPiece::ParallelLine(points.at(points.size() - 2), points.at(0), width); const QLineF bigLine1 = VAbstractPiece::ParallelLine(points.at(points.size() - 2), points.at(0), width);
@ -1625,7 +1625,7 @@ void VAbstractPiece::SetUUID(const QUuid &uuid)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VAbstractPiece::SetUUID(const QString &uuid) void VAbstractPiece::SetUUID(const QString &uuid)
{ {
const QUuid temp = QUuid(uuid); const auto temp = QUuid(uuid);
d->m_uuid = temp.isNull() ? QUuid::createUuid() : temp; d->m_uuid = temp.isNull() ? QUuid::createUuid() : temp;
} }

View File

@ -1269,7 +1269,7 @@ void VLayoutPiece::Mirror(const QLineF &edge)
return; return;
} }
const QLineF axis = QLineF(edge.x2(), edge.y2(), edge.x2() + 100, edge.y2()); // Ox axis const auto axis = QLineF(edge.x2(), edge.y2(), edge.x2() + 100, edge.y2()); // Ox axis
const qreal angle = edge.angleTo(axis); const qreal angle = edge.angleTo(axis);
const QPointF p2 = edge.p2(); const QPointF p2 = edge.p2();

View File

@ -55,9 +55,9 @@ auto LogDirPath(const QString &appName) -> QString
#endif #endif
} }
#if defined(Q_OS_WINDOWS) #if defined(Q_OS_WINDOWS)
QString path = QStringList{logDirPath, logs}.join(QDir::separator()); auto path = QStringList{logDirPath, logs}.join(QDir::separator());
#else #else
QString path = QStringList{logDirPath, VER_COMPANYNAME_STR, logs, appName}.join(QDir::separator()); auto path = QStringList{logDirPath, VER_COMPANYNAME_STR, logs, appName}.join(QDir::separator());
#endif #endif
return path; return path;
} }

View File

@ -662,9 +662,9 @@ auto VAbstractApplication::LogDirPath() -> QString
#endif #endif
} }
#if defined(Q_OS_WINDOWS) #if defined(Q_OS_WINDOWS)
QString path = QStringList{logDirPath, logs}.join(QDir::separator()); auto path = QStringList{logDirPath, logs}.join(QDir::separator());
#else #else
QString path = auto path =
QStringList{logDirPath, QCoreApplication::organizationName(), logs, QCoreApplication::applicationName()}.join( QStringList{logDirPath, QCoreApplication::organizationName(), logs, QCoreApplication::applicationName()}.join(
QDir::separator()); QDir::separator());
#endif #endif

View File

@ -347,7 +347,7 @@ void VCommonSettings::SetPathCustomImage(const QString &value)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VCommonSettings::GetDefPathSVGFonts() -> QString auto VCommonSettings::GetDefPathSVGFonts() -> QString
{ {
QString const defPath = QStringList{QDir::homePath(), "Valentina"_L1, "Svg fonts"_L1}.join(QDir::separator()); auto const defPath = QStringList{QDir::homePath(), "Valentina"_L1, "Svg fonts"_L1}.join(QDir::separator());
#if defined(Q_OS_WIN) #if defined(Q_OS_WIN)
QString const docPath = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation); QString const docPath = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation);

View File

@ -82,7 +82,7 @@ auto PointsToSegments(const QVector<QPointF> &points) -> QVector<QLineF>
lines.reserve(points.size() - 1); lines.reserve(points.size() - 1);
for (int i = 0; i < points.size() - 1; ++i) for (int i = 0; i < points.size() - 1; ++i)
{ {
QLineF const segment = QLineF(points.at(i), points.at(i + 1)); auto const segment = QLineF(points.at(i), points.at(i + 1));
if (segment.length() > 0) if (segment.length() > 0)
{ {
lines.append(segment); lines.append(segment);
@ -183,7 +183,7 @@ auto PassmarkWidth(const VPiecePassmarkData &passmarkData, qreal width) -> qreal
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto FixNotchPoint(const QVector<QPointF> &seamAllowance, const VPiecePassmarkData &data, QPointF *notch) -> bool auto FixNotchPoint(const QVector<QPointF> &seamAllowance, const VPiecePassmarkData &data, QPointF *notch) -> bool
{ {
QLineF axis = QLineF(data.passmarkSAPoint, *notch); auto axis = QLineF(data.passmarkSAPoint, *notch);
if (data.passmarkAngleType == PassmarkAngleType::Straightforward) if (data.passmarkAngleType == PassmarkAngleType::Straightforward)
{ {
@ -274,7 +274,7 @@ auto CreateTwoPassmarkLines(const VPiecePassmarkData &passmarkData, const QLineF
QPointF l1p2; QPointF l1p2;
{ {
QLineF line1 = QLineF(line.p2(), line.p1()); auto line1 = QLineF(line.p2(), line.p1());
line1.setAngle(line1.angle() - 90); line1.setAngle(line1.angle() - 90);
line1.setLength(width / 2.); line1.setLength(width / 2.);
l1p2 = line1.p2(); l1p2 = line1.p2();
@ -282,7 +282,7 @@ auto CreateTwoPassmarkLines(const VPiecePassmarkData &passmarkData, const QLineF
QPointF l2p2; QPointF l2p2;
{ {
QLineF line2 = QLineF(line.p2(), line.p1()); auto line2 = QLineF(line.p2(), line.p1());
line2.setAngle(line2.angle() + 90); line2.setAngle(line2.angle() + 90);
line2.setLength(width / 2.); line2.setLength(width / 2.);
l2p2 = line2.p2(); l2p2 = line2.p2();
@ -321,7 +321,7 @@ auto CreateThreePassmarkLines(const VPiecePassmarkData &passmarkData, const QLin
QPointF l1p2; QPointF l1p2;
{ {
QLineF line1 = QLineF(line.p2(), line.p1()); auto line1 = QLineF(line.p2(), line.p1());
line1.setAngle(line1.angle() - 90); line1.setAngle(line1.angle() - 90);
line1.setLength(width / 2.); line1.setLength(width / 2.);
l1p2 = line1.p2(); l1p2 = line1.p2();
@ -329,7 +329,7 @@ auto CreateThreePassmarkLines(const VPiecePassmarkData &passmarkData, const QLin
QPointF l2p2; QPointF l2p2;
{ {
QLineF line2 = QLineF(line.p2(), line.p1()); auto line2 = QLineF(line.p2(), line.p1());
line2.setAngle(line2.angle() + 90); line2.setAngle(line2.angle() + 90);
line2.setLength(width / 2.); line2.setLength(width / 2.);
l2p2 = line2.p2(); l2p2 = line2.p2();
@ -353,7 +353,7 @@ auto CreateTMarkPassmark(const VPiecePassmarkData &passmarkData, const QLineF &l
QPointF p1; QPointF p1;
{ {
QLineF tmpLine = QLineF(line.p2(), line.p1()); auto tmpLine = QLineF(line.p2(), line.p1());
tmpLine.setAngle(tmpLine.angle() - 90); tmpLine.setAngle(tmpLine.angle() - 90);
tmpLine.setLength(width / 2.); tmpLine.setLength(width / 2.);
p1 = tmpLine.p2(); p1 = tmpLine.p2();
@ -361,7 +361,7 @@ auto CreateTMarkPassmark(const VPiecePassmarkData &passmarkData, const QLineF &l
QPointF p2; QPointF p2;
{ {
QLineF tmpLine = QLineF(line.p2(), line.p1()); auto tmpLine = QLineF(line.p2(), line.p1());
tmpLine.setAngle(tmpLine.angle() + 90); tmpLine.setAngle(tmpLine.angle() + 90);
tmpLine.setLength(width / 2.); tmpLine.setLength(width / 2.);
p2 = tmpLine.p2(); p2 = tmpLine.p2();
@ -396,11 +396,11 @@ auto CreateInternalVMarkPassmark(const VPiecePassmarkData &passmarkData, const Q
const qreal width = PassmarkWidth(passmarkData, defWidth * 2.); const qreal width = PassmarkWidth(passmarkData, defWidth * 2.);
const qreal angle = qRadiansToDegrees(qAtan(qAbs(width) / 2. / line.length())); const qreal angle = qRadiansToDegrees(qAtan(qAbs(width) / 2. / line.length()));
QLineF l1 = QLineF(line.p2(), line.p1()); auto l1 = QLineF(line.p2(), line.p1());
l1.setAngle(l1.angle() + angle); l1.setAngle(l1.angle() + angle);
l1 = VPassmark::FindIntersection(l1, seamAllowance); l1 = VPassmark::FindIntersection(l1, seamAllowance);
QLineF l2 = QLineF(line.p2(), line.p1()); auto l2 = QLineF(line.p2(), line.p1());
l2.setAngle(l2.angle() - angle); l2.setAngle(l2.angle() - angle);
return {{l1.p2(), l1.p1()}, VPassmark::FindIntersection(l2, seamAllowance)}; return {{l1.p2(), l1.p1()}, VPassmark::FindIntersection(l2, seamAllowance)};
@ -439,7 +439,7 @@ auto CreateUMarkPassmark(const VPiecePassmarkData &passmarkData, const QLineF &l
QPointF l1p2; QPointF l1p2;
{ {
QLineF line = QLineF(baseLine.p2(), baseLine.p1()); auto line = QLineF(baseLine.p2(), baseLine.p1());
line.setAngle(line.angle() + 90); line.setAngle(line.angle() + 90);
line.setLength(radius); line.setLength(radius);
l1p2 = line.p2(); l1p2 = line.p2();
@ -447,7 +447,7 @@ auto CreateUMarkPassmark(const VPiecePassmarkData &passmarkData, const QLineF &l
QPointF l2p2; QPointF l2p2;
{ {
QLineF line = QLineF(baseLine.p2(), baseLine.p1()); auto line = QLineF(baseLine.p2(), baseLine.p1());
line.setAngle(line.angle() - 90); line.setAngle(line.angle() - 90);
line.setLength(radius); line.setLength(radius);
l2p2 = line.p2(); l2p2 = line.p2();
@ -497,7 +497,7 @@ auto CreateBoxMarkPassmark(const VPiecePassmarkData &passmarkData, const QLineF
QPointF l1p2; QPointF l1p2;
{ {
QLineF tmp = QLineF(line.p2(), line.p1()); auto tmp = QLineF(line.p2(), line.p1());
tmp.setAngle(tmp.angle() + 90); tmp.setAngle(tmp.angle() + 90);
tmp.setLength(width / 2.); tmp.setLength(width / 2.);
l1p2 = tmp.p2(); l1p2 = tmp.p2();
@ -513,7 +513,7 @@ auto CreateBoxMarkPassmark(const VPiecePassmarkData &passmarkData, const QLineF
QPointF l2p2; QPointF l2p2;
{ {
QLineF tmp = QLineF(line.p2(), line.p1()); auto tmp = QLineF(line.p2(), line.p1());
tmp.setAngle(tmp.angle() - 90); tmp.setAngle(tmp.angle() - 90);
tmp.setLength(width / 2.); tmp.setLength(width / 2.);
l2p2 = tmp.p2(); l2p2 = tmp.p2();
@ -783,7 +783,7 @@ auto VPassmark::PassmarkStraightforwardBaseLine(const QPointF &seamPassmarkSAPoi
return {}; return {};
} }
QLineF line = QLineF(seamPassmarkSAPoint, m_data.passmarkSAPoint); auto line = QLineF(seamPassmarkSAPoint, m_data.passmarkSAPoint);
line.setLength(length); line.setLength(length);
return {line}; return {line};
} }
@ -952,8 +952,8 @@ auto VPassmark::BuiltInSAPassmarkBaseLine(const VPiece &piece) const -> QVector<
} }
} }
QLineF edge1 = QLineF(m_data.passmarkSAPoint, m_data.previousSAPoint); auto edge1 = QLineF(m_data.passmarkSAPoint, m_data.previousSAPoint);
QLineF const edge2 = QLineF(m_data.passmarkSAPoint, m_data.nextSAPoint); auto const edge2 = QLineF(m_data.passmarkSAPoint, m_data.nextSAPoint);
edge1.setAngle(edge1.angle() + edge1.angleTo(edge2) / 2.); edge1.setAngle(edge1.angle() + edge1.angleTo(edge2) / 2.);
edge1.setLength(length); edge1.setLength(length);

View File

@ -269,7 +269,7 @@ void DialogArc::ShowDialog(bool click)
auto *scene = qobject_cast<VMainGraphicsScene *>(VAbstractValApplication::VApp()->getCurrentScene()); auto *scene = qobject_cast<VMainGraphicsScene *>(VAbstractValApplication::VApp()->getCurrentScene());
SCASSERT(scene != nullptr) SCASSERT(scene != nullptr)
const QSharedPointer<VPointF> point = data->GeometricObject<VPointF>(GetCenter()); const QSharedPointer<VPointF> point = data->GeometricObject<VPointF>(GetCenter());
QLineF const line = QLineF(static_cast<QPointF>(*point), scene->getScenePos()); auto const line = QLineF(static_cast<QPointF>(*point), scene->getScenePos());
auto Angle = [&line]() auto Angle = [&line]()
{ {

View File

@ -296,7 +296,7 @@ void DialogArcWithLength::ShowDialog(bool click)
auto *scene = qobject_cast<VMainGraphicsScene *>(VAbstractValApplication::VApp()->getCurrentScene()); auto *scene = qobject_cast<VMainGraphicsScene *>(VAbstractValApplication::VApp()->getCurrentScene());
SCASSERT(scene != nullptr) SCASSERT(scene != nullptr)
const QSharedPointer<VPointF> point = data->GeometricObject<VPointF>(GetCenter()); const QSharedPointer<VPointF> point = data->GeometricObject<VPointF>(GetCenter());
QLineF const line = QLineF(static_cast<QPointF>(*point), scene->getScenePos()); auto const line = QLineF(static_cast<QPointF>(*point), scene->getScenePos());
auto Angle = [&line]() auto Angle = [&line]()
{ {

View File

@ -232,7 +232,7 @@ void DialogCurveIntersectAxis::ShowDialog(bool click)
auto *scene = qobject_cast<VMainGraphicsScene *>(VAbstractValApplication::VApp()->getCurrentScene()); auto *scene = qobject_cast<VMainGraphicsScene *>(VAbstractValApplication::VApp()->getCurrentScene());
SCASSERT(scene != nullptr) SCASSERT(scene != nullptr)
const QSharedPointer<VPointF> point = data->GeometricObject<VPointF>(GetBasePointId()); const QSharedPointer<VPointF> point = data->GeometricObject<VPointF>(GetBasePointId());
QLineF const line = QLineF(static_cast<QPointF>(*point), scene->getScenePos()); auto const line = QLineF(static_cast<QPointF>(*point), scene->getScenePos());
// Radius of point circle, but little bigger. Need handle with hover sizes. // Radius of point circle, but little bigger. Need handle with hover sizes.
if (line.length() <= ScaledRadius(SceneScale(VAbstractValApplication::VApp()->getCurrentScene())) * 1.5) if (line.length() <= ScaledRadius(SceneScale(VAbstractValApplication::VApp()->getCurrentScene())) * 1.5)

View File

@ -590,7 +590,7 @@ void DialogEllipticalArc::ShowDialog(bool click)
SCASSERT(scene != nullptr) SCASSERT(scene != nullptr)
const QSharedPointer<VPointF> center = data->GeometricObject<VPointF>(GetCenter()); const QSharedPointer<VPointF> center = data->GeometricObject<VPointF>(GetCenter());
QLineF line = QLineF(static_cast<QPointF>(*center), scene->getScenePos()); auto line = QLineF(static_cast<QPointF>(*center), scene->getScenePos());
auto Angle = [&line]() auto Angle = [&line]()
{ {

View File

@ -344,7 +344,7 @@ void DialogEndLine::ShowDialog(bool click)
auto *scene = qobject_cast<VMainGraphicsScene *>(VAbstractValApplication::VApp()->getCurrentScene()); auto *scene = qobject_cast<VMainGraphicsScene *>(VAbstractValApplication::VApp()->getCurrentScene());
SCASSERT(scene != nullptr) SCASSERT(scene != nullptr)
const QSharedPointer<VPointF> point = data->GeometricObject<VPointF>(GetBasePointId()); const QSharedPointer<VPointF> point = data->GeometricObject<VPointF>(GetBasePointId());
QLineF const line = QLineF(static_cast<QPointF>(*point), scene->getScenePos()); auto const line = QLineF(static_cast<QPointF>(*point), scene->getScenePos());
// Radius of point circle, but little bigger. Need handle with hover sizes. // Radius of point circle, but little bigger. Need handle with hover sizes.
if (line.length() <= ScaledRadius(SceneScale(VAbstractValApplication::VApp()->getCurrentScene())) * 1.5) if (line.length() <= ScaledRadius(SceneScale(VAbstractValApplication::VApp()->getCurrentScene())) * 1.5)

View File

@ -255,7 +255,7 @@ void DialogLineIntersectAxis::ShowDialog(bool click)
auto *scene = qobject_cast<VMainGraphicsScene *>(VAbstractValApplication::VApp()->getCurrentScene()); auto *scene = qobject_cast<VMainGraphicsScene *>(VAbstractValApplication::VApp()->getCurrentScene());
SCASSERT(scene != nullptr) SCASSERT(scene != nullptr)
const QSharedPointer<VPointF> point = data->GeometricObject<VPointF>(GetBasePointId()); const QSharedPointer<VPointF> point = data->GeometricObject<VPointF>(GetBasePointId());
QLineF const line = QLineF(static_cast<QPointF>(*point), scene->getScenePos()); auto const line = QLineF(static_cast<QPointF>(*point), scene->getScenePos());
// Radius of point circle, but little bigger. Need handle with hover sizes. // Radius of point circle, but little bigger. Need handle with hover sizes.
if (line.length() <= ScaledRadius(SceneScale(VAbstractValApplication::VApp()->getCurrentScene())) * 1.5) if (line.length() <= ScaledRadius(SceneScale(VAbstractValApplication::VApp()->getCurrentScene())) * 1.5)

View File

@ -223,7 +223,7 @@ void DialogPointFromCircleAndTangent::ShowDialog(bool click)
auto *scene = qobject_cast<VMainGraphicsScene *>(VAbstractValApplication::VApp()->getCurrentScene()); auto *scene = qobject_cast<VMainGraphicsScene *>(VAbstractValApplication::VApp()->getCurrentScene());
SCASSERT(scene != nullptr) SCASSERT(scene != nullptr)
const QSharedPointer<VPointF> center = data->GeometricObject<VPointF>(GetCircleCenterId()); const QSharedPointer<VPointF> center = data->GeometricObject<VPointF>(GetCircleCenterId());
QLineF const line = QLineF(static_cast<QPointF>(*center), scene->getScenePos()); auto const line = QLineF(static_cast<QPointF>(*center), scene->getScenePos());
SetCircleRadius(QString::number(FromPixel(line.length(), *data->GetPatternUnit()))); SetCircleRadius(QString::number(FromPixel(line.length(), *data->GetPatternUnit())));
} }

View File

@ -277,7 +277,7 @@ void DialogRotation::ShowDialog(bool click)
try try
{ {
const QSharedPointer<VPointF> point = data->GeometricObject<VPointF>(GetOrigPointId()); const QSharedPointer<VPointF> point = data->GeometricObject<VPointF>(GetOrigPointId());
const QLineF line = QLineF(static_cast<QPointF>(*point), scene->getScenePos()); const auto line = QLineF(static_cast<QPointF>(*point), scene->getScenePos());
// Radius of point circle, but little bigger. Need handle with hover sizes. // Radius of point circle, but little bigger. Need handle with hover sizes.
if (line.length() <= ScaledRadius(SceneScale(VAbstractValApplication::VApp()->getCurrentScene())) * 1.5) if (line.length() <= ScaledRadius(SceneScale(VAbstractValApplication::VApp()->getCurrentScene())) * 1.5)

View File

@ -272,7 +272,7 @@ auto VToolAlongLine::Create(VToolAlongLineInitData &initData) -> VToolAlongLine
{ {
const QSharedPointer<VPointF> firstPoint = initData.data->GeometricObject<VPointF>(initData.firstPointId); const QSharedPointer<VPointF> firstPoint = initData.data->GeometricObject<VPointF>(initData.firstPointId);
const QSharedPointer<VPointF> secondPoint = initData.data->GeometricObject<VPointF>(initData.secondPointId); const QSharedPointer<VPointF> secondPoint = initData.data->GeometricObject<VPointF>(initData.secondPointId);
QLineF line = QLineF(static_cast<QPointF>(*firstPoint), static_cast<QPointF>(*secondPoint)); auto line = QLineF(static_cast<QPointF>(*firstPoint), static_cast<QPointF>(*secondPoint));
// Declare special variable "CurrentLength" // Declare special variable "CurrentLength"
auto *length = new VLengthLine(firstPoint.data(), initData.firstPointId, secondPoint.data(), initData.secondPointId, auto *length = new VLengthLine(firstPoint.data(), initData.firstPointId, secondPoint.data(), initData.secondPointId,

View File

@ -133,7 +133,7 @@ auto VToolEndLine::Create(const QPointer<DialogTool> &dialog, VMainGraphicsScene
auto VToolEndLine::Create(VToolEndLineInitData &initData) -> VToolEndLine * auto VToolEndLine::Create(VToolEndLineInitData &initData) -> VToolEndLine *
{ {
const QSharedPointer<VPointF> basePoint = initData.data->GeometricObject<VPointF>(initData.basePointId); const QSharedPointer<VPointF> basePoint = initData.data->GeometricObject<VPointF>(initData.basePointId);
QLineF line = QLineF(static_cast<QPointF>(*basePoint), QPointF(basePoint->x() + 100, basePoint->y())); auto line = QLineF(static_cast<QPointF>(*basePoint), QPointF(basePoint->x() + 100, basePoint->y()));
line.setAngle(CheckFormula(initData.id, initData.formulaAngle, initData.data)); // First set angle. line.setAngle(CheckFormula(initData.id, initData.formulaAngle, initData.data)); // First set angle.
line.setLength( line.setLength(

View File

@ -120,7 +120,7 @@ auto VToolLineIntersectAxis::Create(const QPointer<DialogTool> &dialog, VMainGra
auto VToolLineIntersectAxis::Create(VToolLineIntersectAxisInitData &initData) -> VToolLineIntersectAxis * auto VToolLineIntersectAxis::Create(VToolLineIntersectAxisInitData &initData) -> VToolLineIntersectAxis *
{ {
const QSharedPointer<VPointF> basePoint = initData.data->GeometricObject<VPointF>(initData.basePointId); const QSharedPointer<VPointF> basePoint = initData.data->GeometricObject<VPointF>(initData.basePointId);
QLineF axis = QLineF(static_cast<QPointF>(*basePoint), QPointF(basePoint->x() + 100, basePoint->y())); auto axis = QLineF(static_cast<QPointF>(*basePoint), QPointF(basePoint->x() + 100, basePoint->y()));
axis.setAngle(CheckFormula(initData.id, initData.formulaAngle, initData.data)); axis.setAngle(CheckFormula(initData.id, initData.formulaAngle, initData.data));
const QSharedPointer<VPointF> firstPoint = initData.data->GeometricObject<VPointF>(initData.firstPointId); const QSharedPointer<VPointF> firstPoint = initData.data->GeometricObject<VPointF>(initData.firstPointId);

View File

@ -114,7 +114,7 @@ auto VToolShoulderPoint::FindPoint(const QPointF &p1Line, const QPointF &p2Line,
return shoulderPoint; return shoulderPoint;
} }
QLineF line = QLineF(p1Line, p2Line); auto line = QLineF(p1Line, p2Line);
const qreal baseLength = line.length(); const qreal baseLength = line.length();
const int baseAngle = qRound(line.angle()); const int baseAngle = qRound(line.angle());
line.setLength(length * 2); line.setLength(length * 2);
@ -126,8 +126,8 @@ auto VToolShoulderPoint::FindPoint(const QPointF &p1Line, const QPointF &p2Line,
if (res == 1 || res == 2) if (res == 1 || res == 2)
{ {
const QLineF line1 = QLineF(p1Line, p1); const auto line1 = QLineF(p1Line, p1);
const QLineF line2 = QLineF(p1Line, p2); const auto line2 = QLineF(p1Line, p2);
if (line1.length() > baseLength && baseAngle == qRound(line1.angle())) if (line1.length() > baseLength && baseAngle == qRound(line1.angle()))
{ {
shoulderPoint = p1; shoulderPoint = p1;

View File

@ -375,8 +375,8 @@ void UnionInitParameters(const VToolUnionDetailsInitData &initData, const VPiece
point4.setX(point4.x() + dx); point4.setX(point4.x() + dx);
point4.setY(point4.y() + dy); point4.setY(point4.y() + dy);
const QLineF p4p3 = QLineF(static_cast<QPointF>(point4), static_cast<QPointF>(point3)); const auto p4p3 = QLineF(static_cast<QPointF>(point4), static_cast<QPointF>(point3));
const QLineF p1p2 = QLineF(static_cast<QPointF>(point1), static_cast<QPointF>(point2)); const auto p1p2 = QLineF(static_cast<QPointF>(point1), static_cast<QPointF>(point2));
angle = p4p3.angleTo(p1p2); angle = p4p3.angleTo(p1p2);
} }

View File

@ -83,7 +83,7 @@ auto VisLine::Ray(const QPointF &firstPoint, const qreal &angle) const -> QPoint
{ {
if (this->scene() == nullptr) if (this->scene() == nullptr)
{ {
QLineF line = QLineF(firstPoint, ScenePos()); auto line = QLineF(firstPoint, ScenePos());
line.setAngle(angle); line.setAngle(angle);
return line.p2(); // We can't find ray because item doesn't have scene. We will return cursor position on scene. return line.p2(); // We can't find ray because item doesn't have scene. We will return cursor position on scene.
} }
@ -91,10 +91,10 @@ auto VisLine::Ray(const QPointF &firstPoint, const qreal &angle) const -> QPoint
QRectF scRect = this->scene()->sceneRect(); QRectF scRect = this->scene()->sceneRect();
// Limit size of the scene rect. Axis that has same size as scene rect cause scene size growth. // Limit size of the scene rect. Axis that has same size as scene rect cause scene size growth.
QLineF line1 = QLineF(scRect.topLeft(), scRect.bottomRight()); auto line1 = QLineF(scRect.topLeft(), scRect.bottomRight());
line1.setLength(2); line1.setLength(2);
QLineF line2 = QLineF(scRect.bottomRight(), scRect.topLeft()); auto line2 = QLineF(scRect.bottomRight(), scRect.topLeft());
line2.setLength(2); line2.setLength(2);
scRect = QRectF(line1.p2(), line2.p2()); scRect = QRectF(line1.p2(), line2.p2());
@ -110,7 +110,7 @@ auto VisLine::Ray(const QPointF &firstPoint, const qreal &angle) const -> QPoint
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VisLine::Ray(const QPointF &firstPoint) const -> QPointF auto VisLine::Ray(const QPointF &firstPoint) const -> QPointF
{ {
QLineF const line = QLineF(firstPoint, ScenePos()); auto const line = QLineF(firstPoint, ScenePos());
return Ray(firstPoint, line.angle()); return Ray(firstPoint, line.angle());
} }

View File

@ -82,7 +82,7 @@ void VisToolNormal::RefreshGeometry()
{ {
QPointF const fPoint = VToolNormal::FindPoint(static_cast<QPointF>(*first), QPointF const fPoint = VToolNormal::FindPoint(static_cast<QPointF>(*first),
static_cast<QPointF>(*second), m_length, m_angle); static_cast<QPointF>(*second), m_length, m_angle);
QLineF const mainLine = QLineF(static_cast<QPointF>(*first), fPoint); auto const mainLine = QLineF(static_cast<QPointF>(*first), fPoint);
DrawLine(this, mainLine, LineStyle()); DrawLine(this, mainLine, LineStyle());
DrawPoint(m_point, mainLine.p2()); DrawPoint(m_point, mainLine.p2());
@ -101,7 +101,7 @@ void VisToolNormal::RefreshGeometry()
QPointF const fPoint = QPointF const fPoint =
VToolNormal::FindPoint(static_cast<QPointF>(*first), static_cast<QPointF>(*second), len, m_angle); VToolNormal::FindPoint(static_cast<QPointF>(*first), static_cast<QPointF>(*second), len, m_angle);
QLineF const mainLine = QLineF(static_cast<QPointF>(*first), fPoint); auto const mainLine = QLineF(static_cast<QPointF>(*first), fPoint);
DrawLine(this, mainLine, LineStyle()); DrawLine(this, mainLine, LineStyle());
DrawPoint(m_point, mainLine.p2()); DrawPoint(m_point, mainLine.p2());

View File

@ -92,7 +92,7 @@ void VisToolShoulderPoint::RefreshGeometry()
QPointF const fPoint = QPointF const fPoint =
VToolShoulderPoint::FindPoint(static_cast<QPointF>(*second), static_cast<QPointF>(*third), VToolShoulderPoint::FindPoint(static_cast<QPointF>(*second), static_cast<QPointF>(*third),
static_cast<QPointF>(*first), m_length); static_cast<QPointF>(*first), m_length);
QLineF const mainLine = QLineF(static_cast<QPointF>(*second), fPoint); auto const mainLine = QLineF(static_cast<QPointF>(*second), fPoint);
DrawLine(this, mainLine, LineStyle()); DrawLine(this, mainLine, LineStyle());
DrawPoint(m_point, mainLine.p2()); DrawPoint(m_point, mainLine.p2());
@ -105,7 +105,7 @@ void VisToolShoulderPoint::RefreshGeometry()
qreal const len = cursorLine.length(); qreal const len = cursorLine.length();
QPointF const fPoint = VToolShoulderPoint::FindPoint( QPointF const fPoint = VToolShoulderPoint::FindPoint(
static_cast<QPointF>(*second), static_cast<QPointF>(*third), static_cast<QPointF>(*first), len); static_cast<QPointF>(*second), static_cast<QPointF>(*third), static_cast<QPointF>(*first), len);
QLineF const mainLine = QLineF(static_cast<QPointF>(*second), fPoint); auto const mainLine = QLineF(static_cast<QPointF>(*second), fPoint);
DrawLine(this, mainLine, LineStyle()); DrawLine(this, mainLine, LineStyle());
DrawPoint(m_point, mainLine.p2()); DrawPoint(m_point, mainLine.p2());

View File

@ -65,7 +65,7 @@ void VisToolArc::RefreshGeometry()
if (GetMode() == Mode::Creation) if (GetMode() == Mode::Creation)
{ {
QLineF const r = QLineF(static_cast<QPointF>(*first), ScenePos()); auto const r = QLineF(static_cast<QPointF>(*first), ScenePos());
auto Angle = [&r]() auto Angle = [&r]()
{ {

View File

@ -63,7 +63,7 @@ void VisToolArcWithLength::RefreshGeometry()
if (GetMode() == Mode::Creation) if (GetMode() == Mode::Creation)
{ {
QLineF const r = QLineF(static_cast<QPointF>(*first), ScenePos()); auto const r = QLineF(static_cast<QPointF>(*first), ScenePos());
auto Angle = [&r]() auto Angle = [&r]()
{ {

View File

@ -52,7 +52,7 @@ void TST_VPointF::TestFlip_data()
QTest::addColumn<QString>("prefix"); QTest::addColumn<QString>("prefix");
VPointF const originPoint; VPointF const originPoint;
QLineF axis = QLineF(QPointF(5, 0), QPointF(5, 10)); auto axis = QLineF(QPointF(5, 0), QPointF(5, 10));
auto flipped = QPointF(10, 0); auto flipped = QPointF(10, 0);
QTest::newRow("Vertical axis") << originPoint << axis << flipped << "a2"; QTest::newRow("Vertical axis") << originPoint << axis << flipped << "a2";
@ -62,7 +62,7 @@ void TST_VPointF::TestFlip_data()
QTest::newRow("Horizontal axis") << originPoint << axis << flipped << "a2"; QTest::newRow("Horizontal axis") << originPoint << axis << flipped << "a2";
QLineF l = QLineF(QPointF(), QPointF(10, 0)); auto l = QLineF(QPointF(), QPointF(10, 0));
l.setAngle(315); l.setAngle(315);
flipped = l.p2(); flipped = l.p2();
l.setLength(l.length() / 2.0); l.setLength(l.length() / 2.0);