From c10279c7e19895c23c0ee108c57a37ee835c484a Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Tue, 23 Aug 2022 16:37:58 +0300 Subject: [PATCH] Refactoring. --- .../vtools/dialogs/tools/dialogalongline.cpp | 20 +-- src/libs/vtools/dialogs/tools/dialogarc.cpp | 23 +-- .../dialogs/tools/dialogarcwithlength.cpp | 22 +-- .../vtools/dialogs/tools/dialogbisector.cpp | 24 +-- .../dialogs/tools/dialogcubicbezier.cpp | 27 ++- .../dialogs/tools/dialogcubicbezierpath.cpp | 8 +- .../tools/dialogcurveintersectaxis.cpp | 8 +- .../vtools/dialogs/tools/dialogcutarc.cpp | 8 +- .../vtools/dialogs/tools/dialogcutspline.cpp | 8 +- .../dialogs/tools/dialogcutsplinepath.cpp | 8 +- .../dialogs/tools/dialogellipticalarc.cpp | 30 ++-- .../vtools/dialogs/tools/dialogendline.cpp | 12 +- .../dialogs/tools/dialogflippingbyaxis.cpp | 5 - .../vtools/dialogs/tools/dialogheight.cpp | 20 +-- src/libs/vtools/dialogs/tools/dialogline.cpp | 12 +- .../dialogs/tools/dialoglineintersect.cpp | 22 +-- .../dialogs/tools/dialoglineintersectaxis.cpp | 20 +-- .../vtools/dialogs/tools/dialognormal.cpp | 18 +- .../tools/dialogpointfromarcandtangent.cpp | 19 +- .../tools/dialogpointfromcircleandtangent.cpp | 19 +- .../dialogs/tools/dialogpointofcontact.cpp | 20 +-- .../tools/dialogpointofintersection.cpp | 14 +- .../tools/dialogpointofintersectionarcs.cpp | 14 +- .../dialogpointofintersectioncircles.cpp | 22 +-- .../tools/dialogpointofintersectioncurves.cpp | 18 +- .../dialogs/tools/dialogshoulderpoint.cpp | 24 +-- .../vtools/dialogs/tools/dialogspline.cpp | 14 +- .../vtools/dialogs/tools/dialogsplinepath.cpp | 2 - .../vtools/dialogs/tools/dialogtriangle.cpp | 23 ++- .../vtools/dialogs/tools/dialogtruedarts.cpp | 30 ++-- .../tools/piece/dialogduplicatedetail.cpp | 1 - .../dialogs/tools/piece/dialogpiecepath.cpp | 3 +- .../vtools/dialogs/tools/piece/dialogpin.cpp | 4 +- .../dialogs/tools/piece/dialogplacelabel.cpp | 12 +- .../tools/piece/dialogseamallowance.cpp | 2 +- .../tools/drawTools/toolcurve/vtoolarc.cpp | 12 +- .../toolcurve/vtoolarcwithlength.cpp | 12 +- .../drawTools/toolcurve/vtoolcubicbezier.cpp | 13 +- .../toolcurve/vtoolcubicbezierpath.cpp | 4 +- .../toolcurve/vtoolellipticalarc.cpp | 14 +- .../tools/drawTools/toolcurve/vtoolspline.cpp | 8 +- .../drawTools/toolcurve/vtoolsplinepath.cpp | 2 +- .../tooldoublepoint/vtooltruedarts.cpp | 10 +- .../toolsinglepoint/toolcut/vtoolcutarc.cpp | 6 +- .../toolcut/vtoolcutspline.cpp | 6 +- .../toolcut/vtoolcutsplinepath.cpp | 6 +- .../toollinepoint/vtoolalongline.cpp | 8 +- .../toollinepoint/vtoolbisector.cpp | 10 +- .../toollinepoint/vtoolcurveintersectaxis.cpp | 4 +- .../toollinepoint/vtoolendline.cpp | 6 +- .../toollinepoint/vtoolheight.cpp | 8 +- .../toollinepoint/vtoollineintersectaxis.cpp | 8 +- .../toollinepoint/vtoollinepoint.h | 12 +- .../toollinepoint/vtoolnormal.cpp | 8 +- .../toollinepoint/vtoolshoulderpoint.cpp | 10 +- .../toolsinglepoint/vtoollineintersect.cpp | 8 +- .../vtoolpointfromarcandtangent.cpp | 6 +- .../vtoolpointfromcircleandtangent.cpp | 8 +- .../toolsinglepoint/vtoolpointofcontact.cpp | 8 +- .../vtoolpointofintersection.cpp | 4 +- .../vtoolpointofintersectionarcs.cpp | 6 +- .../vtoolpointofintersectioncircles.cpp | 10 +- .../vtoolpointofintersectioncurves.cpp | 8 +- .../toolsinglepoint/vtooltriangle.cpp | 10 +- src/libs/vtools/tools/drawTools/vtoolline.cpp | 6 +- .../line/operation/visoperation.cpp | 80 ++++----- .../line/operation/visoperation.h | 54 +++--- .../line/operation/vistoolflippingbyaxis.cpp | 30 +--- .../line/operation/vistoolflippingbyaxis.h | 26 ++- .../line/operation/vistoolflippingbyline.cpp | 41 ++--- .../line/operation/vistoolflippingbyline.h | 25 ++- .../line/operation/vistoolmove.cpp | 165 ++++++++---------- .../line/operation/vistoolmove.h | 58 +++--- .../line/operation/vistoolrotation.cpp | 92 +++++----- .../line/operation/vistoolrotation.h | 30 ++-- .../vtools/visualization/line/visline.cpp | 32 ++-- src/libs/vtools/visualization/line/visline.h | 26 +-- .../visualization/line/vistoolalongline.cpp | 73 ++++---- .../visualization/line/vistoolalongline.h | 30 +++- .../visualization/line/vistoolbisector.cpp | 85 +++++---- .../visualization/line/vistoolbisector.h | 33 +++- .../line/vistoolcurveintersectaxis.cpp | 68 ++++---- .../line/vistoolcurveintersectaxis.h | 45 +++-- .../visualization/line/vistoolendline.cpp | 57 +++--- .../visualization/line/vistoolendline.h | 32 ++-- .../visualization/line/vistoolheight.cpp | 61 +++---- .../vtools/visualization/line/vistoolheight.h | 54 ++++-- .../vtools/visualization/line/vistoolline.cpp | 21 ++- .../vtools/visualization/line/vistoolline.h | 33 +++- .../line/vistoollineintersect.cpp | 74 ++++---- .../visualization/line/vistoollineintersect.h | 60 +++++-- .../line/vistoollineintersectaxis.cpp | 93 +++++----- .../line/vistoollineintersectaxis.h | 60 +++++-- .../visualization/line/vistoolnormal.cpp | 59 ++++--- .../vtools/visualization/line/vistoolnormal.h | 21 ++- .../line/vistoolpointfromarcandtangent.cpp | 44 ++--- .../line/vistoolpointfromarcandtangent.h | 44 +++-- .../line/vistoolpointfromcircleandtangent.cpp | 62 +++---- .../line/vistoolpointfromcircleandtangent.h | 51 ++++-- .../line/vistoolpointofcontact.cpp | 61 +++---- .../line/vistoolpointofcontact.h | 54 ++++-- .../line/vistoolpointofintersection.cpp | 48 ++--- .../line/vistoolpointofintersection.h | 38 ++-- .../line/vistoolpointofintersectionarcs.cpp | 67 ++----- .../line/vistoolpointofintersectionarcs.h | 46 +++-- .../vistoolpointofintersectioncircles.cpp | 79 ++++----- .../line/vistoolpointofintersectioncircles.h | 32 +++- .../line/vistoolshoulderpoint.cpp | 81 +++++---- .../visualization/line/vistoolshoulderpoint.h | 29 ++- .../line/vistoolspecialpoint.cpp | 27 +-- .../visualization/line/vistoolspecialpoint.h | 21 ++- .../visualization/line/vistooltriangle.cpp | 93 +++++----- .../visualization/line/vistooltriangle.h | 69 +++++--- .../visualization/line/vistooltruedarts.cpp | 122 +++++-------- .../visualization/line/vistooltruedarts.h | 79 ++++++--- .../vtools/visualization/path/vispath.cpp | 34 ++-- src/libs/vtools/visualization/path/vispath.h | 24 ++- .../path/vispiecespecialpoints.cpp | 33 ++-- .../path/vispiecespecialpoints.h | 24 +-- .../vtools/visualization/path/vistoolarc.cpp | 97 +++++----- .../vtools/visualization/path/vistoolarc.h | 18 +- .../path/vistoolarcwithlength.cpp | 109 ++++++------ .../visualization/path/vistoolarcwithlength.h | 27 ++- .../visualization/path/vistoolcubicbezier.cpp | 96 ++++------ .../visualization/path/vistoolcubicbezier.h | 60 +++++-- .../path/vistoolcubicbezierpath.cpp | 132 +++++++------- .../path/vistoolcubicbezierpath.h | 42 +++-- .../visualization/path/vistoolcutarc.cpp | 38 ++-- .../vtools/visualization/path/vistoolcutarc.h | 14 +- .../visualization/path/vistoolcutspline.cpp | 38 ++-- .../visualization/path/vistoolcutspline.h | 13 +- .../path/vistoolcutsplinepath.cpp | 41 +++-- .../visualization/path/vistoolcutsplinepath.h | 13 +- .../path/vistoolduplicatedetail.cpp | 30 ++-- .../path/vistoolduplicatedetail.h | 37 ++-- .../path/vistoolellipticalarc.cpp | 46 +++-- .../visualization/path/vistoolellipticalarc.h | 40 +++-- .../visualization/path/vistoolpiece.cpp | 53 +++--- .../vtools/visualization/path/vistoolpiece.h | 39 +++-- .../visualization/path/vistoolpiecepath.cpp | 39 ++--- .../visualization/path/vistoolpiecepath.h | 41 +++-- .../path/vistoolpointofintersectioncurves.cpp | 65 ++----- .../path/vistoolpointofintersectioncurves.h | 53 ++++-- .../visualization/path/vistoolspline.cpp | 95 +++------- .../vtools/visualization/path/vistoolspline.h | 63 ++++++- .../visualization/path/vistoolsplinepath.cpp | 58 +++--- .../visualization/path/vistoolsplinepath.h | 15 +- .../vtools/visualization/visualization.cpp | 118 +++++-------- src/libs/vtools/visualization/visualization.h | 154 +++++++++++----- src/libs/vwidgets/scalesceneitems.cpp | 30 +--- src/libs/vwidgets/scalesceneitems.h | 53 ++++-- 151 files changed, 2917 insertions(+), 2507 deletions(-) diff --git a/src/libs/vtools/dialogs/tools/dialogalongline.cpp b/src/libs/vtools/dialogs/tools/dialogalongline.cpp index a247aec3d..6bd1bb55b 100644 --- a/src/libs/vtools/dialogs/tools/dialogalongline.cpp +++ b/src/libs/vtools/dialogs/tools/dialogalongline.cpp @@ -225,10 +225,10 @@ void DialogAlongLine::SaveData() auto *line = qobject_cast(vis); SCASSERT(line != nullptr) - line->setObject1Id(GetFirstPointId()); - line->setObject2Id(GetSecondPointId()); - line->setLength(m_formula); - line->setLineStyle(LineStyleToPenStyle(GetTypeLine())); + line->SetPoint1Id(GetFirstPointId()); + line->SetPoint2Id(GetSecondPointId()); + line->SetLength(m_formula); + line->SetLineStyle(LineStyleToPenStyle(GetTypeLine())); line->RefreshGeometry(); } @@ -274,7 +274,7 @@ void DialogAlongLine::ChosenSecondPoint(quint32 id, const QString &toolTip) if (m_flagError) { - line->setObject2Id(id); + line->SetPoint2Id(id); if (m_buildMidpoint) { SetFormula(currentLength + QStringLiteral("/2")); @@ -316,7 +316,7 @@ void DialogAlongLine::SetSecondPointId(quint32 value) auto *line = qobject_cast(vis); SCASSERT(line != nullptr) - line->setObject2Id(value); + line->SetPoint2Id(value); } //--------------------------------------------------------------------------------------------------------------------- @@ -339,7 +339,7 @@ void DialogAlongLine::Build(const Tool &type) m_buildMidpoint = true; auto *line = qobject_cast(vis); SCASSERT(line != nullptr) - line->setMidPointMode(m_buildMidpoint); + line->SetMidPointMode(m_buildMidpoint); } } @@ -407,7 +407,7 @@ void DialogAlongLine::SetFirstPointId(quint32 value) auto *line = qobject_cast(vis); SCASSERT(line != nullptr) - line->setObject1Id(value); + line->SetPoint1Id(value); } //--------------------------------------------------------------------------------------------------------------------- @@ -428,7 +428,7 @@ void DialogAlongLine::SetFormula(const QString &value) auto *line = qobject_cast(vis); SCASSERT(line != nullptr) - line->setLength(m_formula); + line->SetLength(m_formula); MoveCursorToEnd(ui->plainTextEditFormula); } @@ -441,7 +441,7 @@ void DialogAlongLine::SetFormula(const QString &value) void DialogAlongLine::SetTypeLine(const QString &value) { ChangeCurrentData(ui->comboBoxLineType, value); - vis->setLineStyle(LineStyleToPenStyle(value)); + vis->SetLineStyle(LineStyleToPenStyle(value)); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/dialogs/tools/dialogarc.cpp b/src/libs/vtools/dialogs/tools/dialogarc.cpp index 80bb3b19a..fd6f62de2 100644 --- a/src/libs/vtools/dialogs/tools/dialogarc.cpp +++ b/src/libs/vtools/dialogs/tools/dialogarc.cpp @@ -154,7 +154,10 @@ DialogArc::~DialogArc() void DialogArc::SetCenter(const quint32 &value) { ChangeCurrentData(ui->comboBoxBasePoint, value); - vis->setObject1Id(value); + + auto *path = qobject_cast(vis); + SCASSERT(path != nullptr) + path->SetCenterId(value); } //--------------------------------------------------------------------------------------------------------------------- @@ -175,7 +178,7 @@ void DialogArc::SetF2(const QString &value) auto *path = qobject_cast(vis); SCASSERT(path != nullptr) - path->setF2(m_f2); + path->SetF2(m_f2); MoveCursorToEnd(ui->plainTextEditF2); } @@ -217,7 +220,7 @@ void DialogArc::SetApproximationScale(qreal value) auto *path = qobject_cast(vis); SCASSERT(path != nullptr) - path->setApproximationScale(value); + path->SetApproximationScale(value); } //--------------------------------------------------------------------------------------------------------------------- @@ -343,7 +346,7 @@ void DialogArc::SetF1(const QString &value) auto *path = qobject_cast(vis); SCASSERT(path != nullptr) - path->setF1(m_f1); + path->SetF1(m_f1); MoveCursorToEnd(ui->plainTextEditF1); } @@ -366,7 +369,7 @@ void DialogArc::SetRadius(const QString &value) auto *path = qobject_cast(vis); SCASSERT(path != nullptr) - path->setRadius(m_radius); + path->SetRadius(m_radius); MoveCursorToEnd(ui->plainTextEditFormula); } @@ -418,11 +421,11 @@ void DialogArc::SaveData() auto *path = qobject_cast(vis); SCASSERT(path != nullptr) - path->setObject1Id(GetCenter()); - path->setRadius(m_radius); - path->setF1(m_f1); - path->setF2(m_f2); - path->setApproximationScale(ui->doubleSpinBoxApproximationScale->value()); + path->SetCenterId(GetCenter()); + path->SetRadius(m_radius); + path->SetF1(m_f1); + path->SetF2(m_f2); + path->SetApproximationScale(ui->doubleSpinBoxApproximationScale->value()); path->RefreshGeometry(); } diff --git a/src/libs/vtools/dialogs/tools/dialogarcwithlength.cpp b/src/libs/vtools/dialogs/tools/dialogarcwithlength.cpp index 6822257d6..987c2f6da 100644 --- a/src/libs/vtools/dialogs/tools/dialogarcwithlength.cpp +++ b/src/libs/vtools/dialogs/tools/dialogarcwithlength.cpp @@ -133,7 +133,9 @@ auto DialogArcWithLength::GetCenter() const -> quint32 void DialogArcWithLength::SetCenter(const quint32 &value) { ChangeCurrentData(ui->comboBoxCenter, value); - vis->setObject1Id(value); + auto *path = qobject_cast(vis); + SCASSERT(path != nullptr) + path->SetCenterId(value); } //--------------------------------------------------------------------------------------------------------------------- @@ -156,7 +158,7 @@ void DialogArcWithLength::SetRadius(const QString &value) auto *path = qobject_cast(vis); SCASSERT(path != nullptr) - path->setRadius(radius); + path->SetRadius(radius); MoveCursorToEnd(ui->plainTextEditRadius); } @@ -181,7 +183,7 @@ void DialogArcWithLength::SetF1(const QString &value) auto *path = qobject_cast(vis); SCASSERT(path != nullptr) - path->setF1(f1); + path->SetF1(f1); MoveCursorToEnd(ui->plainTextEditF1); } @@ -206,7 +208,7 @@ void DialogArcWithLength::SetLength(const QString &value) auto *path = qobject_cast(vis); SCASSERT(path != nullptr) - path->setLength(length); + path->SetLength(length); MoveCursorToEnd(ui->plainTextEditLength); } @@ -248,7 +250,7 @@ void DialogArcWithLength::SetApproximationScale(qreal value) auto *path = qobject_cast(vis); SCASSERT(path != nullptr) - path->setApproximationScale(value); + path->SetApproximationScale(value); } //--------------------------------------------------------------------------------------------------------------------- @@ -462,11 +464,11 @@ void DialogArcWithLength::SaveData() auto *path = qobject_cast(vis); SCASSERT(path != nullptr) - path->setObject1Id(GetCenter()); - path->setRadius(radius); - path->setF1(f1); - path->setLength(length); - path->setApproximationScale(ui->doubleSpinBoxApproximationScale->value()); + path->SetCenterId(GetCenter()); + path->SetRadius(radius); + path->SetF1(f1); + path->SetLength(length); + path->SetApproximationScale(ui->doubleSpinBoxApproximationScale->value()); path->RefreshGeometry(); } diff --git a/src/libs/vtools/dialogs/tools/dialogbisector.cpp b/src/libs/vtools/dialogs/tools/dialogbisector.cpp index ab2cccb18..bc7058319 100644 --- a/src/libs/vtools/dialogs/tools/dialogbisector.cpp +++ b/src/libs/vtools/dialogs/tools/dialogbisector.cpp @@ -218,7 +218,7 @@ void DialogBisector::ChosenObject(quint32 id, const SceneObject &type) if (SetObject(id, ui->comboBoxSecondPoint, tr("Select third point of angle"))) { m_number++; - line->setObject2Id(id); + line->SetPoint2Id(id); line->RefreshGeometry(); } } @@ -251,7 +251,7 @@ void DialogBisector::SetPointName(const QString &value) void DialogBisector::SetTypeLine(const QString &value) { ChangeCurrentData(ui->comboBoxLineType, value); - vis->setLineStyle(LineStyleToPenStyle(value)); + vis->SetLineStyle(LineStyleToPenStyle(value)); } //--------------------------------------------------------------------------------------------------------------------- @@ -272,7 +272,7 @@ void DialogBisector::SetFormula(const QString &value) auto *line = qobject_cast(vis); SCASSERT(line != nullptr) - line->setLength(m_formula); + line->SetLength(m_formula); MoveCursorToEnd(ui->plainTextEditFormula); } @@ -288,7 +288,7 @@ void DialogBisector::SetFirstPointId(const quint32 &value) auto *line = qobject_cast(vis); SCASSERT(line != nullptr) - line->setObject1Id(value); + line->SetPoint1Id(value); } //--------------------------------------------------------------------------------------------------------------------- @@ -302,7 +302,7 @@ void DialogBisector::SetSecondPointId(const quint32 &value) auto *line = qobject_cast(vis); SCASSERT(line != nullptr) - line->setObject2Id(value); + line->SetPoint2Id(value); } //--------------------------------------------------------------------------------------------------------------------- @@ -316,7 +316,7 @@ void DialogBisector::SetThirdPointId(const quint32 &value) auto *line = qobject_cast(vis); SCASSERT(line != nullptr) - line->setObject3Id(value); + line->SetPoint3Id(value); } //--------------------------------------------------------------------------------------------------------------------- @@ -412,11 +412,11 @@ void DialogBisector::SaveData() auto *line = qobject_cast(vis); SCASSERT(line != nullptr) - line->setObject1Id(GetFirstPointId()); - line->setObject2Id(GetSecondPointId()); - line->setObject3Id(GetThirdPointId()); - line->setLength(m_formula); - line->setLineStyle(LineStyleToPenStyle(GetTypeLine())); + line->SetPoint1Id(GetFirstPointId()); + line->SetPoint2Id(GetSecondPointId()); + line->SetPoint3Id(GetThirdPointId()); + line->SetLength(m_formula); + line->SetLineStyle(LineStyleToPenStyle(GetTypeLine())); line->RefreshGeometry(); } @@ -447,7 +447,7 @@ void DialogBisector::ChosenThirdPoint(quint32 id) SCASSERT(line != nullptr) connect(line, &Visualization::ToolTip, window, &VAbstractMainWindow::ShowToolTip); - line->setObject3Id(id); + line->SetPoint3Id(id); line->RefreshGeometry(); prepare = true; } diff --git a/src/libs/vtools/dialogs/tools/dialogcubicbezier.cpp b/src/libs/vtools/dialogs/tools/dialogcubicbezier.cpp index 4db6d3577..1b91da487 100644 --- a/src/libs/vtools/dialogs/tools/dialogcubicbezier.cpp +++ b/src/libs/vtools/dialogs/tools/dialogcubicbezier.cpp @@ -35,7 +35,6 @@ #include #include -#include "../../tools/vabstracttool.h" #include "../../visualization/path/vistoolcubicbezier.h" #include "../../visualization/visualization.h" #include "../vgeometry/vpointf.h" @@ -115,11 +114,11 @@ void DialogCubicBezier::SetSpline(const VCubicBezier &spline) auto path = qobject_cast(vis); SCASSERT(path != nullptr) - path->setApproximationScale(spl.GetApproximationScale()); - path->setObject1Id(spl.GetP1().id()); - path->setObject2Id(spl.GetP2().id()); - path->setObject3Id(spl.GetP3().id()); - path->setObject4Id(spl.GetP4().id()); + path->SetApproximationScale(spl.GetApproximationScale()); + path->SetPoint1Id(spl.GetP1().id()); + path->SetPoint2Id(spl.GetP2().id()); + path->SetPoint3Id(spl.GetP3().id()); + path->SetPoint4Id(spl.GetP4().id()); } //--------------------------------------------------------------------------------------------------------------------- @@ -146,7 +145,7 @@ void DialogCubicBezier::ChosenObject(quint32 id, const SceneObject &type) { ++number; - path->setObject2Id(id); + path->SetPoint2Id(id); path->RefreshGeometry(); } break; @@ -155,7 +154,7 @@ void DialogCubicBezier::ChosenObject(quint32 id, const SceneObject &type) { ++number; - path->setObject3Id(id); + path->SetPoint3Id(id); path->RefreshGeometry(); } break; @@ -166,7 +165,7 @@ void DialogCubicBezier::ChosenObject(quint32 id, const SceneObject &type) { ++number; - path->setObject4Id(id); + path->SetPoint4Id(id); path->RefreshGeometry(); prepare = true; DialogAccepted(); @@ -255,11 +254,11 @@ void DialogCubicBezier::SaveData() auto path = qobject_cast(vis); SCASSERT(path != nullptr) - path->setApproximationScale(ui->doubleSpinBoxApproximationScale->value()); - path->setObject1Id(p1->id()); - path->setObject2Id(p2->id()); - path->setObject3Id(p3->id()); - path->setObject4Id(p4->id()); + path->SetApproximationScale(ui->doubleSpinBoxApproximationScale->value()); + path->SetPoint1Id(p1->id()); + path->SetPoint2Id(p2->id()); + path->SetPoint3Id(p3->id()); + path->SetPoint4Id(p4->id()); path->SetMode(Mode::Show); path->RefreshGeometry(); } diff --git a/src/libs/vtools/dialogs/tools/dialogcubicbezierpath.cpp b/src/libs/vtools/dialogs/tools/dialogcubicbezierpath.cpp index 86568926b..7076cddcc 100644 --- a/src/libs/vtools/dialogs/tools/dialogcubicbezierpath.cpp +++ b/src/libs/vtools/dialogs/tools/dialogcubicbezierpath.cpp @@ -44,12 +44,10 @@ #include #include -#include "../../tools/vabstracttool.h" #include "../../visualization/path/vistoolcubicbezierpath.h" #include "../../visualization/visualization.h" #include "../ifc/ifcdef.h" #include "../vmisc/vabstractapplication.h" -#include "../vmisc/vmath.h" #if QT_VERSION < QT_VERSION_CHECK(5, 7, 0) #include "../vmisc/backport/qoverload.h" #endif // QT_VERSION < QT_VERSION_CHECK(5, 7, 0) @@ -127,7 +125,7 @@ void DialogCubicBezierPath::SetPath(const VCubicBezierPath &value) auto visPath = qobject_cast(vis); SCASSERT(visPath != nullptr) - visPath->setPath(path); + visPath->SetPath(path); ui->listWidget->blockSignals(false); if (ui->listWidget->count() > 0) @@ -155,7 +153,7 @@ void DialogCubicBezierPath::ChosenObject(quint32 id, const SceneObject &type) auto visPath = qobject_cast(vis); SCASSERT(visPath != nullptr) - visPath->setPath(path); + visPath->SetPath(path); if (path.CountPoints() == 1) { @@ -215,7 +213,7 @@ void DialogCubicBezierPath::SaveData() auto visPath = qobject_cast(vis); SCASSERT(visPath != nullptr) - visPath->setPath(path); + visPath->SetPath(path); visPath->SetMode(Mode::Show); visPath->RefreshGeometry(); } diff --git a/src/libs/vtools/dialogs/tools/dialogcurveintersectaxis.cpp b/src/libs/vtools/dialogs/tools/dialogcurveintersectaxis.cpp index c1d00da75..a1061a0f4 100644 --- a/src/libs/vtools/dialogs/tools/dialogcurveintersectaxis.cpp +++ b/src/libs/vtools/dialogs/tools/dialogcurveintersectaxis.cpp @@ -136,7 +136,7 @@ QString DialogCurveIntersectAxis::GetTypeLine() const void DialogCurveIntersectAxis::SetTypeLine(const QString &value) { ChangeCurrentData(ui->comboBoxLineType, value); - vis->setLineStyle(LineStyleToPenStyle(value)); + vis->SetLineStyle(LineStyleToPenStyle(value)); } //--------------------------------------------------------------------------------------------------------------------- @@ -194,7 +194,7 @@ void DialogCurveIntersectAxis::setCurveId(quint32 value) VisToolCurveIntersectAxis *line = qobject_cast(vis); SCASSERT(line != nullptr) - line->setObject1Id(value); + line->SetCurveId(value); } //--------------------------------------------------------------------------------------------------------------------- @@ -342,10 +342,10 @@ void DialogCurveIntersectAxis::SaveData() VisToolCurveIntersectAxis *line = qobject_cast(vis); SCASSERT(line != nullptr) - line->setObject1Id(getCurveId()); + line->SetCurveId(getCurveId()); line->setAxisPointId(GetBasePointId()); line->SetAngle(formulaAngle); - line->setLineStyle(LineStyleToPenStyle(GetTypeLine())); + line->SetLineStyle(LineStyleToPenStyle(GetTypeLine())); line->RefreshGeometry(); } diff --git a/src/libs/vtools/dialogs/tools/dialogcutarc.cpp b/src/libs/vtools/dialogs/tools/dialogcutarc.cpp index 68f052879..1eadc46eb 100644 --- a/src/libs/vtools/dialogs/tools/dialogcutarc.cpp +++ b/src/libs/vtools/dialogs/tools/dialogcutarc.cpp @@ -190,8 +190,8 @@ void DialogCutArc::SaveData() auto *path = qobject_cast(vis); SCASSERT(path != nullptr) - path->setObject1Id(getArcId()); - path->setLength(m_formula); + path->SetArcId(getArcId()); + path->SetLength(m_formula); path->RefreshGeometry(); } @@ -261,7 +261,7 @@ void DialogCutArc::setArcId(quint32 value) auto *path = qobject_cast(vis); SCASSERT(path != nullptr) - path->setObject1Id(value); + path->SetArcId(value); } //--------------------------------------------------------------------------------------------------------------------- @@ -282,7 +282,7 @@ void DialogCutArc::SetFormula(const QString &value) auto *path = qobject_cast(vis); SCASSERT(path != nullptr) - path->setLength(m_formula); + path->SetLength(m_formula); MoveCursorToEnd(ui->plainTextEditFormula); } diff --git a/src/libs/vtools/dialogs/tools/dialogcutspline.cpp b/src/libs/vtools/dialogs/tools/dialogcutspline.cpp index 8410edd64..ecac6d4b2 100644 --- a/src/libs/vtools/dialogs/tools/dialogcutspline.cpp +++ b/src/libs/vtools/dialogs/tools/dialogcutspline.cpp @@ -140,7 +140,7 @@ void DialogCutSpline::SetFormula(const QString &value) auto *path = qobject_cast(vis); SCASSERT(path != nullptr) - path->setLength(m_formula); + path->SetLength(m_formula); MoveCursorToEnd(ui->plainTextEditFormula); } @@ -156,7 +156,7 @@ void DialogCutSpline::setSplineId(quint32 value) auto *path = qobject_cast(vis); SCASSERT(path != nullptr) - path->setObject1Id(value); + path->SetSplineId(value); } //--------------------------------------------------------------------------------------------------------------------- @@ -198,8 +198,8 @@ void DialogCutSpline::SaveData() auto *path = qobject_cast(vis); SCASSERT(path != nullptr) - path->setObject1Id(getSplineId()); - path->setLength(m_formula); + path->SetSplineId(getSplineId()); + path->SetLength(m_formula); path->RefreshGeometry(); } diff --git a/src/libs/vtools/dialogs/tools/dialogcutsplinepath.cpp b/src/libs/vtools/dialogs/tools/dialogcutsplinepath.cpp index 5b658b585..566179fee 100644 --- a/src/libs/vtools/dialogs/tools/dialogcutsplinepath.cpp +++ b/src/libs/vtools/dialogs/tools/dialogcutsplinepath.cpp @@ -140,7 +140,7 @@ void DialogCutSplinePath::SetFormula(const QString &value) auto *path = qobject_cast(vis); SCASSERT(path != nullptr) - path->setLength(m_formula); + path->SetLength(m_formula); MoveCursorToEnd(ui->plainTextEditFormula); } @@ -156,7 +156,7 @@ void DialogCutSplinePath::setSplinePathId(quint32 value) auto *path = qobject_cast(vis); SCASSERT(path != nullptr) - path->setObject1Id(value); + path->SetSplinePathId(value); } //--------------------------------------------------------------------------------------------------------------------- @@ -198,8 +198,8 @@ void DialogCutSplinePath::SaveData() auto *path = qobject_cast(vis); SCASSERT(path != nullptr) - path->setObject1Id(getSplinePathId()); - path->setLength(m_formula); + path->SetSplinePathId(getSplinePathId()); + path->SetLength(m_formula); path->RefreshGeometry(); } diff --git a/src/libs/vtools/dialogs/tools/dialogellipticalarc.cpp b/src/libs/vtools/dialogs/tools/dialogellipticalarc.cpp index 7c213a151..ab8160278 100644 --- a/src/libs/vtools/dialogs/tools/dialogellipticalarc.cpp +++ b/src/libs/vtools/dialogs/tools/dialogellipticalarc.cpp @@ -38,8 +38,6 @@ #include #include -#include "../../tools/vabstracttool.h" -#include "../ifc/xml/vdomdocument.h" #include "../vpatterndb/vtranslatevars.h" #include "../../visualization/path/vistoolellipticalarc.h" #include "../../visualization/visualization.h" @@ -49,6 +47,7 @@ #include "ui_dialogellipticalarc.h" #include "../vgeometry/vellipticalarc.h" #include "../qmuparser/qmudef.h" +#include "../vpatterndb/vcontainer.h" //--------------------------------------------------------------------------------------------------------------------- /** @@ -188,7 +187,10 @@ quint32 DialogEllipticalArc::GetCenter() const void DialogEllipticalArc::SetCenter(const quint32 &value) { ChangeCurrentData(ui->comboBoxBasePoint, value); - vis->setObject1Id(value); + + auto *path = qobject_cast(vis); + SCASSERT(path != nullptr) + path->SetCenterId(value); } //--------------------------------------------------------------------------------------------------------------------- @@ -219,7 +221,7 @@ void DialogEllipticalArc::SetRadius1(const QString &value) VisToolEllipticalArc *path = qobject_cast(vis); SCASSERT(path != nullptr) - path->setRadius1(radius1); + path->SetRadius1(radius1); MoveCursorToEnd(ui->plainTextEditRadius1); } @@ -252,7 +254,7 @@ void DialogEllipticalArc::SetRadius2(const QString &value) VisToolEllipticalArc *path = qobject_cast(vis); SCASSERT(path != nullptr) - path->setRadius2(radius2); + path->SetRadius2(radius2); MoveCursorToEnd(ui->plainTextEditRadius2); } @@ -285,7 +287,7 @@ void DialogEllipticalArc::SetF1(const QString &value) VisToolEllipticalArc *path = qobject_cast(vis); SCASSERT(path != nullptr) - path->setF1(f1); + path->SetF1(f1); MoveCursorToEnd(ui->plainTextEditF1); } @@ -318,7 +320,7 @@ void DialogEllipticalArc::SetF2(const QString &value) VisToolEllipticalArc *path = qobject_cast(vis); SCASSERT(path != nullptr) - path->setF2(f2); + path->SetF2(f2); MoveCursorToEnd(ui->plainTextEditF2); } @@ -351,7 +353,7 @@ void DialogEllipticalArc::SetRotationAngle(const QString &value) VisToolEllipticalArc *path = qobject_cast(vis); SCASSERT(path != nullptr) - path->setRotationAngle(rotationAngle); + path->SetRotationAngle(rotationAngle); MoveCursorToEnd(ui->plainTextEditRotationAngle); } @@ -584,12 +586,12 @@ void DialogEllipticalArc::SaveData() VisToolEllipticalArc *path = qobject_cast(vis); SCASSERT(path != nullptr) - path->setObject1Id(GetCenter()); - path->setRadius1(radius1); - path->setRadius2(radius2); - path->setF1(f1); - path->setF2(f2); - path->setRotationAngle(rotationAngle); + path->SetCenterId(GetCenter()); + path->SetRadius1(radius1); + path->SetRadius2(radius2); + path->SetF1(f1); + path->SetF2(f2); + path->SetRotationAngle(rotationAngle); path->RefreshGeometry(); } diff --git a/src/libs/vtools/dialogs/tools/dialogendline.cpp b/src/libs/vtools/dialogs/tools/dialogendline.cpp index 2689a6ddc..f1844f69a 100644 --- a/src/libs/vtools/dialogs/tools/dialogendline.cpp +++ b/src/libs/vtools/dialogs/tools/dialogendline.cpp @@ -245,7 +245,7 @@ void DialogEndLine::SetPointName(const QString &value) void DialogEndLine::SetTypeLine(const QString &value) { ChangeCurrentData(ui->comboBoxLineType, value); - vis->setLineStyle(LineStyleToPenStyle(value)); + vis->SetLineStyle(LineStyleToPenStyle(value)); } //--------------------------------------------------------------------------------------------------------------------- @@ -267,7 +267,7 @@ void DialogEndLine::SetFormula(const QString &value) auto *line = qobject_cast(vis); SCASSERT(line != nullptr) - line->setLength(formulaLength); + line->SetLength(formulaLength); MoveCursorToEnd(ui->plainTextEditFormula); } @@ -307,7 +307,7 @@ void DialogEndLine::SetBasePointId(const quint32 &value) auto *line = qobject_cast(vis); SCASSERT(line != nullptr) - line->setObject1Id(value); + line->SetBasePointId(value); } //--------------------------------------------------------------------------------------------------------------------- @@ -382,10 +382,10 @@ void DialogEndLine::SaveData() VisToolEndLine *line = qobject_cast(vis); SCASSERT(line != nullptr) - line->setObject1Id(GetBasePointId()); - line->setLength(formulaLength); + line->SetBasePointId(GetBasePointId()); + line->SetLength(formulaLength); line->SetAngle(formulaAngle); - line->setLineStyle(LineStyleToPenStyle(GetTypeLine())); + line->SetLineStyle(LineStyleToPenStyle(GetTypeLine())); line->RefreshGeometry(); } diff --git a/src/libs/vtools/dialogs/tools/dialogflippingbyaxis.cpp b/src/libs/vtools/dialogs/tools/dialogflippingbyaxis.cpp index d8f22ca26..477021ca2 100644 --- a/src/libs/vtools/dialogs/tools/dialogflippingbyaxis.cpp +++ b/src/libs/vtools/dialogs/tools/dialogflippingbyaxis.cpp @@ -50,15 +50,10 @@ #include "../ifc/xml/vabstractpattern.h" #include "../ifc/xml/vdomdocument.h" #include "../qmuparser/qmudef.h" -#include "../vgeometry/vpointf.h" -#include "../vmisc/vabstractapplication.h" -#include "../vmisc/vcommonsettings.h" -#include "../vmisc/compatibility.h" #if QT_VERSION < QT_VERSION_CHECK(5, 7, 0) #include "../vmisc/backport/qoverload.h" #endif // QT_VERSION < QT_VERSION_CHECK(5, 7, 0) #include "../vpatterndb/vcontainer.h" -#include "../vwidgets/vabstractmainwindow.h" #include "../vwidgets/vmaingraphicsscene.h" #include "../vwidgets/vmaingraphicsview.h" #include "ui_dialogflippingbyaxis.h" diff --git a/src/libs/vtools/dialogs/tools/dialogheight.cpp b/src/libs/vtools/dialogs/tools/dialogheight.cpp index ac512d03a..cfd221539 100644 --- a/src/libs/vtools/dialogs/tools/dialogheight.cpp +++ b/src/libs/vtools/dialogs/tools/dialogheight.cpp @@ -123,7 +123,7 @@ void DialogHeight::SetPointName(const QString &value) void DialogHeight::SetTypeLine(const QString &value) { ChangeCurrentData(ui->comboBoxLineType, value); - vis->setLineStyle(LineStyleToPenStyle(value)); + vis->SetLineStyle(LineStyleToPenStyle(value)); } //--------------------------------------------------------------------------------------------------------------------- @@ -137,7 +137,7 @@ void DialogHeight::SetBasePointId(const quint32 &value) auto *line = qobject_cast(vis); SCASSERT(line != nullptr) - line->setObject1Id(value); + line->SetBasePointId(value); } //--------------------------------------------------------------------------------------------------------------------- @@ -151,7 +151,7 @@ void DialogHeight::SetP1LineId(const quint32 &value) auto *line = qobject_cast(vis); SCASSERT(line != nullptr) - line->setLineP1Id(value); + line->SetLineP1Id(value); } //--------------------------------------------------------------------------------------------------------------------- @@ -165,7 +165,7 @@ void DialogHeight::SetP2LineId(const quint32 &value) auto *line = qobject_cast(vis); SCASSERT(line != nullptr) - line->setLineP2Id(value); + line->SetLineP2Id(value); } //--------------------------------------------------------------------------------------------------------------------- @@ -213,7 +213,7 @@ void DialogHeight::ChosenObject(quint32 id, const SceneObject &type) if (SetObject(id, ui->comboBoxP1Line, tr("Select second point of line"))) { m_number++; - line->setLineP1Id(id); + line->SetLineP1Id(id); line->RefreshGeometry(); } } @@ -229,7 +229,7 @@ void DialogHeight::ChosenObject(quint32 id, const SceneObject &type) { if (SetObject(id, ui->comboBoxP2Line, QString())) { - line->setLineP2Id(id); + line->SetLineP2Id(id); line->RefreshGeometry(); prepare = true; DialogAccepted(); @@ -251,10 +251,10 @@ void DialogHeight::SaveData() auto *line = qobject_cast(vis); SCASSERT(line != nullptr) - line->setObject1Id(GetBasePointId()); - line->setLineP1Id(GetP1LineId()); - line->setLineP2Id(GetP2LineId()); - line->setLineStyle(LineStyleToPenStyle(GetTypeLine())); + line->SetBasePointId(GetBasePointId()); + line->SetLineP1Id(GetP1LineId()); + line->SetLineP2Id(GetP2LineId()); + line->SetLineStyle(LineStyleToPenStyle(GetTypeLine())); line->RefreshGeometry(); } diff --git a/src/libs/vtools/dialogs/tools/dialogline.cpp b/src/libs/vtools/dialogs/tools/dialogline.cpp index d0b246932..3e04fcc8f 100644 --- a/src/libs/vtools/dialogs/tools/dialogline.cpp +++ b/src/libs/vtools/dialogs/tools/dialogline.cpp @@ -94,7 +94,7 @@ void DialogLine::SetSecondPoint(quint32 value) VisToolLine *line = qobject_cast(vis); SCASSERT(line != nullptr) - line->setPoint2Id(value); + line->SetPoint2Id(value); } //--------------------------------------------------------------------------------------------------------------------- @@ -105,7 +105,7 @@ void DialogLine::SetSecondPoint(quint32 value) void DialogLine::SetTypeLine(const QString &value) { ChangeCurrentData(ui->comboBoxLineType, value); - vis->setLineStyle(LineStyleToPenStyle(value)); + vis->SetLineStyle(LineStyleToPenStyle(value)); } //--------------------------------------------------------------------------------------------------------------------- @@ -131,7 +131,7 @@ void DialogLine::SetFirstPoint(quint32 value) VisToolLine *line = qobject_cast(vis); SCASSERT(line != nullptr) - line->setObject1Id(value); + line->SetPoint1Id(value); } //--------------------------------------------------------------------------------------------------------------------- @@ -165,9 +165,9 @@ void DialogLine::SaveData() VisToolLine *line = qobject_cast(vis); SCASSERT(line != nullptr) - line->setObject1Id(GetFirstPoint()); - line->setPoint2Id(GetSecondPoint()); - line->setLineStyle(LineStyleToPenStyle(GetTypeLine())); + line->SetPoint1Id(GetFirstPoint()); + line->SetPoint2Id(GetSecondPoint()); + line->SetLineStyle(LineStyleToPenStyle(GetTypeLine())); line->RefreshGeometry(); } diff --git a/src/libs/vtools/dialogs/tools/dialoglineintersect.cpp b/src/libs/vtools/dialogs/tools/dialoglineintersect.cpp index 89e06a050..bee0f2fe9 100644 --- a/src/libs/vtools/dialogs/tools/dialoglineintersect.cpp +++ b/src/libs/vtools/dialogs/tools/dialoglineintersect.cpp @@ -137,7 +137,7 @@ void DialogLineIntersect::ChosenObject(quint32 id, const SceneObject &type) if (SetObject(id, ui->comboBoxP2Line1, tr("Select first point of second line"))) { number++; - line->setLine1P2Id(id); + line->SetLine1P2Id(id); line->RefreshGeometry(); } } @@ -146,7 +146,7 @@ void DialogLineIntersect::ChosenObject(quint32 id, const SceneObject &type) if (SetObject(id, ui->comboBoxP1Line2, tr("Select second point of second line"))) { number++; - line->setLine2P1Id(id); + line->SetLine2P1Id(id); line->RefreshGeometry(); } break; @@ -162,7 +162,7 @@ void DialogLineIntersect::ChosenObject(quint32 id, const SceneObject &type) { if (SetObject(id, ui->comboBoxP2Line2, QString())) { - line->setLine2P2Id(id); + line->SetLine2P2Id(id); line->RefreshGeometry(); prepare = true; flagPoint = CheckIntersecion(); @@ -203,10 +203,10 @@ void DialogLineIntersect::SaveData() VisToolLineIntersect *line = qobject_cast(vis); SCASSERT(line != nullptr) - line->setObject1Id(GetP1Line1()); - line->setLine1P2Id(GetP2Line1()); - line->setLine2P1Id(GetP1Line2()); - line->setLine2P2Id(GetP2Line2()); + line->SetLine1P1Id(GetP1Line1()); + line->SetLine1P2Id(GetP2Line1()); + line->SetLine2P1Id(GetP1Line2()); + line->SetLine2P2Id(GetP2Line2()); line->RefreshGeometry(); } @@ -308,7 +308,7 @@ void DialogLineIntersect::SetP2Line2(quint32 value) VisToolLineIntersect *line = qobject_cast(vis); SCASSERT(line != nullptr) - line->setLine2P2Id(value); + line->SetLine2P2Id(value); } //--------------------------------------------------------------------------------------------------------------------- @@ -328,7 +328,7 @@ void DialogLineIntersect::SetP1Line2(quint32 value) VisToolLineIntersect *line = qobject_cast(vis); SCASSERT(line != nullptr) - line->setLine2P1Id(value); + line->SetLine2P1Id(value); } //--------------------------------------------------------------------------------------------------------------------- @@ -342,7 +342,7 @@ void DialogLineIntersect::SetP2Line1(quint32 value) VisToolLineIntersect *line = qobject_cast(vis); SCASSERT(line != nullptr) - line->setLine1P2Id(value); + line->SetLine1P2Id(value); } //--------------------------------------------------------------------------------------------------------------------- @@ -356,7 +356,7 @@ void DialogLineIntersect::SetP1Line1(quint32 value) VisToolLineIntersect *line = qobject_cast(vis); SCASSERT(line != nullptr) - line->setObject1Id(value); + line->SetLine1P1Id(value); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/dialogs/tools/dialoglineintersectaxis.cpp b/src/libs/vtools/dialogs/tools/dialoglineintersectaxis.cpp index 9a1cc7837..bedce0dcb 100644 --- a/src/libs/vtools/dialogs/tools/dialoglineintersectaxis.cpp +++ b/src/libs/vtools/dialogs/tools/dialoglineintersectaxis.cpp @@ -144,7 +144,7 @@ QString DialogLineIntersectAxis::GetTypeLine() const void DialogLineIntersectAxis::SetTypeLine(const QString &value) { ChangeCurrentData(ui->comboBoxLineType, value); - vis->setLineStyle(LineStyleToPenStyle(value)); + vis->SetLineStyle(LineStyleToPenStyle(value)); } //--------------------------------------------------------------------------------------------------------------------- @@ -186,7 +186,7 @@ void DialogLineIntersectAxis::SetBasePointId(quint32 value) VisToolLineIntersectAxis *line = qobject_cast(vis); SCASSERT(line != nullptr) - line->setAxisPointId(value); + line->SetAxisPointId(value); } //--------------------------------------------------------------------------------------------------------------------- @@ -202,7 +202,7 @@ void DialogLineIntersectAxis::SetFirstPointId(quint32 value) VisToolLineIntersectAxis *line = qobject_cast(vis); SCASSERT(line != nullptr) - line->setObject1Id(value); + line->SetPoint1Id(value); } //--------------------------------------------------------------------------------------------------------------------- @@ -218,7 +218,7 @@ void DialogLineIntersectAxis::SetSecondPointId(quint32 value) VisToolLineIntersectAxis *line = qobject_cast(vis); SCASSERT(line != nullptr) - line->setPoint2Id(value); + line->SetPoint2Id(value); } //--------------------------------------------------------------------------------------------------------------------- @@ -301,7 +301,7 @@ void DialogLineIntersectAxis::ChosenObject(quint32 id, const SceneObject &type) if (SetObject(id, ui->comboBoxSecondLinePoint, tr("Select axis point"))) { number++; - line->setPoint2Id(id); + line->SetPoint2Id(id); line->RefreshGeometry(); } } @@ -317,7 +317,7 @@ void DialogLineIntersectAxis::ChosenObject(quint32 id, const SceneObject &type) { if (SetObject(id, ui->comboBoxAxisPoint, QString())) { - line->setAxisPointId(id); + line->SetAxisPointId(id); line->RefreshGeometry(); prepare = true; } @@ -405,11 +405,11 @@ void DialogLineIntersectAxis::SaveData() VisToolLineIntersectAxis *line = qobject_cast(vis); SCASSERT(line != nullptr) - line->setObject1Id(GetFirstPointId()); - line->setPoint2Id(GetSecondPointId()); - line->setAxisPointId(GetBasePointId()); + line->SetPoint1Id(GetFirstPointId()); + line->SetPoint2Id(GetSecondPointId()); + line->SetAxisPointId(GetBasePointId()); line->SetAngle(formulaAngle); - line->setLineStyle(LineStyleToPenStyle(GetTypeLine())); + line->SetLineStyle(LineStyleToPenStyle(GetTypeLine())); line->RefreshGeometry(); } diff --git a/src/libs/vtools/dialogs/tools/dialognormal.cpp b/src/libs/vtools/dialogs/tools/dialognormal.cpp index e07f067bb..2a80c9f4f 100644 --- a/src/libs/vtools/dialogs/tools/dialognormal.cpp +++ b/src/libs/vtools/dialogs/tools/dialognormal.cpp @@ -217,7 +217,7 @@ void DialogNormal::ChosenObject(quint32 id, const SceneObject &type) { if (SetObject(id, ui->comboBoxSecondPoint, QString())) { - line->setObject2Id(id); + line->SetPoint2Id(id); line->RefreshGeometry(); prepare = true; @@ -244,11 +244,11 @@ void DialogNormal::SaveData() auto *line = qobject_cast(vis); SCASSERT(line != nullptr) - line->setObject1Id(GetFirstPointId()); - line->setObject2Id(GetSecondPointId()); - line->setLength(m_formula); + line->SetPoint1Id(GetFirstPointId()); + line->SetPoint2Id(GetSecondPointId()); + line->SetLength(m_formula); line->SetAngle(m_angle); - line->setLineStyle(LineStyleToPenStyle(GetTypeLine())); + line->SetLineStyle(LineStyleToPenStyle(GetTypeLine())); line->RefreshGeometry(); } @@ -270,7 +270,7 @@ void DialogNormal::SetSecondPointId(quint32 value) auto *line = qobject_cast(vis); SCASSERT(line != nullptr) - line->setObject2Id(value); + line->SetPoint2Id(value); } //--------------------------------------------------------------------------------------------------------------------- @@ -296,7 +296,7 @@ void DialogNormal::SetFirstPointId(quint32 value) auto *line = qobject_cast(vis); SCASSERT(line != nullptr) - line->setObject1Id(value); + line->SetPoint1Id(value); } //--------------------------------------------------------------------------------------------------------------------- @@ -332,7 +332,7 @@ void DialogNormal::SetFormula(const QString &value) auto *line = qobject_cast(vis); SCASSERT(line != nullptr) - line->setLength(m_formula); + line->SetLength(m_formula); MoveCursorToEnd(ui->plainTextEditFormula); } @@ -345,7 +345,7 @@ void DialogNormal::SetFormula(const QString &value) void DialogNormal::SetTypeLine(const QString &value) { ChangeCurrentData(ui->comboBoxLineType, value); - vis->setLineStyle(LineStyleToPenStyle(value)); + vis->SetLineStyle(LineStyleToPenStyle(value)); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/dialogs/tools/dialogpointfromarcandtangent.cpp b/src/libs/vtools/dialogs/tools/dialogpointfromarcandtangent.cpp index b0e5dcc18..9955c3aec 100644 --- a/src/libs/vtools/dialogs/tools/dialogpointfromarcandtangent.cpp +++ b/src/libs/vtools/dialogs/tools/dialogpointfromarcandtangent.cpp @@ -34,7 +34,6 @@ #include "../../visualization/visualization.h" #include "../../visualization/line/vistoolpointfromarcandtangent.h" -#include "../vmisc/vabstractapplication.h" #include "dialogs/tools/dialogtool.h" #include "ui_dialogpointfromarcandtangent.h" @@ -102,7 +101,7 @@ void DialogPointFromArcAndTangent::SetArcId(quint32 value) VisToolPointFromArcAndTangent *point = qobject_cast(vis); SCASSERT(point != nullptr) - point->setArcId(value); + point->SetArcId(value); } //--------------------------------------------------------------------------------------------------------------------- @@ -116,9 +115,9 @@ void DialogPointFromArcAndTangent::SetTangentPointId(quint32 value) { setCurrentPointId(ui->comboBoxTangentPoint, value); - VisToolPointFromArcAndTangent *point = qobject_cast(vis); + auto *point = qobject_cast(vis); SCASSERT(point != nullptr) - point->setObject1Id(value); + point->SetPointId(value); } //--------------------------------------------------------------------------------------------------------------------- @@ -137,7 +136,7 @@ void DialogPointFromArcAndTangent::SetCrossCirclesPoint(CrossCirclesPoint p) VisToolPointFromArcAndTangent *point = qobject_cast(vis); SCASSERT(point != nullptr) - point->setCrossPoint(p); + point->SetCrossPoint(p); } } @@ -169,7 +168,7 @@ void DialogPointFromArcAndTangent::ChosenObject(quint32 id, const SceneObject &t if (SetObject(id, ui->comboBoxArc, QString())) { number = 0; - point->setArcId(id); + point->SetArcId(id); point->RefreshGeometry(); prepare = true; DialogAccepted(); @@ -194,12 +193,12 @@ void DialogPointFromArcAndTangent::SaveData() { pointName = ui->lineEditNamePoint->text(); - VisToolPointFromArcAndTangent *point = qobject_cast(vis); + auto *point = qobject_cast(vis); SCASSERT(point != nullptr) - point->setObject1Id(GetTangentPointId()); - point->setArcId(GetArcId()); - point->setCrossPoint(GetCrossCirclesPoint()); + point->SetPointId(GetTangentPointId()); + point->SetArcId(GetArcId()); + point->SetCrossPoint(GetCrossCirclesPoint()); point->RefreshGeometry(); } diff --git a/src/libs/vtools/dialogs/tools/dialogpointfromcircleandtangent.cpp b/src/libs/vtools/dialogs/tools/dialogpointfromcircleandtangent.cpp index 33e208a3d..677156b97 100644 --- a/src/libs/vtools/dialogs/tools/dialogpointfromcircleandtangent.cpp +++ b/src/libs/vtools/dialogs/tools/dialogpointfromcircleandtangent.cpp @@ -45,7 +45,6 @@ #include "../vpatterndb/vcontainer.h" #include "../../visualization/visualization.h" #include "../../visualization/line/vistoolpointfromcircleandtangent.h" -#include "../ifc/xml/vdomdocument.h" #include "../support/dialogeditwrongformula.h" #include "../vmisc/vabstractapplication.h" #include "../vmisc/vcommonsettings.h" @@ -141,7 +140,7 @@ void DialogPointFromCircleAndTangent::SetCircleCenterId(const quint32 &value) VisToolPointFromCircleAndTangent *point = qobject_cast(vis); SCASSERT(point != nullptr) - point->setObject2Id(value); + point->SetCenterId(value); } //--------------------------------------------------------------------------------------------------------------------- @@ -165,7 +164,7 @@ void DialogPointFromCircleAndTangent::SetCircleRadius(const QString &value) VisToolPointFromCircleAndTangent *point = qobject_cast(vis); SCASSERT(point != nullptr) - point->setCRadius(formula); + point->SetCRadius(formula); MoveCursorToEnd(ui->plainTextEditRadius); } @@ -183,7 +182,7 @@ void DialogPointFromCircleAndTangent::SetTangentPointId(const quint32 &value) VisToolPointFromCircleAndTangent *point = qobject_cast(vis); SCASSERT(point != nullptr) - point->setObject1Id(value); + point->SetPointId(value); } //--------------------------------------------------------------------------------------------------------------------- @@ -202,7 +201,7 @@ void DialogPointFromCircleAndTangent::SetCrossCirclesPoint(const CrossCirclesPoi VisToolPointFromCircleAndTangent *point = qobject_cast(vis); SCASSERT(point != nullptr) - point->setCrossPoint(p); + point->SetCrossPoint(p); } } @@ -231,7 +230,7 @@ void DialogPointFromCircleAndTangent::ChosenObject(quint32 id, const SceneObject if (SetObject(id, ui->comboBoxCircleCenter, QString())) { number = 0; - point->setObject2Id(id); + point->SetCenterId(id); point->RefreshGeometry(); prepare = true; this->setModal(true); @@ -322,10 +321,10 @@ void DialogPointFromCircleAndTangent::SaveData() VisToolPointFromCircleAndTangent *point = qobject_cast(vis); SCASSERT(point != nullptr) - point->setObject1Id(GetTangentPointId()); - point->setObject2Id(GetCircleCenterId()); - point->setCRadius(ui->plainTextEditRadius->toPlainText()); - point->setCrossPoint(GetCrossCirclesPoint()); + point->SetPointId(GetTangentPointId()); + point->SetCenterId(GetCircleCenterId()); + point->SetCRadius(ui->plainTextEditRadius->toPlainText()); + point->SetCrossPoint(GetCrossCirclesPoint()); point->RefreshGeometry(); } diff --git a/src/libs/vtools/dialogs/tools/dialogpointofcontact.cpp b/src/libs/vtools/dialogs/tools/dialogpointofcontact.cpp index 3cf1e9726..5d720855d 100644 --- a/src/libs/vtools/dialogs/tools/dialogpointofcontact.cpp +++ b/src/libs/vtools/dialogs/tools/dialogpointofcontact.cpp @@ -216,7 +216,7 @@ void DialogPointOfContact::ChosenObject(quint32 id, const SceneObject &type) if (SetObject(id, ui->comboBoxSecondPoint, tr("Select point of center of arc"))) { number++; - line->setLineP2Id(id); + line->SetLineP2Id(id); line->RefreshGeometry(); } } @@ -232,7 +232,7 @@ void DialogPointOfContact::ChosenObject(quint32 id, const SceneObject &type) { if (SetObject(id, ui->comboBoxCenter, QString())) { - line->setRadiusId(id); + line->SetRadiusId(id); line->RefreshGeometry(); prepare = true; this->setModal(true); @@ -257,10 +257,10 @@ void DialogPointOfContact::SaveData() VisToolPointOfContact *line = qobject_cast(vis); SCASSERT(line != nullptr) - line->setObject1Id(GetFirstPoint()); - line->setLineP2Id(GetSecondPoint()); - line->setRadiusId(getCenter()); - line->setRadius(radius); + line->SetLineP1Id(GetFirstPoint()); + line->SetLineP2Id(GetSecondPoint()); + line->SetRadiusId(getCenter()); + line->SetRadius(radius); line->RefreshGeometry(); } @@ -282,7 +282,7 @@ void DialogPointOfContact::SetSecondPoint(quint32 value) VisToolPointOfContact *line = qobject_cast(vis); SCASSERT(line != nullptr) - line->setLineP2Id(value); + line->SetLineP2Id(value); } //--------------------------------------------------------------------------------------------------------------------- @@ -296,7 +296,7 @@ void DialogPointOfContact::SetFirstPoint(quint32 value) VisToolPointOfContact *line = qobject_cast(vis); SCASSERT(line != nullptr) - line->setObject1Id(value); + line->SetLineP1Id(value); } //--------------------------------------------------------------------------------------------------------------------- @@ -310,7 +310,7 @@ void DialogPointOfContact::setCenter(quint32 value) VisToolPointOfContact *line = qobject_cast(vis); SCASSERT(line != nullptr) - line->setRadiusId(value); + line->SetRadiusId(value); } //--------------------------------------------------------------------------------------------------------------------- @@ -331,7 +331,7 @@ void DialogPointOfContact::setRadius(const QString &value) VisToolPointOfContact *line = qobject_cast(vis); SCASSERT(line != nullptr) - line->setRadius(radius); + line->SetRadius(radius); MoveCursorToEnd(ui->plainTextEditFormula); } diff --git a/src/libs/vtools/dialogs/tools/dialogpointofintersection.cpp b/src/libs/vtools/dialogs/tools/dialogpointofintersection.cpp index 80de3dee9..727427949 100644 --- a/src/libs/vtools/dialogs/tools/dialogpointofintersection.cpp +++ b/src/libs/vtools/dialogs/tools/dialogpointofintersection.cpp @@ -37,8 +37,6 @@ #include "../../visualization/visualization.h" #include "../../visualization/line/vistoolpointofintersection.h" #include "../ifc/xml/vabstractpattern.h" -#include "../ifc/ifcdef.h" -#include "../vmisc/vabstractapplication.h" #include "dialogtool.h" #include "ui_dialogpointofintersection.h" @@ -107,7 +105,7 @@ void DialogPointOfIntersection::SetSecondPointId(quint32 value) VisToolPointOfIntersection *line = qobject_cast(vis); SCASSERT(line != nullptr) - line->setPoint2Id(value); + line->SetPoint2Id(value); } //--------------------------------------------------------------------------------------------------------------------- @@ -131,7 +129,7 @@ void DialogPointOfIntersection::ChosenObject(quint32 id, const SceneObject &type if (SetObject(id, ui->comboBoxFirstPoint, tr("Select point for Y value (horizontal)"))) { number++; - line->setObject1Id(id); + line->SetPoint1Id(id); line->RefreshGeometry(); } break; @@ -140,7 +138,7 @@ void DialogPointOfIntersection::ChosenObject(quint32 id, const SceneObject &type { if (SetObject(id, ui->comboBoxSecondPoint, QString())) { - line->setPoint2Id(id); + line->SetPoint2Id(id); line->RefreshGeometry(); prepare = true; DialogAccepted(); @@ -162,8 +160,8 @@ void DialogPointOfIntersection::SaveData() VisToolPointOfIntersection *line = qobject_cast(vis); SCASSERT(line != nullptr) - line->setObject1Id(GetFirstPointId()); - line->setPoint2Id(GetSecondPointId()); + line->SetPoint1Id(GetFirstPointId()); + line->SetPoint2Id(GetSecondPointId()); line->RefreshGeometry(); } @@ -203,7 +201,7 @@ void DialogPointOfIntersection::SetFirstPointId(quint32 value) VisToolPointOfIntersection *line = qobject_cast(vis); SCASSERT(line != nullptr) - line->setObject1Id(value); + line->SetPoint1Id(value); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/dialogs/tools/dialogpointofintersectionarcs.cpp b/src/libs/vtools/dialogs/tools/dialogpointofintersectionarcs.cpp index 888e2e8ad..4034baa57 100644 --- a/src/libs/vtools/dialogs/tools/dialogpointofintersectionarcs.cpp +++ b/src/libs/vtools/dialogs/tools/dialogpointofintersectionarcs.cpp @@ -109,7 +109,7 @@ void DialogPointOfIntersectionArcs::SetFirstArcId(quint32 value) VisToolPointOfIntersectionArcs *point = qobject_cast(vis); SCASSERT(point != nullptr) - point->setArc1Id(value); + point->SetArc1Id(value); } //--------------------------------------------------------------------------------------------------------------------- @@ -125,7 +125,7 @@ void DialogPointOfIntersectionArcs::SetSecondArcId(quint32 value) VisToolPointOfIntersectionArcs *point = qobject_cast(vis); SCASSERT(point != nullptr) - point->setArc2Id(value); + point->SetArc2Id(value); } //--------------------------------------------------------------------------------------------------------------------- @@ -144,7 +144,7 @@ void DialogPointOfIntersectionArcs::SetCrossArcPoint(CrossCirclesPoint p) VisToolPointOfIntersectionArcs *point = qobject_cast(vis); SCASSERT(point != nullptr) - point->setCrossPoint(p); + point->SetCrossPoint(p); } } @@ -173,7 +173,7 @@ void DialogPointOfIntersectionArcs::ChosenObject(quint32 id, const SceneObject & if (SetObject(id, ui->comboBoxArc2, QString())) { number = 0; - point->setArc2Id(id); + point->SetArc2Id(id); point->RefreshGeometry(); prepare = true; DialogAccepted(); @@ -220,9 +220,9 @@ void DialogPointOfIntersectionArcs::SaveData() VisToolPointOfIntersectionArcs *point = qobject_cast(vis); SCASSERT(point != nullptr) - point->setArc1Id(GetFirstArcId()); - point->setArc2Id(GetSecondArcId()); - point->setCrossPoint(GetCrossArcPoint()); + point->SetArc1Id(GetFirstArcId()); + point->SetArc2Id(GetSecondArcId()); + point->SetCrossPoint(GetCrossArcPoint()); point->RefreshGeometry(); } diff --git a/src/libs/vtools/dialogs/tools/dialogpointofintersectioncircles.cpp b/src/libs/vtools/dialogs/tools/dialogpointofintersectioncircles.cpp index 15cf40739..4a613ed3a 100644 --- a/src/libs/vtools/dialogs/tools/dialogpointofintersectioncircles.cpp +++ b/src/libs/vtools/dialogs/tools/dialogpointofintersectioncircles.cpp @@ -153,7 +153,7 @@ void DialogPointOfIntersectionCircles::SetFirstCircleCenterId(const quint32 &val auto *point = qobject_cast(vis); SCASSERT(point != nullptr) - point->setObject1Id(value); + point->SetCircle1Id(value); } //--------------------------------------------------------------------------------------------------------------------- @@ -169,7 +169,7 @@ void DialogPointOfIntersectionCircles::SetSecondCircleCenterId(const quint32 &va auto *point = qobject_cast(vis); SCASSERT(point != nullptr) - point->setObject2Id(value); + point->SetCircle2Id(value); } //--------------------------------------------------------------------------------------------------------------------- @@ -193,7 +193,7 @@ void DialogPointOfIntersectionCircles::SetFirstCircleRadius(const QString &value auto *point = qobject_cast(vis); SCASSERT(point != nullptr) - point->setC1Radius(formula); + point->SetC1Radius(formula); MoveCursorToEnd(ui->plainTextEditCircle1Radius); } @@ -219,7 +219,7 @@ void DialogPointOfIntersectionCircles::SetSecondCircleRadius(const QString &valu auto *point = qobject_cast(vis); SCASSERT(point != nullptr) - point->setC2Radius(formula); + point->SetC2Radius(formula); MoveCursorToEnd(ui->plainTextEditCircle2Radius); } @@ -240,7 +240,7 @@ void DialogPointOfIntersectionCircles::SetCrossCirclesPoint(const CrossCirclesPo auto *point = qobject_cast(vis); SCASSERT(point != nullptr) - point->setCrossPoint(p); + point->SetCrossPoint(p); } } @@ -337,7 +337,7 @@ void DialogPointOfIntersectionCircles::ChosenObject(quint32 id, const SceneObjec { if (SetObject(id, ui->comboBoxCircle2Center, QString())) { - point->setObject2Id(id); + point->SetCircle2Id(id); point->RefreshGeometry(); ++m_stage; prepare = true; @@ -469,11 +469,11 @@ void DialogPointOfIntersectionCircles::SaveData() auto *point = qobject_cast(vis); SCASSERT(point != nullptr) - point->setObject1Id(GetFirstCircleCenterId()); - point->setObject2Id(GetSecondCircleCenterId()); - point->setC1Radius(ui->plainTextEditCircle1Radius->toPlainText()); - point->setC2Radius(ui->plainTextEditCircle2Radius->toPlainText()); - point->setCrossPoint(GetCrossCirclesPoint()); + point->SetCircle1Id(GetFirstCircleCenterId()); + point->SetCircle2Id(GetSecondCircleCenterId()); + point->SetC1Radius(ui->plainTextEditCircle1Radius->toPlainText()); + point->SetC2Radius(ui->plainTextEditCircle2Radius->toPlainText()); + point->SetCrossPoint(GetCrossCirclesPoint()); point->RefreshGeometry(); } diff --git a/src/libs/vtools/dialogs/tools/dialogpointofintersectioncurves.cpp b/src/libs/vtools/dialogs/tools/dialogpointofintersectioncurves.cpp index b16ce1858..088958238 100644 --- a/src/libs/vtools/dialogs/tools/dialogpointofintersectioncurves.cpp +++ b/src/libs/vtools/dialogs/tools/dialogpointofintersectioncurves.cpp @@ -117,7 +117,7 @@ void DialogPointOfIntersectionCurves::SetFirstCurveId(quint32 value) auto point = qobject_cast(vis); SCASSERT(point != nullptr) - point->setObject1Id(value); + point->SetCurve1Id(value); } //--------------------------------------------------------------------------------------------------------------------- @@ -133,7 +133,7 @@ void DialogPointOfIntersectionCurves::SetSecondCurveId(quint32 value) auto point = qobject_cast(vis); SCASSERT(point != nullptr) - point->setObject2Id(value); + point->SetCurve2Id(value); } //--------------------------------------------------------------------------------------------------------------------- @@ -152,7 +152,7 @@ void DialogPointOfIntersectionCurves::SetVCrossPoint(VCrossCurvesPoint vP) auto point = qobject_cast(vis); SCASSERT(point != nullptr) - point->setVCrossPoint(vP); + point->SetVCrossPoint(vP); } } @@ -172,7 +172,7 @@ void DialogPointOfIntersectionCurves::SetHCrossPoint(HCrossCurvesPoint hP) auto point = qobject_cast(vis); SCASSERT(point != nullptr) - point->setHCrossPoint(hP); + point->SetHCrossPoint(hP); } } @@ -204,7 +204,7 @@ void DialogPointOfIntersectionCurves::ChosenObject(quint32 id, const SceneObject if (SetObject(id, ui->comboBoxCurve2, QString())) { number = 0; - point->setObject2Id(id); + point->SetCurve2Id(id); point->RefreshGeometry(); prepare = true; DialogAccepted(); @@ -232,10 +232,10 @@ void DialogPointOfIntersectionCurves::SaveData() auto point = qobject_cast(vis); SCASSERT(point != nullptr) - point->setObject1Id(GetFirstCurveId()); - point->setObject2Id(GetSecondCurveId()); - point->setVCrossPoint(GetVCrossPoint()); - point->setHCrossPoint(GetHCrossPoint()); + point->SetCurve1Id(GetFirstCurveId()); + point->SetCurve2Id(GetSecondCurveId()); + point->SetVCrossPoint(GetVCrossPoint()); + point->SetHCrossPoint(GetHCrossPoint()); point->RefreshGeometry(); } diff --git a/src/libs/vtools/dialogs/tools/dialogshoulderpoint.cpp b/src/libs/vtools/dialogs/tools/dialogshoulderpoint.cpp index 1b6644d25..a7c966fb6 100644 --- a/src/libs/vtools/dialogs/tools/dialogshoulderpoint.cpp +++ b/src/libs/vtools/dialogs/tools/dialogshoulderpoint.cpp @@ -216,7 +216,7 @@ void DialogShoulderPoint::ChosenObject(quint32 id, const SceneObject &type) if (SetObject(id, ui->comboBoxP1Line, tr("Select second point of line"))) { m_number++; - line->setLineP1Id(id); + line->SetLineP1Id(id); line->RefreshGeometry(); } } @@ -239,11 +239,11 @@ void DialogShoulderPoint::SaveData() auto *line = qobject_cast(vis); SCASSERT(line != nullptr) - line->setObject1Id(GetP3()); - line->setLineP1Id(GetP1Line()); - line->setLineP2Id(GetP2Line()); - line->setLength(m_formula); - line->setLineStyle(LineStyleToPenStyle(GetTypeLine())); + line->SetPoint3Id(GetP3()); + line->SetLineP1Id(GetP1Line()); + line->SetLineP2Id(GetP2Line()); + line->SetLength(m_formula); + line->SetLineStyle(LineStyleToPenStyle(GetTypeLine())); line->RefreshGeometry(); } @@ -274,7 +274,7 @@ void DialogShoulderPoint::ChosenThirdPoint(quint32 id) SCASSERT(line != nullptr) connect(line, &Visualization::ToolTip, window, &VAbstractMainWindow::ShowToolTip); - line->setLineP2Id(id); + line->SetLineP2Id(id); line->RefreshGeometry(); prepare = true; } @@ -292,7 +292,7 @@ void DialogShoulderPoint::SetP3(const quint32 &value) auto *line = qobject_cast(vis); SCASSERT(line != nullptr) - line->setObject1Id(value); + line->SetPoint3Id(value); } //--------------------------------------------------------------------------------------------------------------------- @@ -318,7 +318,7 @@ void DialogShoulderPoint::SetP2Line(const quint32 &value) auto *line = qobject_cast(vis); SCASSERT(line != nullptr) - line->setLineP2Id(value); + line->SetLineP2Id(value); } //--------------------------------------------------------------------------------------------------------------------- @@ -332,7 +332,7 @@ void DialogShoulderPoint::SetP1Line(const quint32 &value) auto *line = qobject_cast(vis); SCASSERT(line != nullptr) - line->setLineP1Id(value); + line->SetLineP1Id(value); } //--------------------------------------------------------------------------------------------------------------------- @@ -353,7 +353,7 @@ void DialogShoulderPoint::SetFormula(const QString &value) auto *line = qobject_cast(vis); SCASSERT(line != nullptr) - line->setLength(m_formula); + line->SetLength(m_formula); MoveCursorToEnd(ui->plainTextEditFormula); } @@ -365,7 +365,7 @@ void DialogShoulderPoint::SetFormula(const QString &value) void DialogShoulderPoint::SetTypeLine(const QString &value) { ChangeCurrentData(ui->comboBoxLineType, value); - vis->setLineStyle(LineStyleToPenStyle(value)); + vis->SetLineStyle(LineStyleToPenStyle(value)); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/dialogs/tools/dialogspline.cpp b/src/libs/vtools/dialogs/tools/dialogspline.cpp index d8b854f1e..8376b196e 100644 --- a/src/libs/vtools/dialogs/tools/dialogspline.cpp +++ b/src/libs/vtools/dialogs/tools/dialogspline.cpp @@ -202,7 +202,7 @@ void DialogSpline::ChosenObject(quint32 id, const SceneObject &type) { ++number; - path->SetObject4Id(id); + path->SetPoint4Id(id); path->RefreshGeometry(); prepare = true; } @@ -227,14 +227,14 @@ void DialogSpline::SaveData() auto path = qobject_cast(vis); SCASSERT(path != nullptr) - path->setObject1Id(GetP1()->id()); - path->SetObject4Id(GetP4()->id()); + path->SetPoint1Id(GetP1()->id()); + path->SetPoint4Id(GetP4()->id()); path->SetAngle1(spl.GetStartAngle()); path->SetAngle2(spl.GetEndAngle()); path->SetKAsm1(spl.GetKasm1()); path->SetKAsm2(spl.GetKasm2()); path->SetKCurve(spl.GetKcurve()); - path->setApproximationScale(spl.GetApproximationScale()); + path->SetApproximationScale(spl.GetApproximationScale()); path->SetMode(Mode::Show); path->RefreshGeometry(); } @@ -631,14 +631,14 @@ void DialogSpline::SetSpline(const VSpline &spline) auto path = qobject_cast(vis); SCASSERT(path != nullptr) - path->setObject1Id(spl.GetP1().id()); - path->SetObject4Id(spl.GetP4().id()); + path->SetPoint1Id(spl.GetP1().id()); + path->SetPoint4Id(spl.GetP4().id()); path->SetAngle1(spl.GetStartAngle()); path->SetAngle2(spl.GetEndAngle()); path->SetKAsm1(spl.GetKasm1()); path->SetKAsm2(spl.GetKasm2()); path->SetKCurve(spl.GetKcurve()); - path->setApproximationScale(spl.GetApproximationScale()); + path->SetApproximationScale(spl.GetApproximationScale()); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/dialogs/tools/dialogsplinepath.cpp b/src/libs/vtools/dialogs/tools/dialogsplinepath.cpp index f549beaf5..8f9fe2962 100644 --- a/src/libs/vtools/dialogs/tools/dialogsplinepath.cpp +++ b/src/libs/vtools/dialogs/tools/dialogsplinepath.cpp @@ -47,11 +47,9 @@ #include #include -#include "../../tools/vabstracttool.h" #include "../../visualization/visualization.h" #include "../../visualization/path/vistoolsplinepath.h" #include "../ifc/xml/vdomdocument.h" -#include "../qmuparser/qmuparsererror.h" #include "../support/dialogeditwrongformula.h" #include "../vgeometry/../ifc/ifcdef.h" #include "../vgeometry/vpointf.h" diff --git a/src/libs/vtools/dialogs/tools/dialogtriangle.cpp b/src/libs/vtools/dialogs/tools/dialogtriangle.cpp index ea6fbbf0b..7be58e250 100644 --- a/src/libs/vtools/dialogs/tools/dialogtriangle.cpp +++ b/src/libs/vtools/dialogs/tools/dialogtriangle.cpp @@ -38,7 +38,6 @@ #include "../../visualization/visualization.h" #include "../../visualization/line/vistooltriangle.h" #include "../ifc/xml/vabstractpattern.h" -#include "../vmisc/vabstractapplication.h" #include "dialogtool.h" #include "ui_dialogtriangle.h" @@ -125,7 +124,7 @@ void DialogTriangle::ChosenObject(quint32 id, const SceneObject &type) if (SetObject(id, ui->comboBoxAxisP2, tr("Select first point"))) { number++; - line->setObject2Id(id); + line->SetObject2Id(id); line->RefreshGeometry(); } } @@ -142,7 +141,7 @@ void DialogTriangle::ChosenObject(quint32 id, const SceneObject &type) if (SetObject(id, ui->comboBoxFirstPoint, tr("Select second point"))) { number++; - line->setHypotenuseP1Id(id); + line->SetHypotenuseP1Id(id); line->RefreshGeometry(); } } @@ -160,7 +159,7 @@ void DialogTriangle::ChosenObject(quint32 id, const SceneObject &type) { if (SetObject(id, ui->comboBoxSecondPoint, QString())) { - line->setHypotenuseP2Id(id); + line->SetHypotenuseP2Id(id); line->RefreshGeometry(); prepare = true; DialogAccepted(); @@ -183,10 +182,10 @@ void DialogTriangle::SaveData() VisToolTriangle *line = qobject_cast(vis); SCASSERT(line != nullptr) - line->setObject1Id(GetAxisP1Id()); - line->setObject2Id(GetAxisP2Id()); - line->setHypotenuseP1Id(GetFirstPointId()); - line->setHypotenuseP2Id(GetSecondPointId()); + line->SetObject1Id(GetAxisP1Id()); + line->SetObject2Id(GetAxisP2Id()); + line->SetHypotenuseP1Id(GetFirstPointId()); + line->SetHypotenuseP2Id(GetSecondPointId()); line->RefreshGeometry(); } @@ -245,7 +244,7 @@ void DialogTriangle::SetSecondPointId(const quint32 &value) VisToolTriangle *line = qobject_cast(vis); SCASSERT(line != nullptr) - line->setHypotenuseP2Id(value); + line->SetHypotenuseP2Id(value); } //--------------------------------------------------------------------------------------------------------------------- @@ -265,7 +264,7 @@ void DialogTriangle::SetFirstPointId(const quint32 &value) VisToolTriangle *line = qobject_cast(vis); SCASSERT(line != nullptr) - line->setHypotenuseP1Id(value); + line->SetHypotenuseP1Id(value); } //--------------------------------------------------------------------------------------------------------------------- @@ -279,7 +278,7 @@ void DialogTriangle::SetAxisP2Id(const quint32 &value) VisToolTriangle *line = qobject_cast(vis); SCASSERT(line != nullptr) - line->setObject2Id(value); + line->SetObject2Id(value); } //--------------------------------------------------------------------------------------------------------------------- @@ -293,7 +292,7 @@ void DialogTriangle::SetAxisP1Id(const quint32 &value) VisToolTriangle *line = qobject_cast(vis); SCASSERT(line != nullptr) - line->setObject1Id(value); + line->SetObject1Id(value); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/dialogs/tools/dialogtruedarts.cpp b/src/libs/vtools/dialogs/tools/dialogtruedarts.cpp index 4659c36dc..d033a1c6f 100644 --- a/src/libs/vtools/dialogs/tools/dialogtruedarts.cpp +++ b/src/libs/vtools/dialogs/tools/dialogtruedarts.cpp @@ -43,8 +43,6 @@ #include "../../visualization/line/vistooltruedarts.h" #include "../ifc/xml/vabstractpattern.h" #include "../qmuparser/qmudef.h" -#include "../vgeometry/../ifc/ifcdef.h" -#include "../vmisc/vabstractapplication.h" #include "../vpatterndb/vcontainer.h" #include "dialogtool.h" #include "ui_dialogtruedarts.h" @@ -147,7 +145,7 @@ void DialogTrueDarts::SetFirstBasePointId(const quint32 &value) VisToolTrueDarts *points = qobject_cast(vis); SCASSERT(points != nullptr) - points->setObject1Id(value); + points->SetBaseLineP1Id(value); } //--------------------------------------------------------------------------------------------------------------------- @@ -163,7 +161,7 @@ void DialogTrueDarts::SetSecondBasePointId(const quint32 &value) VisToolTrueDarts *points = qobject_cast(vis); SCASSERT(points != nullptr) - points->setObject2Id(value); + points->SetBaseLineP2Id(value); } //--------------------------------------------------------------------------------------------------------------------- @@ -179,7 +177,7 @@ void DialogTrueDarts::SetFirstDartPointId(const quint32 &value) VisToolTrueDarts *points = qobject_cast(vis); SCASSERT(points != nullptr) - points->setD1PointId(value); + points->SetD1PointId(value); } //--------------------------------------------------------------------------------------------------------------------- @@ -195,7 +193,7 @@ void DialogTrueDarts::SetSecondDartPointId(const quint32 &value) VisToolTrueDarts *points = qobject_cast(vis); SCASSERT(points != nullptr) - points->setD2PointId(value); + points->SetD2PointId(value); } //--------------------------------------------------------------------------------------------------------------------- @@ -211,7 +209,7 @@ void DialogTrueDarts::SetThirdDartPointId(const quint32 &value) VisToolTrueDarts *points = qobject_cast(vis); SCASSERT(points != nullptr) - points->setD3PointId(value); + points->SetD3PointId(value); } //--------------------------------------------------------------------------------------------------------------------- @@ -247,7 +245,7 @@ void DialogTrueDarts::ChosenObject(quint32 id, const SceneObject &type) if (SetObject(id, ui->comboBoxSecondBasePoint, tr("Select the first dart point"))) { number++; - points->setObject2Id(id); + points->SetBaseLineP2Id(id); points->RefreshGeometry(); } } @@ -264,7 +262,7 @@ void DialogTrueDarts::ChosenObject(quint32 id, const SceneObject &type) if (SetObject(id, ui->comboBoxFirstDartPoint, tr("Select the second dart point"))) { number++; - points->setD1PointId(id); + points->SetD1PointId(id); points->RefreshGeometry(); } } @@ -283,7 +281,7 @@ void DialogTrueDarts::ChosenObject(quint32 id, const SceneObject &type) if (SetObject(id, ui->comboBoxSecondDartPoint, tr("Select the third dart point"))) { number++; - points->setD2PointId(id); + points->SetD2PointId(id); points->RefreshGeometry(); } } @@ -302,7 +300,7 @@ void DialogTrueDarts::ChosenObject(quint32 id, const SceneObject &type) { if (SetObject(id, ui->comboBoxThirdDartPoint, QString())) { - points->setD3PointId(id); + points->SetD3PointId(id); points->RefreshGeometry(); prepare = true; DialogAccepted(); @@ -373,11 +371,11 @@ void DialogTrueDarts::SaveData() VisToolTrueDarts *points = qobject_cast(vis); SCASSERT(points != nullptr) - points->setObject1Id(GetFirstBasePointId()); - points->setObject2Id(GetSecondBasePointId()); - points->setD1PointId(GetFirstDartPointId()); - points->setD2PointId(GetSecondDartPointId()); - points->setD3PointId(GetThirdDartPointId()); + points->SetBaseLineP1Id(GetFirstBasePointId()); + points->SetBaseLineP2Id(GetSecondBasePointId()); + points->SetD1PointId(GetFirstDartPointId()); + points->SetD2PointId(GetSecondDartPointId()); + points->SetD3PointId(GetThirdDartPointId()); points->RefreshGeometry(); } diff --git a/src/libs/vtools/dialogs/tools/piece/dialogduplicatedetail.cpp b/src/libs/vtools/dialogs/tools/piece/dialogduplicatedetail.cpp index eb7f3d042..7fa557890 100644 --- a/src/libs/vtools/dialogs/tools/piece/dialogduplicatedetail.cpp +++ b/src/libs/vtools/dialogs/tools/piece/dialogduplicatedetail.cpp @@ -27,7 +27,6 @@ *************************************************************************/ #include "dialogduplicatedetail.h" #include "ui_dialogduplicatedetail.h" -#include "../vwidgets/vabstractmainwindow.h" #include "../../../visualization/path/vistoolduplicatedetail.h" #include "../../../tools/vabstracttool.h" diff --git a/src/libs/vtools/dialogs/tools/piece/dialogpiecepath.cpp b/src/libs/vtools/dialogs/tools/piece/dialogpiecepath.cpp index a17ac7cdf..305173174 100644 --- a/src/libs/vtools/dialogs/tools/piece/dialogpiecepath.cpp +++ b/src/libs/vtools/dialogs/tools/piece/dialogpiecepath.cpp @@ -30,7 +30,6 @@ #include "ui_dialogpiecepath.h" #include "../vpatterndb/vpiecenode.h" #include "visualization/path/vistoolpiecepath.h" -#include "../../../tools/vabstracttool.h" #include "../../../tools/vtoolseamallowance.h" #include "../../support/dialogeditwrongformula.h" #include "../vmisc/vmodifierkey.h" @@ -1394,7 +1393,7 @@ Qt::PenStyle DialogPiecePath::GetPenType() const void DialogPiecePath::SetPenType(const Qt::PenStyle &type) { ChangeCurrentData(ui->comboBoxPenType, PenStyleToLineStyle(type)); - vis->setLineStyle(type); + vis->SetLineStyle(type); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/dialogs/tools/piece/dialogpin.cpp b/src/libs/vtools/dialogs/tools/piece/dialogpin.cpp index dc2deb434..44a322ac2 100644 --- a/src/libs/vtools/dialogs/tools/piece/dialogpin.cpp +++ b/src/libs/vtools/dialogs/tools/piece/dialogpin.cpp @@ -29,10 +29,10 @@ #include "dialogpin.h" #include "ui_dialogpin.h" #include "visualization/line/vistoolspecialpoint.h" -#include "../../../tools/vabstracttool.h" #if QT_VERSION < QT_VERSION_CHECK(5, 7, 0) #include "../vmisc/backport/qoverload.h" #endif // QT_VERSION < QT_VERSION_CHECK(5, 7, 0) +#include "../vpatterndb/vcontainer.h" //--------------------------------------------------------------------------------------------------------------------- DialogPin::DialogPin(const VContainer *data, quint32 toolId, QWidget *parent) @@ -108,7 +108,7 @@ void DialogPin::SetPointId(quint32 id) VisToolSpecialPoint *point = qobject_cast(vis); SCASSERT(point != nullptr) - point->setObject1Id(id); + point->SetPointId(id); CheckPoint(); } diff --git a/src/libs/vtools/dialogs/tools/piece/dialogplacelabel.cpp b/src/libs/vtools/dialogs/tools/piece/dialogplacelabel.cpp index 65e546946..3fe3fd764 100644 --- a/src/libs/vtools/dialogs/tools/piece/dialogplacelabel.cpp +++ b/src/libs/vtools/dialogs/tools/piece/dialogplacelabel.cpp @@ -29,13 +29,11 @@ #include "ui_dialogplacelabel.h" #include "visualization/line/vistoolspecialpoint.h" -#include "../../../tools/vabstracttool.h" -#include "../../../tools/vtoolseamallowance.h" #include "../../support/dialogeditwrongformula.h" -#include "../vgeometry/vplacelabelitem.h" #if QT_VERSION < QT_VERSION_CHECK(5, 7, 0) #include "../vmisc/backport/qoverload.h" #endif // QT_VERSION < QT_VERSION_CHECK(5, 7, 0) +#include "../vpatterndb/vcontainer.h" #include @@ -104,7 +102,7 @@ void DialogPlaceLabel::SetCenterPoint(quint32 id) { VisToolSpecialPoint *point = qobject_cast(vis); SCASSERT(point != nullptr) - point->setObject1Id(id); + point->SetPointId(id); } CheckPoint(); @@ -148,7 +146,7 @@ void DialogPlaceLabel::SetWidth(const QString &value) // VisToolPlaceLabel *point = qobject_cast(vis); // SCASSERT(point != nullptr) -// point->setObject1Id(id); +// point->SetPointId(id); MoveCursorToEnd(ui->plainTextEditFormulaWidth); } @@ -175,7 +173,7 @@ void DialogPlaceLabel::SetHeight(const QString &value) // VisToolPlaceLabel *point = qobject_cast(vis); // SCASSERT(point != nullptr) -// point->setObject1Id(id); +// point->SetPointId(id); MoveCursorToEnd(ui->plainTextEditFormulaHeight); } @@ -202,7 +200,7 @@ void DialogPlaceLabel::SetAngle(const QString &value) // VisToolPlaceLabel *point = qobject_cast(vis); // SCASSERT(point != nullptr) -// point->setObject1Id(id); +// point->SetPointId(id); MoveCursorToEnd(ui->plainTextEditFormulaAngle); } diff --git a/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp b/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp index 0acc9688c..a8ac9dc65 100644 --- a/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp +++ b/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp @@ -3750,7 +3750,7 @@ void DialogSeamAllowance::ShowPieceSpecialPointsWithRect(const QListWidget *list if (not VAbstractValApplication::VApp()->getCurrentScene()->items().contains(m_visSpecialPoints)) { - m_visSpecialPoints->VisualMode(NULL_ID); + m_visSpecialPoints->VisualMode(); m_visSpecialPoints->setZValue(10); // pins should be on top VToolSeamAllowance *tool = qobject_cast(VAbstractPattern::getTool(toolId)); SCASSERT(tool != nullptr); diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vtoolarc.cpp b/src/libs/vtools/tools/drawTools/toolcurve/vtoolarc.cpp index 64dd758ab..3fd435ff2 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vtoolarc.cpp +++ b/src/libs/vtools/tools/drawTools/toolcurve/vtoolarc.cpp @@ -374,12 +374,12 @@ void VToolArc::SetVisualization() const bool osSeparator = VAbstractApplication::VApp()->Settings()->GetOsSeparator(); const VTranslateVars *trVars = VAbstractApplication::VApp()->TrVars(); - visual->setObject1Id(arc->GetCenter().id()); - visual->setRadius(trVars->FormulaToUser(arc->GetFormulaRadius(), osSeparator)); - visual->setF1(trVars->FormulaToUser(arc->GetFormulaF1(), osSeparator)); - visual->setF2(trVars->FormulaToUser(arc->GetFormulaF2(), osSeparator)); - visual->setLineStyle(LineStyleToPenStyle(arc->GetPenStyle())); - visual->setApproximationScale(arc->GetApproximationScale()); + visual->SetCenterId(arc->GetCenter().id()); + visual->SetRadius(trVars->FormulaToUser(arc->GetFormulaRadius(), osSeparator)); + visual->SetF1(trVars->FormulaToUser(arc->GetFormulaF1(), osSeparator)); + visual->SetF2(trVars->FormulaToUser(arc->GetFormulaF2(), osSeparator)); + visual->SetLineStyle(LineStyleToPenStyle(arc->GetPenStyle())); + visual->SetApproximationScale(arc->GetApproximationScale()); visual->SetMode(Mode::Show); visual->RefreshGeometry(); } diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vtoolarcwithlength.cpp b/src/libs/vtools/tools/drawTools/toolcurve/vtoolarcwithlength.cpp index 49c3529e1..2a3bf28da 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vtoolarcwithlength.cpp +++ b/src/libs/vtools/tools/drawTools/toolcurve/vtoolarcwithlength.cpp @@ -353,12 +353,12 @@ void VToolArcWithLength::SetVisualization() const bool osSeparator = VAbstractApplication::VApp()->Settings()->GetOsSeparator(); const VTranslateVars *trVars = VAbstractApplication::VApp()->TrVars(); - visual->setObject1Id(arc->GetCenter().id()); - visual->setRadius(trVars->FormulaToUser(arc->GetFormulaRadius(), osSeparator)); - visual->setF1(trVars->FormulaToUser(arc->GetFormulaF1(), osSeparator)); - visual->setLength(trVars->FormulaToUser(arc->GetFormulaLength(), osSeparator)); - visual->setLineStyle(LineStyleToPenStyle(arc->GetPenStyle())); - visual->setApproximationScale(arc->GetApproximationScale()); + visual->SetCenterId(arc->GetCenter().id()); + visual->SetRadius(trVars->FormulaToUser(arc->GetFormulaRadius(), osSeparator)); + visual->SetF1(trVars->FormulaToUser(arc->GetFormulaF1(), osSeparator)); + visual->SetLength(trVars->FormulaToUser(arc->GetFormulaLength(), osSeparator)); + visual->SetLineStyle(LineStyleToPenStyle(arc->GetPenStyle())); + visual->SetApproximationScale(arc->GetApproximationScale()); visual->SetMode(Mode::Show); visual->RefreshGeometry(); } diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vtoolcubicbezier.cpp b/src/libs/vtools/tools/drawTools/toolcurve/vtoolcubicbezier.cpp index b0f6ce7af..ec760c61a 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vtoolcubicbezier.cpp +++ b/src/libs/vtools/tools/drawTools/toolcurve/vtoolcubicbezier.cpp @@ -47,7 +47,6 @@ #include "../vgeometry/vcubicbezier.h" #include "../vgeometry/vgobject.h" #include "../vgeometry/vpointf.h" -#include "../vmisc/vabstractapplication.h" #include "../vpatterndb/vcontainer.h" #include "../vwidgets/vmaingraphicsscene.h" #include "../../vabstracttool.h" @@ -257,12 +256,12 @@ void VToolCubicBezier::SetVisualization() SCASSERT(visual != nullptr) const QSharedPointer spl = VAbstractTool::data.GeometricObject(m_id); - visual->setObject1Id(spl->GetP1().id()); - visual->setObject2Id(spl->GetP2().id()); - visual->setObject3Id(spl->GetP3().id()); - visual->setObject4Id(spl->GetP4().id()); - visual->setLineStyle(LineStyleToPenStyle(spl->GetPenStyle())); - visual->setApproximationScale(spl->GetApproximationScale()); + visual->SetPoint1Id(spl->GetP1().id()); + visual->SetPoint2Id(spl->GetP2().id()); + visual->SetPoint3Id(spl->GetP3().id()); + visual->SetPoint4Id(spl->GetP4().id()); + visual->SetLineStyle(LineStyleToPenStyle(spl->GetPenStyle())); + visual->SetApproximationScale(spl->GetApproximationScale()); visual->SetMode(Mode::Show); visual->RefreshGeometry(); } diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vtoolcubicbezierpath.cpp b/src/libs/vtools/tools/drawTools/toolcurve/vtoolcubicbezierpath.cpp index ac35a5491..6a3a89c3e 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vtoolcubicbezierpath.cpp +++ b/src/libs/vtools/tools/drawTools/toolcurve/vtoolcubicbezierpath.cpp @@ -245,8 +245,8 @@ void VToolCubicBezierPath::SetVisualization() SCASSERT(visual != nullptr) QSharedPointer splPath = VAbstractTool::data.GeometricObject(m_id); - visual->setPath(*splPath.data()); - visual->setLineStyle(LineStyleToPenStyle(splPath->GetPenStyle())); + visual->SetPath(*splPath.data()); + visual->SetLineStyle(LineStyleToPenStyle(splPath->GetPenStyle())); visual->SetMode(Mode::Show); visual->RefreshGeometry(); } diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vtoolellipticalarc.cpp b/src/libs/vtools/tools/drawTools/toolcurve/vtoolellipticalarc.cpp index 2a58f4035..8c3d2484e 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vtoolellipticalarc.cpp +++ b/src/libs/vtools/tools/drawTools/toolcurve/vtoolellipticalarc.cpp @@ -423,13 +423,13 @@ void VToolEllipticalArc::SetVisualization() const bool osSeparator = VAbstractApplication::VApp()->Settings()->GetOsSeparator(); const VTranslateVars *trVars = VAbstractApplication::VApp()->TrVars(); - visual->setObject1Id(elArc->GetCenter().id()); - visual->setRadius1(trVars->FormulaToUser(elArc->GetFormulaRadius1(), osSeparator)); - visual->setRadius2(trVars->FormulaToUser(elArc->GetFormulaRadius2(), osSeparator)); - visual->setF1(trVars->FormulaToUser(elArc->GetFormulaF1(), osSeparator)); - visual->setF2(trVars->FormulaToUser(elArc->GetFormulaF2(), osSeparator)); - visual->setRotationAngle(trVars->FormulaToUser(elArc->GetFormulaRotationAngle(), osSeparator)); - visual->setLineStyle(LineStyleToPenStyle(elArc->GetPenStyle())); + visual->SetCenterId(elArc->GetCenter().id()); + visual->SetRadius1(trVars->FormulaToUser(elArc->GetFormulaRadius1(), osSeparator)); + visual->SetRadius2(trVars->FormulaToUser(elArc->GetFormulaRadius2(), osSeparator)); + visual->SetF1(trVars->FormulaToUser(elArc->GetFormulaF1(), osSeparator)); + visual->SetF2(trVars->FormulaToUser(elArc->GetFormulaF2(), osSeparator)); + visual->SetRotationAngle(trVars->FormulaToUser(elArc->GetFormulaRotationAngle(), osSeparator)); + visual->SetLineStyle(LineStyleToPenStyle(elArc->GetPenStyle())); visual->RefreshGeometry(); } } diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vtoolspline.cpp b/src/libs/vtools/tools/drawTools/toolcurve/vtoolspline.cpp index ed78d4d19..4301bac42 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vtoolspline.cpp +++ b/src/libs/vtools/tools/drawTools/toolcurve/vtoolspline.cpp @@ -544,15 +544,15 @@ void VToolSpline::SetVisualization() SCASSERT(visual != nullptr) const QSharedPointer spl = VAbstractTool::data.GeometricObject(m_id); - visual->setObject1Id(spl->GetP1().id()); - visual->SetObject4Id(spl->GetP4().id()); + visual->SetPoint1Id(spl->GetP1().id()); + visual->SetPoint4Id(spl->GetP4().id()); visual->SetAngle1(spl->GetStartAngle()); visual->SetAngle2(spl->GetEndAngle()); visual->SetKAsm1(spl->GetKasm1()); visual->SetKAsm2(spl->GetKasm2()); visual->SetKCurve(spl->GetKcurve()); - visual->setLineStyle(LineStyleToPenStyle(spl->GetPenStyle())); - visual->setApproximationScale(spl->GetApproximationScale()); + visual->SetLineStyle(LineStyleToPenStyle(spl->GetPenStyle())); + visual->SetApproximationScale(spl->GetApproximationScale()); visual->SetMode(Mode::Show); visual->RefreshGeometry(); } diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vtoolsplinepath.cpp b/src/libs/vtools/tools/drawTools/toolcurve/vtoolsplinepath.cpp index bd3ea8b5e..58bd26eab 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vtoolsplinepath.cpp +++ b/src/libs/vtools/tools/drawTools/toolcurve/vtoolsplinepath.cpp @@ -754,7 +754,7 @@ void VToolSplinePath::SetVisualization() QSharedPointer splPath = VAbstractTool::data.GeometricObject(m_id); visual->SetPath(*splPath.data()); - visual->setLineStyle(LineStyleToPenStyle(splPath->GetPenStyle())); + visual->SetLineStyle(LineStyleToPenStyle(splPath->GetPenStyle())); visual->SetMode(Mode::Show); visual->RefreshGeometry(); } diff --git a/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooltruedarts.cpp b/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooltruedarts.cpp index 57ba0c1d7..88aeafdd5 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooltruedarts.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooltruedarts.cpp @@ -327,11 +327,11 @@ void VToolTrueDarts::SetVisualization() auto *visual = qobject_cast(vis); SCASSERT(visual != nullptr) - visual->setObject1Id(baseLineP1Id); - visual->setObject2Id(baseLineP2Id); - visual->setD1PointId(dartP1Id); - visual->setD2PointId(dartP2Id); - visual->setD3PointId(dartP3Id); + visual->SetBaseLineP1Id(baseLineP1Id); + visual->SetBaseLineP2Id(baseLineP2Id); + visual->SetD1PointId(dartP1Id); + visual->SetD2PointId(dartP2Id); + visual->SetD3PointId(dartP3Id); visual->RefreshGeometry(); } } diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutarc.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutarc.cpp index ca10fa76e..2c0b32702 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutarc.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutarc.cpp @@ -270,12 +270,12 @@ void VToolCutArc::SetVisualization() auto *visual = qobject_cast(vis); SCASSERT(visual != nullptr) - visual->setObject1Id(baseCurveId); - visual->setLength(VAbstractApplication::VApp()->TrVars() + visual->SetArcId(baseCurveId); + visual->SetLength(VAbstractApplication::VApp()->TrVars() ->FormulaToUser(formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator())); const QSharedPointer curve = VAbstractTool::data.GeometricObject(baseCurveId); - visual->setLineStyle(LineStyleToPenStyle(curve->GetPenStyle())); + visual->SetLineStyle(LineStyleToPenStyle(curve->GetPenStyle())); visual->RefreshGeometry(); } diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutspline.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutspline.cpp index f361715e2..96832a502 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutspline.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutspline.cpp @@ -269,12 +269,12 @@ void VToolCutSpline::SetVisualization() auto *visual = qobject_cast(vis); SCASSERT(visual != nullptr) - visual->setObject1Id(baseCurveId); - visual->setLength(VAbstractApplication::VApp()->TrVars() + visual->SetSplineId(baseCurveId); + visual->SetLength(VAbstractApplication::VApp()->TrVars() ->FormulaToUser(formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator())); const QSharedPointer curve = VAbstractTool::data.GeometricObject(baseCurveId); - visual->setLineStyle(LineStyleToPenStyle(curve->GetPenStyle())); + visual->SetLineStyle(LineStyleToPenStyle(curve->GetPenStyle())); visual->RefreshGeometry(); } diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutsplinepath.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutsplinepath.cpp index 09a0488b8..633bd7912 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutsplinepath.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutsplinepath.cpp @@ -363,12 +363,12 @@ void VToolCutSplinePath::SetVisualization() auto *visual = qobject_cast(vis); SCASSERT(visual != nullptr) - visual->setObject1Id(baseCurveId); - visual->setLength(VAbstractApplication::VApp()->TrVars() + visual->SetSplinePathId(baseCurveId); + visual->SetLength(VAbstractApplication::VApp()->TrVars() ->FormulaToUser(formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator())); const QSharedPointer curve = VAbstractTool::data.GeometricObject(baseCurveId); - visual->setLineStyle(LineStyleToPenStyle(curve->GetPenStyle())); + visual->SetLineStyle(LineStyleToPenStyle(curve->GetPenStyle())); visual->RefreshGeometry(); } diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolalongline.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolalongline.cpp index 68a00bd33..a5c2bab20 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolalongline.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolalongline.cpp @@ -141,11 +141,11 @@ void VToolAlongLine::SetVisualization() { auto *visual = qobject_cast(vis); SCASSERT(visual != nullptr) - visual->setObject1Id(basePointId); - visual->setObject2Id(m_secondPointId); - visual->setLength(VAbstractApplication::VApp()->TrVars() + visual->SetPoint1Id(basePointId); + visual->SetPoint2Id(m_secondPointId); + visual->SetLength(VAbstractApplication::VApp()->TrVars() ->FormulaToUser(formulaLength, VAbstractApplication::VApp()->Settings()->GetOsSeparator())); - visual->setLineStyle(LineStyleToPenStyle(m_lineType)); + visual->SetLineStyle(LineStyleToPenStyle(m_lineType)); visual->RefreshGeometry(); } } diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolbisector.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolbisector.cpp index 31535c4c1..0906f6513 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolbisector.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolbisector.cpp @@ -301,12 +301,12 @@ void VToolBisector::SetVisualization() auto *visual = qobject_cast(vis); SCASSERT(visual != nullptr) - visual->setObject1Id(firstPointId); - visual->setObject2Id(basePointId); - visual->setObject3Id(thirdPointId); - visual->setLength(VAbstractApplication::VApp()->TrVars() + visual->SetPoint1Id(firstPointId); + visual->SetPoint2Id(basePointId); + visual->SetPoint3Id(thirdPointId); + visual->SetLength(VAbstractApplication::VApp()->TrVars() ->FormulaToUser(formulaLength, VAbstractApplication::VApp()->Settings()->GetOsSeparator())); - visual->setLineStyle(LineStyleToPenStyle(m_lineType)); + visual->SetLineStyle(LineStyleToPenStyle(m_lineType)); visual->RefreshGeometry(); } } diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolcurveintersectaxis.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolcurveintersectaxis.cpp index 66dadab62..5eb577fdf 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolcurveintersectaxis.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolcurveintersectaxis.cpp @@ -322,11 +322,11 @@ void VToolCurveIntersectAxis::SetVisualization() auto *visual = qobject_cast(vis); SCASSERT(visual != nullptr) - visual->setObject1Id(curveId); + visual->SetCurveId(curveId); visual->setAxisPointId(basePointId); visual->SetAngle(VAbstractApplication::VApp()->TrVars() ->FormulaToUser(formulaAngle, VAbstractApplication::VApp()->Settings()->GetOsSeparator())); - visual->setLineStyle(LineStyleToPenStyle(m_lineType)); + visual->SetLineStyle(LineStyleToPenStyle(m_lineType)); visual->RefreshGeometry(); } } diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolendline.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolendline.cpp index 5c9a5188d..c88c6707f 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolendline.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolendline.cpp @@ -231,10 +231,10 @@ void VToolEndLine::SetVisualization() const bool osSeparator = VAbstractApplication::VApp()->Settings()->GetOsSeparator(); const VTranslateVars *trVars = VAbstractApplication::VApp()->TrVars(); - visual->setObject1Id(basePointId); - visual->setLength(trVars->FormulaToUser(formulaLength, osSeparator)); + visual->SetBasePointId(basePointId); + visual->SetLength(trVars->FormulaToUser(formulaLength, osSeparator)); visual->SetAngle(trVars->FormulaToUser(formulaAngle, osSeparator)); - visual->setLineStyle(LineStyleToPenStyle(m_lineType)); + visual->SetLineStyle(LineStyleToPenStyle(m_lineType)); visual->SetMode(Mode::Show); visual->RefreshGeometry(); } diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolheight.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolheight.cpp index 8ca92e30d..c30d9c726 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolheight.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolheight.cpp @@ -260,10 +260,10 @@ void VToolHeight::SetVisualization() auto *visual = qobject_cast(vis); SCASSERT(visual != nullptr) - visual->setObject1Id(basePointId); - visual->setLineP1Id(p1LineId); - visual->setLineP2Id(p2LineId); - visual->setLineStyle(LineStyleToPenStyle(m_lineType)); + visual->SetBasePointId(basePointId); + visual->SetLineP1Id(p1LineId); + visual->SetLineP2Id(p2LineId); + visual->SetLineStyle(LineStyleToPenStyle(m_lineType)); visual->RefreshGeometry(); } } diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollineintersectaxis.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollineintersectaxis.cpp index 0856d8a1e..d15bc6068 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollineintersectaxis.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollineintersectaxis.cpp @@ -318,12 +318,12 @@ void VToolLineIntersectAxis::SetVisualization() auto *visual = qobject_cast(vis); SCASSERT(visual != nullptr) - visual->setObject1Id(firstPointId); - visual->setPoint2Id(secondPointId); - visual->setAxisPointId(basePointId); + visual->SetPoint1Id(firstPointId); + visual->SetPoint2Id(secondPointId); + visual->SetAxisPointId(basePointId); visual->SetAngle(VAbstractApplication::VApp()->TrVars() ->FormulaToUser(formulaAngle, VAbstractApplication::VApp()->Settings()->GetOsSeparator())); - visual->setLineStyle(LineStyleToPenStyle(m_lineType)); + visual->SetLineStyle(LineStyleToPenStyle(m_lineType)); visual->RefreshGeometry(); } } diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollinepoint.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollinepoint.h index 873073f03..134f2e25b 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollinepoint.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollinepoint.h @@ -45,13 +45,11 @@ template class QSharedPointer; struct VToolLinePointInitData : VToolSinglePointInitData { VToolLinePointInitData() - : VToolSinglePointInitData(), - typeLine(TypeLineLine), - lineColor(ColorBlack) + : VToolSinglePointInitData() {} - QString typeLine; - QString lineColor; + QString typeLine{TypeLineLine}; + QString lineColor{ColorBlack}; }; /** @@ -68,8 +66,8 @@ public: virtual int type() const override {return Type;} enum { Type = UserType + static_cast(Tool::LinePoint)}; - virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, - QWidget *widget = nullptr) override; + virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, + QWidget *widget = nullptr) override; VFormula GetFormulaLength() const; void SetFormulaLength(const VFormula &value); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolnormal.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolnormal.cpp index 0fa6add25..4383673cc 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolnormal.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolnormal.cpp @@ -271,12 +271,12 @@ void VToolNormal::SetVisualization() auto *visual = qobject_cast(vis); SCASSERT(visual != nullptr) - visual->setObject1Id(basePointId); - visual->setObject2Id(secondPointId); - visual->setLength(VAbstractApplication::VApp()->TrVars() + visual->SetPoint1Id(basePointId); + visual->SetPoint2Id(secondPointId); + visual->SetLength(VAbstractApplication::VApp()->TrVars() ->FormulaToUser(formulaLength, VAbstractApplication::VApp()->Settings()->GetOsSeparator())); visual->SetAngle(angle); - visual->setLineStyle(LineStyleToPenStyle(m_lineType)); + visual->SetLineStyle(LineStyleToPenStyle(m_lineType)); visual->RefreshGeometry(); } } diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolshoulderpoint.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolshoulderpoint.cpp index f6aad771e..ae1a09575 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolshoulderpoint.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolshoulderpoint.cpp @@ -321,12 +321,12 @@ void VToolShoulderPoint::SetVisualization() auto *visual = qobject_cast(vis); SCASSERT(visual != nullptr) - visual->setObject1Id(pShoulder); - visual->setLineP1Id(basePointId); - visual->setLineP2Id(p2Line); - visual->setLength(VAbstractApplication::VApp()->TrVars() + visual->SetLineP1Id(pShoulder); + visual->SetLineP1Id(basePointId); + visual->SetLineP2Id(p2Line); + visual->SetLength(VAbstractApplication::VApp()->TrVars() ->FormulaToUser(formulaLength, VAbstractApplication::VApp()->Settings()->GetOsSeparator())); - visual->setLineStyle(LineStyleToPenStyle(m_lineType)); + visual->SetLineStyle(LineStyleToPenStyle(m_lineType)); visual->RefreshGeometry(); } } diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoollineintersect.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoollineintersect.cpp index 68b8026d7..04c360e2c 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoollineintersect.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoollineintersect.cpp @@ -296,10 +296,10 @@ void VToolLineIntersect::SetVisualization() auto *visual = qobject_cast(vis); SCASSERT(visual != nullptr) - visual->setObject1Id(p1Line1); - visual->setLine1P2Id(p2Line1); - visual->setLine2P1Id(p1Line2); - visual->setLine2P2Id(p2Line2); + visual->SetLine1P1Id(p1Line1); + visual->SetLine1P2Id(p2Line1); + visual->SetLine2P1Id(p1Line2); + visual->SetLine2P2Id(p2Line2); visual->RefreshGeometry(); } } diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromarcandtangent.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromarcandtangent.cpp index fe331315e..6a22bb0a1 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromarcandtangent.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromarcandtangent.cpp @@ -334,9 +334,9 @@ void VToolPointFromArcAndTangent::SetVisualization() auto *visual = qobject_cast(vis); SCASSERT(visual != nullptr) - visual->setObject1Id(tangentPointId); - visual->setArcId(arcId); - visual->setCrossPoint(crossPoint); + visual->SetPointId(tangentPointId); + visual->SetArcId(arcId); + visual->SetCrossPoint(crossPoint); visual->RefreshGeometry(); } } diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromcircleandtangent.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromcircleandtangent.cpp index c7a14be52..a3f6fb5ae 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromcircleandtangent.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromcircleandtangent.cpp @@ -328,10 +328,10 @@ void VToolPointFromCircleAndTangent::SetVisualization() auto *visual = qobject_cast(vis); SCASSERT(visual != nullptr) - visual->setObject1Id(tangentPointId); - visual->setObject2Id(circleCenterId); - visual->setCRadius(circleRadius); - visual->setCrossPoint(crossPoint); + visual->SetPointId(tangentPointId); + visual->SetCenterId(circleCenterId); + visual->SetCRadius(circleRadius); + visual->SetCrossPoint(crossPoint); visual->RefreshGeometry(); } } diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofcontact.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofcontact.cpp index 3087ad865..f28e1ef6f 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofcontact.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofcontact.cpp @@ -351,10 +351,10 @@ void VToolPointOfContact::SetVisualization() auto *visual = qobject_cast(vis); SCASSERT(visual != nullptr) - visual->setObject1Id(firstPointId); - visual->setLineP2Id(secondPointId); - visual->setRadiusId(center); - visual->setRadius(VAbstractApplication::VApp()->TrVars() + visual->SetLineP1Id(firstPointId); + visual->SetLineP2Id(secondPointId); + visual->SetRadiusId(center); + visual->SetRadius(VAbstractApplication::VApp()->TrVars() ->FormulaToUser(arcRadius, VAbstractApplication::VApp()->Settings()->GetOsSeparator())); visual->RefreshGeometry(); } diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersection.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersection.cpp index 6284bedc1..472ca93d8 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersection.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersection.cpp @@ -240,8 +240,8 @@ void VToolPointOfIntersection::SetVisualization() auto *visual = qobject_cast(vis); SCASSERT(visual != nullptr) - visual->setObject1Id(firstPointId); - visual->setPoint2Id(secondPointId); + visual->SetPoint1Id(firstPointId); + visual->SetPoint2Id(secondPointId); visual->RefreshGeometry(); } } diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectionarcs.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectionarcs.cpp index ef5303aa8..584025844 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectionarcs.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectionarcs.cpp @@ -354,9 +354,9 @@ void VToolPointOfIntersectionArcs::SetVisualization() auto *visual = qobject_cast(vis); SCASSERT(visual != nullptr) - visual->setArc1Id(firstArcId); - visual->setArc2Id(secondArcId); - visual->setCrossPoint(crossPoint); + visual->SetArc1Id(firstArcId); + visual->SetArc2Id(secondArcId); + visual->SetCrossPoint(crossPoint); visual->RefreshGeometry(); } } diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncircles.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncircles.cpp index ca156c68e..037d7c115 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncircles.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncircles.cpp @@ -370,15 +370,15 @@ void VToolPointOfIntersectionCircles::SetVisualization() auto *visual = qobject_cast(vis); SCASSERT(visual != nullptr) - visual->setObject1Id(firstCircleCenterId); - visual->setObject2Id(secondCircleCenterId); + visual->SetCircle1Id(firstCircleCenterId); + visual->SetCircle2Id(secondCircleCenterId); const bool osSeparator = VAbstractApplication::VApp()->Settings()->GetOsSeparator(); const VTranslateVars *trVars = VAbstractApplication::VApp()->TrVars(); - visual->setC1Radius(trVars->FormulaToUser(firstCircleRadius, osSeparator)); - visual->setC2Radius(trVars->FormulaToUser(secondCircleRadius, osSeparator)); - visual->setCrossPoint(crossPoint); + visual->SetC1Radius(trVars->FormulaToUser(firstCircleRadius, osSeparator)); + visual->SetC2Radius(trVars->FormulaToUser(secondCircleRadius, osSeparator)); + visual->SetCrossPoint(crossPoint); visual->RefreshGeometry(); } } diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncurves.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncurves.cpp index b84c0a98d..ba4fd7ae5 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncurves.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncurves.cpp @@ -469,10 +469,10 @@ void VToolPointOfIntersectionCurves::SetVisualization() auto visual = qobject_cast(vis); SCASSERT(visual != nullptr) - visual->setObject1Id(firstCurveId); - visual->setObject2Id(secondCurveId); - visual->setVCrossPoint(vCrossPoint); - visual->setHCrossPoint(hCrossPoint); + visual->SetCurve1Id(firstCurveId); + visual->SetCurve2Id(secondCurveId); + visual->SetVCrossPoint(vCrossPoint); + visual->SetHCrossPoint(hCrossPoint); visual->RefreshGeometry(); } } diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtooltriangle.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtooltriangle.cpp index 2e1ecf20a..005b037e4 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtooltriangle.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtooltriangle.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #include "../../../../dialogs/tools/dialogtriangle.h" #include "../../../../dialogs/tools/dialogtool.h" @@ -50,7 +51,6 @@ #include "../../../vabstracttool.h" #include "../../vdrawtool.h" #include "vtoolsinglepoint.h" -#include "../vmisc/vmath.h" #include "../vmisc/compatibility.h" template class QSharedPointer; @@ -341,10 +341,10 @@ void VToolTriangle::SetVisualization() auto * visual = qobject_cast(vis); SCASSERT(visual != nullptr) - visual->setObject1Id(axisP1Id); - visual->setObject2Id(axisP2Id); - visual->setHypotenuseP1Id(firstPointId); - visual->setHypotenuseP2Id(secondPointId); + visual->SetObject1Id(axisP1Id); + visual->SetObject2Id(axisP2Id); + visual->SetHypotenuseP1Id(firstPointId); + visual->SetHypotenuseP2Id(secondPointId); visual->RefreshGeometry(); } } diff --git a/src/libs/vtools/tools/drawTools/vtoolline.cpp b/src/libs/vtools/tools/drawTools/vtoolline.cpp index 5b16060c7..4a9aa4c68 100644 --- a/src/libs/vtools/tools/drawTools/vtoolline.cpp +++ b/src/libs/vtools/tools/drawTools/vtoolline.cpp @@ -426,9 +426,9 @@ void VToolLine::SetVisualization() auto *visual = qobject_cast(vis); SCASSERT(visual != nullptr) - visual->setObject1Id(firstPoint); - visual->setPoint2Id(secondPoint); - visual->setLineStyle(LineStyleToPenStyle(m_lineType)); + visual->SetPoint1Id(firstPoint); + visual->SetPoint2Id(secondPoint); + visual->SetLineStyle(LineStyleToPenStyle(m_lineType)); visual->RefreshGeometry(); } } diff --git a/src/libs/vtools/visualization/line/operation/visoperation.cpp b/src/libs/vtools/visualization/line/operation/visoperation.cpp index 32bc0638f..3c2ebcb48 100644 --- a/src/libs/vtools/visualization/line/operation/visoperation.cpp +++ b/src/libs/vtools/visualization/line/operation/visoperation.cpp @@ -27,7 +27,6 @@ *************************************************************************/ #include "visoperation.h" -#include "../vgeometry/vabstractcurve.h" #include "../vgeometry/varc.h" #include "../vgeometry/vcubicbezier.h" #include "../vgeometry/vcubicbezierpath.h" @@ -40,73 +39,61 @@ //--------------------------------------------------------------------------------------------------------------------- VisOperation::VisOperation(const VContainer *data, QGraphicsItem *parent) - : VisLine(data, parent), - objects(), - supportColor2(Qt::darkGreen), - supportColor3(Qt::darkBlue), - points(), - curves() + : VisLine(data, parent) { + SetColor(VColor::SupportColor2, Qt::darkGreen); + SetColor(VColor::SupportColor3, Qt::darkBlue); } //--------------------------------------------------------------------------------------------------------------------- VisOperation::~VisOperation() { - qDeleteAll(points); - qDeleteAll(curves); + qDeleteAll(m_points); + qDeleteAll(m_curves); } //--------------------------------------------------------------------------------------------------------------------- void VisOperation::SetObjects(const QVector &objects) { - this->objects = objects; + m_objects = objects; } //--------------------------------------------------------------------------------------------------------------------- -void VisOperation::VisualMode(const quint32 &pointId) +void VisOperation::VisualMode(quint32 id) { - Q_UNUSED(pointId) - VMainGraphicsScene *scene = qobject_cast(VAbstractValApplication::VApp()->getCurrentScene()); - SCASSERT(scene != nullptr) - - Visualization::scenePos = scene->getScenePos(); - RefreshGeometry(); - - AddOnScene(); + Q_UNUSED(id) + StartVisualMode(); } //--------------------------------------------------------------------------------------------------------------------- -VScaledEllipse *VisOperation::GetPoint(quint32 i, const QColor &color) +auto VisOperation::GetPoint(quint32 i, const QColor &color) -> VScaledEllipse * { - return GetPointItem(points, i, color, this); + return GetPointItem(m_points, i, color, this); } //--------------------------------------------------------------------------------------------------------------------- -VCurvePathItem *VisOperation::GetCurve(quint32 i, const QColor &color) +auto VisOperation::GetCurve(quint32 i, const QColor &color) -> VCurvePathItem * { - if (not curves.isEmpty() && static_cast(curves.size() - 1) >= i) + if (!m_curves.isEmpty() && static_cast(m_curves.size() - 1) >= i) { - return curves.at(static_cast(i)); + return m_curves.at(static_cast(i)); } - else - { - auto curve = InitItem(color, this); - curves.append(curve); - return curve; - } - return nullptr; + + auto *curve = InitItem(color, this); + m_curves.append(curve); + return curve; } //--------------------------------------------------------------------------------------------------------------------- QT_WARNING_PUSH QT_WARNING_DISABLE_GCC("-Wswitch-default") -void VisOperation::RefreshFlippedObjects(const QPointF &firstPoint, const QPointF &secondPoint) +void VisOperation::RefreshFlippedObjects(quint32 originPointId, const QPointF &firstPoint, const QPointF &secondPoint) { int iPoint = -1; int iCurve = -1; - for (auto id : qAsConst(objects)) + for (auto id : qAsConst(m_objects)) { - const QSharedPointer obj = Visualization::data->GetGObject(id); + const QSharedPointer obj = GetData()->GetGObject(id); // This check helps to find missed objects in the switch Q_STATIC_ASSERT_X(static_cast(GOType::Unknown) == 8, "Not all objects were handled."); @@ -115,49 +102,50 @@ void VisOperation::RefreshFlippedObjects(const QPointF &firstPoint, const QPoint { case GOType::Point: { - const QSharedPointer p = Visualization::data->GeometricObject(id); + const QSharedPointer p = GetData()->GeometricObject(id); ++iPoint; - VScaledEllipse *point = GetPoint(static_cast(iPoint), supportColor2); - DrawPoint(point, static_cast(*p), supportColor2); + VScaledEllipse *point = GetPoint(static_cast(iPoint), Color(VColor::SupportColor2)); + DrawPoint(point, static_cast(*p), Color(VColor::SupportColor2)); ++iPoint; - point = GetPoint(static_cast(iPoint), supportColor); + point = GetPoint(static_cast(iPoint), Color(VColor::SupportColor)); - if (object1Id != NULL_ID) + if (originPointId != NULL_ID) { - DrawPoint(point, static_cast(p->Flip(QLineF(firstPoint, secondPoint))), supportColor); + DrawPoint(point, static_cast(p->Flip(QLineF(firstPoint, secondPoint))), + Color(VColor::SupportColor)); } break; } case GOType::Arc: { - iCurve = AddFlippedCurve(firstPoint, secondPoint, id, iCurve); + iCurve = AddFlippedCurve(originPointId, firstPoint, secondPoint, id, iCurve); break; } case GOType::EllipticalArc: { - iCurve = AddFlippedCurve(firstPoint, secondPoint, id, iCurve); + iCurve = AddFlippedCurve(originPointId, firstPoint, secondPoint, id, iCurve); break; } case GOType::Spline: { - iCurve = AddFlippedCurve(firstPoint, secondPoint, id, iCurve); + iCurve = AddFlippedCurve(originPointId, firstPoint, secondPoint, id, iCurve); break; } case GOType::SplinePath: { - iCurve = AddFlippedCurve(firstPoint, secondPoint, id, iCurve); + iCurve = AddFlippedCurve(originPointId, firstPoint, secondPoint, id, iCurve); break; } case GOType::CubicBezier: { - iCurve = AddFlippedCurve(firstPoint, secondPoint, id, iCurve); + iCurve = AddFlippedCurve(originPointId, firstPoint, secondPoint, id, iCurve); break; } case GOType::CubicBezierPath: { - iCurve = AddFlippedCurve(firstPoint, secondPoint, id, iCurve); + iCurve = AddFlippedCurve(originPointId, firstPoint, secondPoint, id, iCurve); break; } case GOType::Unknown: diff --git a/src/libs/vtools/visualization/line/operation/visoperation.h b/src/libs/vtools/visualization/line/operation/visoperation.h index 6fa325978..42a55032a 100644 --- a/src/libs/vtools/visualization/line/operation/visoperation.h +++ b/src/libs/vtools/visualization/line/operation/visoperation.h @@ -39,52 +39,62 @@ class VisOperation : public VisLine Q_OBJECT // NOLINT public: explicit VisOperation(const VContainer *data, QGraphicsItem *parent = nullptr); - virtual ~VisOperation(); + ~VisOperation() override; void SetObjects(const QVector &objects); + void VisualMode(quint32 id = NULL_ID) override; - virtual void VisualMode(const quint32 &pointId = NULL_ID) override; + auto type() const -> int override {return Type;} + enum {Type = UserType + static_cast(Vis::ToolRotation)}; - virtual int type() const override {return Type;} - enum { Type = UserType + static_cast(Vis::ToolRotation)}; protected: - QVector objects; - QColor supportColor2; - QColor supportColor3; - - QVector points; - QVector curves; - - VScaledEllipse *GetPoint(quint32 i, const QColor &color); - VCurvePathItem *GetCurve(quint32 i, const QColor &color); + auto GetPoint(quint32 i, const QColor &color) -> VScaledEllipse *; + auto GetCurve(quint32 i, const QColor &color) -> VCurvePathItem *; template - int AddFlippedCurve(const QPointF &firstPoint, const QPointF &secondPoint, quint32 id, int i); + auto AddFlippedCurve(quint32 originPointId, const QPointF &firstPoint, const QPointF &secondPoint, quint32 id, + int i) -> int; - void RefreshFlippedObjects(const QPointF &firstPoint, const QPointF &secondPoint); + void RefreshFlippedObjects(quint32 originPointId, const QPointF &firstPoint, const QPointF &secondPoint); + + auto Objects() const -> const QVector &; private: Q_DISABLE_COPY_MOVE(VisOperation) // NOLINT + + QVector m_objects{}; + + QVector m_points{}; + QVector m_curves{}; }; //--------------------------------------------------------------------------------------------------------------------- template -int VisOperation::AddFlippedCurve(const QPointF &firstPoint, const QPointF &secondPoint, quint32 id, int i) +auto VisOperation::AddFlippedCurve(quint32 originPointId, const QPointF &firstPoint, const QPointF &secondPoint, + quint32 id, int i) -> int { - const QSharedPointer curve = Visualization::data->template GeometricObject(id); + const QSharedPointer curve = GetData()->template GeometricObject(id); ++i; - VCurvePathItem *path = GetCurve(static_cast(i), supportColor2); - DrawPath(path, curve->GetPath(), curve->DirectionArrows(), supportColor2, Qt::SolidLine, Qt::RoundCap); + VCurvePathItem *path = GetCurve(static_cast(i), Color(VColor::SupportColor2)); + DrawPath(path, curve->GetPath(), curve->DirectionArrows(), Color(VColor::SupportColor2), Qt::SolidLine, + Qt::RoundCap); ++i; - path = GetCurve(static_cast(i), supportColor); - if (object1Id != NULL_ID) + path = GetCurve(static_cast(i), Color(VColor::SupportColor)); + if (originPointId != NULL_ID) { const Item flipped = curve->Flip(QLineF(firstPoint, secondPoint)); - DrawPath(path, flipped.GetPath(), flipped.DirectionArrows(), supportColor, Qt::SolidLine, Qt::RoundCap); + DrawPath(path, flipped.GetPath(), flipped.DirectionArrows(), Color(VColor::SupportColor), Qt::SolidLine, + Qt::RoundCap); } return i; } +//--------------------------------------------------------------------------------------------------------------------- +inline auto VisOperation::Objects() const -> const QVector & +{ + return m_objects; +} + #endif // VISOPERATION_H diff --git a/src/libs/vtools/visualization/line/operation/vistoolflippingbyaxis.cpp b/src/libs/vtools/visualization/line/operation/vistoolflippingbyaxis.cpp index 22c77e625..e8ae81f9e 100644 --- a/src/libs/vtools/visualization/line/operation/vistoolflippingbyaxis.cpp +++ b/src/libs/vtools/visualization/line/operation/vistoolflippingbyaxis.cpp @@ -31,17 +31,15 @@ //--------------------------------------------------------------------------------------------------------------------- VisToolFlippingByAxis::VisToolFlippingByAxis(const VContainer *data, QGraphicsItem *parent) - : VisOperation(data, parent), - m_axisType(AxisType::VerticalAxis), - point1(nullptr) + : VisOperation(data, parent) { - point1 = InitPoint(supportColor2, this); + m_point1 = InitPoint(Color(VColor::SupportColor2), this); } //--------------------------------------------------------------------------------------------------------------------- void VisToolFlippingByAxis::RefreshGeometry() { - if (objects.isEmpty()) + if (Objects().isEmpty()) { return; } @@ -49,10 +47,10 @@ void VisToolFlippingByAxis::RefreshGeometry() QPointF firstPoint; QPointF secondPoint; - if (object1Id != NULL_ID) + if (m_originPointId != NULL_ID) { - firstPoint = static_cast(*Visualization::data->GeometricObject(object1Id)); - DrawPoint(point1, firstPoint, supportColor2); + firstPoint = static_cast(*GetData()->GeometricObject(m_originPointId)); + DrawPoint(m_point1, firstPoint, Color(VColor::SupportColor2)); if (m_axisType == AxisType::VerticalAxis) { @@ -63,20 +61,8 @@ void VisToolFlippingByAxis::RefreshGeometry() secondPoint = QPointF(firstPoint.x() + 100, firstPoint.y()); } - DrawLine(this, Axis(firstPoint, secondPoint), supportColor2, Qt::DashLine); + DrawLine(this, Axis(firstPoint, secondPoint), Color(VColor::SupportColor2), Qt::DashLine); } - RefreshFlippedObjects(firstPoint, secondPoint); -} - -//--------------------------------------------------------------------------------------------------------------------- -void VisToolFlippingByAxis::SetOriginPointId(quint32 value) -{ - object1Id = value; -} - -//--------------------------------------------------------------------------------------------------------------------- -void VisToolFlippingByAxis::SetAxisType(AxisType value) -{ - m_axisType = value; + RefreshFlippedObjects(m_originPointId, firstPoint, secondPoint); } diff --git a/src/libs/vtools/visualization/line/operation/vistoolflippingbyaxis.h b/src/libs/vtools/visualization/line/operation/vistoolflippingbyaxis.h index f52d0d2c8..69782de8b 100644 --- a/src/libs/vtools/visualization/line/operation/vistoolflippingbyaxis.h +++ b/src/libs/vtools/visualization/line/operation/vistoolflippingbyaxis.h @@ -39,22 +39,36 @@ class VisToolFlippingByAxis : public VisOperation Q_OBJECT // NOLINT public: explicit VisToolFlippingByAxis(const VContainer *data, QGraphicsItem *parent = nullptr); - virtual ~VisToolFlippingByAxis() = default; + ~VisToolFlippingByAxis() override = default; - virtual void RefreshGeometry() override; + void RefreshGeometry() override; void SetOriginPointId(quint32 value); void SetAxisType(AxisType value); - virtual int type() const override {return Type;} - enum { Type = UserType + static_cast(Vis::ToolFlippingByAxis)}; + auto type() const -> int override {return Type;} + enum {Type = UserType + static_cast(Vis::ToolFlippingByAxis)}; private: // cppcheck-suppress unknownMacro Q_DISABLE_COPY_MOVE(VisToolFlippingByAxis) // NOLINT - AxisType m_axisType; + AxisType m_axisType{AxisType::VerticalAxis}; - VScaledEllipse *point1; + VScaledEllipse *m_point1{nullptr}; + + quint32 m_originPointId{NULL_ID}; }; +//--------------------------------------------------------------------------------------------------------------------- +inline void VisToolFlippingByAxis::SetOriginPointId(quint32 value) +{ + m_originPointId = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline void VisToolFlippingByAxis::SetAxisType(AxisType value) +{ + m_axisType = value; +} + #endif // VISTOOLFLIPPINGBYAXIS_H diff --git a/src/libs/vtools/visualization/line/operation/vistoolflippingbyline.cpp b/src/libs/vtools/visualization/line/operation/vistoolflippingbyline.cpp index f9601b314..6701d6c9d 100644 --- a/src/libs/vtools/visualization/line/operation/vistoolflippingbyline.cpp +++ b/src/libs/vtools/visualization/line/operation/vistoolflippingbyline.cpp @@ -31,19 +31,16 @@ //--------------------------------------------------------------------------------------------------------------------- VisToolFlippingByLine::VisToolFlippingByLine(const VContainer *data, QGraphicsItem *parent) - : VisOperation(data, parent), - object2Id(NULL_ID), - point1(nullptr), - point2(nullptr) + : VisOperation(data, parent) { - point1 = InitPoint(supportColor2, this); - point2 = InitPoint(supportColor2, this); + m_point1 = InitPoint(Color(VColor::SupportColor2), this); + m_point2 = InitPoint(Color(VColor::SupportColor2), this); } //--------------------------------------------------------------------------------------------------------------------- void VisToolFlippingByLine::RefreshGeometry() { - if (objects.isEmpty()) + if (Objects().isEmpty()) { return; } @@ -51,35 +48,23 @@ void VisToolFlippingByLine::RefreshGeometry() QPointF firstPoint; QPointF secondPoint; - if (object1Id != NULL_ID) + if (m_lineP1Id != NULL_ID) { - firstPoint = static_cast(*Visualization::data->GeometricObject(object1Id)); - DrawPoint(point1, firstPoint, supportColor2); + firstPoint = static_cast(*GetData()->GeometricObject(m_lineP1Id)); + DrawPoint(m_point1, firstPoint, Color(VColor::SupportColor2)); - if (object2Id == NULL_ID) + if (m_lineP2Id == NULL_ID) { - secondPoint = Visualization::scenePos; + secondPoint = ScenePos(); } else { - secondPoint = static_cast(*Visualization::data->GeometricObject(object2Id)); - DrawPoint(point2, secondPoint, supportColor2); + secondPoint = static_cast(*GetData()->GeometricObject(m_lineP2Id)); + DrawPoint(m_point2, secondPoint, Color(VColor::SupportColor2)); } - DrawLine(this, QLineF(firstPoint, secondPoint), supportColor2, Qt::DashLine); + DrawLine(this, QLineF(firstPoint, secondPoint), Color(VColor::SupportColor2), Qt::DashLine); } - RefreshFlippedObjects(firstPoint, secondPoint); -} - -//--------------------------------------------------------------------------------------------------------------------- -void VisToolFlippingByLine::SetFirstLinePointId(quint32 value) -{ - object1Id = value; -} - -//--------------------------------------------------------------------------------------------------------------------- -void VisToolFlippingByLine::SetSecondLinePointId(quint32 value) -{ - object2Id = value; + RefreshFlippedObjects(m_lineP1Id, firstPoint, secondPoint); } diff --git a/src/libs/vtools/visualization/line/operation/vistoolflippingbyline.h b/src/libs/vtools/visualization/line/operation/vistoolflippingbyline.h index 95af24e8d..55d59df52 100644 --- a/src/libs/vtools/visualization/line/operation/vistoolflippingbyline.h +++ b/src/libs/vtools/visualization/line/operation/vistoolflippingbyline.h @@ -38,21 +38,34 @@ class VisToolFlippingByLine : public VisOperation Q_OBJECT // NOLINT public: explicit VisToolFlippingByLine(const VContainer *data, QGraphicsItem *parent = nullptr); - virtual ~VisToolFlippingByLine() = default; + ~VisToolFlippingByLine() override = default; - virtual void RefreshGeometry() override; + void RefreshGeometry() override; void SetFirstLinePointId(quint32 value); void SetSecondLinePointId(quint32 value); - virtual int type() const override {return Type;} + auto type() const -> int override {return Type;} enum { Type = UserType + static_cast(Vis::ToolFlippingByLine)}; private: // cppcheck-suppress unknownMacro Q_DISABLE_COPY_MOVE(VisToolFlippingByLine) // NOLINT - quint32 object2Id; - VScaledEllipse *point1; - VScaledEllipse *point2; + quint32 m_lineP1Id{NULL_ID}; + quint32 m_lineP2Id{NULL_ID}; + VScaledEllipse *m_point1{nullptr}; + VScaledEllipse *m_point2{nullptr}; }; +//--------------------------------------------------------------------------------------------------------------------- +inline void VisToolFlippingByLine::SetFirstLinePointId(quint32 value) +{ + m_lineP1Id = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline void VisToolFlippingByLine::SetSecondLinePointId(quint32 value) +{ + m_lineP2Id = value; +} + #endif // VISTOOLFLIPPINGBYLINE_H diff --git a/src/libs/vtools/visualization/line/operation/vistoolmove.cpp b/src/libs/vtools/visualization/line/operation/vistoolmove.cpp index 40da9035e..b9dbf39f0 100644 --- a/src/libs/vtools/visualization/line/operation/vistoolmove.cpp +++ b/src/libs/vtools/visualization/line/operation/vistoolmove.cpp @@ -62,29 +62,20 @@ //--------------------------------------------------------------------------------------------------------------------- VisToolMove::VisToolMove(const VContainer *data, QGraphicsItem *parent) - : VisOperation(data, parent), - angle(0), - rotationAngle(INT_MIN), - length(0), - pointOrigin(nullptr), - pointRotationOrigin(nullptr), - pointFinish(nullptr), - angleArc(nullptr), - rotationLine(nullptr), - xAxis(nullptr) + : VisOperation(data, parent) { - pointOrigin = InitPoint(supportColor2, this); - pointRotationOrigin = InitPoint(supportColor2, this); - pointFinish = InitPoint(supportColor, this); - angleArc = InitItem(supportColor3, this); - rotationLine = InitItem(supportColor3, this); - xAxis = InitItem(supportColor3, this); + m_pointOrigin = InitPoint(Color(VColor::SupportColor2), this); + m_pointRotationOrigin = InitPoint(Color(VColor::SupportColor2), this); + m_pointFinish = InitPoint(Color(VColor::SupportColor), this); + m_angleArc = InitItem(Color(VColor::SupportColor3), this); + m_rotationLine = InitItem(Color(VColor::SupportColor3), this); + m_xAxis = InitItem(Color(VColor::SupportColor3), this); } //--------------------------------------------------------------------------------------------------------------------- void VisToolMove::RefreshGeometry() { - if (objects.isEmpty()) + if (Objects().isEmpty()) { return; } @@ -95,23 +86,23 @@ void VisToolMove::RefreshGeometry() const QVector originObjects = CreateOriginObjects(iPoint, iCurve); QPointF origin = GetOriginPoint(originObjects); - DrawPoint(pointOrigin, origin, supportColor2); + DrawPoint(m_pointOrigin, origin, Color(VColor::SupportColor2)); qreal tempAngle = 0; qreal tempLength = 0; qreal tempRoationAngle = 0; QLineF line; - if (qFuzzyIsNull(length)) + if (qFuzzyIsNull(m_length)) { if (QGuiApplication::keyboardModifiers() == Qt::ShiftModifier) { - line = QLineF(origin, Visualization::scenePos); + line = QLineF(origin, ScenePos()); line.setAngle(CorrectAngle(line.angle())); } else { - line = QLineF(origin, Visualization::scenePos); + line = QLineF(origin, ScenePos()); } tempAngle = line.angle(); @@ -119,25 +110,25 @@ void VisToolMove::RefreshGeometry() } else { - line = VGObject::BuildLine(origin, length, angle); - tempAngle = angle; - tempLength = length; + line = VGObject::BuildLine(origin, m_length, m_angle); + tempAngle = m_angle; + tempLength = m_length; - if (object1Id != NULL_ID) + if (m_rotationOriginId != NULL_ID) { - origin = Visualization::data->GeometricObject(object1Id)->toQPointF(); - DrawPoint(pointRotationOrigin, origin, supportColor2); + origin = GetData()->GeometricObject(m_rotationOriginId)->toQPointF(); + DrawPoint(m_pointRotationOrigin, origin, Color(VColor::SupportColor2)); } else { origin = line.p2(); - pointRotationOrigin->setVisible(false); + m_pointRotationOrigin->setVisible(false); } QLineF rLine; - if (VFuzzyComparePossibleNulls(rotationAngle, INT_MIN)) + if (VFuzzyComparePossibleNulls(m_rotationAngle, INT_MIN)) { - rLine = QLineF(origin, Visualization::scenePos); + rLine = QLineF(origin, ScenePos()); if (QGuiApplication::keyboardModifiers() == Qt::ShiftModifier) { @@ -159,48 +150,48 @@ void VisToolMove::RefreshGeometry() } else { - rLine = QLineF(origin, Ray(origin, rotationAngle)); - tempRoationAngle = rotationAngle; + rLine = QLineF(origin, Ray(origin, m_rotationAngle)); + tempRoationAngle = m_rotationAngle; } - DrawLine(rotationLine, rLine, supportColor3, Qt::DashLine); - DrawLine(xAxis, QLineF(origin, Ray(origin, 0)), supportColor3, Qt::DashLine); + DrawLine(m_rotationLine, rLine, Color(VColor::SupportColor3), Qt::DashLine); + DrawLine(m_xAxis, QLineF(origin, Ray(origin, 0)), Color(VColor::SupportColor3), Qt::DashLine); VArc arc(VPointF(origin), ScaledRadius(SceneScale(VAbstractValApplication::VApp()->getCurrentScene()))*2, 0, tempRoationAngle); - DrawPath(angleArc, arc.GetPath(), supportColor3, Qt::SolidLine, Qt::RoundCap); + DrawPath(m_angleArc, arc.GetPath(), Color(VColor::SupportColor3), Qt::SolidLine, Qt::RoundCap); } - DrawLine(this, line, supportColor2, Qt::DashLine); - DrawPoint(pointFinish, line.p2(), supportColor); + DrawLine(this, line, Color(VColor::SupportColor2), Qt::DashLine); + DrawPoint(m_pointFinish, line.p2(), Color(VColor::SupportColor)); static const QString prefix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true); - if (qFuzzyIsNull(length)) + if (qFuzzyIsNull(m_length)) { - Visualization::toolTip = tr("Length = %1%2, angle = %3°, %4 - sticking angle, " - "Mouse click - finish selecting a position") - .arg(VAbstractApplication::VApp()->TrVars()->FormulaToUser( - QString::number(VAbstractValApplication::VApp()->fromPixel(tempLength)), - VAbstractApplication::VApp()->Settings()->GetOsSeparator()), prefix) - .arg(tempAngle) - .arg(VModifierKey::Shift()); + SetToolTip(tr("Length = %1%2, angle = %3°, %4 - sticking angle, " + "Mouse click - finish selecting a position") + .arg(VAbstractApplication::VApp()->TrVars()->FormulaToUser( + QString::number(VAbstractValApplication::VApp()->fromPixel(tempLength)), + VAbstractApplication::VApp()->Settings()->GetOsSeparator()), prefix) + .arg(tempAngle) + .arg(VModifierKey::Shift())); } else { - Visualization::toolTip = tr("Length = %1%2, angle = %3°, rotation angle = %4°, %5 - sticking angle, " - "%6 - change rotation origin point, Mouse click - finish creating") - .arg(VAbstractApplication::VApp()->TrVars()->FormulaToUser( - QString::number(VAbstractValApplication::VApp()->fromPixel(tempLength)), - VAbstractApplication::VApp()->Settings()->GetOsSeparator()), prefix) - .arg(tempAngle) - .arg(tempRoationAngle) - .arg(VModifierKey::Shift(), VModifierKey::Control()); + SetToolTip(tr("Length = %1%2, angle = %3°, rotation angle = %4°, %5 - sticking angle, " + "%6 - change rotation origin point, Mouse click - finish creating") + .arg(VAbstractApplication::VApp()->TrVars()->FormulaToUser( + QString::number(VAbstractValApplication::VApp()->fromPixel(tempLength)), + VAbstractApplication::VApp()->Settings()->GetOsSeparator()), prefix) + .arg(tempAngle) + .arg(tempRoationAngle) + .arg(VModifierKey::Shift(), VModifierKey::Control())); } CreateMovedRotatedObjects(iPoint, iCurve, tempLength, tempAngle, tempRoationAngle, origin); } //--------------------------------------------------------------------------------------------------------------------- -QString VisToolMove::Angle() const +auto VisToolMove::Angle() const -> QString { return QString::number(line().angle()); } @@ -208,29 +199,29 @@ QString VisToolMove::Angle() const //--------------------------------------------------------------------------------------------------------------------- void VisToolMove::SetAngle(const QString &expression) { - angle = FindValFromUser(expression, Visualization::data->DataVariables()); + m_angle = FindValFromUser(expression, GetData()->DataVariables()); } //--------------------------------------------------------------------------------------------------------------------- -QString VisToolMove::RotationAngle() const +auto VisToolMove::RotationAngle() const -> QString { - return QString::number(rotationLine->line().angle()); + return QString::number(m_rotationLine->line().angle()); } //--------------------------------------------------------------------------------------------------------------------- void VisToolMove::SetRotationAngle(const QString &expression) { - rotationAngle = FindValFromUser(expression, Visualization::data->DataVariables()); + m_rotationAngle = FindValFromUser(expression, GetData()->DataVariables()); } //--------------------------------------------------------------------------------------------------------------------- -QString VisToolMove::Length() const +auto VisToolMove::Length() const -> QString { return QString::number(LengthValue()); } //--------------------------------------------------------------------------------------------------------------------- -qreal VisToolMove::LengthValue() const +auto VisToolMove::LengthValue() const -> qreal { return VAbstractValApplication::VApp()->fromPixel(line().length()); } @@ -238,48 +229,43 @@ qreal VisToolMove::LengthValue() const //--------------------------------------------------------------------------------------------------------------------- void VisToolMove::SetLength(const QString &expression) { - length = FindLengthFromUser(expression, Visualization::data->DataVariables()); -} - -//--------------------------------------------------------------------------------------------------------------------- -void VisToolMove::SetRotationOriginPointId(quint32 value) -{ - object1Id = value; + m_length = FindLengthFromUser(expression, GetData()->DataVariables()); } //--------------------------------------------------------------------------------------------------------------------- template -QGraphicsPathItem *VisToolMove::AddOriginCurve(quint32 id, int &i) +auto VisToolMove::AddOriginCurve(quint32 id, int &i) -> QGraphicsPathItem * { - const QSharedPointer curve = Visualization::data->template GeometricObject(id); + const QSharedPointer curve = GetData()->template GeometricObject(id); ++i; - VCurvePathItem *path = GetCurve(static_cast(i), supportColor2); - DrawPath(path, curve->GetPath(), curve->DirectionArrows(), supportColor2, Qt::SolidLine, Qt::RoundCap); + VCurvePathItem *path = GetCurve(static_cast(i), Color(VColor::SupportColor2)); + DrawPath(path, curve->GetPath(), curve->DirectionArrows(), Color(VColor::SupportColor2), Qt::SolidLine, + Qt::RoundCap); return path; } //--------------------------------------------------------------------------------------------------------------------- template -int VisToolMove::AddMovedRotatedCurve(qreal angle, qreal length, quint32 id, int i, qreal rotationAngle, - const QPointF &rotationOrigin) +auto VisToolMove::AddMovedRotatedCurve(qreal angle, qreal length, quint32 id, int i, qreal rotationAngle, + const QPointF &rotationOrigin) -> int { - const QSharedPointer curve = Visualization::data->template GeometricObject(id); + const QSharedPointer curve = GetData()->template GeometricObject(id); ++i; - VCurvePathItem *path = GetCurve(static_cast(i), supportColor); + VCurvePathItem *path = GetCurve(static_cast(i), Color(VColor::SupportColor)); const Item moved = curve->Move(length, angle).Rotate(rotationOrigin, rotationAngle); - DrawPath(path, moved.GetPath(), moved.DirectionArrows(), supportColor, Qt::SolidLine, Qt::RoundCap); + DrawPath(path, moved.GetPath(), moved.DirectionArrows(), Color(VColor::SupportColor), Qt::SolidLine, Qt::RoundCap); return i; } //--------------------------------------------------------------------------------------------------------------------- -QPointF VisToolMove::GetOriginPoint(const QVector &objects) +auto VisToolMove::GetOriginPoint(const QVector &objects) -> QPointF { QRectF boundingRect; - for (auto object : qAsConst(objects)) + for (auto *object : qAsConst(objects)) { if (object) { @@ -303,13 +289,14 @@ QPointF VisToolMove::GetOriginPoint(const QVector &objects) QT_WARNING_PUSH QT_WARNING_DISABLE_GCC("-Wswitch-default") -QVector VisToolMove::CreateOriginObjects(int &iPoint, int &iCurve) +auto VisToolMove::CreateOriginObjects(int &iPoint, int &iCurve) -> QVector { QVector originObjects; + originObjects.reserve(Objects().size()); - for (auto id : qAsConst(objects)) + for (auto id : Objects()) { - const QSharedPointer obj = Visualization::data->GetGObject(id); + const QSharedPointer obj = GetData()->GetGObject(id); // This check helps to find missed objects in the switch Q_STATIC_ASSERT_X(static_cast(GOType::Unknown) == 8, "Not all objects were handled."); @@ -318,11 +305,11 @@ QVector VisToolMove::CreateOriginObjects(int &iPoint, int &iCur { case GOType::Point: { - const QSharedPointer p = Visualization::data->GeometricObject(id); + const QSharedPointer p = GetData()->GeometricObject(id); ++iPoint; - VScaledEllipse *point = GetPoint(static_cast(iPoint), supportColor2); - DrawPoint(point, static_cast(*p), supportColor2); + VScaledEllipse *point = GetPoint(static_cast(iPoint), Color(VColor::SupportColor2)); + DrawPoint(point, static_cast(*p), Color(VColor::SupportColor2)); originObjects.append(point); break; @@ -364,9 +351,9 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default") void VisToolMove::CreateMovedRotatedObjects(int &iPoint, int &iCurve, qreal length, qreal angle, qreal rotationAngle, const QPointF &rotationOrigin) { - for (auto id : qAsConst(objects)) + for (auto id : Objects()) { - const QSharedPointer obj = Visualization::data->GetGObject(id); + const QSharedPointer obj = GetData()->GetGObject(id); // This check helps to find missed objects in the switch Q_STATIC_ASSERT_X(static_cast(GOType::Unknown) == 8, "Not all objects was handled."); @@ -375,12 +362,12 @@ void VisToolMove::CreateMovedRotatedObjects(int &iPoint, int &iCurve, qreal leng { case GOType::Point: { - const QSharedPointer p = Visualization::data->GeometricObject(id); + const QSharedPointer p = GetData()->GeometricObject(id); ++iPoint; - VScaledEllipse *point = GetPoint(static_cast(iPoint), supportColor); + VScaledEllipse *point = GetPoint(static_cast(iPoint), Color(VColor::SupportColor)); DrawPoint(point, static_cast(p->Move(length, angle).Rotate(rotationOrigin, rotationAngle)), - supportColor); + Color(VColor::SupportColor)); break; } case GOType::Arc: diff --git a/src/libs/vtools/visualization/line/operation/vistoolmove.h b/src/libs/vtools/visualization/line/operation/vistoolmove.h index 092e208d1..7b94a6a41 100644 --- a/src/libs/vtools/visualization/line/operation/vistoolmove.h +++ b/src/libs/vtools/visualization/line/operation/vistoolmove.h @@ -39,7 +39,6 @@ #include #include -#include "../ifc/ifcdef.h" #include "../vmisc/def.h" #include "visoperation.h" @@ -48,49 +47,56 @@ class VisToolMove : public VisOperation Q_OBJECT // NOLINT public: explicit VisToolMove(const VContainer *data, QGraphicsItem *parent = nullptr); - virtual ~VisToolMove() = default; + ~VisToolMove() override = default; - virtual void RefreshGeometry() override; + void RefreshGeometry() override; - QString Angle() const; - void SetAngle(const QString &expression); + auto Angle() const -> QString; + void SetAngle(const QString &expression); - QString RotationAngle() const; - void SetRotationAngle(const QString &expression); + auto RotationAngle() const -> QString; + void SetRotationAngle(const QString &expression); - QString Length() const; - qreal LengthValue() const; - void SetLength(const QString &expression); + auto Length() const -> QString; + auto LengthValue() const -> qreal; + void SetLength(const QString &expression); void SetRotationOriginPointId(quint32 value); - virtual int type() const override {return Type;} - enum { Type = UserType + static_cast(Vis::ToolMove)}; + auto type() const -> int override {return Type;} + enum {Type = UserType + static_cast(Vis::ToolMove)}; private: // cppcheck-suppress unknownMacro Q_DISABLE_COPY_MOVE(VisToolMove) // NOLINT - qreal angle; - qreal rotationAngle; - qreal length; - VScaledEllipse *pointOrigin; - VScaledEllipse *pointRotationOrigin; - VScaledEllipse *pointFinish; - VCurvePathItem *angleArc; - VScaledLine *rotationLine; - VScaledLine *xAxis; + qreal m_angle{0}; + qreal m_rotationAngle{INT_MIN}; + qreal m_length{0}; + VScaledEllipse *m_pointOrigin{nullptr}; + VScaledEllipse *m_pointRotationOrigin{nullptr}; + VScaledEllipse *m_pointFinish{nullptr}; + VCurvePathItem *m_angleArc{nullptr}; + VScaledLine *m_rotationLine{nullptr}; + VScaledLine *m_xAxis{nullptr}; + quint32 m_rotationOriginId{NULL_ID}; template - QGraphicsPathItem *AddOriginCurve(quint32 id, int &i); + auto AddOriginCurve(quint32 id, int &i) -> QGraphicsPathItem *; template - int AddMovedRotatedCurve(qreal angle, qreal length, quint32 id, int i, qreal rotationAngle, - const QPointF &rotationOrigin); + auto AddMovedRotatedCurve(qreal angle, qreal length, quint32 id, int i, qreal rotationAngle, + const QPointF &rotationOrigin) -> int; - static QPointF GetOriginPoint(const QVector &objects); + static auto GetOriginPoint(const QVector &objects) -> QPointF; - QVector CreateOriginObjects(int &iPoint, int &iCurve); + auto CreateOriginObjects(int &iPoint, int &iCurve) -> QVector; void CreateMovedRotatedObjects(int &iPoint, int &iCurve, qreal length, qreal angle, qreal rotationAngle, const QPointF &rotationOrigin); }; +//--------------------------------------------------------------------------------------------------------------------- +inline void VisToolMove::SetRotationOriginPointId(quint32 value) +{ + m_rotationOriginId = value; +} + #endif // VISTOOLMOVE_H diff --git a/src/libs/vtools/visualization/line/operation/vistoolrotation.cpp b/src/libs/vtools/visualization/line/operation/vistoolrotation.cpp index 28699490d..244a56d2b 100644 --- a/src/libs/vtools/visualization/line/operation/vistoolrotation.cpp +++ b/src/libs/vtools/visualization/line/operation/vistoolrotation.cpp @@ -59,20 +59,11 @@ //--------------------------------------------------------------------------------------------------------------------- VisToolRotation::VisToolRotation(const VContainer *data, QGraphicsItem *parent) - : VisOperation(data, parent), - angle(INT_MIN), - point(nullptr), - angleArc(nullptr), - xAxis(nullptr) -{ - point = InitPoint(supportColor2, this); - angleArc = InitItem(supportColor2, this); - xAxis = InitItem(supportColor2, this); -} - -//--------------------------------------------------------------------------------------------------------------------- -VisToolRotation::~VisToolRotation() + : VisOperation(data, parent) { + m_point = InitPoint(Color(VColor::SupportColor2), this); + m_angleArc = InitItem(Color(VColor::SupportColor2), this); + m_xAxis = InitItem(Color(VColor::SupportColor2), this); } //--------------------------------------------------------------------------------------------------------------------- @@ -81,7 +72,7 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default") void VisToolRotation::RefreshGeometry() { - if (objects.isEmpty()) + if (Objects().isEmpty()) { return; } @@ -90,15 +81,15 @@ void VisToolRotation::RefreshGeometry() qreal tempAngle = 0; - if (object1Id != NULL_ID) + if (m_originPointId != NULL_ID) { - origin = Visualization::data->GeometricObject(object1Id); - DrawPoint(point, static_cast(*origin), supportColor2); + origin = GetData()->GeometricObject(m_originPointId); + DrawPoint(m_point, static_cast(*origin), Color(VColor::SupportColor2)); QLineF rLine; - if (VFuzzyComparePossibleNulls(angle, INT_MIN)) + if (VFuzzyComparePossibleNulls(m_angle, INT_MIN)) { - rLine = QLineF(static_cast(*origin), Visualization::scenePos); + rLine = QLineF(static_cast(*origin), ScenePos()); if (QGuiApplication::keyboardModifiers() == Qt::ShiftModifier) { @@ -110,28 +101,28 @@ void VisToolRotation::RefreshGeometry() } else { - rLine = QLineF(static_cast(*origin), Ray(static_cast(*origin), angle)); - tempAngle = angle; + rLine = QLineF(static_cast(*origin), Ray(static_cast(*origin), m_angle)); + tempAngle = m_angle; } - DrawLine(this, rLine, supportColor2, Qt::DashLine); - DrawLine(xAxis, QLineF(static_cast(*origin), Ray(static_cast(*origin), 0)), supportColor2, - Qt::DashLine); + DrawLine(this, rLine, Color(VColor::SupportColor2), Qt::DashLine); + DrawLine(m_xAxis, QLineF(static_cast(*origin), Ray(static_cast(*origin), 0)), + Color(VColor::SupportColor2), Qt::DashLine); VArc arc(*origin, ScaledRadius(SceneScale(VAbstractValApplication::VApp()->getCurrentScene()))*2, 0, tempAngle); - DrawPath(angleArc, arc.GetPath(), supportColor2, Qt::SolidLine, Qt::RoundCap); + DrawPath(m_angleArc, arc.GetPath(), Color(VColor::SupportColor2), Qt::SolidLine, Qt::RoundCap); - Visualization::toolTip = tr("Rotating angle = %1°, %2 - sticking angle, " - "Mouse click - finish creation") - .arg(tempAngle) - .arg(VModifierKey::Shift()); + SetToolTip(tr("Rotating angle = %1°, %2 - sticking angle, " + "Mouse click - finish creation") + .arg(tempAngle) + .arg(VModifierKey::Shift())); } int iPoint = -1; int iCurve = -1; - for (auto id : qAsConst(objects)) + for (auto id : Objects()) { - const QSharedPointer obj = Visualization::data->GetGObject(id); + const QSharedPointer obj = GetData()->GetGObject(id); // This check helps to find missed objects in the switch Q_STATIC_ASSERT_X(static_cast(GOType::Unknown) == 8, "Not all objects was handled."); @@ -140,19 +131,19 @@ void VisToolRotation::RefreshGeometry() { case GOType::Point: { - const QSharedPointer p = Visualization::data->GeometricObject(id); + const QSharedPointer p = GetData()->GeometricObject(id); ++iPoint; - VScaledEllipse *point = GetPoint(static_cast(iPoint), supportColor2); - DrawPoint(point, static_cast(*p), supportColor2); + VScaledEllipse *point = GetPoint(static_cast(iPoint), Color(VColor::SupportColor2)); + DrawPoint(point, static_cast(*p), Color(VColor::SupportColor2)); ++iPoint; - point = GetPoint(static_cast(iPoint), supportColor); + point = GetPoint(static_cast(iPoint), Color(VColor::SupportColor)); - if (object1Id != NULL_ID) + if (m_originPointId != NULL_ID) { DrawPoint(point, static_cast(p->Rotate(static_cast(*origin), tempAngle)), - supportColor); + Color(VColor::SupportColor)); } break; } @@ -193,16 +184,11 @@ void VisToolRotation::RefreshGeometry() } } } + QT_WARNING_POP //--------------------------------------------------------------------------------------------------------------------- -void VisToolRotation::SetOriginPointId(quint32 value) -{ - object1Id = value; -} - -//--------------------------------------------------------------------------------------------------------------------- -QString VisToolRotation::Angle() const +auto VisToolRotation::Angle() const -> QString { return QString::number(line().angle()); } @@ -210,25 +196,27 @@ QString VisToolRotation::Angle() const //--------------------------------------------------------------------------------------------------------------------- void VisToolRotation::SetAngle(const QString &expression) { - angle = FindValFromUser(expression, Visualization::data->DataVariables()); + m_angle = FindValFromUser(expression, GetData()->DataVariables()); } //--------------------------------------------------------------------------------------------------------------------- template -int VisToolRotation::AddCurve(qreal angle, const QPointF &origin, quint32 id, int i) +auto VisToolRotation::AddCurve(qreal angle, const QPointF &origin, quint32 id, int i) -> int { - const QSharedPointer curve = Visualization::data->template GeometricObject(id); + const QSharedPointer curve = GetData()->template GeometricObject(id); ++i; - VCurvePathItem *path = GetCurve(static_cast(i), supportColor2); - DrawPath(path, curve->GetPath(), curve->DirectionArrows(), supportColor2, Qt::SolidLine, Qt::RoundCap); + VCurvePathItem *path = GetCurve(static_cast(i), Color(VColor::SupportColor2)); + DrawPath(path, curve->GetPath(), curve->DirectionArrows(), Color(VColor::SupportColor2), Qt::SolidLine, + Qt::RoundCap); ++i; - path = GetCurve(static_cast(i), supportColor); - if (object1Id != NULL_ID) + path = GetCurve(static_cast(i), Color(VColor::SupportColor)); + if (m_originPointId != NULL_ID) { const Item rotated = curve->Rotate(origin, angle); - DrawPath(path, rotated.GetPath(), rotated.DirectionArrows(), supportColor, Qt::SolidLine, Qt::RoundCap); + DrawPath(path, rotated.GetPath(), rotated.DirectionArrows(), Color(VColor::SupportColor), Qt::SolidLine, + Qt::RoundCap); } return i; diff --git a/src/libs/vtools/visualization/line/operation/vistoolrotation.h b/src/libs/vtools/visualization/line/operation/vistoolrotation.h index f06853212..488361d8a 100644 --- a/src/libs/vtools/visualization/line/operation/vistoolrotation.h +++ b/src/libs/vtools/visualization/line/operation/vistoolrotation.h @@ -39,7 +39,6 @@ #include #include -#include "../ifc/ifcdef.h" #include "../vmisc/def.h" #include "visoperation.h" @@ -48,27 +47,34 @@ class VisToolRotation : public VisOperation Q_OBJECT // NOLINT public: explicit VisToolRotation(const VContainer *data, QGraphicsItem *parent = nullptr); - virtual ~VisToolRotation(); + ~VisToolRotation() override = default; - virtual void RefreshGeometry() override; + void RefreshGeometry() override; void SetOriginPointId(quint32 value); - QString Angle() const; - void SetAngle(const QString &expression); + auto Angle() const -> QString; + void SetAngle(const QString &expression); - virtual int type() const override {return Type;} - enum { Type = UserType + static_cast(Vis::ToolRotation)}; + auto type() const -> int override {return Type;} + enum {Type = UserType + static_cast(Vis::ToolRotation)}; private: // cppcheck-suppress unknownMacro Q_DISABLE_COPY_MOVE(VisToolRotation) // NOLINT - qreal angle; - VScaledEllipse *point; - VCurvePathItem *angleArc; - VScaledLine *xAxis; + qreal m_angle{INT_MIN}; + VScaledEllipse *m_point{nullptr}; + VCurvePathItem *m_angleArc{nullptr}; + VScaledLine *m_xAxis{nullptr}; + quint32 m_originPointId{NULL_ID}; template - int AddCurve(qreal angle, const QPointF &origin, quint32 id, int i); + auto AddCurve(qreal angle, const QPointF &origin, quint32 id, int i) -> int; }; +//--------------------------------------------------------------------------------------------------------------------- +inline void VisToolRotation::SetOriginPointId(quint32 value) +{ + m_originPointId = value; +} + #endif // VISTOOLROTATION_H diff --git a/src/libs/vtools/visualization/line/visline.cpp b/src/libs/vtools/visualization/line/visline.cpp index ef7f77881..a0719581d 100644 --- a/src/libs/vtools/visualization/line/visline.cpp +++ b/src/libs/vtools/visualization/line/visline.cpp @@ -32,11 +32,9 @@ #include #include #include +#include -#include "../ifc/ifcdef.h" #include "../vgeometry/vgobject.h" -#include "../vmisc/vabstractapplication.h" -#include "../vmisc/vmath.h" #include "../vpatterndb/vcontainer.h" //--------------------------------------------------------------------------------------------------------------------- @@ -48,7 +46,7 @@ VisLine::VisLine(const VContainer *data, QGraphicsItem *parent) } //--------------------------------------------------------------------------------------------------------------------- -qreal VisLine::CorrectAngle(const qreal &angle) +auto VisLine::CorrectAngle(const qreal &angle) -> qreal { qreal ang = angle; if (angle > 360) @@ -79,11 +77,11 @@ qreal VisLine::CorrectAngle(const qreal &angle) } //--------------------------------------------------------------------------------------------------------------------- -QPointF VisLine::Ray(const QPointF &firstPoint, const qreal &angle) const +auto VisLine::Ray(const QPointF &firstPoint, const qreal &angle) const -> QPointF { if (this->scene() == nullptr) { - QLineF line = QLineF(firstPoint, Visualization::scenePos); + QLineF line = QLineF(firstPoint, ScenePos()); line.setAngle(angle); return line.p2();// We can't find ray because item doesn't have scene. We will return cursor position on scene. } @@ -103,29 +101,25 @@ QPointF VisLine::Ray(const QPointF &firstPoint, const qreal &angle) const { return VGObject::BuildRay(firstPoint, CorrectAngle(angle), scRect); } - else - { - return VGObject::BuildRay(firstPoint, angle, scRect); - } + + return VGObject::BuildRay(firstPoint, angle, scRect); } //--------------------------------------------------------------------------------------------------------------------- -QPointF VisLine::Ray(const QPointF &firstPoint) const +auto VisLine::Ray(const QPointF &firstPoint) const -> QPointF { - QLineF line = QLineF(firstPoint, Visualization::scenePos); + QLineF line = QLineF(firstPoint, ScenePos()); return Ray(firstPoint, line.angle()); } //--------------------------------------------------------------------------------------------------------------------- -QLineF VisLine::Axis(const QPointF &p, const qreal &angle) const +auto VisLine::Axis(const QPointF &p, const qreal &angle) const -> QLineF { - QPointF endP1 = Ray(p, angle+180); - QPointF endP2 = Ray(p, angle); - return QLineF(endP1, endP2); + return {Ray(p, angle+180), Ray(p, angle)}; } //--------------------------------------------------------------------------------------------------------------------- -QLineF VisLine::Axis(const QPointF &p1, const QPointF &p2) const +auto VisLine::Axis(const QPointF &p1, const QPointF &p2) const -> QLineF { QLineF line(p1, p2); return Axis(p1, line.angle()); @@ -135,8 +129,8 @@ QLineF VisLine::Axis(const QPointF &p1, const QPointF &p2) const void VisLine::InitPen() { QPen visPen = pen(); - visPen.setColor(mainColor); - visPen.setStyle(lineStyle); + visPen.setColor(Color(VColor::MainColor)); + visPen.setStyle(LineStyle()); setPen(visPen); } diff --git a/src/libs/vtools/visualization/line/visline.h b/src/libs/vtools/visualization/line/visline.h index d1a39963c..0b42f103a 100644 --- a/src/libs/vtools/visualization/line/visline.h +++ b/src/libs/vtools/visualization/line/visline.h @@ -50,21 +50,23 @@ class VisLine: public Visualization, public VScaledLine Q_OBJECT // NOLINT public: explicit VisLine(const VContainer *data, QGraphicsItem *parent = nullptr); - virtual ~VisLine() = default; + ~VisLine() override = default; - virtual int type() const override {return Type;} - enum { Type = UserType + static_cast(Vis::Line)}; - static qreal CorrectAngle(const qreal &angle); + auto type() const -> int override {return Type;} + enum {Type = UserType + static_cast(Vis::Line)}; + + static auto CorrectAngle(const qreal &angle) -> qreal; protected: - QPointF Ray(const QPointF &firstPoint, const qreal &angle) const; - QPointF Ray(const QPointF &firstPoint) const; - QLineF Axis(const QPointF &p, const qreal &angle) const; - QLineF Axis(const QPointF &p1, const QPointF &p2) const; - virtual void InitPen() override; - virtual void AddOnScene() override; + auto Ray(const QPointF &firstPoint, const qreal &angle) const -> QPointF; + auto Ray(const QPointF &firstPoint) const -> QPointF; + auto Axis(const QPointF &p, const qreal &angle) const -> QLineF; + auto Axis(const QPointF &p1, const QPointF &p2) const -> QLineF; - void DrawRay(VScaledLine *lineItem, const QPointF &p, const QPointF &pTangent, - const QColor &color, Qt::PenStyle style); + void InitPen() override; + void AddOnScene() override; + + void DrawRay(VScaledLine *lineItem, const QPointF &p, const QPointF &pTangent, const QColor &color, + Qt::PenStyle style); private: Q_DISABLE_COPY_MOVE(VisLine) // NOLINT }; diff --git a/src/libs/vtools/visualization/line/vistoolalongline.cpp b/src/libs/vtools/visualization/line/vistoolalongline.cpp index e04423970..933c39f37 100644 --- a/src/libs/vtools/visualization/line/vistoolalongline.cpp +++ b/src/libs/vtools/visualization/line/vistoolalongline.cpp @@ -47,70 +47,58 @@ VisToolAlongLine::VisToolAlongLine(const VContainer *data, QGraphicsItem *parent) : VisLine(data, parent) { - this->mainColor = Qt::red; + SetMainColor(Qt::red); this->setZValue(2);// Show on top real tool - m_lineP1 = InitPoint(supportColor, this); - m_lineP2 = InitPoint(supportColor, this); //-V656 - m_line = InitItem(supportColor, this); - m_point = InitPoint(mainColor, this); + m_lineP1 = InitPoint(Color(VColor::SupportColor), this); + m_lineP2 = InitPoint(Color(VColor::SupportColor), this); //-V656 + m_line = InitItem(Color(VColor::SupportColor), this); + m_point = InitPoint(Color(VColor::MainColor), this); } //--------------------------------------------------------------------------------------------------------------------- -void VisToolAlongLine::setObject2Id(const quint32 &value) +void VisToolAlongLine::SetLength(const QString &expression) { - m_object2Id = value; -} - -//--------------------------------------------------------------------------------------------------------------------- -void VisToolAlongLine::setLength(const QString &expression) -{ - m_length = FindLengthFromUser(expression, Visualization::data->DataVariables()); -} - -//--------------------------------------------------------------------------------------------------------------------- -void VisToolAlongLine::setMidPointMode(bool midPointMode) -{ - m_midPointMode = midPointMode; + m_length = FindLengthFromUser(expression, GetData()->DataVariables()); } //--------------------------------------------------------------------------------------------------------------------- void VisToolAlongLine::RefreshGeometry() { - if (object1Id > NULL_ID) + if (m_point1Id > NULL_ID) { - const QSharedPointer first = Visualization::data->GeometricObject(object1Id); - DrawPoint(m_lineP1, static_cast(*first), supportColor); + const QSharedPointer first = GetData()->GeometricObject(m_point1Id); + DrawPoint(m_lineP1, static_cast(*first), Color(VColor::SupportColor)); - if (m_object2Id <= NULL_ID) + if (m_point2Id <= NULL_ID) { - QLineF cursorLine (static_cast(*first), Visualization::scenePos); - DrawLine(m_line, cursorLine, supportColor); + QLineF cursorLine (static_cast(*first), ScenePos()); + DrawLine(m_line, cursorLine, Color(VColor::SupportColor)); if (m_midPointMode) { cursorLine.setLength(cursorLine.length()/2.0); - DrawPoint(m_point, cursorLine.p2(), mainColor); + DrawPoint(m_point, cursorLine.p2(), Color(VColor::MainColor)); } } else { - const QSharedPointer second = Visualization::data->GeometricObject(m_object2Id); - DrawPoint(m_lineP2, static_cast(*second), supportColor); + const QSharedPointer second = GetData()->GeometricObject(m_point2Id); + DrawPoint(m_lineP2, static_cast(*second), Color(VColor::SupportColor)); QLineF baseLine(static_cast(*first), static_cast(*second)); - DrawLine(m_line, baseLine, supportColor); + DrawLine(m_line, baseLine, Color(VColor::SupportColor)); if (not qFuzzyIsNull(m_length)) { QLineF mainLine = VGObject::BuildLine(static_cast(*first), m_length, m_line->line().angle()); - DrawLine(this, mainLine, mainColor, lineStyle); + DrawLine(this, mainLine, Color(VColor::MainColor), LineStyle()); - DrawPoint(m_point, mainLine.p2(), mainColor); + DrawPoint(m_point, mainLine.p2(), Color(VColor::MainColor)); } - else if (mode == Mode::Creation) + else if (GetMode() == Mode::Creation) { - QLineF cursorLine (static_cast(*first), Visualization::scenePos); + QLineF cursorLine (static_cast(*first), ScenePos()); qreal len = cursorLine.length(); qreal angleTo = baseLine.angleTo(cursorLine); @@ -120,16 +108,23 @@ void VisToolAlongLine::RefreshGeometry() } QLineF mainLine = VGObject::BuildLine(static_cast(*first), len, m_line->line().angle()); - DrawLine(this, mainLine, mainColor, lineStyle); + DrawLine(this, mainLine, Color(VColor::MainColor), LineStyle()); - DrawPoint(m_point, mainLine.p2(), mainColor); + DrawPoint(m_point, mainLine.p2(), Color(VColor::MainColor)); const QString prefix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true); - Visualization::toolTip = tr("Length = %1%2; " - "Mouse click - finish selecting the length, " - "%3 - skip") - .arg(NumberToUser(len), prefix, VModifierKey::EnterKey()); + SetToolTip(tr("Length = %1%2; " + "Mouse click - finish selecting the length, " + "%3 - skip") + .arg(NumberToUser(len), prefix, VModifierKey::EnterKey())); } } } } + +//--------------------------------------------------------------------------------------------------------------------- +void VisToolAlongLine::VisualMode(quint32 id) +{ + m_point1Id = id; + StartVisualMode(); +} diff --git a/src/libs/vtools/visualization/line/vistoolalongline.h b/src/libs/vtools/visualization/line/vistoolalongline.h index acc46f0a2..41afb2f9b 100644 --- a/src/libs/vtools/visualization/line/vistoolalongline.h +++ b/src/libs/vtools/visualization/line/vistoolalongline.h @@ -47,16 +47,20 @@ public: ~VisToolAlongLine() override = default; void RefreshGeometry() override; - void setObject2Id(const quint32 &value); - void setLength(const QString &expression); - void setMidPointMode(bool midPointMode); + void VisualMode(quint32 id) override; + + void SetPoint1Id(quint32 value); + void SetPoint2Id(quint32 value); + void SetLength(const QString &expression); + void SetMidPointMode(bool midPointMode); auto type() const -> int override {return Type;} enum {Type = UserType + static_cast(Vis::ToolAlongLine)}; private: // cppcheck-suppress unknownMacro Q_DISABLE_COPY_MOVE(VisToolAlongLine) // NOLINT - quint32 m_object2Id{NULL_ID}; + quint32 m_point1Id{NULL_ID}; + quint32 m_point2Id{NULL_ID}; VScaledEllipse *m_point{nullptr}; VScaledEllipse *m_lineP1{nullptr}; VScaledEllipse *m_lineP2{nullptr}; @@ -65,4 +69,22 @@ private: bool m_midPointMode{false}; }; +//--------------------------------------------------------------------------------------------------------------------- +inline void VisToolAlongLine::SetPoint1Id(quint32 value) +{ + m_point1Id = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline void VisToolAlongLine::SetPoint2Id(quint32 value) +{ + m_point2Id = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline void VisToolAlongLine::SetMidPointMode(bool midPointMode) +{ + m_midPointMode = midPointMode; +} + #endif // VISTOOLALONGLINE_H diff --git a/src/libs/vtools/visualization/line/vistoolbisector.cpp b/src/libs/vtools/visualization/line/vistoolbisector.cpp index 3b577c107..5c4caa7f7 100644 --- a/src/libs/vtools/visualization/line/vistoolbisector.cpp +++ b/src/libs/vtools/visualization/line/vistoolbisector.cpp @@ -46,63 +46,53 @@ VisToolBisector::VisToolBisector(const VContainer *data, QGraphicsItem *parent) :VisLine(data, parent) { - m_line1P1 = InitPoint(supportColor, this); - m_line1P2 = InitPoint(supportColor, this); //-V656 - m_line1 = InitItem(supportColor, this); + m_line1P1 = InitPoint(Color(VColor::SupportColor), this); + m_line1P2 = InitPoint(Color(VColor::SupportColor), this); //-V656 + m_line1 = InitItem(Color(VColor::SupportColor), this); - m_line2P2 = InitPoint(supportColor, this); - m_line2 = InitItem(supportColor, this); + m_line2P2 = InitPoint(Color(VColor::SupportColor), this); + m_line2 = InitItem(Color(VColor::SupportColor), this); - m_point = InitPoint(mainColor, this); + m_point = InitPoint(Color(VColor::MainColor), this); } //--------------------------------------------------------------------------------------------------------------------- -void VisToolBisector::setObject2Id(const quint32 &value) +void VisToolBisector::SetLength(const QString &expression) { - m_object2Id = value; -} - -//--------------------------------------------------------------------------------------------------------------------- -void VisToolBisector::setObject3Id(const quint32 &value) -{ - m_object3Id = value; -} - -//--------------------------------------------------------------------------------------------------------------------- -void VisToolBisector::setLength(const QString &expression) -{ - m_length = FindLengthFromUser(expression, Visualization::data->DataVariables()); + m_length = FindLengthFromUser(expression, GetData()->DataVariables()); } //--------------------------------------------------------------------------------------------------------------------- void VisToolBisector::RefreshGeometry() { - if (object1Id > NULL_ID) + if (m_point1Id > NULL_ID) { - const QSharedPointer first = Visualization::data->GeometricObject(object1Id); - DrawPoint(m_line1P1, static_cast(*first), supportColor); + const QSharedPointer first = GetData()->GeometricObject(m_point1Id); + DrawPoint(m_line1P1, static_cast(*first), Color(VColor::SupportColor)); - if (m_object2Id <= NULL_ID) + if (m_point2Id <= NULL_ID) { - DrawLine(m_line1, QLineF(static_cast(*first), Visualization::scenePos), supportColor); + DrawLine(m_line1, QLineF(static_cast(*first), ScenePos()), Color(VColor::SupportColor)); } else { - const QSharedPointer second = Visualization::data->GeometricObject(m_object2Id); - DrawPoint(m_line1P2, static_cast(*second), supportColor); + const QSharedPointer second = GetData()->GeometricObject(m_point2Id); + DrawPoint(m_line1P2, static_cast(*second), Color(VColor::SupportColor)); - DrawLine(m_line1, QLineF(static_cast(*first), static_cast(*second)), supportColor); + DrawLine(m_line1, QLineF(static_cast(*first), static_cast(*second)), + Color(VColor::SupportColor)); - if (m_object3Id <= NULL_ID) + if (m_point3Id <= NULL_ID) { - DrawLine(m_line2, QLineF(static_cast(*second), Visualization::scenePos), supportColor); + DrawLine(m_line2, QLineF(static_cast(*second), ScenePos()), Color(VColor::SupportColor)); } else { - const QSharedPointer third = Visualization::data->GeometricObject(m_object3Id); - DrawPoint(m_line2P2, static_cast(*third), supportColor); + const QSharedPointer third = GetData()->GeometricObject(m_point3Id); + DrawPoint(m_line2P2, static_cast(*third), Color(VColor::SupportColor)); - DrawLine(m_line2, QLineF(static_cast(*second), static_cast(*third)), supportColor); + DrawLine(m_line2, QLineF(static_cast(*second), static_cast(*third)), + Color(VColor::SupportColor)); if (not qFuzzyIsNull(m_length)) { @@ -110,13 +100,13 @@ void VisToolBisector::RefreshGeometry() static_cast(*second), static_cast(*third)); QLineF mainLine = VGObject::BuildLine(static_cast(*second), m_length, angle); - DrawLine(this, mainLine, mainColor, lineStyle); + DrawLine(this, mainLine, Color(VColor::MainColor), LineStyle()); - DrawPoint(m_point, mainLine.p2(), mainColor); + DrawPoint(m_point, mainLine.p2(), Color(VColor::MainColor)); } - else if (mode == Mode::Creation) + else if (GetMode() == Mode::Creation) { - QLineF cursorLine (static_cast(*second), Visualization::scenePos); + QLineF cursorLine (static_cast(*second), ScenePos()); QLineF baseLine(static_cast(*second), static_cast(*third)); qreal angle = VToolBisector::BisectorAngle(static_cast(*first), @@ -134,15 +124,15 @@ void VisToolBisector::RefreshGeometry() QLineF mainLine = VGObject::BuildLine(static_cast(*second), len, angle); - DrawLine(this, mainLine, mainColor, lineStyle); + DrawLine(this, mainLine, Color(VColor::MainColor), LineStyle()); - DrawPoint(m_point, mainLine.p2(), mainColor); + DrawPoint(m_point, mainLine.p2(), Color(VColor::MainColor)); const QString prefix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true); - Visualization::toolTip = tr("Length = %1%2; " - "Mouse click - finish selecting the length, " - "%3 - skip") - .arg(NumberToUser(len), prefix, VModifierKey::EnterKey()); + SetToolTip(tr("Length = %1%2; " + "Mouse click - finish selecting the length, " + "%3 - skip") + .arg(NumberToUser(len), prefix, VModifierKey::EnterKey())); } else { @@ -153,9 +143,16 @@ void VisToolBisector::RefreshGeometry() QLineF mainLine = VGObject::BuildLine(static_cast(*second), QLineF(static_cast(*second), endRay).length(), angle); - DrawLine(this, mainLine, mainColor, lineStyle); + DrawLine(this, mainLine, Color(VColor::MainColor), LineStyle()); } } } } } + +//--------------------------------------------------------------------------------------------------------------------- +void VisToolBisector::VisualMode(quint32 id) +{ + m_point1Id = id; + StartVisualMode(); +} diff --git a/src/libs/vtools/visualization/line/vistoolbisector.h b/src/libs/vtools/visualization/line/vistoolbisector.h index 946b90140..9fd48a580 100644 --- a/src/libs/vtools/visualization/line/vistoolbisector.h +++ b/src/libs/vtools/visualization/line/vistoolbisector.h @@ -47,16 +47,21 @@ public: ~VisToolBisector() override = default; void RefreshGeometry() override; - void setObject2Id(const quint32 &value); - void setObject3Id(const quint32 &value); - void setLength(const QString &expression); + void VisualMode(quint32 id) override; + + void SetPoint1Id(quint32 value); + void SetPoint2Id(quint32 value); + void SetPoint3Id(quint32 value); + void SetLength(const QString &expression); + auto type() const -> int override {return Type;} enum {Type = UserType + static_cast(Vis::ToolBisector)}; private: // cppcheck-suppress unknownMacro Q_DISABLE_COPY_MOVE(VisToolBisector) // NOLINT - quint32 m_object2Id{NULL_ID}; - quint32 m_object3Id{NULL_ID}; + quint32 m_point1Id{NULL_ID}; + quint32 m_point2Id{NULL_ID}; + quint32 m_point3Id{NULL_ID}; VScaledEllipse *m_point{nullptr}; VScaledEllipse *m_line1P1{nullptr}; VScaledEllipse *m_line1P2{nullptr}; @@ -66,4 +71,22 @@ private: qreal m_length{0}; }; +//--------------------------------------------------------------------------------------------------------------------- +inline void VisToolBisector::SetPoint1Id(quint32 value) +{ + m_point1Id = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline void VisToolBisector::SetPoint2Id(quint32 value) +{ + m_point2Id = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline void VisToolBisector::SetPoint3Id(quint32 value) +{ + m_point3Id = value; +} + #endif // VISTOOLBISECTOR_H diff --git a/src/libs/vtools/visualization/line/vistoolcurveintersectaxis.cpp b/src/libs/vtools/visualization/line/vistoolcurveintersectaxis.cpp index 7ef62d40c..a997166c9 100644 --- a/src/libs/vtools/visualization/line/vistoolcurveintersectaxis.cpp +++ b/src/libs/vtools/visualization/line/vistoolcurveintersectaxis.cpp @@ -39,7 +39,6 @@ #include #include "../../tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolcurveintersectaxis.h" -#include "../ifc/ifcdef.h" #include "../vgeometry/vabstractcurve.h" #include "../vgeometry/vpointf.h" #include "../vpatterndb/vcontainer.h" @@ -49,70 +48,71 @@ //--------------------------------------------------------------------------------------------------------------------- VisToolCurveIntersectAxis::VisToolCurveIntersectAxis(const VContainer *data, QGraphicsItem *parent) - : VisLine(data, parent), axisPointId(NULL_ID), angle(-1), point(nullptr), basePoint(nullptr), baseLine(nullptr), - axisLine(nullptr), visCurve(nullptr) + : VisLine(data, parent) { - this->mainColor = Qt::red; + SetMainColor(Qt::red); - visCurve = InitItem(Qt::darkGreen, this); - basePoint = InitPoint(supportColor, this); - baseLine = InitItem(supportColor, this); - axisLine = InitItem(supportColor, this); //-V656 - point = InitPoint(mainColor, this); + m_visCurve = InitItem(Qt::darkGreen, this); + m_basePoint = InitPoint(Color(VColor::SupportColor), this); + m_baseLine = InitItem(Color(VColor::SupportColor), this); + m_axisLine = InitItem(Color(VColor::SupportColor), this); //-V656 + m_point = InitPoint(Color(VColor::MainColor), this); } //--------------------------------------------------------------------------------------------------------------------- void VisToolCurveIntersectAxis::RefreshGeometry() { - if (object1Id > NULL_ID) + if (m_curveId > NULL_ID) { - const QSharedPointer curve = Visualization::data->GeometricObject(object1Id); - DrawPath(visCurve, curve->GetPath(), curve->DirectionArrows(), supportColor, Qt::SolidLine, Qt::RoundCap); + const QSharedPointer curve = GetData()->GeometricObject(m_curveId); + DrawPath(m_visCurve, curve->GetPath(), curve->DirectionArrows(), Color(VColor::SupportColor), Qt::SolidLine, + Qt::RoundCap); - if (axisPointId > NULL_ID) + if (m_axisPointId > NULL_ID) { QLineF axis; - const QSharedPointer first = Visualization::data->GeometricObject(axisPointId); - if (VFuzzyComparePossibleNulls(angle, -1)) + const QSharedPointer first = GetData()->GeometricObject(m_axisPointId); + if (VFuzzyComparePossibleNulls(m_angle, -1)) { - axis = Axis(static_cast(*first), Visualization::scenePos); + axis = Axis(static_cast(*first), ScenePos()); } else { - axis = Axis(static_cast(*first), angle); + axis = Axis(static_cast(*first), m_angle); } - DrawPoint(basePoint, static_cast(*first), mainColor); - DrawLine(axisLine, axis, supportColor, Qt::DashLine); + DrawPoint(m_basePoint, static_cast(*first), Color(VColor::MainColor)); + DrawLine(m_axisLine, axis, Color(VColor::SupportColor), Qt::DashLine); QPointF p; VToolCurveIntersectAxis::FindPoint(static_cast(*first), axis.angle(), curve->GetPoints(), &p); QLineF axis_line(static_cast(*first), p); - DrawLine(this, axis_line, mainColor, lineStyle); + DrawLine(this, axis_line, Color(VColor::MainColor), LineStyle()); - DrawPoint(point, p, mainColor); + DrawPoint(m_point, p, Color(VColor::MainColor)); - Visualization::toolTip = tr("Intersection curve and axis: angle = %1°; %2 - " - "sticking angle, %3 - finish creation") - .arg(this->line().angle()) - .arg(VModifierKey::Shift(), VModifierKey::EnterKey()); + SetToolTip(tr("Intersection curve and axis: angle = %1°; %2 - " + "sticking angle, %3 - finish creation") + .arg(this->line().angle()) + .arg(VModifierKey::Shift(), VModifierKey::EnterKey())); } } } //--------------------------------------------------------------------------------------------------------------------- -QString VisToolCurveIntersectAxis::Angle() const +void VisToolCurveIntersectAxis::VisualMode(quint32 id) { - return QString("%1").arg(this->line().angle()); + m_curveId = id; + StartVisualMode(); +} + +//--------------------------------------------------------------------------------------------------------------------- +auto VisToolCurveIntersectAxis::Angle() const -> QString +{ + return QString::number(this->line().angle()); } //--------------------------------------------------------------------------------------------------------------------- void VisToolCurveIntersectAxis::SetAngle(const QString &expression) { - angle = FindValFromUser(expression, Visualization::data->DataVariables()); -} - -//--------------------------------------------------------------------------------------------------------------------- -void VisToolCurveIntersectAxis::setAxisPointId(const quint32 &value) -{ - axisPointId = value; + m_angle = FindValFromUser(expression, GetData()->DataVariables()); } diff --git a/src/libs/vtools/visualization/line/vistoolcurveintersectaxis.h b/src/libs/vtools/visualization/line/vistoolcurveintersectaxis.h index d1e7a3ca3..52607537e 100644 --- a/src/libs/vtools/visualization/line/vistoolcurveintersectaxis.h +++ b/src/libs/vtools/visualization/line/vistoolcurveintersectaxis.h @@ -44,26 +44,43 @@ class VisToolCurveIntersectAxis final : public VisLine Q_OBJECT // NOLINT public: explicit VisToolCurveIntersectAxis(const VContainer *data, QGraphicsItem *parent = nullptr); - virtual ~VisToolCurveIntersectAxis() = default; + ~VisToolCurveIntersectAxis() override = default; - virtual void RefreshGeometry() override; + void RefreshGeometry() override; + void VisualMode(quint32 id) override; - QString Angle() const; - void SetAngle(const QString &expression); - void setAxisPointId(const quint32 &value); + auto Angle() const -> QString; + void SetAngle(const QString &expression); + + void SetCurveId(quint32 newCurveId); + void setAxisPointId(const quint32 &value); + + auto type() const -> int override {return Type;} + enum {Type = UserType + static_cast(Vis::ToolLineIntersectAxis)}; - virtual int type() const override {return Type;} - enum { Type = UserType + static_cast(Vis::ToolLineIntersectAxis)}; private: // cppcheck-suppress unknownMacro Q_DISABLE_COPY_MOVE(VisToolCurveIntersectAxis) // NOLINT - quint32 axisPointId; - qreal angle; - VScaledEllipse *point; - VScaledEllipse *basePoint; - VScaledLine *baseLine; - VScaledLine *axisLine; - VCurvePathItem *visCurve; + quint32 m_axisPointId{NULL_ID}; + qreal m_angle{-1}; + VScaledEllipse *m_point{nullptr}; + VScaledEllipse *m_basePoint{nullptr}; + VScaledLine *m_baseLine{nullptr}; + VScaledLine *m_axisLine{nullptr}; + VCurvePathItem *m_visCurve{nullptr}; + quint32 m_curveId{NULL_ID}; }; +//--------------------------------------------------------------------------------------------------------------------- +inline void VisToolCurveIntersectAxis::SetCurveId(quint32 newCurveId) +{ + m_curveId = newCurveId; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline void VisToolCurveIntersectAxis::setAxisPointId(const quint32 &value) +{ + m_axisPointId = value; +} + #endif // VISTOOLCURVEINTERSECTAXIS_H diff --git a/src/libs/vtools/visualization/line/vistoolendline.cpp b/src/libs/vtools/visualization/line/vistoolendline.cpp index e002c2379..c9bb36a5c 100644 --- a/src/libs/vtools/visualization/line/vistoolendline.cpp +++ b/src/libs/vtools/visualization/line/vistoolendline.cpp @@ -36,7 +36,6 @@ #include #include -#include "../ifc/xml/vdomdocument.h" #include "../vgeometry/vgobject.h" #include "../vgeometry/vpointf.h" #include "../vmisc/vabstractapplication.h" @@ -49,55 +48,63 @@ //--------------------------------------------------------------------------------------------------------------------- VisToolEndLine::VisToolEndLine(const VContainer *data, QGraphicsItem *parent) - : VisLine(data, parent), length(0), angle(0), point(nullptr) + : VisLine(data, parent) { - this->mainColor = Qt::red; + SetMainColor(Qt::red); - point = InitPoint(mainColor, this); + m_point = InitPoint(Color(VColor::MainColor), this); } //--------------------------------------------------------------------------------------------------------------------- void VisToolEndLine::RefreshGeometry() { - const QSharedPointer first = Visualization::data->GeometricObject(object1Id); + const QSharedPointer first = GetData()->GeometricObject(m_basePointId); QLineF line; - if (qFuzzyIsNull(length)) + if (qFuzzyIsNull(m_length)) { - if (mode == Mode::Creation) + if (GetMode() == Mode::Creation) { if (QGuiApplication::keyboardModifiers() == Qt::ShiftModifier) { - line = QLineF(static_cast(*first), Visualization::scenePos); + line = QLineF(static_cast(*first), ScenePos()); line.setAngle(CorrectAngle(line.angle())); } else { - line = QLineF(static_cast(*first), Visualization::scenePos); + line = QLineF(static_cast(*first), ScenePos()); } } else { - DrawPoint(point, static_cast(*first), mainColor); + DrawPoint(m_point, static_cast(*first), Color(VColor::MainColor)); } } else { - line = VGObject::BuildLine(static_cast(*first), length, angle); - DrawPoint(point, line.p2(), mainColor); + line = VGObject::BuildLine(static_cast(*first), m_length, m_angle); + DrawPoint(m_point, line.p2(), Color(VColor::MainColor)); } - DrawLine(this, line, mainColor, lineStyle); + DrawLine(this, line, Color(VColor::MainColor), LineStyle()); static const QString prefix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true); - Visualization::toolTip = tr("Point at distance and angle: angle = %1°, length = %2%3; " - "%4 - sticking angle, %5 - finish creation") - .arg(this->line().angle()) - .arg(VAbstractApplication::VApp()->TrVars() - ->FormulaToUser(QString::number(VAbstractValApplication::VApp()->fromPixel(this->line().length())), - VAbstractApplication::VApp()->Settings()->GetOsSeparator()), - prefix, VModifierKey::Shift(), VModifierKey::EnterKey()); + SetToolTip(tr("Point at distance and angle: angle = %1°, length = %2%3; " + "%4 - sticking angle, %5 - finish creation") + .arg(this->line().angle()) + .arg(VAbstractApplication::VApp()->TrVars() + ->FormulaToUser( + QString::number(VAbstractValApplication::VApp()->fromPixel(this->line().length())), + VAbstractApplication::VApp()->Settings()->GetOsSeparator()), + prefix, VModifierKey::Shift(), VModifierKey::EnterKey())); } //--------------------------------------------------------------------------------------------------------------------- -QString VisToolEndLine::Angle() const +void VisToolEndLine::VisualMode(quint32 id) +{ + m_basePointId = id; + StartVisualMode(); +} + +//--------------------------------------------------------------------------------------------------------------------- +auto VisToolEndLine::Angle() const -> QString { return QString::number(this->line().angle()); } @@ -105,17 +112,17 @@ QString VisToolEndLine::Angle() const //--------------------------------------------------------------------------------------------------------------------- void VisToolEndLine::SetAngle(const QString &expression) { - angle = FindValFromUser(expression, Visualization::data->DataVariables()); + m_angle = FindValFromUser(expression, GetData()->DataVariables()); } //--------------------------------------------------------------------------------------------------------------------- -QString VisToolEndLine::Length() const +auto VisToolEndLine::Length() const -> QString { return QString::number(VAbstractValApplication::VApp()->fromPixel(this->line().length())); } //--------------------------------------------------------------------------------------------------------------------- -void VisToolEndLine::setLength(const QString &expression) +void VisToolEndLine::SetLength(const QString &expression) { - length = FindLengthFromUser(expression, Visualization::data->DataVariables()); + m_length = FindLengthFromUser(expression, GetData()->DataVariables()); } diff --git a/src/libs/vtools/visualization/line/vistoolendline.h b/src/libs/vtools/visualization/line/vistoolendline.h index d1d7890e9..74fdab706 100644 --- a/src/libs/vtools/visualization/line/vistoolendline.h +++ b/src/libs/vtools/visualization/line/vistoolendline.h @@ -44,24 +44,34 @@ class VisToolEndLine final : public VisLine Q_OBJECT // NOLINT public: explicit VisToolEndLine(const VContainer *data, QGraphicsItem *parent = nullptr); - virtual ~VisToolEndLine() = default; + ~VisToolEndLine() override = default; - virtual void RefreshGeometry() override; + void RefreshGeometry() override; + void VisualMode(quint32 id) override; - QString Angle() const; - void SetAngle(const QString &expression); + auto Angle() const -> QString; + void SetAngle(const QString &expression); - QString Length() const; - void setLength(const QString &expression); + auto Length() const -> QString; + void SetLength(const QString &expression); - virtual int type() const override {return Type;} - enum { Type = UserType + static_cast(Vis::ToolEndLine)}; + void SetBasePointId(quint32 id); + + auto type() const -> int override {return Type;} + enum {Type = UserType + static_cast(Vis::ToolEndLine)}; private: // cppcheck-suppress unknownMacro Q_DISABLE_COPY_MOVE(VisToolEndLine) // NOLINT - qreal length; - qreal angle; - VScaledEllipse *point; + qreal m_length{0}; + qreal m_angle{0}; + VScaledEllipse *m_point{nullptr}; + quint32 m_basePointId{NULL_ID}; }; +//--------------------------------------------------------------------------------------------------------------------- +inline void VisToolEndLine::SetBasePointId(quint32 id) +{ + m_basePointId = id; +} + #endif // VISTOOLENDLINE_H diff --git a/src/libs/vtools/visualization/line/vistoolheight.cpp b/src/libs/vtools/visualization/line/vistoolheight.cpp index 94afe33ba..12a1af460 100644 --- a/src/libs/vtools/visualization/line/vistoolheight.cpp +++ b/src/libs/vtools/visualization/line/vistoolheight.cpp @@ -36,7 +36,6 @@ #include #include "../../tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolheight.h" -#include "../ifc/ifcdef.h" #include "../vgeometry/vpointf.h" #include "../vpatterndb/vcontainer.h" #include "../visualization.h" @@ -47,53 +46,53 @@ VisToolHeight::VisToolHeight(const VContainer *data, QGraphicsItem *parent) : VisLine(data, parent) { - base_point = InitPoint(supportColor, this); - lineP1 = InitPoint(supportColor, this); - lineP2 = InitPoint(supportColor, this); - line = InitItem(supportColor, this); - line_intersection = InitItem(supportColor, this); //-V656 + m_basePoint = InitPoint(Color(VColor::SupportColor), this); + m_lineP1 = InitPoint(Color(VColor::SupportColor), this); + m_lineP2 = InitPoint(Color(VColor::SupportColor), this); + m_line = InitItem(Color(VColor::SupportColor), this); + m_lineIntersection = InitItem(Color(VColor::SupportColor), this); //-V656 - point = InitPoint(mainColor, this); + m_point = InitPoint(Color(VColor::MainColor), this); } //--------------------------------------------------------------------------------------------------------------------- void VisToolHeight::RefreshGeometry() { - if (object1Id > NULL_ID) + if (m_basePointId > NULL_ID) { - const QSharedPointer first = Visualization::data->GeometricObject(object1Id); - DrawPoint(base_point, static_cast(*first), supportColor); + const QSharedPointer first = GetData()->GeometricObject(m_basePointId); + DrawPoint(m_basePoint, static_cast(*first), Color(VColor::SupportColor)); - if (lineP1Id <= NULL_ID) + if (m_lineP1Id <= NULL_ID) { - DrawLine(this, QLineF(static_cast(*first), Visualization::scenePos), mainColor); + DrawLine(this, QLineF(static_cast(*first), ScenePos()), Color(VColor::MainColor)); } else { - const QSharedPointer second = Visualization::data->GeometricObject(lineP1Id); - DrawPoint(lineP1, static_cast(*second), supportColor); + const QSharedPointer second = GetData()->GeometricObject(m_lineP1Id); + DrawPoint(m_lineP1, static_cast(*second), Color(VColor::SupportColor)); QLineF base_line; - if (lineP2Id <= NULL_ID) + if (m_lineP2Id <= NULL_ID) { - base_line = QLineF(static_cast(*second), Visualization::scenePos); - DrawLine(line, base_line, supportColor); + base_line = QLineF(static_cast(*second), ScenePos()); + DrawLine(m_line, base_line, Color(VColor::SupportColor)); } else { - const QSharedPointer third = Visualization::data->GeometricObject(lineP2Id); - DrawPoint(lineP2, static_cast(*third), supportColor); + const QSharedPointer third = GetData()->GeometricObject(m_lineP2Id); + DrawPoint(m_lineP2, static_cast(*third), Color(VColor::SupportColor)); base_line = QLineF(static_cast(*second), static_cast(*third)); } - DrawLine(line, base_line, supportColor); + DrawLine(m_line, base_line, Color(VColor::SupportColor)); QPointF height = VToolHeight::FindPoint(base_line, static_cast(*first)); - DrawPoint(point, height, mainColor); + DrawPoint(m_point, height, Color(VColor::MainColor)); QLineF height_line(static_cast(*first), height); - DrawLine(this, height_line, mainColor, lineStyle); + DrawLine(this, height_line, Color(VColor::MainColor), LineStyle()); ShowIntersection(height_line, base_line); } @@ -101,15 +100,10 @@ void VisToolHeight::RefreshGeometry() } //--------------------------------------------------------------------------------------------------------------------- -void VisToolHeight::setLineP1Id(const quint32 &value) +void VisToolHeight::VisualMode(quint32 id) { - lineP1Id = value; -} - -//--------------------------------------------------------------------------------------------------------------------- -void VisToolHeight::setLineP2Id(const quint32 &value) -{ - lineP2Id = value; + m_basePointId = id; + StartVisualMode(); } //--------------------------------------------------------------------------------------------------------------------- @@ -120,11 +114,12 @@ void VisToolHeight::ShowIntersection(const QLineF &height_line, const QLineF &ba if (intersect == QLineF::UnboundedIntersection) { - line_intersection->setVisible(true); - DrawLine(line_intersection, QLineF(base_line.p1(), height_line.p2()), supportColor, Qt::DashLine); + m_lineIntersection->setVisible(true); + DrawLine(m_lineIntersection, QLineF(base_line.p1(), height_line.p2()), Color(VColor::SupportColor), + Qt::DashLine); } else if (intersect == QLineF::BoundedIntersection) { - line_intersection->setVisible(false); + m_lineIntersection->setVisible(false); } } diff --git a/src/libs/vtools/visualization/line/vistoolheight.h b/src/libs/vtools/visualization/line/vistoolheight.h index 927fd0c73..448d3f266 100644 --- a/src/libs/vtools/visualization/line/vistoolheight.h +++ b/src/libs/vtools/visualization/line/vistoolheight.h @@ -45,27 +45,49 @@ class VisToolHeight final : public VisLine Q_OBJECT // NOLINT public: explicit VisToolHeight(const VContainer *data, QGraphicsItem *parent = nullptr); - virtual ~VisToolHeight() = default; + ~VisToolHeight() override = default; - virtual void RefreshGeometry() override; + void RefreshGeometry() override; + void VisualMode(quint32 id) override; - void setLineP1Id(const quint32 &value); - void setLineP2Id(const quint32 &value); - virtual int type() const override {return Type;} - enum { Type = UserType + static_cast(Vis::ToolHeight)}; + void SetBasePointId(quint32 value); + void SetLineP1Id(quint32 value); + void SetLineP2Id(quint32 value); + + auto type() const -> int override {return Type;} + enum {Type = UserType + static_cast(Vis::ToolHeight)}; private: // cppcheck-suppress unknownMacro Q_DISABLE_COPY_MOVE(VisToolHeight) // NOLINT - //base point in parent class - quint32 lineP1Id{NULL_ID};//first point of line - quint32 lineP2Id{NULL_ID};//second point of line - VScaledEllipse *point{nullptr}; - VScaledEllipse *base_point{nullptr}; - VScaledEllipse *lineP1{nullptr}; - VScaledEllipse *lineP2{nullptr}; - VScaledLine *line{nullptr}; - VScaledLine *line_intersection{nullptr}; - void ShowIntersection(const QLineF &height_line, const QLineF &base_line); + quint32 m_basePointId{NULL_ID}; + quint32 m_lineP1Id{NULL_ID};//first point of line + quint32 m_lineP2Id{NULL_ID};//second point of line + VScaledEllipse *m_point{nullptr}; + VScaledEllipse *m_basePoint{nullptr}; + VScaledEllipse *m_lineP1{nullptr}; + VScaledEllipse *m_lineP2{nullptr}; + VScaledLine *m_line{nullptr}; + VScaledLine *m_lineIntersection{nullptr}; + + void ShowIntersection(const QLineF &height_line, const QLineF &base_line); }; +//--------------------------------------------------------------------------------------------------------------------- +inline void VisToolHeight::SetBasePointId(quint32 value) +{ + m_basePointId = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline void VisToolHeight::SetLineP1Id(quint32 value) +{ + m_lineP1Id = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline void VisToolHeight::SetLineP2Id(quint32 value) +{ + m_lineP2Id = value; +} + #endif // VISTOOLHEIGHT_H diff --git a/src/libs/vtools/visualization/line/vistoolline.cpp b/src/libs/vtools/visualization/line/vistoolline.cpp index 8c5a584e9..189a3c1dd 100644 --- a/src/libs/vtools/visualization/line/vistoolline.cpp +++ b/src/libs/vtools/visualization/line/vistoolline.cpp @@ -34,41 +34,40 @@ #include #include -#include "../ifc/ifcdef.h" #include "../vgeometry/vpointf.h" -#include "../vmisc/vabstractapplication.h" #include "../vpatterndb/vcontainer.h" #include "../visualization.h" #include "visualization/line/visline.h" //--------------------------------------------------------------------------------------------------------------------- VisToolLine::VisToolLine(const VContainer *data, QGraphicsItem *parent) - :VisLine(data, parent), point2Id(NULL_ID) + :VisLine(data, parent) { - this->mainColor = Qt::red; + SetMainColor(Qt::red); } //--------------------------------------------------------------------------------------------------------------------- void VisToolLine::RefreshGeometry() { QLineF line; - const QSharedPointer first = Visualization::data->GeometricObject(object1Id); - if (point2Id == NULL_ID) + const QSharedPointer first = GetData()->GeometricObject(m_point1Id); + if (m_point2Id == NULL_ID) { - line = QLineF(static_cast(*first), Visualization::scenePos); + line = QLineF(static_cast(*first), ScenePos()); } else { - const QSharedPointer second = Visualization::data->GeometricObject(point2Id); + const QSharedPointer second = GetData()->GeometricObject(m_point2Id); line = QLineF(static_cast(*first), static_cast(*second)); } - DrawLine(this, line, mainColor, lineStyle); + DrawLine(this, line, Color(VColor::MainColor), LineStyle()); } //--------------------------------------------------------------------------------------------------------------------- -void VisToolLine::setPoint2Id(const quint32 &value) +void VisToolLine::VisualMode(quint32 id) { - point2Id = value; + m_point1Id = id; + StartVisualMode(); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/visualization/line/vistoolline.h b/src/libs/vtools/visualization/line/vistoolline.h index 7ac24a614..7b81790e3 100644 --- a/src/libs/vtools/visualization/line/vistoolline.h +++ b/src/libs/vtools/visualization/line/vistoolline.h @@ -47,19 +47,36 @@ class VisToolLine : public VisLine Q_OBJECT // NOLINT public: explicit VisToolLine(const VContainer *data, QGraphicsItem *parent = nullptr); - virtual ~VisToolLine() = default; + ~VisToolLine() override = default; - virtual void RefreshGeometry() override; - void setPoint2Id(const quint32 &value); - virtual int type() const override {return Type;} - enum { Type = UserType + static_cast(Vis::ToolLine)}; + void RefreshGeometry() override; + void VisualMode(quint32 id) override; + + void SetPoint1Id(quint32 value); + void SetPoint2Id(quint32 value); + + auto type() const -> int override {return Type;} + enum {Type = UserType + static_cast(Vis::ToolLine)}; protected: - virtual void DrawLine(VScaledLine *lineItem, const QLineF &line, const QColor &color, - Qt::PenStyle style = Qt::SolidLine) override; + void DrawLine(VScaledLine *lineItem, const QLineF &line, const QColor &color, + Qt::PenStyle style = Qt::SolidLine) override; private: // cppcheck-suppress unknownMacro Q_DISABLE_COPY_MOVE(VisToolLine) // NOLINT - quint32 point2Id; + quint32 m_point1Id{NULL_ID}; + quint32 m_point2Id{NULL_ID}; }; +//--------------------------------------------------------------------------------------------------------------------- +inline void VisToolLine::SetPoint1Id(quint32 value) +{ + m_point1Id = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline void VisToolLine::SetPoint2Id(quint32 value) +{ + m_point2Id = value; +} + #endif // VGRAPHICSLINEITEM_H diff --git a/src/libs/vtools/visualization/line/vistoollineintersect.cpp b/src/libs/vtools/visualization/line/vistoollineintersect.cpp index 1528736a2..fca638b2f 100644 --- a/src/libs/vtools/visualization/line/vistoollineintersect.cpp +++ b/src/libs/vtools/visualization/line/vistoollineintersect.cpp @@ -35,7 +35,6 @@ #include #include -#include "../ifc/ifcdef.h" #include "../vgeometry/vpointf.h" #include "../vpatterndb/vcontainer.h" #include "../visualization.h" @@ -44,63 +43,65 @@ //--------------------------------------------------------------------------------------------------------------------- VisToolLineIntersect::VisToolLineIntersect(const VContainer *data, QGraphicsItem *parent) - :VisLine(data, parent), line1P2Id(NULL_ID), line2P1Id(NULL_ID), line2P2Id(NULL_ID), point(nullptr), - line1P1(nullptr), line1P2(nullptr), line1(nullptr), line2P1(nullptr), line2P2(nullptr) + :VisLine(data, parent) { - line1P1 = InitPoint(supportColor, this); - line1P2 = InitPoint(supportColor, this); - line1 = InitItem(supportColor, this); + m_line1P1 = InitPoint(Color(VColor::SupportColor), this); + m_line1P2 = InitPoint(Color(VColor::SupportColor), this); + m_line1 = InitItem(Color(VColor::SupportColor), this); - line2P1 = InitPoint(supportColor, this); - line2P2 = InitPoint(supportColor, this); + m_line2P1 = InitPoint(Color(VColor::SupportColor), this); + m_line2P2 = InitPoint(Color(VColor::SupportColor), this); - point = InitPoint(mainColor, this); + m_point = InitPoint(Color(VColor::MainColor), this); } //--------------------------------------------------------------------------------------------------------------------- void VisToolLineIntersect::RefreshGeometry() { - if (object1Id > NULL_ID) + if (m_line1P1Id > NULL_ID) { - const QSharedPointer first = Visualization::data->GeometricObject(object1Id); - DrawPoint(line1P1, static_cast(*first), supportColor); + const QSharedPointer first = GetData()->GeometricObject(m_line1P1Id); + DrawPoint(m_line1P1, static_cast(*first), Color(VColor::SupportColor)); - if (line1P2Id <= NULL_ID) + if (m_line1P2Id <= NULL_ID) { - DrawLine(line1, QLineF(static_cast(*first), Visualization::scenePos), supportColor); + DrawLine(m_line1, QLineF(static_cast(*first), ScenePos()), Color(VColor::SupportColor)); } else { - const QSharedPointer second = Visualization::data->GeometricObject(line1P2Id); - DrawPoint(line1P2, static_cast(*second), supportColor); + const QSharedPointer second = GetData()->GeometricObject(m_line1P2Id); + DrawPoint(m_line1P2, static_cast(*second), Color(VColor::SupportColor)); - DrawLine(line1, QLineF(static_cast(*first), static_cast(*second)), supportColor); + DrawLine(m_line1, QLineF(static_cast(*first), static_cast(*second)), + Color(VColor::SupportColor)); - if (line2P1Id > NULL_ID) + if (m_line2P1Id > NULL_ID) { - const QSharedPointer third = Visualization::data->GeometricObject(line2P1Id); - DrawPoint(line2P1, static_cast(*third), supportColor); + const QSharedPointer third = GetData()->GeometricObject(m_line2P1Id); + DrawPoint(m_line2P1, static_cast(*third), Color(VColor::SupportColor)); - if (line2P2Id <= NULL_ID) + if (m_line2P2Id <= NULL_ID) { - DrawLine(this, QLineF(static_cast(*third), Visualization::scenePos), supportColor); + DrawLine(this, QLineF(static_cast(*third), ScenePos()), + Color(VColor::SupportColor)); QLineF l1(static_cast(*first), static_cast(*second)); - QLineF l2(static_cast(*third), Visualization::scenePos); + QLineF l2(static_cast(*third), ScenePos()); QPointF fPoint; QLineF::IntersectType intersect = Intersects(l1, l2, &fPoint); if (intersect == QLineF::UnboundedIntersection || intersect == QLineF::BoundedIntersection) { - DrawPoint(point, fPoint, mainColor); + DrawPoint(m_point, fPoint, Color(VColor::MainColor)); } } else { - const QSharedPointer forth = Visualization::data->GeometricObject(line2P2Id); - DrawPoint(line2P2, static_cast(*forth), supportColor); + const QSharedPointer forth = GetData()->GeometricObject(m_line2P2Id); + DrawPoint(m_line2P2, static_cast(*forth), Color(VColor::SupportColor)); - DrawLine(this, QLineF(static_cast(*third), static_cast(*forth)), supportColor); + DrawLine(this, QLineF(static_cast(*third), static_cast(*forth)), + Color(VColor::SupportColor)); QLineF l1(static_cast(*first), static_cast(*second)); QLineF l2(static_cast(*third), static_cast(*forth)); @@ -109,7 +110,7 @@ void VisToolLineIntersect::RefreshGeometry() if (intersect == QLineF::UnboundedIntersection || intersect == QLineF::BoundedIntersection) { - DrawPoint(point, fPoint, mainColor); + DrawPoint(m_point, fPoint, Color(VColor::MainColor)); } } } @@ -118,19 +119,8 @@ void VisToolLineIntersect::RefreshGeometry() } //--------------------------------------------------------------------------------------------------------------------- -void VisToolLineIntersect::setLine1P2Id(const quint32 &value) +void VisToolLineIntersect::VisualMode(quint32 id) { - line1P2Id = value; -} - -//--------------------------------------------------------------------------------------------------------------------- -void VisToolLineIntersect::setLine2P1Id(const quint32 &value) -{ - line2P1Id = value; -} - -//--------------------------------------------------------------------------------------------------------------------- -void VisToolLineIntersect::setLine2P2Id(const quint32 &value) -{ - line2P2Id = value; + m_line1P1Id = id; + StartVisualMode(); } diff --git a/src/libs/vtools/visualization/line/vistoollineintersect.h b/src/libs/vtools/visualization/line/vistoollineintersect.h index 90d4cd0fe..2c9b299b5 100644 --- a/src/libs/vtools/visualization/line/vistoollineintersect.h +++ b/src/libs/vtools/visualization/line/vistoollineintersect.h @@ -44,27 +44,55 @@ class VisToolLineIntersect :public VisLine Q_OBJECT // NOLINT public: explicit VisToolLineIntersect(const VContainer *data, QGraphicsItem *parent = nullptr); - virtual ~VisToolLineIntersect() = default; + ~VisToolLineIntersect() override = default; - virtual void RefreshGeometry() override; + void RefreshGeometry() override; + void VisualMode(quint32 id) override; - void setLine1P2Id(const quint32 &value); - void setLine2P1Id(const quint32 &value); - void setLine2P2Id(const quint32 &value); - virtual int type() const override {return Type;} - enum { Type = UserType + static_cast(Vis::ToolLineIntersect)}; + void SetLine1P1Id(quint32 value); + void SetLine1P2Id(quint32 value); + void SetLine2P1Id(quint32 value); + void SetLine2P2Id(quint32 value); + + auto type() const -> int override {return Type;} + enum {Type = UserType + static_cast(Vis::ToolLineIntersect)}; private: // cppcheck-suppress unknownMacro Q_DISABLE_COPY_MOVE(VisToolLineIntersect) // NOLINT - quint32 line1P2Id; - quint32 line2P1Id; - quint32 line2P2Id; - VScaledEllipse *point; - VScaledEllipse *line1P1; - VScaledEllipse *line1P2; - VScaledLine *line1; - VScaledEllipse *line2P1; - VScaledEllipse *line2P2; + quint32 m_line1P1Id{NULL_ID}; + quint32 m_line1P2Id{NULL_ID}; + quint32 m_line2P1Id{NULL_ID}; + quint32 m_line2P2Id{NULL_ID}; + VScaledEllipse *m_point{nullptr}; + VScaledEllipse *m_line1P1{nullptr}; + VScaledEllipse *m_line1P2{nullptr}; + VScaledLine *m_line1{nullptr}; + VScaledEllipse *m_line2P1{nullptr}; + VScaledEllipse *m_line2P2{nullptr}; }; +//--------------------------------------------------------------------------------------------------------------------- +inline void VisToolLineIntersect::SetLine1P1Id(quint32 value) +{ + m_line1P1Id = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline void VisToolLineIntersect::SetLine1P2Id(quint32 value) +{ + m_line1P2Id = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline void VisToolLineIntersect::SetLine2P1Id(quint32 value) +{ + m_line2P1Id = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline void VisToolLineIntersect::SetLine2P2Id(quint32 value) +{ + m_line2P2Id = value; +} + #endif // VISTOOLLINEINTERSECT_H diff --git a/src/libs/vtools/visualization/line/vistoollineintersectaxis.cpp b/src/libs/vtools/visualization/line/vistoollineintersectaxis.cpp index d79591e62..bbcf78a8a 100644 --- a/src/libs/vtools/visualization/line/vistoollineintersectaxis.cpp +++ b/src/libs/vtools/visualization/line/vistoollineintersectaxis.cpp @@ -37,7 +37,6 @@ #include #include "../../tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollineintersectaxis.h" -#include "../ifc/ifcdef.h" #include "../vgeometry/vpointf.h" #include "../vpatterndb/vcontainer.h" #include "../visualization.h" @@ -47,97 +46,91 @@ //--------------------------------------------------------------------------------------------------------------------- VisToolLineIntersectAxis::VisToolLineIntersectAxis(const VContainer *data, QGraphicsItem *parent) - : VisLine(data, parent), point2Id(NULL_ID), axisPointId(NULL_ID), angle(-1), point(nullptr), lineP1(nullptr), - lineP2(nullptr), basePoint(nullptr), baseLine(nullptr), axisLine(nullptr), line_intersection(nullptr) + : VisLine(data, parent) { - this->mainColor = Qt::red; + SetMainColor(Qt::red); - lineP1 = InitPoint(supportColor, this); - lineP2 = InitPoint(supportColor, this); - basePoint = InitPoint(supportColor, this); - baseLine = InitItem(supportColor, this); - axisLine = InitItem(supportColor, this); - line_intersection = InitItem(supportColor, this); - point = InitPoint(mainColor, this); + m_lineP1 = InitPoint(Color(VColor::SupportColor), this); + m_lineP2 = InitPoint(Color(VColor::SupportColor), this); + m_basePoint = InitPoint(Color(VColor::SupportColor), this); + m_baseLine = InitItem(Color(VColor::SupportColor), this); + m_axisLine = InitItem(Color(VColor::SupportColor), this); + m_lineIntersection = InitItem(Color(VColor::SupportColor), this); + m_point = InitPoint(Color(VColor::MainColor), this); } //--------------------------------------------------------------------------------------------------------------------- void VisToolLineIntersectAxis::RefreshGeometry() { - if (object1Id > NULL_ID) + if (m_point1Id > NULL_ID) { - const QSharedPointer first = Visualization::data->GeometricObject(object1Id); - DrawPoint(lineP1, static_cast(*first), supportColor); + const QSharedPointer first = GetData()->GeometricObject(m_point1Id); + DrawPoint(m_lineP1, static_cast(*first), Color(VColor::SupportColor)); - if (point2Id <= NULL_ID) + if (m_point2Id <= NULL_ID) { - DrawLine(baseLine, QLineF(static_cast(*first), Visualization::scenePos), supportColor); + DrawLine(m_baseLine, QLineF(static_cast(*first), ScenePos()), Color(VColor::SupportColor)); } else { - const QSharedPointer second = Visualization::data->GeometricObject(point2Id); - DrawPoint(lineP2, static_cast(*second), supportColor); + const QSharedPointer second = GetData()->GeometricObject(m_point2Id); + DrawPoint(m_lineP2, static_cast(*second), Color(VColor::SupportColor)); const QLineF base_line(static_cast(*first), static_cast(*second)); - DrawLine(baseLine, base_line, supportColor); + DrawLine(m_baseLine, base_line, Color(VColor::SupportColor)); - if (axisPointId > NULL_ID) + if (m_axisPointId > NULL_ID) { QLineF axis; - const QSharedPointer third = Visualization::data->GeometricObject(axisPointId); - if (VFuzzyComparePossibleNulls(angle, -1)) + const QSharedPointer third = GetData()->GeometricObject(m_axisPointId); + if (VFuzzyComparePossibleNulls(m_angle, -1)) { - axis = Axis(static_cast(*third), Visualization::scenePos); + axis = Axis(static_cast(*third), ScenePos()); } else { - axis = Axis(static_cast(*third), angle); + axis = Axis(static_cast(*third), m_angle); } - DrawPoint(basePoint, static_cast(*third), mainColor); - DrawLine(axisLine, axis, supportColor, Qt::DashLine); + DrawPoint(m_basePoint, static_cast(*third), Color(VColor::MainColor)); + DrawLine(m_axisLine, axis, Color(VColor::SupportColor), Qt::DashLine); QPointF p; VToolLineIntersectAxis::FindPoint(axis, base_line, &p); QLineF axis_line(static_cast(*third), p); if (not axis_line.isNull()) { - DrawLine(this, axis_line, mainColor, lineStyle); + DrawLine(this, axis_line, Color(VColor::MainColor), LineStyle()); } - DrawPoint(point, p, mainColor); + DrawPoint(m_point, p, Color(VColor::MainColor)); ShowIntersection(axis_line, base_line); - Visualization::toolTip = tr("Intersection line and axis: angle = %1°; %2 - " - "sticking angle, %3 - finish creation") - .arg(this->line().angle()) - .arg(VModifierKey::Shift(), VModifierKey::EnterKey()); + SetToolTip(tr("Intersection line and axis: angle = %1°; %2 - " + "sticking angle, %3 - finish creation") + .arg(this->line().angle()) + .arg(VModifierKey::Shift(), VModifierKey::EnterKey())); } } } } //--------------------------------------------------------------------------------------------------------------------- -QString VisToolLineIntersectAxis::Angle() const +void VisToolLineIntersectAxis::VisualMode(quint32 id) { - return QString("%1").arg(this->line().angle()); + m_point1Id = id; + StartVisualMode(); +} + +//--------------------------------------------------------------------------------------------------------------------- +auto VisToolLineIntersectAxis::Angle() const -> QString +{ + return QString::number(this->line().angle()); } //--------------------------------------------------------------------------------------------------------------------- void VisToolLineIntersectAxis::SetAngle(const QString &expression) { - angle = FindValFromUser(expression, Visualization::data->DataVariables()); -} - -//--------------------------------------------------------------------------------------------------------------------- -void VisToolLineIntersectAxis::setPoint2Id(const quint32 &value) -{ - point2Id = value; -} - -//--------------------------------------------------------------------------------------------------------------------- -void VisToolLineIntersectAxis::setAxisPointId(const quint32 &value) -{ - axisPointId = value; + m_angle = FindValFromUser(expression, GetData()->DataVariables()); } //--------------------------------------------------------------------------------------------------------------------- @@ -148,11 +141,11 @@ void VisToolLineIntersectAxis::ShowIntersection(const QLineF &axis_line, const Q if (intersect == QLineF::UnboundedIntersection) { - line_intersection->setVisible(true); - DrawLine(line_intersection, QLineF(base_line.p1(), axis_line.p2()), supportColor, Qt::DashLine); + m_lineIntersection->setVisible(true); + DrawLine(m_lineIntersection, QLineF(base_line.p1(), axis_line.p2()), Color(VColor::SupportColor), Qt::DashLine); } else if (intersect == QLineF::BoundedIntersection || intersect == QLineF::NoIntersection) { - line_intersection->setVisible(false); + m_lineIntersection->setVisible(false); } } diff --git a/src/libs/vtools/visualization/line/vistoollineintersectaxis.h b/src/libs/vtools/visualization/line/vistoollineintersectaxis.h index 87144fab1..2623d3a61 100644 --- a/src/libs/vtools/visualization/line/vistoollineintersectaxis.h +++ b/src/libs/vtools/visualization/line/vistoollineintersectaxis.h @@ -45,31 +45,53 @@ class VisToolLineIntersectAxis : public VisLine Q_OBJECT // NOLINT public: explicit VisToolLineIntersectAxis(const VContainer *data, QGraphicsItem *parent = nullptr); - virtual ~VisToolLineIntersectAxis() = default; + ~VisToolLineIntersectAxis() override = default; - virtual void RefreshGeometry() override; + void RefreshGeometry() override; + void VisualMode(quint32 id) override; - QString Angle() const; - void SetAngle(const QString &expression); - void setPoint2Id(const quint32 &value); - void setAxisPointId(const quint32 &value); + auto Angle() const -> QString; + void SetAngle(const QString &expression); + void SetPoint1Id(quint32 value); + void SetPoint2Id(quint32 value); + void SetAxisPointId(quint32 value); - virtual int type() const override {return Type;} - enum { Type = UserType + static_cast(Vis::ToolLineIntersectAxis)}; + auto type() const -> int override {return Type;} + enum {Type = UserType + static_cast(Vis::ToolLineIntersectAxis)}; private: // cppcheck-suppress unknownMacro Q_DISABLE_COPY_MOVE(VisToolLineIntersectAxis) // NOLINT - quint32 point2Id; - quint32 axisPointId; - qreal angle; - VScaledEllipse *point; - VScaledEllipse *lineP1; - VScaledEllipse *lineP2; - VScaledEllipse *basePoint; - VScaledLine *baseLine; - VScaledLine *axisLine; - VScaledLine *line_intersection; - void ShowIntersection(const QLineF &axis_line, const QLineF &base_line); + quint32 m_point1Id{NULL_ID}; + quint32 m_point2Id{NULL_ID}; + quint32 m_axisPointId{NULL_ID}; + qreal m_angle{-1}; + VScaledEllipse *m_point{nullptr}; + VScaledEllipse *m_lineP1{nullptr}; + VScaledEllipse *m_lineP2{nullptr}; + VScaledEllipse *m_basePoint{nullptr}; + VScaledLine *m_baseLine{nullptr}; + VScaledLine *m_axisLine{nullptr}; + VScaledLine *m_lineIntersection{nullptr}; + + void ShowIntersection(const QLineF &axis_line, const QLineF &base_line); }; +//--------------------------------------------------------------------------------------------------------------------- +inline void VisToolLineIntersectAxis::SetPoint1Id(quint32 value) +{ + m_point1Id = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline void VisToolLineIntersectAxis::SetPoint2Id(quint32 value) +{ + m_point2Id = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline void VisToolLineIntersectAxis::SetAxisPointId(quint32 value) +{ + m_axisPointId = value; +} + #endif // VISTOOLLINEINTERSECTAXIS_H diff --git a/src/libs/vtools/visualization/line/vistoolnormal.cpp b/src/libs/vtools/visualization/line/vistoolnormal.cpp index 51076014f..0d81770ac 100644 --- a/src/libs/vtools/visualization/line/vistoolnormal.cpp +++ b/src/libs/vtools/visualization/line/vistoolnormal.cpp @@ -47,52 +47,52 @@ VisToolNormal::VisToolNormal(const VContainer *data, QGraphicsItem *parent) : VisLine(data, parent) { - this->mainColor = Qt::red; + SetMainColor(Qt::red); - m_lineP1 = InitPoint(supportColor, this); - m_lineP2 = InitPoint(supportColor, this); //-V656 - m_line = InitItem(supportColor, this); + m_lineP1 = InitPoint(Color(VColor::SupportColor), this); + m_lineP2 = InitPoint(Color(VColor::SupportColor), this); //-V656 + m_line = InitItem(Color(VColor::SupportColor), this); - m_point = InitPoint(mainColor, this); + m_point = InitPoint(Color(VColor::MainColor), this); } //--------------------------------------------------------------------------------------------------------------------- void VisToolNormal::RefreshGeometry() { - if (object1Id > NULL_ID) + if (m_object1Id > NULL_ID) { - const QSharedPointer first = Visualization::data->GeometricObject(object1Id); - DrawPoint(m_lineP1, static_cast(*first), supportColor); + const QSharedPointer first = GetData()->GeometricObject(m_object1Id); + DrawPoint(m_lineP1, static_cast(*first), Color(VColor::SupportColor)); if (m_object2Id <= NULL_ID) { - QLineF line_mouse(static_cast(*first), Visualization::scenePos); - DrawLine(m_line, line_mouse, supportColor); + QLineF line_mouse(static_cast(*first), ScenePos()); + DrawLine(m_line, line_mouse, Color(VColor::SupportColor)); QLineF normal = line_mouse.normalVector(); QPointF endRay = Ray(normal.p1(), normal.angle()); - DrawLine(this, QLineF(normal.p1(), endRay), mainColor); + DrawLine(this, QLineF(normal.p1(), endRay), Color(VColor::MainColor)); } else { - const QSharedPointer second = Visualization::data->GeometricObject(m_object2Id); - DrawPoint(m_lineP2, static_cast(*second), supportColor); + const QSharedPointer second = GetData()->GeometricObject(m_object2Id); + DrawPoint(m_lineP2, static_cast(*second), Color(VColor::SupportColor)); QLineF line_mouse(static_cast(*first), static_cast(*second)); - DrawLine(m_line, line_mouse, supportColor); + DrawLine(m_line, line_mouse, Color(VColor::SupportColor)); if (not qFuzzyIsNull(m_length)) { QPointF fPoint = VToolNormal::FindPoint(static_cast(*first), static_cast(*second), m_length, m_angle); QLineF mainLine = QLineF(static_cast(*first), fPoint); - DrawLine(this, mainLine, mainColor, lineStyle); + DrawLine(this, mainLine, Color(VColor::MainColor), LineStyle()); - DrawPoint(m_point, mainLine.p2(), mainColor); + DrawPoint(m_point, mainLine.p2(), Color(VColor::MainColor)); } - else if (mode == Mode::Creation) + else if (GetMode() == Mode::Creation) { - QLineF cursorLine (static_cast(*first), Visualization::scenePos); + QLineF cursorLine (static_cast(*first), ScenePos()); QLineF normal = line_mouse.normalVector(); qreal len = cursorLine.length(); @@ -105,36 +105,37 @@ void VisToolNormal::RefreshGeometry() QPointF fPoint = VToolNormal::FindPoint(static_cast(*first), static_cast(*second), len, m_angle); QLineF mainLine = QLineF(static_cast(*first), fPoint); - DrawLine(this, mainLine, mainColor, lineStyle); + DrawLine(this, mainLine, Color(VColor::MainColor), LineStyle()); - DrawPoint(m_point, mainLine.p2(), mainColor); + DrawPoint(m_point, mainLine.p2(), Color(VColor::MainColor)); const QString prefix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true); - Visualization::toolTip = tr("Length = %1%2; " - "Mouse click - finish selecting the length, " - "%3 - skip") - .arg(NumberToUser(len), prefix, VModifierKey::EnterKey()); + SetToolTip(tr("Length = %1%2; " + "Mouse click - finish selecting the length, " + "%3 - skip") + .arg(NumberToUser(len), prefix, VModifierKey::EnterKey())); } else { QLineF normal = line_mouse.normalVector(); QPointF endRay = Ray(normal.p1(), normal.angle()); - DrawLine(this, QLineF(normal.p1(), endRay), mainColor); + DrawLine(this, QLineF(normal.p1(), endRay), Color(VColor::MainColor)); } } } } //--------------------------------------------------------------------------------------------------------------------- -void VisToolNormal::setObject2Id(const quint32 &value) +void VisToolNormal::VisualMode(quint32 id) { - m_object2Id = value; + m_object1Id = id; + StartVisualMode(); } //--------------------------------------------------------------------------------------------------------------------- -void VisToolNormal::setLength(const QString &expression) +void VisToolNormal::SetLength(const QString &expression) { - m_length = FindLengthFromUser(expression, Visualization::data->DataVariables()); + m_length = FindLengthFromUser(expression, GetData()->DataVariables()); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/visualization/line/vistoolnormal.h b/src/libs/vtools/visualization/line/vistoolnormal.h index a4aa0c2ef..dde98a676 100644 --- a/src/libs/vtools/visualization/line/vistoolnormal.h +++ b/src/libs/vtools/visualization/line/vistoolnormal.h @@ -47,17 +47,21 @@ public: ~VisToolNormal() override = default; void RefreshGeometry() override; + void VisualMode(quint32 id) override; - void setObject2Id(const quint32 &value); - void setLength(const QString &expression); + void SetPoint1Id(quint32 value); + void SetPoint2Id(quint32 value); + void SetLength(const QString &expression); auto GetAngle() const -> qreal; void SetAngle(const qreal &value); + auto type() const -> int override {return Type;} enum {Type = UserType + static_cast(Vis::ToolNormal)}; private: // cppcheck-suppress unknownMacro Q_DISABLE_COPY_MOVE(VisToolNormal) // NOLINT + quint32 m_object1Id{NULL_ID}; quint32 m_object2Id{NULL_ID}; VScaledEllipse *m_point{nullptr}; VScaledEllipse *m_lineP1{nullptr}; @@ -65,7 +69,18 @@ private: VScaledLine *m_line{nullptr}; qreal m_length{0}; qreal m_angle{0}; - }; +//--------------------------------------------------------------------------------------------------------------------- +inline void VisToolNormal::SetPoint1Id(quint32 value) +{ + m_object1Id = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline void VisToolNormal::SetPoint2Id(quint32 value) +{ + m_object2Id = value; +} + #endif // VISTOOLNORMAL_H diff --git a/src/libs/vtools/visualization/line/vistoolpointfromarcandtangent.cpp b/src/libs/vtools/visualization/line/vistoolpointfromarcandtangent.cpp index c6c159ce1..8d3a1d32f 100644 --- a/src/libs/vtools/visualization/line/vistoolpointfromarcandtangent.cpp +++ b/src/libs/vtools/visualization/line/vistoolpointfromarcandtangent.cpp @@ -37,7 +37,6 @@ #include #include "../../tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromarcandtangent.h" -#include "../ifc/ifcdef.h" #include "../vgeometry/vabstractcurve.h" #include "../vgeometry/varc.h" #include "../vgeometry/vgobject.h" @@ -48,46 +47,40 @@ //--------------------------------------------------------------------------------------------------------------------- VisToolPointFromArcAndTangent::VisToolPointFromArcAndTangent(const VContainer *data, QGraphicsItem *parent) - : VisLine(data, parent), arcId(NULL_ID), crossPoint(CrossCirclesPoint::FirstPoint), - point(nullptr), tangent(nullptr), arcPath(nullptr) + : VisLine(data, parent) { - arcPath = InitItem(Qt::darkGreen, this); - point = InitPoint(mainColor, this); - tangent = InitPoint(supportColor, this); + m_arcPath = InitItem(Qt::darkGreen, this); + m_point = InitPoint(Color(VColor::MainColor), this); + m_tangent = InitPoint(Color(VColor::SupportColor), this); } //--------------------------------------------------------------------------------------------------------------------- void VisToolPointFromArcAndTangent::RefreshGeometry() { - if (object1Id > NULL_ID)// tangent point + if (m_pointId > NULL_ID)// tangent point { - const QSharedPointer tan = Visualization::data->GeometricObject(object1Id); - DrawPoint(tangent, static_cast(*tan), supportColor); + const QSharedPointer tan = GetData()->GeometricObject(m_pointId); + DrawPoint(m_tangent, static_cast(*tan), Color(VColor::SupportColor)); - if (arcId > NULL_ID)// circle center + if (m_arcId > NULL_ID)// circle center { - const QSharedPointer arc = Visualization::data->GeometricObject(arcId); - DrawPath(arcPath, arc->GetPath(), arc->DirectionArrows(), Qt::darkGreen, Qt::SolidLine, Qt::RoundCap); + const QSharedPointer arc = GetData()->GeometricObject(m_arcId); + DrawPath(m_arcPath, arc->GetPath(), arc->DirectionArrows(), Qt::darkGreen, Qt::SolidLine, Qt::RoundCap); FindRays(static_cast(*tan), arc.data()); QPointF fPoint; - VToolPointFromArcAndTangent::FindPoint(static_cast(*tan), arc.data(), crossPoint, &fPoint); - DrawPoint(point, fPoint, mainColor); + VToolPointFromArcAndTangent::FindPoint(static_cast(*tan), arc.data(), m_crossPoint, &fPoint); + DrawPoint(m_point, fPoint, Color(VColor::MainColor)); } } } //--------------------------------------------------------------------------------------------------------------------- -void VisToolPointFromArcAndTangent::setArcId(const quint32 &value) +void VisToolPointFromArcAndTangent::VisualMode(quint32 id) { - arcId = value; -} - -//--------------------------------------------------------------------------------------------------------------------- -void VisToolPointFromArcAndTangent::setCrossPoint(const CrossCirclesPoint &value) -{ - crossPoint = value; + m_pointId = id; + StartVisualMode(); } //--------------------------------------------------------------------------------------------------------------------- @@ -125,10 +118,11 @@ void VisToolPointFromArcAndTangent::FindRays(const QPointF &p, const VArc *arc) switch(localRes) { case 2: - DrawRay(this, p, crossPoint == CrossCirclesPoint::FirstPoint ? p1 : p2, supportColor, Qt::DashLine); + DrawRay(this, p, m_crossPoint == CrossCirclesPoint::FirstPoint ? p1 : p2, + Color(VColor::SupportColor), Qt::DashLine); break; case 1: - DrawRay(this, p, flagP1 ? p1 : p2, supportColor, Qt::DashLine); + DrawRay(this, p, flagP1 ? p1 : p2, Color(VColor::SupportColor), Qt::DashLine); break; case 0: default: @@ -139,7 +133,7 @@ void VisToolPointFromArcAndTangent::FindRays(const QPointF &p, const VArc *arc) break; } case 1: - DrawRay(this, p, p1, supportColor, Qt::DashLine); + DrawRay(this, p, p1, Color(VColor::SupportColor), Qt::DashLine); break; case 3: case 0: diff --git a/src/libs/vtools/visualization/line/vistoolpointfromarcandtangent.h b/src/libs/vtools/visualization/line/vistoolpointfromarcandtangent.h index f22433a1d..9677971a0 100644 --- a/src/libs/vtools/visualization/line/vistoolpointfromarcandtangent.h +++ b/src/libs/vtools/visualization/line/vistoolpointfromarcandtangent.h @@ -48,25 +48,47 @@ class VisToolPointFromArcAndTangent : public VisLine Q_OBJECT // NOLINT public: explicit VisToolPointFromArcAndTangent(const VContainer *data, QGraphicsItem *parent = nullptr); - virtual ~VisToolPointFromArcAndTangent() = default; + ~VisToolPointFromArcAndTangent() override = default; - virtual void RefreshGeometry() override; + void RefreshGeometry() override; + void VisualMode(quint32 id) override; - void setArcId(const quint32 &value); - void setCrossPoint(const CrossCirclesPoint &value); + void SetPointId(quint32 newPointId); + void SetArcId(const quint32 &value); + void SetCrossPoint(const CrossCirclesPoint &value); + + auto type() const -> int override {return Type;} + enum {Type = UserType + static_cast(Vis::ToolPointFromArcAndTangent)}; - virtual int type() const override {return Type;} - enum { Type = UserType + static_cast(Vis::ToolPointFromArcAndTangent)}; private: // cppcheck-suppress unknownMacro Q_DISABLE_COPY_MOVE(VisToolPointFromArcAndTangent) // NOLINT - quint32 arcId; - CrossCirclesPoint crossPoint; - VScaledEllipse *point; - VScaledEllipse *tangent; - VCurvePathItem *arcPath; + quint32 m_arcId{NULL_ID}; + CrossCirclesPoint m_crossPoint{CrossCirclesPoint::FirstPoint}; + VScaledEllipse *m_point{nullptr}; + VScaledEllipse *m_tangent{nullptr}; + VCurvePathItem *m_arcPath{nullptr}; + quint32 m_pointId{NULL_ID}; void FindRays(const QPointF &p, const VArc *arc); }; +//--------------------------------------------------------------------------------------------------------------------- +inline void VisToolPointFromArcAndTangent::SetPointId(quint32 newPointId) +{ + m_pointId = newPointId; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline void VisToolPointFromArcAndTangent::SetArcId(const quint32 &value) +{ + m_arcId = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline void VisToolPointFromArcAndTangent::SetCrossPoint(const CrossCirclesPoint &value) +{ + m_crossPoint = value; +} + #endif // VISTOOLPOINTFROMARCANDTANGENT_H diff --git a/src/libs/vtools/visualization/line/vistoolpointfromcircleandtangent.cpp b/src/libs/vtools/visualization/line/vistoolpointfromcircleandtangent.cpp index d27e6079c..1badd385a 100644 --- a/src/libs/vtools/visualization/line/vistoolpointfromcircleandtangent.cpp +++ b/src/libs/vtools/visualization/line/vistoolpointfromcircleandtangent.cpp @@ -44,61 +44,55 @@ //--------------------------------------------------------------------------------------------------------------------- VisToolPointFromCircleAndTangent::VisToolPointFromCircleAndTangent(const VContainer *data, QGraphicsItem *parent) - : VisLine(data, parent), object2Id(NULL_ID), cRadius(0), crossPoint(CrossCirclesPoint::FirstPoint), - point(nullptr), tangent(nullptr), cCenter(nullptr), cPath(nullptr), tangent2(nullptr) + : VisLine(data, parent) { - cPath = InitItem(Qt::darkGreen, this); - point = InitPoint(mainColor, this); - tangent = InitPoint(supportColor, this); - cCenter = InitPoint(supportColor, this); //-V656 - tangent2 = InitItem(supportColor, this); + m_cPath = InitItem(Qt::darkGreen, this); + m_point = InitPoint(Color(VColor::MainColor), this); + m_tangent = InitPoint(Color(VColor::SupportColor), this); + m_cCenter = InitPoint(Color(VColor::SupportColor), this); //-V656 + m_tangent2 = InitItem(Color(VColor::SupportColor), this); } //--------------------------------------------------------------------------------------------------------------------- void VisToolPointFromCircleAndTangent::RefreshGeometry() { - if (object1Id > NULL_ID)// tangent point + if (m_pointId > NULL_ID)// tangent point { - const QSharedPointer tan = Visualization::data->GeometricObject(object1Id); - DrawPoint(tangent, static_cast(*tan), supportColor); + const QSharedPointer tan = GetData()->GeometricObject(m_pointId); + DrawPoint(m_tangent, static_cast(*tan), Color(VColor::SupportColor)); - if (object2Id > NULL_ID)// circle center + if (m_centerId > NULL_ID)// circle center { - const QSharedPointer center = Visualization::data->GeometricObject(object2Id); - DrawPoint(cCenter, static_cast(*center), supportColor); + const QSharedPointer center = GetData()->GeometricObject(m_centerId); + DrawPoint(m_cCenter, static_cast(*center), Color(VColor::SupportColor)); - if (cRadius > 0) + if (m_cRadius > 0) { - cPath->setRect(PointRect(cRadius)); - DrawPoint(cPath, static_cast(*center), Qt::darkGreen, Qt::DashLine); + m_cPath->setRect(PointRect(m_cRadius)); + DrawPoint(m_cPath, static_cast(*center), Qt::darkGreen, Qt::DashLine); - FindRays(static_cast(*tan), static_cast(*center), cRadius); + FindRays(static_cast(*tan), static_cast(*center), m_cRadius); QPointF fPoint; VToolPointFromCircleAndTangent::FindPoint(static_cast(*tan), static_cast(*center), - cRadius, crossPoint, &fPoint); - DrawPoint(point, fPoint, mainColor); + m_cRadius, m_crossPoint, &fPoint); + DrawPoint(m_point, fPoint, Color(VColor::MainColor)); } } } } //--------------------------------------------------------------------------------------------------------------------- -void VisToolPointFromCircleAndTangent::setObject2Id(const quint32 &value) +void VisToolPointFromCircleAndTangent::VisualMode(quint32 id) { - object2Id = value; + m_pointId = id; + StartVisualMode(); } //--------------------------------------------------------------------------------------------------------------------- -void VisToolPointFromCircleAndTangent::setCRadius(const QString &value) +void VisToolPointFromCircleAndTangent::SetCRadius(const QString &value) { - cRadius = FindLengthFromUser(value, Visualization::data->DataVariables()); -} - -//--------------------------------------------------------------------------------------------------------------------- -void VisToolPointFromCircleAndTangent::setCrossPoint(const CrossCirclesPoint &value) -{ - crossPoint = value; + m_cRadius = FindLengthFromUser(value, GetData()->DataVariables()); } //--------------------------------------------------------------------------------------------------------------------- @@ -110,16 +104,16 @@ void VisToolPointFromCircleAndTangent::FindRays(const QPointF &p, const QPointF switch(res) { case 2: - DrawRay(this, p, p1, supportColor, Qt::DashLine); - DrawRay(tangent2, p, p2, supportColor, Qt::DashLine); + DrawRay(this, p, p1, Color(VColor::SupportColor), Qt::DashLine); + DrawRay(m_tangent2, p, p2, Color(VColor::SupportColor), Qt::DashLine); break; case 1: - DrawRay(this, p, p1, supportColor, Qt::DashLine); - tangent2->setVisible(false); + DrawRay(this, p, p1, Color(VColor::SupportColor), Qt::DashLine); + m_tangent2->setVisible(false); break; default: this->setVisible(false); - tangent2->setVisible(false); + m_tangent2->setVisible(false); break; } } diff --git a/src/libs/vtools/visualization/line/vistoolpointfromcircleandtangent.h b/src/libs/vtools/visualization/line/vistoolpointfromcircleandtangent.h index 994b6c1c9..1286c64cb 100644 --- a/src/libs/vtools/visualization/line/vistoolpointfromcircleandtangent.h +++ b/src/libs/vtools/visualization/line/vistoolpointfromcircleandtangent.h @@ -46,29 +46,50 @@ class VisToolPointFromCircleAndTangent : public VisLine Q_OBJECT // NOLINT public: explicit VisToolPointFromCircleAndTangent(const VContainer *data, QGraphicsItem *parent = nullptr); - virtual ~VisToolPointFromCircleAndTangent() = default; + ~VisToolPointFromCircleAndTangent() override = default; - virtual void RefreshGeometry() override; + void RefreshGeometry() override; + void VisualMode(quint32 id) override; - void setObject2Id(const quint32 &value); - void setCRadius(const QString &value); - void setCrossPoint(const CrossCirclesPoint &value); + void SetPointId(quint32 value); + void SetCenterId(quint32 value); + void SetCRadius(const QString &value); + void SetCrossPoint(CrossCirclesPoint value); - virtual int type() const override {return Type;} - enum { Type = UserType + static_cast(Vis::ToolPointFromCircleAndTangent)}; + auto type() const -> int override {return Type;} + enum {Type = UserType + static_cast(Vis::ToolPointFromCircleAndTangent)}; private: // cppcheck-suppress unknownMacro Q_DISABLE_COPY_MOVE(VisToolPointFromCircleAndTangent) // NOLINT - quint32 object2Id; - qreal cRadius; - CrossCirclesPoint crossPoint; - VScaledEllipse *point; - VScaledEllipse *tangent; - VScaledEllipse *cCenter; - QGraphicsEllipseItem *cPath; - VScaledLine *tangent2; + quint32 m_centerId{NULL_ID}; + qreal m_cRadius{0}; + CrossCirclesPoint m_crossPoint{CrossCirclesPoint::FirstPoint}; + VScaledEllipse *m_point{nullptr}; + VScaledEllipse *m_tangent{nullptr}; + VScaledEllipse *m_cCenter{nullptr}; + QGraphicsEllipseItem *m_cPath{nullptr}; + VScaledLine *m_tangent2{nullptr}; + quint32 m_pointId{NULL_ID}; void FindRays(const QPointF &p, const QPointF ¢er, qreal radius); }; +//--------------------------------------------------------------------------------------------------------------------- +inline void VisToolPointFromCircleAndTangent::SetPointId(quint32 value) +{ + m_pointId = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline void VisToolPointFromCircleAndTangent::SetCenterId(quint32 value) +{ + m_centerId = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline void VisToolPointFromCircleAndTangent::SetCrossPoint(CrossCirclesPoint value) +{ + m_crossPoint = value; +} + #endif // VISTOOLPOINTFROMCIRCLEANDTANGENT_H diff --git a/src/libs/vtools/visualization/line/vistoolpointofcontact.cpp b/src/libs/vtools/visualization/line/vistoolpointofcontact.cpp index b3c533c65..185657f40 100644 --- a/src/libs/vtools/visualization/line/vistoolpointofcontact.cpp +++ b/src/libs/vtools/visualization/line/vistoolpointofcontact.cpp @@ -44,49 +44,49 @@ //--------------------------------------------------------------------------------------------------------------------- VisToolPointOfContact::VisToolPointOfContact(const VContainer *data, QGraphicsItem *parent) - :VisLine(data, parent), lineP2Id(NULL_ID), radiusId(NULL_ID), point(nullptr), lineP1(nullptr), lineP2(nullptr), - arc_point(nullptr), circle(nullptr), radius(0) + :VisLine(data, parent) { - arc_point = InitPoint(supportColor, this); - lineP1 = InitPoint(supportColor, this); - lineP2 = InitPoint(supportColor, this); - circle = InitItem(supportColor, this); + m_arcPoint = InitPoint(Color(VColor::SupportColor), this); + m_lineP1 = InitPoint(Color(VColor::SupportColor), this); + m_lineP2 = InitPoint(Color(VColor::SupportColor), this); + m_circle = InitItem(Color(VColor::SupportColor), this); - point = InitPoint(mainColor, this); + m_point = InitPoint(Color(VColor::MainColor), this); } //--------------------------------------------------------------------------------------------------------------------- void VisToolPointOfContact::RefreshGeometry() { - if (object1Id > NULL_ID) + if (m_lineP1Id > NULL_ID) { - const QSharedPointer first = Visualization::data->GeometricObject(object1Id); - DrawPoint(lineP1, static_cast(*first), supportColor); + const QSharedPointer first = GetData()->GeometricObject(m_lineP1Id); + DrawPoint(m_lineP1, static_cast(*first), Color(VColor::SupportColor)); - if (lineP2Id <= NULL_ID) + if (m_lineP2Id <= NULL_ID) { - DrawLine(this, QLineF(static_cast(*first), Visualization::scenePos), supportColor); + DrawLine(this, QLineF(static_cast(*first), ScenePos()), Color(VColor::SupportColor)); } else { - const QSharedPointer second = Visualization::data->GeometricObject(lineP2Id); - DrawPoint(lineP2, static_cast(*second), supportColor); - DrawLine(this, QLineF(static_cast(*first), static_cast(*second)), supportColor); + const QSharedPointer second = GetData()->GeometricObject(m_lineP2Id); + DrawPoint(m_lineP2, static_cast(*second), Color(VColor::SupportColor)); + DrawLine(this, QLineF(static_cast(*first), static_cast(*second)), + Color(VColor::SupportColor)); - if (radiusId > NULL_ID) + if (m_radiusId > NULL_ID) { - const QSharedPointer third = Visualization::data->GeometricObject(radiusId); - DrawPoint(arc_point, static_cast(*third), supportColor); + const QSharedPointer third = GetData()->GeometricObject(m_radiusId); + DrawPoint(m_arcPoint, static_cast(*third), Color(VColor::SupportColor)); - if (not qFuzzyIsNull(radius)) + if (not qFuzzyIsNull(m_radius)) { QPointF fPoint; - VToolPointOfContact::FindPoint(radius, static_cast(*third), static_cast(*first), + VToolPointOfContact::FindPoint(m_radius, static_cast(*third), static_cast(*first), static_cast(*second), &fPoint); - DrawPoint(point, fPoint, mainColor); + DrawPoint(m_point, fPoint, Color(VColor::MainColor)); - circle->setRect(PointRect(radius)); - DrawPoint(circle, static_cast(*third), supportColor, Qt::DashLine); + m_circle->setRect(PointRect(m_radius)); + DrawPoint(m_circle, static_cast(*third), Color(VColor::SupportColor), Qt::DashLine); } } } @@ -94,19 +94,14 @@ void VisToolPointOfContact::RefreshGeometry() } //--------------------------------------------------------------------------------------------------------------------- -void VisToolPointOfContact::setLineP2Id(const quint32 &value) +void VisToolPointOfContact::VisualMode(quint32 id) { - lineP2Id = value; + m_lineP1Id = id; + StartVisualMode(); } //--------------------------------------------------------------------------------------------------------------------- -void VisToolPointOfContact::setRadiusId(const quint32 &value) +void VisToolPointOfContact::SetRadius(const QString &expression) { - radiusId = value; -} - -//--------------------------------------------------------------------------------------------------------------------- -void VisToolPointOfContact::setRadius(const QString &expression) -{ - radius = FindLengthFromUser(expression, Visualization::data->DataVariables()); + m_radius = FindLengthFromUser(expression, GetData()->DataVariables()); } diff --git a/src/libs/vtools/visualization/line/vistoolpointofcontact.h b/src/libs/vtools/visualization/line/vistoolpointofcontact.h index 436ca3a40..1379a1dd8 100644 --- a/src/libs/vtools/visualization/line/vistoolpointofcontact.h +++ b/src/libs/vtools/visualization/line/vistoolpointofcontact.h @@ -44,26 +44,48 @@ class VisToolPointOfContact : public VisLine Q_OBJECT // NOLINT public: explicit VisToolPointOfContact(const VContainer *data, QGraphicsItem *parent = nullptr); - virtual ~VisToolPointOfContact() = default; + ~VisToolPointOfContact() override = default; - virtual void RefreshGeometry() override; - void setLineP2Id(const quint32 &value); - void setRadiusId(const quint32 &value); - void setRadius(const QString &expression); - virtual int type() const override {return Type;} - enum { Type = UserType + static_cast(Vis::ToolPointOfContact)}; + void RefreshGeometry() override; + void VisualMode(quint32 id) override; + + void SetLineP1Id(quint32 value); + void SetLineP2Id(quint32 value); + void SetRadiusId(quint32 value); + void SetRadius(const QString &expression); + + auto type() const -> int override {return Type;} + enum {Type = UserType + static_cast(Vis::ToolPointOfContact)}; private: // cppcheck-suppress unknownMacro Q_DISABLE_COPY_MOVE(VisToolPointOfContact) // NOLINT - quint32 lineP2Id; - quint32 radiusId; - VScaledEllipse *point; - VScaledEllipse *lineP1; - VScaledEllipse *lineP2; - VScaledEllipse *arc_point; - QGraphicsEllipseItem *circle; - qreal radius; - + quint32 m_lineP1Id{NULL_ID}; + quint32 m_lineP2Id{NULL_ID}; + quint32 m_radiusId{NULL_ID}; + VScaledEllipse *m_point{nullptr}; + VScaledEllipse *m_lineP1{nullptr}; + VScaledEllipse *m_lineP2{nullptr}; + VScaledEllipse *m_arcPoint{nullptr}; + QGraphicsEllipseItem *m_circle{nullptr}; + qreal m_radius{0}; }; +//--------------------------------------------------------------------------------------------------------------------- +inline void VisToolPointOfContact::SetLineP1Id(quint32 value) +{ + m_lineP1Id = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline void VisToolPointOfContact::SetLineP2Id(quint32 value) +{ + m_lineP2Id = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline void VisToolPointOfContact::SetRadiusId(quint32 value) +{ + m_radiusId = value; +} + #endif // VISTOOLPOINTOFCONTACT_H diff --git a/src/libs/vtools/visualization/line/vistoolpointofintersection.cpp b/src/libs/vtools/visualization/line/vistoolpointofintersection.cpp index 09b35ae12..ab0194e05 100644 --- a/src/libs/vtools/visualization/line/vistoolpointofintersection.cpp +++ b/src/libs/vtools/visualization/line/vistoolpointofintersection.cpp @@ -36,7 +36,6 @@ #include #include -#include "../ifc/ifcdef.h" #include "../vgeometry/vpointf.h" #include "../vpatterndb/vcontainer.h" #include "../visualization.h" @@ -45,53 +44,54 @@ //--------------------------------------------------------------------------------------------------------------------- VisToolPointOfIntersection::VisToolPointOfIntersection(const VContainer *data, QGraphicsItem *parent) - : VisLine(data, parent), point2Id(NULL_ID), point(nullptr), axisP1(nullptr), axisP2(nullptr), axis2(nullptr) + : VisLine(data, parent) { - axisP1 = InitPoint(supportColor, this); - axisP2 = InitPoint(supportColor, this); //-V656 - axis2 = InitItem(supportColor, this); + m_axisP1 = InitPoint(Color(VColor::SupportColor), this); + m_axisP2 = InitPoint(Color(VColor::SupportColor), this); //-V656 + m_axis2 = InitItem(Color(VColor::SupportColor), this); - point = InitPoint(mainColor, this); + m_point = InitPoint(Color(VColor::MainColor), this); } //--------------------------------------------------------------------------------------------------------------------- void VisToolPointOfIntersection::RefreshGeometry() { QLineF axisL1; - if (object1Id <= NULL_ID) + if (m_point1Id <= NULL_ID) { - axisL1 = Axis(Visualization::scenePos, 90); - DrawLine(this, axisL1, supportColor, Qt::DashLine); + axisL1 = Axis(ScenePos(), 90); + DrawLine(this, axisL1, Color(VColor::SupportColor), Qt::DashLine); } else { - const QSharedPointer first = Visualization::data->GeometricObject(object1Id); - DrawPoint(axisP1, static_cast(*first), supportColor); + const QSharedPointer first = GetData()->GeometricObject(m_point1Id); + DrawPoint(m_axisP1, static_cast(*first), Color(VColor::SupportColor)); axisL1 = Axis(static_cast(*first), 90); - DrawLine(this, axisL1, supportColor, Qt::DashLine); + DrawLine(this, axisL1, Color(VColor::SupportColor), Qt::DashLine); QLineF axisL2; - if (point2Id <= NULL_ID) + if (m_point2Id <= NULL_ID) { - axisL2 = Axis(Visualization::scenePos, 180); - ShowIntersection(axisL1, axisL2, supportColor); + axisL2 = Axis(ScenePos(), 180); + ShowIntersection(axisL1, axisL2, Color(VColor::SupportColor)); } else { - const QSharedPointer second = Visualization::data->GeometricObject(point2Id); - DrawPoint(axisP2, static_cast(*second), supportColor); + const QSharedPointer second = GetData()->GeometricObject(m_point2Id); + DrawPoint(m_axisP2, static_cast(*second), Color(VColor::SupportColor)); axisL2 = Axis(static_cast(*second), 180); - ShowIntersection(axisL1, axisL2, mainColor); + ShowIntersection(axisL1, axisL2, Color(VColor::MainColor)); } - DrawLine(axis2, axisL2, supportColor, Qt::DashLine); + DrawLine(m_axis2, axisL2, Color(VColor::SupportColor), Qt::DashLine); } } //--------------------------------------------------------------------------------------------------------------------- -void VisToolPointOfIntersection::setPoint2Id(const quint32 &value) +void VisToolPointOfIntersection::VisualMode(quint32 id) { - point2Id = value; + m_point1Id = id; + StartVisualMode(); } //--------------------------------------------------------------------------------------------------------------------- @@ -102,11 +102,11 @@ void VisToolPointOfIntersection::ShowIntersection(const QLineF &axis1, const QLi if (intersect == QLineF::UnboundedIntersection || intersect == QLineF::BoundedIntersection) { - point->setVisible(true); - DrawPoint(point, p, color); + m_point->setVisible(true); + DrawPoint(m_point, p, color); } else { - point->setVisible(false); + m_point->setVisible(false); } } diff --git a/src/libs/vtools/visualization/line/vistoolpointofintersection.h b/src/libs/vtools/visualization/line/vistoolpointofintersection.h index 6a7f76b70..5294ea94c 100644 --- a/src/libs/vtools/visualization/line/vistoolpointofintersection.h +++ b/src/libs/vtools/visualization/line/vistoolpointofintersection.h @@ -46,23 +46,39 @@ class VisToolPointOfIntersection : public VisLine Q_OBJECT // NOLINT public: explicit VisToolPointOfIntersection(const VContainer *data, QGraphicsItem *parent = nullptr); - virtual ~VisToolPointOfIntersection() = default; + ~VisToolPointOfIntersection() override = default; - virtual void RefreshGeometry() override; + void RefreshGeometry() override; + void VisualMode(quint32 id) override; - void setPoint2Id(const quint32 &value); - virtual int type() const override {return Type;} - enum { Type = UserType + static_cast(Vis::ToolPointOfIntersection)}; + void SetPoint1Id(quint32 value); + void SetPoint2Id(quint32 value); + + auto type() const -> int override {return Type;} + enum {Type = UserType + static_cast(Vis::ToolPointOfIntersection)}; private: // cppcheck-suppress unknownMacro Q_DISABLE_COPY_MOVE(VisToolPointOfIntersection) // NOLINT - quint32 point2Id; - VScaledEllipse *point; - VScaledEllipse *axisP1;//axis1 is class themself - VScaledEllipse *axisP2; - VScaledLine *axis2;//axis1 is class themself + quint32 m_point1Id{NULL_ID}; + quint32 m_point2Id{NULL_ID}; + VScaledEllipse *m_point{nullptr}; + VScaledEllipse *m_axisP1{nullptr};//axis1 is class themself + VScaledEllipse *m_axisP2{nullptr}; + VScaledLine *m_axis2{nullptr};//axis1 is class themself - void ShowIntersection(const QLineF &axis1, const QLineF &axis2, const QColor &color); + void ShowIntersection(const QLineF &axis1, const QLineF &axis2, const QColor &color); }; +//--------------------------------------------------------------------------------------------------------------------- +inline void VisToolPointOfIntersection::SetPoint1Id(quint32 value) +{ + m_point1Id = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline void VisToolPointOfIntersection::SetPoint2Id(quint32 value) +{ + m_point2Id = value; +} + #endif // VISTOOLPOINTOFINTERSECTION_H diff --git a/src/libs/vtools/visualization/line/vistoolpointofintersectionarcs.cpp b/src/libs/vtools/visualization/line/vistoolpointofintersectionarcs.cpp index 99975c1e2..a725ba90b 100644 --- a/src/libs/vtools/visualization/line/vistoolpointofintersectionarcs.cpp +++ b/src/libs/vtools/visualization/line/vistoolpointofintersectionarcs.cpp @@ -38,80 +38,51 @@ #include #include "../../tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectionarcs.h" -#include "../ifc/ifcdef.h" #include "../vgeometry/vabstractcurve.h" #include "../vgeometry/varc.h" -#include "../vmisc/vabstractapplication.h" #include "../vpatterndb/vcontainer.h" -#include "../vwidgets/vmaingraphicsscene.h" #include "../visualization.h" #include "visualization/line/visline.h" //--------------------------------------------------------------------------------------------------------------------- VisToolPointOfIntersectionArcs::VisToolPointOfIntersectionArcs(const VContainer *data, QGraphicsItem *parent) - : VisLine(data, parent), arc1Id(NULL_ID), arc2Id(NULL_ID), crossPoint(CrossCirclesPoint::FirstPoint), - point(nullptr), - arc1Path(nullptr), arc2Path(nullptr) + : VisLine(data, parent) { this->setPen(QPen(Qt::NoPen)); // don't use parent this time - arc1Path = InitItem(Qt::darkGreen, this); - arc1Path->setFlag(QGraphicsItem::ItemStacksBehindParent, false); - arc2Path = InitItem(Qt::darkRed, this); - arc2Path->setFlag(QGraphicsItem::ItemStacksBehindParent, false); + m_arc1Path = InitItem(Qt::darkGreen, this); + m_arc1Path->setFlag(QGraphicsItem::ItemStacksBehindParent, false); + m_arc2Path = InitItem(Qt::darkRed, this); + m_arc2Path->setFlag(QGraphicsItem::ItemStacksBehindParent, false); - point = InitPoint(mainColor, this); - point->setZValue(2); - point->setFlag(QGraphicsItem::ItemStacksBehindParent, false); + m_point = InitPoint(Color(VColor::MainColor), this); + m_point->setZValue(2); + m_point->setFlag(QGraphicsItem::ItemStacksBehindParent, false); } //--------------------------------------------------------------------------------------------------------------------- void VisToolPointOfIntersectionArcs::RefreshGeometry() { - if (arc1Id > NULL_ID) + if (m_arc1Id > NULL_ID) { - const QSharedPointer arc1 = Visualization::data->GeometricObject(arc1Id); - DrawPath(arc1Path, arc1->GetPath(), arc1->DirectionArrows(), Qt::darkGreen, Qt::SolidLine, Qt::RoundCap); + const QSharedPointer arc1 = GetData()->GeometricObject(m_arc1Id); + DrawPath(m_arc1Path, arc1->GetPath(), arc1->DirectionArrows(), Qt::darkGreen, Qt::SolidLine, Qt::RoundCap); - if (arc2Id > NULL_ID) + if (m_arc2Id > NULL_ID) { - const QSharedPointer arc2 = Visualization::data->GeometricObject(arc2Id); - DrawPath(arc2Path, arc2->GetPath(), arc2->DirectionArrows(), Qt::darkRed, Qt::SolidLine, Qt::RoundCap); + const QSharedPointer arc2 = GetData()->GeometricObject(m_arc2Id); + DrawPath(m_arc2Path, arc2->GetPath(), arc2->DirectionArrows(), Qt::darkRed, Qt::SolidLine, Qt::RoundCap); QPointF fPoint; - VToolPointOfIntersectionArcs::FindPoint(arc1.data(), arc2.data(), crossPoint, &fPoint); - DrawPoint(point, fPoint, mainColor); + VToolPointOfIntersectionArcs::FindPoint(arc1.data(), arc2.data(), m_crossPoint, &fPoint); + DrawPoint(m_point, fPoint, Color(VColor::MainColor)); } } } //--------------------------------------------------------------------------------------------------------------------- -void VisToolPointOfIntersectionArcs::VisualMode(const quint32 &id) +void VisToolPointOfIntersectionArcs::VisualMode(quint32 id) { - VMainGraphicsScene *scene = qobject_cast(VAbstractValApplication::VApp()->getCurrentScene()); - SCASSERT(scene != nullptr) - - this->arc1Id = id; - Visualization::scenePos = scene->getScenePos(); - RefreshGeometry(); - - AddOnScene(); -} - -//--------------------------------------------------------------------------------------------------------------------- -void VisToolPointOfIntersectionArcs::setArc1Id(const quint32 &value) -{ - arc1Id = value; -} - -//--------------------------------------------------------------------------------------------------------------------- -void VisToolPointOfIntersectionArcs::setArc2Id(const quint32 &value) -{ - arc2Id = value; -} - -//--------------------------------------------------------------------------------------------------------------------- -void VisToolPointOfIntersectionArcs::setCrossPoint(const CrossCirclesPoint &value) -{ - crossPoint = value; + m_arc1Id = id; + StartVisualMode(); } diff --git a/src/libs/vtools/visualization/line/vistoolpointofintersectionarcs.h b/src/libs/vtools/visualization/line/vistoolpointofintersectionarcs.h index 2a4dbde39..b6ba69900 100644 --- a/src/libs/vtools/visualization/line/vistoolpointofintersectionarcs.h +++ b/src/libs/vtools/visualization/line/vistoolpointofintersectionarcs.h @@ -45,26 +45,44 @@ class VisToolPointOfIntersectionArcs : public VisLine Q_OBJECT // NOLINT public: explicit VisToolPointOfIntersectionArcs(const VContainer *data, QGraphicsItem *parent = nullptr); - virtual ~VisToolPointOfIntersectionArcs() = default; + ~VisToolPointOfIntersectionArcs() override = default; - virtual void RefreshGeometry() override; - virtual void VisualMode(const quint32 &id) override; + void RefreshGeometry() override; + void VisualMode(quint32 id) override; - void setArc1Id(const quint32 &value); - void setArc2Id(const quint32 &value); - void setCrossPoint(const CrossCirclesPoint &value); + void SetArc1Id(quint32 value); + void SetArc2Id(quint32 value); + void SetCrossPoint(CrossCirclesPoint value); - virtual int type() const override {return Type;} - enum { Type = UserType + static_cast(Vis::ToolPointOfIntersectionArcs)}; + auto type() const -> int override {return Type;} + enum {Type = UserType + static_cast(Vis::ToolPointOfIntersectionArcs)}; private: // cppcheck-suppress unknownMacro Q_DISABLE_COPY_MOVE(VisToolPointOfIntersectionArcs) // NOLINT - quint32 arc1Id; - quint32 arc2Id; - CrossCirclesPoint crossPoint; - VScaledEllipse *point; - VCurvePathItem *arc1Path; - VCurvePathItem *arc2Path; + quint32 m_arc1Id{NULL_ID}; + quint32 m_arc2Id{NULL_ID}; + CrossCirclesPoint m_crossPoint{CrossCirclesPoint::FirstPoint}; + VScaledEllipse *m_point{nullptr}; + VCurvePathItem *m_arc1Path{nullptr}; + VCurvePathItem *m_arc2Path{nullptr}; }; +//--------------------------------------------------------------------------------------------------------------------- +inline void VisToolPointOfIntersectionArcs::SetArc1Id(quint32 value) +{ + m_arc1Id = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline void VisToolPointOfIntersectionArcs::SetArc2Id(quint32 value) +{ + m_arc2Id = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline void VisToolPointOfIntersectionArcs::SetCrossPoint(CrossCirclesPoint value) +{ + m_crossPoint = value; +} + #endif // VISTOOLPOINTOFINTERSECTIONARCS_H diff --git a/src/libs/vtools/visualization/line/vistoolpointofintersectioncircles.cpp b/src/libs/vtools/visualization/line/vistoolpointofintersectioncircles.cpp index fd64ee36c..8105cb7c4 100644 --- a/src/libs/vtools/visualization/line/vistoolpointofintersectioncircles.cpp +++ b/src/libs/vtools/visualization/line/vistoolpointofintersectioncircles.cpp @@ -38,7 +38,6 @@ #include "../../tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncircles.h" #include "../vgeometry/vpointf.h" #include "../vpatterndb/vcontainer.h" -#include "../vwidgets/vmaingraphicsscene.h" #include "../vwidgets/global.h" #include "../visualization.h" #include "visline.h" @@ -56,30 +55,30 @@ VisToolPointOfIntersectionCircles::VisToolPointOfIntersectionCircles(const VCont m_c2Path = InitItem(Qt::darkRed, this); m_c2Path->SetPointMode(false); - m_point = InitPoint(mainColor, this); + m_point = InitPoint(Color(VColor::MainColor), this); m_point->setZValue(1); - m_c1Center = InitPoint(supportColor, this); - m_c2Center = InitPoint(supportColor, this); //-V656 + m_c1Center = InitPoint(Color(VColor::SupportColor), this); + m_c2Center = InitPoint(Color(VColor::SupportColor), this); //-V656 } //--------------------------------------------------------------------------------------------------------------------- void VisToolPointOfIntersectionCircles::RefreshGeometry() { - if (object1Id > NULL_ID) + if (m_circle1Id > NULL_ID) { - const QSharedPointer first = Visualization::data->GeometricObject(object1Id); - DrawPoint(m_c1Center, static_cast(*first), supportColor); + const QSharedPointer first = GetData()->GeometricObject(m_circle1Id); + DrawPoint(m_c1Center, static_cast(*first), Color(VColor::SupportColor)); if (m_c1Radius > 0) { m_c1Path->setRect(PointRect(m_c1Radius)); DrawPoint(m_c1Path, static_cast(*first), Qt::darkGreen, Qt::DashLine); - if (m_object2Id > NULL_ID) + if (m_circle2Id > NULL_ID) { - const QSharedPointer second = Visualization::data->GeometricObject(m_object2Id); - DrawPoint(m_c2Center, static_cast(*second), supportColor); + const QSharedPointer second = GetData()->GeometricObject(m_circle2Id); + DrawPoint(m_c2Center, static_cast(*second), Color(VColor::SupportColor)); if (m_c2Radius > 0) { @@ -90,11 +89,11 @@ void VisToolPointOfIntersectionCircles::RefreshGeometry() VToolPointOfIntersectionCircles::FindPoint(static_cast(*first), static_cast(*second), m_c1Radius, m_c2Radius, m_crossPoint, &fPoint); - DrawPoint(m_point, fPoint, mainColor); + DrawPoint(m_point, fPoint, Color(VColor::MainColor)); } - else if (mode == Mode::Creation) + else if (GetMode() == Mode::Creation) { - QLineF radiusLine (static_cast(*second), Visualization::scenePos); + QLineF radiusLine (static_cast(*second), ScenePos()); const qreal length = radiusLine.length(); m_c2Path->setRect(PointRect(length)); @@ -104,66 +103,48 @@ void VisToolPointOfIntersectionCircles::RefreshGeometry() VToolPointOfIntersectionCircles::FindPoint(static_cast(*first), static_cast(*second), m_c1Radius, length, m_crossPoint, &fPoint); - DrawPoint(m_point, fPoint, mainColor); + DrawPoint(m_point, fPoint, Color(VColor::MainColor)); const QString prefix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true); - Visualization::toolTip = tr("Radius = %1%2; " - "Mouse click - finish selecting the second radius, " - "%3 - skip") - .arg(NumberToUser(length), prefix, VModifierKey::EnterKey()); + SetToolTip(tr("Radius = %1%2; " + "Mouse click - finish selecting the second radius, " + "%3 - skip") + .arg(NumberToUser(length), prefix, VModifierKey::EnterKey())); } } } - else if (mode == Mode::Creation) + else if (GetMode() == Mode::Creation) { - QLineF radiusLine (static_cast(*first), Visualization::scenePos); + QLineF radiusLine (static_cast(*first), ScenePos()); const qreal length = radiusLine.length(); m_c1Path->setRect(PointRect(length)); DrawPoint(m_c1Path, static_cast(*first), Qt::darkGreen, Qt::DashLine); const QString prefix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true); - Visualization::toolTip = tr("Radius = %1%2; " - "Mouse click - finish selecting the first radius, " - "%3 - skip") - .arg(NumberToUser(length), prefix, VModifierKey::EnterKey()); + SetToolTip(tr("Radius = %1%2; " + "Mouse click - finish selecting the first radius, " + "%3 - skip") + .arg(NumberToUser(length), prefix, VModifierKey::EnterKey())); } } } //--------------------------------------------------------------------------------------------------------------------- -void VisToolPointOfIntersectionCircles::VisualMode(const quint32 &id) +void VisToolPointOfIntersectionCircles::VisualMode(quint32 id) { - auto *scene = qobject_cast(VAbstractValApplication::VApp()->getCurrentScene()); - SCASSERT(scene != nullptr) - - this->object1Id = id; - Visualization::scenePos = scene->getScenePos(); - RefreshGeometry(); - - AddOnScene(); + m_circle1Id = id; + StartVisualMode(); } //--------------------------------------------------------------------------------------------------------------------- -void VisToolPointOfIntersectionCircles::setObject2Id(const quint32 &value) +void VisToolPointOfIntersectionCircles::SetC1Radius(const QString &value) { - m_object2Id = value; + m_c1Radius = FindLengthFromUser(value, GetData()->DataVariables()); } //--------------------------------------------------------------------------------------------------------------------- -void VisToolPointOfIntersectionCircles::setC1Radius(const QString &value) +void VisToolPointOfIntersectionCircles::SetC2Radius(const QString &value) { - m_c1Radius = FindLengthFromUser(value, Visualization::data->DataVariables()); -} - -//--------------------------------------------------------------------------------------------------------------------- -void VisToolPointOfIntersectionCircles::setC2Radius(const QString &value) -{ - m_c2Radius = FindLengthFromUser(value, Visualization::data->DataVariables()); -} - -//--------------------------------------------------------------------------------------------------------------------- -void VisToolPointOfIntersectionCircles::setCrossPoint(const CrossCirclesPoint &value) -{ - m_crossPoint = value; + m_c2Radius = FindLengthFromUser(value, GetData()->DataVariables()); } diff --git a/src/libs/vtools/visualization/line/vistoolpointofintersectioncircles.h b/src/libs/vtools/visualization/line/vistoolpointofintersectioncircles.h index 7dcc9ba9c..89d13ab51 100644 --- a/src/libs/vtools/visualization/line/vistoolpointofintersectioncircles.h +++ b/src/libs/vtools/visualization/line/vistoolpointofintersectioncircles.h @@ -48,19 +48,21 @@ public: ~VisToolPointOfIntersectionCircles() override = default; void RefreshGeometry() override; - void VisualMode(const quint32 &id) override; + void VisualMode(quint32 id) override; - void setObject2Id(const quint32 &value); - void setC1Radius(const QString &value); - void setC2Radius(const QString &value); - void setCrossPoint(const CrossCirclesPoint &value); + void SetCircle1Id(quint32 value); + void SetCircle2Id(quint32 value); + void SetC1Radius(const QString &value); + void SetC2Radius(const QString &value); + void SetCrossPoint(CrossCirclesPoint value); auto type() const -> int override {return Type;} enum {Type = UserType + static_cast(Vis::ToolPointOfIntersectionCircles)}; private: // cppcheck-suppress unknownMacro Q_DISABLE_COPY_MOVE(VisToolPointOfIntersectionCircles) // NOLINT - quint32 m_object2Id{NULL_ID}; + quint32 m_circle1Id{NULL_ID}; + quint32 m_circle2Id{NULL_ID}; qreal m_c1Radius{0}; qreal m_c2Radius{0}; CrossCirclesPoint m_crossPoint{CrossCirclesPoint::FirstPoint}; @@ -71,4 +73,22 @@ private: VScaledEllipse *m_c2Path{nullptr}; }; +//--------------------------------------------------------------------------------------------------------------------- +inline void VisToolPointOfIntersectionCircles::SetCircle1Id(quint32 value) +{ + m_circle1Id = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline void VisToolPointOfIntersectionCircles::SetCircle2Id(quint32 value) +{ + m_circle2Id = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline void VisToolPointOfIntersectionCircles::SetCrossPoint(CrossCirclesPoint value) +{ + m_crossPoint = value; +} + #endif // VISTOOLPOINTOFINTERSECTIONCIRCLES_H diff --git a/src/libs/vtools/visualization/line/vistoolshoulderpoint.cpp b/src/libs/vtools/visualization/line/vistoolshoulderpoint.cpp index 12140dafb..1d8347dce 100644 --- a/src/libs/vtools/visualization/line/vistoolshoulderpoint.cpp +++ b/src/libs/vtools/visualization/line/vistoolshoulderpoint.cpp @@ -47,46 +47,48 @@ VisToolShoulderPoint::VisToolShoulderPoint(const VContainer *data, QGraphicsItem *parent) :VisLine(data, parent) { - m_line1P1 = InitPoint(supportColor, this); - m_line1P2 = InitPoint(supportColor, this); //-V656 - m_line1 = InitItem(supportColor, this); + m_line1P1 = InitPoint(Color(VColor::SupportColor), this); + m_line1P2 = InitPoint(Color(VColor::SupportColor), this); //-V656 + m_line1 = InitItem(Color(VColor::SupportColor), this); - m_line2P2 = InitPoint(supportColor, this); - m_line2 = InitItem(supportColor, this); - m_line3 = InitItem(supportColor, this); //-V656 + m_line2P2 = InitPoint(Color(VColor::SupportColor), this); + m_line2 = InitItem(Color(VColor::SupportColor), this); + m_line3 = InitItem(Color(VColor::SupportColor), this); //-V656 - m_point = InitPoint(mainColor, this); + m_point = InitPoint(Color(VColor::MainColor), this); } //--------------------------------------------------------------------------------------------------------------------- void VisToolShoulderPoint::RefreshGeometry() { - if (object1Id > NULL_ID) + if (m_point3Id > NULL_ID) { - const QSharedPointer first = Visualization::data->GeometricObject(object1Id); - DrawPoint(m_line1P1, static_cast(*first), supportColor); + const QSharedPointer first = GetData()->GeometricObject(m_point3Id); + DrawPoint(m_line1P1, static_cast(*first), Color(VColor::SupportColor)); if (m_lineP1Id <= NULL_ID) { - DrawLine(m_line1, QLineF(static_cast(*first), Visualization::scenePos), supportColor); + DrawLine(m_line1, QLineF(static_cast(*first), ScenePos()), Color(VColor::SupportColor)); } else { - const QSharedPointer second = Visualization::data->GeometricObject(m_lineP1Id); - DrawPoint(m_line1P2, static_cast(*second), supportColor); + const QSharedPointer second = GetData()->GeometricObject(m_lineP1Id); + DrawPoint(m_line1P2, static_cast(*second), Color(VColor::SupportColor)); - DrawLine(m_line1, QLineF(static_cast(*first), static_cast(*second)), supportColor); + DrawLine(m_line1, QLineF(static_cast(*first), static_cast(*second)), + Color(VColor::SupportColor)); if (m_lineP2Id <= NULL_ID) { - DrawLine(m_line2, QLineF(static_cast(*second), Visualization::scenePos), supportColor); + DrawLine(m_line2, QLineF(static_cast(*second), ScenePos()), Color(VColor::SupportColor)); } else { - const QSharedPointer third = Visualization::data->GeometricObject(m_lineP2Id); - DrawPoint(m_line2P2, static_cast(*third), supportColor); + const QSharedPointer third = GetData()->GeometricObject(m_lineP2Id); + DrawPoint(m_line2P2, static_cast(*third), Color(VColor::SupportColor)); - DrawLine(m_line2, QLineF(static_cast(*second), static_cast(*third)), supportColor); + DrawLine(m_line2, QLineF(static_cast(*second), static_cast(*third)), + Color(VColor::SupportColor)); if (not qFuzzyIsNull(m_length)) { @@ -94,30 +96,32 @@ void VisToolShoulderPoint::RefreshGeometry() static_cast(*third), static_cast(*first), m_length); QLineF mainLine = QLineF(static_cast(*second), fPoint); - DrawLine(this, mainLine, mainColor, lineStyle); + DrawLine(this, mainLine, Color(VColor::MainColor), LineStyle()); - DrawPoint(m_point, mainLine.p2(), mainColor); - DrawLine(m_line3, QLineF(static_cast(*first), mainLine.p2()), supportColor, Qt::DashLine); + DrawPoint(m_point, mainLine.p2(), Color(VColor::MainColor)); + DrawLine(m_line3, QLineF(static_cast(*first), mainLine.p2()), Color(VColor::SupportColor), + Qt::DashLine); } - else if (mode == Mode::Creation) + else if (GetMode() == Mode::Creation) { - QLineF cursorLine (static_cast(*first), Visualization::scenePos); + QLineF cursorLine (static_cast(*first), ScenePos()); qreal len = cursorLine.length(); QPointF fPoint = VToolShoulderPoint::FindPoint(static_cast(*second), static_cast(*third), static_cast(*first), len); QLineF mainLine = QLineF(static_cast(*second), fPoint); - DrawLine(this, mainLine, mainColor, lineStyle); + DrawLine(this, mainLine, Color(VColor::MainColor), LineStyle()); - DrawPoint(m_point, mainLine.p2(), mainColor); - DrawLine(m_line3, QLineF(static_cast(*first), mainLine.p2()), supportColor, Qt::DashLine); + DrawPoint(m_point, mainLine.p2(), Color(VColor::MainColor)); + DrawLine(m_line3, QLineF(static_cast(*first), mainLine.p2()), Color(VColor::SupportColor), + Qt::DashLine); const QString prefix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true); - Visualization::toolTip = tr("Length = %1%2; " - "Mouse click - finish selecting the length, " - "%3 - skip") - .arg(NumberToUser(len), prefix, VModifierKey::EnterKey()); + SetToolTip(tr("Length = %1%2; " + "Mouse click - finish selecting the length, " + "%3 - skip") + .arg(NumberToUser(len), prefix, VModifierKey::EnterKey())); } else { @@ -126,7 +130,7 @@ void VisToolShoulderPoint::RefreshGeometry() QLineF mainLine = VGObject::BuildLine(static_cast(*second), QLineF(static_cast(*second), endRay).length(), angle); - DrawLine(this, mainLine, mainColor, lineStyle); + DrawLine(this, mainLine, Color(VColor::MainColor), LineStyle()); } } } @@ -134,19 +138,14 @@ void VisToolShoulderPoint::RefreshGeometry() } //--------------------------------------------------------------------------------------------------------------------- -void VisToolShoulderPoint::setLineP1Id(const quint32 &value) +void VisToolShoulderPoint::VisualMode(quint32 id) { - m_lineP1Id = value; + m_point3Id = id; + StartVisualMode(); } //--------------------------------------------------------------------------------------------------------------------- -void VisToolShoulderPoint::setLineP2Id(const quint32 &value) +void VisToolShoulderPoint::SetLength(const QString &expression) { - m_lineP2Id = value; -} - -//--------------------------------------------------------------------------------------------------------------------- -void VisToolShoulderPoint::setLength(const QString &expression) -{ - m_length = FindLengthFromUser(expression, Visualization::data->DataVariables()); + m_length = FindLengthFromUser(expression, GetData()->DataVariables()); } diff --git a/src/libs/vtools/visualization/line/vistoolshoulderpoint.h b/src/libs/vtools/visualization/line/vistoolshoulderpoint.h index da4ddb4b3..48a2e2811 100644 --- a/src/libs/vtools/visualization/line/vistoolshoulderpoint.h +++ b/src/libs/vtools/visualization/line/vistoolshoulderpoint.h @@ -47,9 +47,13 @@ public: ~VisToolShoulderPoint() override = default; void RefreshGeometry() override; - void setLineP1Id(const quint32 &value); - void setLineP2Id(const quint32 &value); - void setLength(const QString &expression); + void VisualMode(quint32 id) override; + + void SetPoint3Id(quint32 newPoint3Id); + void SetLineP1Id(quint32 value); + void SetLineP2Id(quint32 value); + void SetLength(const QString &expression); + auto type() const -> int override {return Type;} enum {Type = UserType + static_cast(Vis::ToolShoulderPoint)}; private: @@ -65,6 +69,25 @@ private: VScaledLine *m_line2{nullptr}; VScaledLine *m_line3{nullptr}; qreal m_length{0}; + quint32 m_point3Id{NULL_ID}; }; +//--------------------------------------------------------------------------------------------------------------------- +inline void VisToolShoulderPoint::SetPoint3Id(quint32 newPoint3Id) +{ + m_point3Id = newPoint3Id; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline void VisToolShoulderPoint::SetLineP1Id(quint32 value) +{ + m_lineP1Id = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline void VisToolShoulderPoint::SetLineP2Id(quint32 value) +{ + m_lineP2Id = value; +} + #endif // VISTOOLSHOULDERPOINT_H diff --git a/src/libs/vtools/visualization/line/vistoolspecialpoint.cpp b/src/libs/vtools/visualization/line/vistoolspecialpoint.cpp index 36c283a52..4e964bf01 100644 --- a/src/libs/vtools/visualization/line/vistoolspecialpoint.cpp +++ b/src/libs/vtools/visualization/line/vistoolspecialpoint.cpp @@ -33,14 +33,13 @@ //--------------------------------------------------------------------------------------------------------------------- VisToolSpecialPoint::VisToolSpecialPoint(const VContainer *data, QGraphicsItem *parent) - : VisLine(data, parent), - m_point() + : VisLine(data, parent) { - this->mainColor = Qt::red; + SetMainColor(Qt::red); this->setZValue(2);// Show on top real tool this->setPen(QPen(Qt::NoPen)); - m_point = new VSimplePoint(NULL_ID, mainColor); + m_point = new VSimplePoint(NULL_ID, Color(VColor::MainColor)); m_point->SetPointHighlight(true); m_point->setParentItem(this); m_point->SetVisualizationMode(true); @@ -50,21 +49,25 @@ VisToolSpecialPoint::VisToolSpecialPoint(const VContainer *data, QGraphicsItem * //--------------------------------------------------------------------------------------------------------------------- VisToolSpecialPoint::~VisToolSpecialPoint() { - if (not m_point.isNull()) - { - delete m_point; - } + delete m_point; } //--------------------------------------------------------------------------------------------------------------------- void VisToolSpecialPoint::RefreshGeometry() { - if (object1Id > NULL_ID) + if (m_pointId > NULL_ID) { - // Keep first, you can hide only objects those have shape - m_point->RefreshPointGeometry(*Visualization::data->GeometricObject(object1Id)); - m_point->SetOnlyPoint(mode == Mode::Creation); + // Keep first, you can hide only objects which have shape + m_point->RefreshPointGeometry(*GetData()->GeometricObject(m_pointId)); + m_point->SetOnlyPoint(GetMode() == Mode::Creation); m_point->setVisible(true); } } +//--------------------------------------------------------------------------------------------------------------------- +void VisToolSpecialPoint::VisualMode(quint32 id) +{ + m_pointId = id; + StartVisualMode(); +} + diff --git a/src/libs/vtools/visualization/line/vistoolspecialpoint.h b/src/libs/vtools/visualization/line/vistoolspecialpoint.h index 1df45a1a5..bbe429475 100644 --- a/src/libs/vtools/visualization/line/vistoolspecialpoint.h +++ b/src/libs/vtools/visualization/line/vistoolspecialpoint.h @@ -38,15 +38,26 @@ class VisToolSpecialPoint : public VisLine Q_OBJECT // NOLINT public: explicit VisToolSpecialPoint(const VContainer *data, QGraphicsItem *parent = nullptr); - virtual ~VisToolSpecialPoint(); + ~VisToolSpecialPoint() override; - virtual void RefreshGeometry() override; - virtual int type() const override {return Type;} - enum { Type = UserType + static_cast(Vis::ToolSpecialPoint)}; + void RefreshGeometry() override; + void VisualMode(quint32 id) override; + + void SetPointId(quint32 newPointId); + + auto type() const -> int override {return Type;} + enum {Type = UserType + static_cast(Vis::ToolSpecialPoint)}; private: // cppcheck-suppress unknownMacro Q_DISABLE_COPY_MOVE(VisToolSpecialPoint) // NOLINT - QPointer m_point; + QPointer m_point{}; + quint32 m_pointId{NULL_ID}; }; +//--------------------------------------------------------------------------------------------------------------------- +inline void VisToolSpecialPoint::SetPointId(quint32 newPointId) +{ + m_pointId = newPointId; +} + #endif // VISTOOLSPECIALPOINT_H diff --git a/src/libs/vtools/visualization/line/vistooltriangle.cpp b/src/libs/vtools/visualization/line/vistooltriangle.cpp index cb7d4a83e..7f538efbf 100644 --- a/src/libs/vtools/visualization/line/vistooltriangle.cpp +++ b/src/libs/vtools/visualization/line/vistooltriangle.cpp @@ -35,85 +35,85 @@ #include #include #include +#include #include "../../tools/drawTools/toolpoint/toolsinglepoint/vtooltriangle.h" -#include "../ifc/ifcdef.h" #include "../vgeometry/vpointf.h" -#include "../vmisc/vabstractapplication.h" -#include "../vmisc/vmath.h" #include "../vpatterndb/vcontainer.h" #include "../visualization.h" #include "visline.h" //--------------------------------------------------------------------------------------------------------------------- VisToolTriangle::VisToolTriangle(const VContainer *data, QGraphicsItem *parent) - :VisLine(data, parent), object2Id(NULL_ID), hypotenuseP1Id(NULL_ID), hypotenuseP2Id(NULL_ID), point(nullptr), - axisP1(nullptr), axisP2(nullptr), axis(nullptr), hypotenuseP1(nullptr), hypotenuseP2(nullptr), foot1(nullptr), - foot2(nullptr) + :VisLine(data, parent) { - axisP1 = InitPoint(supportColor, this); - axisP2 = InitPoint(supportColor, this); - axis = InitItem(supportColor, this); - hypotenuseP1 = InitPoint(supportColor, this); - hypotenuseP2 = InitPoint(supportColor, this); - foot1 = InitItem(supportColor, this); - foot2 = InitItem(supportColor, this); //-V656 + m_axisP1 = InitPoint(Color(VColor::SupportColor), this); + m_axisP2 = InitPoint(Color(VColor::SupportColor), this); + m_axis = InitItem(Color(VColor::SupportColor), this); + m_hypotenuseP1 = InitPoint(Color(VColor::SupportColor), this); + m_hypotenuseP2 = InitPoint(Color(VColor::SupportColor), this); + m_foot1 = InitItem(Color(VColor::SupportColor), this); + m_foot2 = InitItem(Color(VColor::SupportColor), this); //-V656 - point = InitPoint(mainColor, this); + m_point = InitPoint(Color(VColor::MainColor), this); } //--------------------------------------------------------------------------------------------------------------------- void VisToolTriangle::RefreshGeometry() { - if (object1Id > NULL_ID) + if (m_object1Id > NULL_ID) { - const QSharedPointer first = Visualization::data->GeometricObject(object1Id); - DrawPoint(axisP1, static_cast(*first), supportColor); + const QSharedPointer first = GetData()->GeometricObject(m_object1Id); + DrawPoint(m_axisP1, static_cast(*first), Color(VColor::SupportColor)); - if (object2Id <= NULL_ID) + if (m_object2Id <= NULL_ID) { - DrawAimedAxis(axis, QLineF(static_cast(*first), Visualization::scenePos), supportColor); + DrawAimedAxis(m_axis, QLineF(static_cast(*first), ScenePos()), Color(VColor::SupportColor)); } else { - const QSharedPointer second = Visualization::data->GeometricObject(object2Id); - DrawPoint(axisP2, static_cast(*second), supportColor); + const QSharedPointer second = GetData()->GeometricObject(m_object2Id); + DrawPoint(m_axisP2, static_cast(*second), Color(VColor::SupportColor)); - DrawAimedAxis(axis, QLineF(static_cast(*first), static_cast(*second)), supportColor); + DrawAimedAxis(m_axis, QLineF(static_cast(*first), static_cast(*second)), + Color(VColor::SupportColor)); - if (hypotenuseP1Id > NULL_ID) + if (m_hypotenuseP1Id > NULL_ID) { - const QSharedPointer third = Visualization::data->GeometricObject(hypotenuseP1Id); - DrawPoint(hypotenuseP1, static_cast(*third), supportColor); + const QSharedPointer third = GetData()->GeometricObject(m_hypotenuseP1Id); + DrawPoint(m_hypotenuseP1, static_cast(*third), Color(VColor::SupportColor)); - if (hypotenuseP2Id <= NULL_ID) + if (m_hypotenuseP2Id <= NULL_ID) { - DrawLine(this, QLineF(static_cast(*third), Visualization::scenePos), supportColor, + DrawLine(this, QLineF(static_cast(*third), ScenePos()), Color(VColor::SupportColor), Qt::DashLine); QPointF trPoint; VToolTriangle::FindPoint(static_cast(*first), static_cast(*second), - static_cast(*third), Visualization::scenePos, &trPoint); - DrawPoint(point, trPoint, mainColor); + static_cast(*third), ScenePos(), &trPoint); + DrawPoint(m_point, trPoint, Color(VColor::MainColor)); - DrawLine(foot1, QLineF(static_cast(*third), trPoint), supportColor, Qt::DashLine); - DrawLine(foot2, QLineF(Visualization::scenePos, trPoint), supportColor, Qt::DashLine); + DrawLine(m_foot1, QLineF(static_cast(*third), trPoint), Color(VColor::SupportColor), + Qt::DashLine); + DrawLine(m_foot2, QLineF(ScenePos(), trPoint), Color(VColor::SupportColor), Qt::DashLine); } else { - const QSharedPointer forth = Visualization::data->GeometricObject(hypotenuseP2Id); - DrawPoint(hypotenuseP2, static_cast(*forth), supportColor); + const QSharedPointer forth = GetData()->GeometricObject(m_hypotenuseP2Id); + DrawPoint(m_hypotenuseP2, static_cast(*forth), Color(VColor::SupportColor)); - DrawLine(this, QLineF(static_cast(*third), static_cast(*forth)), supportColor, - Qt::DashLine); + DrawLine(this, QLineF(static_cast(*third), static_cast(*forth)), + Color(VColor::SupportColor), Qt::DashLine); QPointF trPoint; VToolTriangle::FindPoint(static_cast(*first), static_cast(*second), static_cast(*third), static_cast(*forth), &trPoint); - DrawPoint(point, trPoint, mainColor); + DrawPoint(m_point, trPoint, Color(VColor::MainColor)); - DrawLine(foot1, QLineF(static_cast(*third), trPoint), supportColor, Qt::DashLine); - DrawLine(foot2, QLineF(static_cast(*forth), trPoint), supportColor, Qt::DashLine); + DrawLine(m_foot1, QLineF(static_cast(*third), trPoint), Color(VColor::SupportColor), + Qt::DashLine); + DrawLine(m_foot2, QLineF(static_cast(*forth), trPoint), Color(VColor::SupportColor), + Qt::DashLine); } } } @@ -121,21 +121,10 @@ void VisToolTriangle::RefreshGeometry() } //--------------------------------------------------------------------------------------------------------------------- -void VisToolTriangle::setObject2Id(const quint32 &value) +void VisToolTriangle::VisualMode(quint32 id) { - object2Id = value; -} - -//--------------------------------------------------------------------------------------------------------------------- -void VisToolTriangle::setHypotenuseP1Id(const quint32 &value) -{ - hypotenuseP1Id = value; -} - -//--------------------------------------------------------------------------------------------------------------------- -void VisToolTriangle::setHypotenuseP2Id(const quint32 &value) -{ - hypotenuseP2Id = value; + m_object1Id = id; + StartVisualMode(); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/visualization/line/vistooltriangle.h b/src/libs/vtools/visualization/line/vistooltriangle.h index 5d890e45e..94bf1f2ea 100644 --- a/src/libs/vtools/visualization/line/vistooltriangle.h +++ b/src/libs/vtools/visualization/line/vistooltriangle.h @@ -47,34 +47,61 @@ class VisToolTriangle : public VisLine Q_OBJECT // NOLINT public: explicit VisToolTriangle(const VContainer *data, QGraphicsItem *parent = nullptr); - virtual ~VisToolTriangle() = default; + ~VisToolTriangle() override = default; - virtual void RefreshGeometry() override; + void RefreshGeometry() override; + void VisualMode(quint32 id) override; - void setObject2Id(const quint32 &value); - void setHypotenuseP1Id(const quint32 &value); - void setHypotenuseP2Id(const quint32 &value); + void SetObject1Id(quint32 value); + void SetObject2Id(quint32 value); + void SetHypotenuseP1Id(quint32 value); + void SetHypotenuseP2Id(quint32 value); - virtual int type() const override {return Type;} - enum { Type = UserType + static_cast(Vis::ToolTriangle)}; + auto type() const -> int override {return Type;} + enum {Type = UserType + static_cast(Vis::ToolTriangle)}; private: // cppcheck-suppress unknownMacro Q_DISABLE_COPY_MOVE(VisToolTriangle) // NOLINT - quint32 object2Id;//axis second point - quint32 hypotenuseP1Id; - quint32 hypotenuseP2Id; - VScaledEllipse *point; - VScaledEllipse *axisP1; - VScaledEllipse *axisP2; - VCurvePathItem *axis; - VScaledEllipse *hypotenuseP1; - VScaledEllipse *hypotenuseP2; - VScaledLine *foot1; - VScaledLine *foot2; + quint32 m_object1Id{NULL_ID};//axis first point + quint32 m_object2Id{NULL_ID};//axis second point + quint32 m_hypotenuseP1Id{NULL_ID}; + quint32 m_hypotenuseP2Id{NULL_ID}; + VScaledEllipse *m_point{nullptr}; + VScaledEllipse *m_axisP1{nullptr}; + VScaledEllipse *m_axisP2{nullptr}; + VCurvePathItem *m_axis{nullptr}; + VScaledEllipse *m_hypotenuseP1{nullptr}; + VScaledEllipse *m_hypotenuseP2{nullptr}; + VScaledLine *m_foot1{nullptr}; + VScaledLine *m_foot2{nullptr}; - void DrawAimedAxis(VCurvePathItem *item, const QLineF &line, const QColor &color, - Qt::PenStyle style = Qt::SolidLine); - void DrawArrow(const QLineF &axis, QPainterPath &path, const qreal &arrow_size); + static void DrawAimedAxis(VCurvePathItem *item, const QLineF &line, const QColor &color, + Qt::PenStyle style = Qt::SolidLine); + static void DrawArrow(const QLineF &axis, QPainterPath &path, const qreal &arrow_size); }; +//--------------------------------------------------------------------------------------------------------------------- +inline void VisToolTriangle::SetObject1Id(quint32 value) +{ + m_object1Id = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline void VisToolTriangle::SetObject2Id(quint32 value) +{ + m_object2Id = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline void VisToolTriangle::SetHypotenuseP1Id(quint32 value) +{ + m_hypotenuseP1Id = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline void VisToolTriangle::SetHypotenuseP2Id(quint32 value) +{ + m_hypotenuseP2Id = value; +} + #endif // VISTOOLTRIANGLE_H diff --git a/src/libs/vtools/visualization/line/vistooltruedarts.cpp b/src/libs/vtools/visualization/line/vistooltruedarts.cpp index 681588557..df48395d2 100644 --- a/src/libs/vtools/visualization/line/vistooltruedarts.cpp +++ b/src/libs/vtools/visualization/line/vistooltruedarts.cpp @@ -36,7 +36,6 @@ #include #include "../../tools/drawTools/toolpoint/tooldoublepoint/vtooltruedarts.h" -#include "../ifc/ifcdef.h" #include "../vgeometry/vpointf.h" #include "../vpatterndb/vcontainer.h" #include "../visualization.h" @@ -44,81 +43,69 @@ //--------------------------------------------------------------------------------------------------------------------- VisToolTrueDarts::VisToolTrueDarts(const VContainer *data, QGraphicsItem *parent) - :VisLine(data, parent), - baseLineP2Id(NULL_ID), - dartP1Id(NULL_ID), - dartP2Id(NULL_ID), - dartP3Id(NULL_ID), - point1(nullptr), - point2(nullptr), - baseLineP1(nullptr), - baseLineP2(nullptr), - dartP1(nullptr), - dartP2(nullptr), - dartP3(nullptr), - lineblP1P1(nullptr), - lineblP2P2(nullptr), - p1d2(nullptr), - d2p2(nullptr) + :VisLine(data, parent) { - baseLineP1 = InitPoint(supportColor, this); - baseLineP2 = InitPoint(supportColor, this); - dartP1 = InitPoint(supportColor, this); - dartP2 = InitPoint(supportColor, this); - dartP3 = InitPoint(supportColor, this); + m_baseLineP1 = InitPoint(Color(VColor::SupportColor), this); + m_baseLineP2 = InitPoint(Color(VColor::SupportColor), this); + m_dartP1 = InitPoint(Color(VColor::SupportColor), this); + m_dartP2 = InitPoint(Color(VColor::SupportColor), this); + m_dartP3 = InitPoint(Color(VColor::SupportColor), this); - lineblP1P1 = InitItem(supportColor, this); - lineblP2P2 = InitItem(supportColor, this); - p1d2 = InitItem(supportColor, this); - d2p2 = InitItem(supportColor, this); + m_lineblP1P1 = InitItem(Color(VColor::SupportColor), this); + m_lineblP2P2 = InitItem(Color(VColor::SupportColor), this); + m_p1d2 = InitItem(Color(VColor::SupportColor), this); + m_d2p2 = InitItem(Color(VColor::SupportColor), this); - point1 = InitPoint(mainColor, this); - point2 = InitPoint(mainColor, this); //-V656 + m_point1 = InitPoint(Color(VColor::MainColor), this); + m_point2 = InitPoint(Color(VColor::MainColor), this); //-V656 } //--------------------------------------------------------------------------------------------------------------------- void VisToolTrueDarts::RefreshGeometry() { - if (object1Id > NULL_ID) + if (m_baseLineP1Id > NULL_ID) { - const QSharedPointer blP1 = Visualization::data->GeometricObject(object1Id); - DrawPoint(baseLineP1, static_cast(*blP1), supportColor); + const QSharedPointer blP1 = GetData()->GeometricObject(m_baseLineP1Id); + DrawPoint(m_baseLineP1, static_cast(*blP1), Color(VColor::SupportColor)); - if (baseLineP2Id <= NULL_ID) + if (m_baseLineP2Id <= NULL_ID) { - DrawLine(this, QLineF(static_cast(*blP1), Visualization::scenePos), supportColor, Qt::DashLine); + DrawLine(this, QLineF(static_cast(*blP1), ScenePos()), Color(VColor::SupportColor), Qt::DashLine); } else { - const QSharedPointer blP2 = Visualization::data->GeometricObject(baseLineP2Id); - DrawPoint(baseLineP2, static_cast(*blP2), supportColor); - DrawLine(this, QLineF(static_cast(*blP1), static_cast(*blP2)), supportColor, - Qt::DashLine); + const QSharedPointer blP2 = GetData()->GeometricObject(m_baseLineP2Id); + DrawPoint(m_baseLineP2, static_cast(*blP2), Color(VColor::SupportColor)); + DrawLine(this, QLineF(static_cast(*blP1), static_cast(*blP2)), + Color(VColor::SupportColor), Qt::DashLine); - if (dartP1Id > NULL_ID) + if (m_dartP1Id > NULL_ID) { - const QSharedPointer d1 = Visualization::data->GeometricObject(dartP1Id); - DrawPoint(dartP1, static_cast(*d1), supportColor); + const QSharedPointer d1 = GetData()->GeometricObject(m_dartP1Id); + DrawPoint(m_dartP1, static_cast(*d1), Color(VColor::SupportColor)); - if (dartP2Id <= NULL_ID) + if (m_dartP2Id <= NULL_ID) { - DrawLine(p1d2, QLineF(static_cast(*d1), Visualization::scenePos), supportColor); + DrawLine(m_p1d2, QLineF(static_cast(*d1), ScenePos()), + Color(VColor::SupportColor)); } else { - const QSharedPointer d2 = Visualization::data->GeometricObject(dartP2Id); - DrawPoint(dartP2, static_cast(*d2), supportColor); - DrawLine(p1d2, QLineF(static_cast(*d1), static_cast(*d2)), supportColor); + const QSharedPointer d2 = GetData()->GeometricObject(m_dartP2Id); + DrawPoint(m_dartP2, static_cast(*d2), Color(VColor::SupportColor)); + DrawLine(m_p1d2, QLineF(static_cast(*d1), static_cast(*d2)), + Color(VColor::SupportColor)); - if (dartP3Id <= NULL_ID) + if (m_dartP3Id <= NULL_ID) { - DrawLine(d2p2, QLineF(static_cast(*d2), Visualization::scenePos), supportColor); + DrawLine(m_d2p2, QLineF(static_cast(*d2), ScenePos()), Color(VColor::SupportColor)); } else { - const QSharedPointer d3 = Visualization::data->GeometricObject(dartP3Id); - DrawPoint(dartP3, static_cast(*d3), supportColor); - DrawLine(d2p2, QLineF(static_cast(*d2), static_cast(*d3)), supportColor); + const QSharedPointer d3 = GetData()->GeometricObject(m_dartP3Id); + DrawPoint(m_dartP3, static_cast(*d3), Color(VColor::SupportColor)); + DrawLine(m_d2p2, QLineF(static_cast(*d2), static_cast(*d3)), + Color(VColor::SupportColor)); QPointF p1; QPointF p2; @@ -126,13 +113,13 @@ void VisToolTrueDarts::RefreshGeometry() static_cast(*d1), static_cast(*d2), static_cast(*d3), p1, p2); - DrawLine(lineblP1P1, QLineF(static_cast(*blP1), p1), supportColor); - DrawLine(lineblP2P2, QLineF(static_cast(*blP2), p2), supportColor); - DrawLine(p1d2, QLineF(p1, static_cast(*d2)), supportColor); - DrawLine(d2p2, QLineF(static_cast(*d2), p2), supportColor); + DrawLine(m_lineblP1P1, QLineF(static_cast(*blP1), p1), Color(VColor::SupportColor)); + DrawLine(m_lineblP2P2, QLineF(static_cast(*blP2), p2), Color(VColor::SupportColor)); + DrawLine(m_p1d2, QLineF(p1, static_cast(*d2)), Color(VColor::SupportColor)); + DrawLine(m_d2p2, QLineF(static_cast(*d2), p2), Color(VColor::SupportColor)); - DrawPoint(point1, p1, mainColor); - DrawPoint(point2, p2, mainColor); + DrawPoint(m_point1, p1, Color(VColor::MainColor)); + DrawPoint(m_point2, p2, Color(VColor::MainColor)); } } } @@ -141,25 +128,8 @@ void VisToolTrueDarts::RefreshGeometry() } //--------------------------------------------------------------------------------------------------------------------- -void VisToolTrueDarts::setObject2Id(const quint32 &value) +void VisToolTrueDarts::VisualMode(quint32 id) { - baseLineP2Id = value; -} - -//--------------------------------------------------------------------------------------------------------------------- -void VisToolTrueDarts::setD1PointId(const quint32 &value) -{ - dartP1Id = value; -} - -//--------------------------------------------------------------------------------------------------------------------- -void VisToolTrueDarts::setD2PointId(const quint32 &value) -{ - dartP2Id = value; -} - -//--------------------------------------------------------------------------------------------------------------------- -void VisToolTrueDarts::setD3PointId(const quint32 &value) -{ - dartP3Id = value; + m_baseLineP1Id = id; + StartVisualMode(); } diff --git a/src/libs/vtools/visualization/line/vistooltruedarts.h b/src/libs/vtools/visualization/line/vistooltruedarts.h index ffce3a1cd..d6988d34c 100644 --- a/src/libs/vtools/visualization/line/vistooltruedarts.h +++ b/src/libs/vtools/visualization/line/vistooltruedarts.h @@ -44,37 +44,70 @@ class VisToolTrueDarts :public VisLine Q_OBJECT // NOLINT public: explicit VisToolTrueDarts(const VContainer *data, QGraphicsItem *parent = nullptr); - virtual ~VisToolTrueDarts() = default; + ~VisToolTrueDarts() override = default; - virtual void RefreshGeometry() override; + void RefreshGeometry() override; + void VisualMode(quint32 id) override; - void setObject2Id(const quint32 &value); - void setD1PointId(const quint32 &value); - void setD2PointId(const quint32 &value); - void setD3PointId(const quint32 &value); + void SetBaseLineP1Id(quint32 value); + void SetBaseLineP2Id(quint32 value); + void SetD1PointId(quint32 value); + void SetD2PointId(quint32 value); + void SetD3PointId(quint32 value); - virtual int type() const override {return Type;} - enum { Type = UserType + static_cast(Vis::ToolTrueDarts)}; + auto type() const -> int override {return Type;} + enum {Type = UserType + static_cast(Vis::ToolTrueDarts)}; private: // cppcheck-suppress unknownMacro Q_DISABLE_COPY_MOVE(VisToolTrueDarts) // NOLINT - quint32 baseLineP2Id; - quint32 dartP1Id; - quint32 dartP2Id; - quint32 dartP3Id; + quint32 m_baseLineP1Id{NULL_ID}; + quint32 m_baseLineP2Id{NULL_ID}; + quint32 m_dartP1Id{NULL_ID}; + quint32 m_dartP2Id{NULL_ID}; + quint32 m_dartP3Id{NULL_ID}; - VScaledEllipse *point1; - VScaledEllipse *point2; - VScaledEllipse *baseLineP1; - VScaledEllipse *baseLineP2; - VScaledEllipse *dartP1; - VScaledEllipse *dartP2; - VScaledEllipse *dartP3; + VScaledEllipse *m_point1{nullptr}; + VScaledEllipse *m_point2{nullptr}; + VScaledEllipse *m_baseLineP1{nullptr}; + VScaledEllipse *m_baseLineP2{nullptr}; + VScaledEllipse *m_dartP1{nullptr}; + VScaledEllipse *m_dartP2{nullptr}; + VScaledEllipse *m_dartP3{nullptr}; - VScaledLine *lineblP1P1; - VScaledLine *lineblP2P2; - VScaledLine *p1d2; - VScaledLine *d2p2; + VScaledLine *m_lineblP1P1{nullptr}; + VScaledLine *m_lineblP2P2{nullptr}; + VScaledLine *m_p1d2{nullptr}; + VScaledLine *m_d2p2{nullptr}; }; +//--------------------------------------------------------------------------------------------------------------------- +inline void VisToolTrueDarts::SetBaseLineP1Id(quint32 value) +{ + m_baseLineP1Id = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline void VisToolTrueDarts::SetBaseLineP2Id(quint32 value) +{ + m_baseLineP2Id = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline void VisToolTrueDarts::SetD1PointId(quint32 value) +{ + m_dartP1Id = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline void VisToolTrueDarts::SetD2PointId(quint32 value) +{ + m_dartP2Id = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline void VisToolTrueDarts::SetD3PointId(quint32 value) +{ + m_dartP3Id = value; +} + #endif // VISTOOLTRUEDARTS_H diff --git a/src/libs/vtools/visualization/path/vispath.cpp b/src/libs/vtools/visualization/path/vispath.cpp index 0504aae77..df85a2635 100644 --- a/src/libs/vtools/visualization/path/vispath.cpp +++ b/src/libs/vtools/visualization/path/vispath.cpp @@ -30,8 +30,6 @@ #include -#include "../ifc/ifcdef.h" -#include "../vmisc/vabstractapplication.h" #include "../vpatterndb/vcontainer.h" #include "../visualization.h" #include "../vwidgets/vsimplepoint.h" @@ -39,19 +37,18 @@ //--------------------------------------------------------------------------------------------------------------------- VisPath::VisPath(const VContainer *data, QGraphicsItem *parent) : Visualization(data), - VCurvePathItem(parent), - m_approximationScale(0) + VCurvePathItem(parent) { - this->setZValue(1);// Show on top real tool - InitPen(); + setZValue(1);// Show on top real tool + VisPath::InitPen(); } //--------------------------------------------------------------------------------------------------------------------- void VisPath::InitPen() { QPen visPen = pen(); - visPen.setColor(mainColor); - visPen.setStyle(lineStyle); + visPen.setColor(Color(VColor::MainColor)); + visPen.setStyle(LineStyle()); setPen(visPen); } @@ -63,27 +60,24 @@ void VisPath::AddOnScene() } //--------------------------------------------------------------------------------------------------------------------- -VSimplePoint *VisPath::GetPoint(QVector &points, quint32 i, const QColor &color) +auto VisPath::GetPoint(QVector &points, quint32 i, const QColor &color) -> VSimplePoint * { if (not points.isEmpty() && static_cast(points.size() - 1) >= i) { return points.at(static_cast(i)); } - else - { - VSimplePoint *point = new VSimplePoint(NULL_ID, color); - point->SetPointHighlight(true); - point->setParentItem(this); - point->SetVisualizationMode(true); - points.append(point); - return point; - } - return nullptr; + auto *point = new VSimplePoint(NULL_ID, color); + point->SetPointHighlight(true); + point->setParentItem(this); + point->SetVisualizationMode(true); + points.append(point); + + return point; } //--------------------------------------------------------------------------------------------------------------------- -void VisPath::setApproximationScale(qreal approximationScale) +void VisPath::SetApproximationScale(qreal approximationScale) { m_approximationScale = approximationScale; } diff --git a/src/libs/vtools/visualization/path/vispath.h b/src/libs/vtools/visualization/path/vispath.h index f4b93de66..df85d7518 100644 --- a/src/libs/vtools/visualization/path/vispath.h +++ b/src/libs/vtools/visualization/path/vispath.h @@ -47,21 +47,29 @@ class VisPath : public Visualization, public VCurvePathItem Q_OBJECT // NOLINT public: explicit VisPath(const VContainer *data, QGraphicsItem *parent = nullptr); - virtual ~VisPath() = default; + ~VisPath() override = default; - void setApproximationScale(qreal approximationScale); + void SetApproximationScale(qreal approximationScale); - virtual int type() const override {return Type;} - enum { Type = UserType + static_cast(Vis::Path)}; + auto type() const -> int override {return Type;} + enum {Type = UserType + static_cast(Vis::Path)}; protected: - qreal m_approximationScale; + void InitPen() override; + void AddOnScene() override; - virtual void InitPen() override; - virtual void AddOnScene() override; + auto GetPoint(QVector &points, quint32 i, const QColor &color) -> VSimplePoint *; - VSimplePoint *GetPoint(QVector &points, quint32 i, const QColor &color); + auto ApproximationScale() const -> qreal; private: Q_DISABLE_COPY_MOVE(VisPath) // NOLINT + + qreal m_approximationScale{0}; }; +//--------------------------------------------------------------------------------------------------------------------- +inline auto VisPath::ApproximationScale() const -> qreal +{ + return m_approximationScale; +} + #endif // VISPATH_H diff --git a/src/libs/vtools/visualization/path/vispiecespecialpoints.cpp b/src/libs/vtools/visualization/path/vispiecespecialpoints.cpp index 7c1fcff07..ae0916562 100644 --- a/src/libs/vtools/visualization/path/vispiecespecialpoints.cpp +++ b/src/libs/vtools/visualization/path/vispiecespecialpoints.cpp @@ -33,7 +33,7 @@ namespace { -QPainterPath RectPath(const QRectF &rect) +auto RectPath(const QRectF &rect) -> QPainterPath { QPainterPath path; if (not rect.isNull()) @@ -42,19 +42,15 @@ QPainterPath RectPath(const QRectF &rect) } return path; } -} +} // namespace //--------------------------------------------------------------------------------------------------------------------- VisPieceSpecialPoints::VisPieceSpecialPoints(const VContainer *data, QGraphicsItem *parent) - : VisPath(data, parent), - m_points(), - m_spoints(), - m_showRect(false), - m_placeLabelRect(), - m_rectItem(nullptr), - supportColor2(Qt::darkGreen) + : VisPath(data, parent) { - m_rectItem = InitItem(supportColor2, this); + SetColor(VColor::SupportColor2, Qt::darkGreen); + + m_rectItem = InitItem(Color(VColor::SupportColor2), this); m_rectItem->SetWidth(VAbstractApplication::VApp()->Settings()->WidthHairLine()); } @@ -65,21 +61,28 @@ void VisPieceSpecialPoints::RefreshGeometry() for (int i = 0; i < m_spoints.size(); ++i) { - VSimplePoint *point = GetPoint(static_cast(i), supportColor); + VSimplePoint *point = GetPoint(static_cast(i), Color(VColor::SupportColor)); // Keep first, you can hide only objects those have shape - point->RefreshPointGeometry(*Visualization::data->GeometricObject(m_spoints.at(i))); + point->RefreshPointGeometry(*GetData()->GeometricObject(m_spoints.at(i))); point->SetOnlyPoint(false); point->setVisible(true); if (m_showRect) { - DrawPath(m_rectItem, RectPath(m_placeLabelRect), supportColor2, Qt::SolidLine, Qt::RoundCap); + DrawPath(m_rectItem, RectPath(m_placeLabelRect), Color(VColor::SupportColor2), Qt::SolidLine, Qt::RoundCap); } } } //--------------------------------------------------------------------------------------------------------------------- -VSimplePoint *VisPieceSpecialPoints::GetPoint(quint32 i, const QColor &color) +void VisPieceSpecialPoints::VisualMode(quint32 id) +{ + Q_UNUSED(id) + StartVisualMode(); +} + +//--------------------------------------------------------------------------------------------------------------------- +auto VisPieceSpecialPoints::GetPoint(quint32 i, const QColor &color) -> VSimplePoint * { return VisPath::GetPoint(m_points, i, color); } @@ -87,7 +90,7 @@ VSimplePoint *VisPieceSpecialPoints::GetPoint(quint32 i, const QColor &color) //--------------------------------------------------------------------------------------------------------------------- void VisPieceSpecialPoints::HideAllItems() { - for (auto item : qAsConst(m_points)) + for (auto *item : qAsConst(m_points)) { if (item) { diff --git a/src/libs/vtools/visualization/path/vispiecespecialpoints.h b/src/libs/vtools/visualization/path/vispiecespecialpoints.h index 01ca3e082..a1c80fe66 100644 --- a/src/libs/vtools/visualization/path/vispiecespecialpoints.h +++ b/src/libs/vtools/visualization/path/vispiecespecialpoints.h @@ -37,27 +37,27 @@ class VisPieceSpecialPoints : public VisPath { Q_OBJECT // NOLINT public: - VisPieceSpecialPoints(const VContainer *data, QGraphicsItem *parent = nullptr); - virtual ~VisPieceSpecialPoints() Q_DECL_EQ_DEFAULT; + explicit VisPieceSpecialPoints(const VContainer *data, QGraphicsItem *parent = nullptr); + ~VisPieceSpecialPoints() override = default; - virtual void RefreshGeometry() override; + void RefreshGeometry() override; + void VisualMode(quint32 id = NULL_ID) override; void SetPoints(const QVector &pins); void SetShowRect(bool show); void SetRect(const QRectF &rect); - virtual int type() const override {return Type;} - enum { Type = UserType + static_cast(Vis::PieceSpecialPoints)}; + auto type() const -> int override {return Type;} + enum {Type = UserType + static_cast(Vis::PieceSpecialPoints)}; private: Q_DISABLE_COPY_MOVE(VisPieceSpecialPoints) // NOLINT - QVector m_points; - QVector m_spoints; - bool m_showRect; - QRectF m_placeLabelRect; - VCurvePathItem *m_rectItem; - QColor supportColor2; + QVector m_points{}; + QVector m_spoints{}; + bool m_showRect{false}; + QRectF m_placeLabelRect{}; + VCurvePathItem *m_rectItem{nullptr}; - VSimplePoint *GetPoint(quint32 i, const QColor &color); + auto GetPoint(quint32 i, const QColor &color) -> VSimplePoint *; void HideAllItems(); }; diff --git a/src/libs/vtools/visualization/path/vistoolarc.cpp b/src/libs/vtools/visualization/path/vistoolarc.cpp index 1ff86cef9..66d008fce 100644 --- a/src/libs/vtools/visualization/path/vistoolarc.cpp +++ b/src/libs/vtools/visualization/path/vistoolarc.cpp @@ -51,23 +51,23 @@ VisToolArc::VisToolArc(const VContainer *data, QGraphicsItem *parent) :VisPath(data, parent) { - m_arcCenter = InitPoint(mainColor, this); - m_f1Point = InitPoint(supportColor, this); + m_arcCenter = InitPoint(Color(VColor::MainColor), this); + m_f1Point = InitPoint(Color(VColor::SupportColor), this); } //--------------------------------------------------------------------------------------------------------------------- void VisToolArc::RefreshGeometry() { - if (object1Id > NULL_ID) + if (m_centerId > NULL_ID) { m_f1Point->setVisible(false); - const QSharedPointer first = Visualization::data->GeometricObject(object1Id); - DrawPoint(m_arcCenter, static_cast(*first), supportColor); + const QSharedPointer first = GetData()->GeometricObject(m_centerId); + DrawPoint(m_arcCenter, static_cast(*first), Color(VColor::SupportColor)); - if (mode == Mode::Creation) + if (GetMode() == Mode::Creation) { - QLineF r = QLineF(static_cast(*first), Visualization::scenePos); + QLineF r = QLineF(static_cast(*first), ScenePos()); auto Angle = [r]() { @@ -86,51 +86,53 @@ void VisToolArc::RefreshGeometry() if (qFuzzyIsNull(m_radius)) { VArc arc = VArc (*first, r.length(), r.angle(), r.angle()); - arc.SetApproximationScale(m_approximationScale); - DrawPath(this, arc.GetPath(), QVector(), supportColor, Qt::DashLine, Qt::RoundCap); + arc.SetApproximationScale(ApproximationScale()); + DrawPath(this, arc.GetPath(), QVector(), Color(VColor::SupportColor), Qt::DashLine, + Qt::RoundCap); - Visualization::toolTip = tr("Arc: radius = %1%2; " - "Mouse click - finish selecting the radius, " - "%3 - skip") - .arg(NumberToUser(r.length()), prefix, VModifierKey::EnterKey()); + SetToolTip(tr("Arc: radius = %1%2; " + "Mouse click - finish selecting the radius, " + "%3 - skip").arg(NumberToUser(r.length()), prefix, VModifierKey::EnterKey())); } else if (m_f1 < 0) { qreal f1Angle = Angle(); VArc arc = VArc (*first, m_radius, f1Angle, f1Angle); - arc.SetApproximationScale(m_approximationScale); - DrawPath(this, arc.GetPath(), QVector(), supportColor, Qt::DashLine, Qt::RoundCap); + arc.SetApproximationScale(ApproximationScale()); + DrawPath(this, arc.GetPath(), QVector(), Color(VColor::SupportColor), Qt::DashLine, + Qt::RoundCap); QLineF f1Line = r; f1Line.setLength(m_radius); f1Line.setAngle(f1Angle); - DrawPoint(m_f1Point, f1Line.p2(), supportColor); + DrawPoint(m_f1Point, f1Line.p2(), Color(VColor::SupportColor)); - Visualization::toolTip = tr("Arc: radius = %1%2, first angle = %3°; " - "Mouse click - finish selecting the first angle, " - "%4 - sticking angle, " - "%5 - skip") - .arg(NumberToUser(m_radius), prefix) - .arg(f1Angle) - .arg(VModifierKey::Shift(), VModifierKey::EnterKey()); + SetToolTip(tr("Arc: radius = %1%2, first angle = %3°; " + "Mouse click - finish selecting the first angle, " + "%4 - sticking angle, " + "%5 - skip") + .arg(NumberToUser(m_radius), prefix) + .arg(f1Angle) + .arg(VModifierKey::Shift(), VModifierKey::EnterKey())); } else if (m_f1 >= 0) { qreal f2Angle = StickyEnd(Angle()); VArc arc = VArc (*first, m_radius, m_f1, f2Angle); - arc.SetApproximationScale(m_approximationScale); - DrawPath(this, arc.GetPath(), arc.DirectionArrows(), mainColor, lineStyle, Qt::RoundCap); + arc.SetApproximationScale(ApproximationScale()); + DrawPath(this, arc.GetPath(), arc.DirectionArrows(), Color(VColor::MainColor), LineStyle(), + Qt::RoundCap); - Visualization::toolTip = tr("Arc: radius = %1%2, first angle = %3°, second angle = %4°; " - "Mouse click - finish creating, " - "%5 - sticking angle, " - "%6 - sticking end, " - "%7 - skip") - .arg(NumberToUser(m_radius), prefix) - .arg(m_f1) - .arg(f2Angle) - .arg(VModifierKey::Shift(), VModifierKey::Control(), VModifierKey::EnterKey()); + SetToolTip(tr("Arc: radius = %1%2, first angle = %3°, second angle = %4°; " + "Mouse click - finish creating, " + "%5 - sticking angle, " + "%6 - sticking end, " + "%7 - skip") + .arg(NumberToUser(m_radius), prefix) + .arg(m_f1) + .arg(f2Angle) + .arg(VModifierKey::Shift(), VModifierKey::Control(), VModifierKey::EnterKey())); } } else @@ -138,33 +140,42 @@ void VisToolArc::RefreshGeometry() if (not qFuzzyIsNull(m_radius) && m_f1 >= 0 && m_f2 >= 0) { VArc arc = VArc (*first, m_radius, m_f1, m_f2); - arc.SetApproximationScale(m_approximationScale); - DrawPath(this, arc.GetPath(), arc.DirectionArrows(), mainColor, lineStyle, Qt::RoundCap); + arc.SetApproximationScale(ApproximationScale()); + DrawPath(this, arc.GetPath(), arc.DirectionArrows(), Color(VColor::MainColor), LineStyle(), + Qt::RoundCap); } else { - DrawPath(this, QPainterPath(), QVector(), mainColor, lineStyle, Qt::RoundCap); + DrawPath(this, QPainterPath(), QVector(), Color(VColor::MainColor), LineStyle(), + Qt::RoundCap); } } } } //--------------------------------------------------------------------------------------------------------------------- -void VisToolArc::setRadius(const QString &expression) +void VisToolArc::SetRadius(const QString &expression) { - m_radius = FindLengthFromUser(expression, Visualization::data->DataVariables()); + m_radius = FindLengthFromUser(expression, GetData()->DataVariables()); } //--------------------------------------------------------------------------------------------------------------------- -void VisToolArc::setF1(const QString &expression) +void VisToolArc::SetF1(const QString &expression) { - m_f1 = FindValFromUser(expression, Visualization::data->DataVariables()); + m_f1 = FindValFromUser(expression, GetData()->DataVariables()); } //--------------------------------------------------------------------------------------------------------------------- -void VisToolArc::setF2(const QString &expression) +void VisToolArc::SetF2(const QString &expression) { - m_f2 = FindValFromUser(expression, Visualization::data->DataVariables()); + m_f2 = FindValFromUser(expression, GetData()->DataVariables()); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VisToolArc::VisualMode(quint32 id) +{ + m_centerId = id; + StartVisualMode(); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/visualization/path/vistoolarc.h b/src/libs/vtools/visualization/path/vistoolarc.h index bb4bfe86a..9a40ba556 100644 --- a/src/libs/vtools/visualization/path/vistoolarc.h +++ b/src/libs/vtools/visualization/path/vistoolarc.h @@ -48,14 +48,19 @@ public: ~VisToolArc() override =default; void RefreshGeometry() override; - void setRadius(const QString &expression); - void setF1(const QString &expression); - void setF2(const QString &expression); + void VisualMode(quint32 id) override; + + void SetCenterId(quint32 newCenterId); + void SetRadius(const QString &expression); + void SetF1(const QString &expression); + void SetF2(const QString &expression); + auto type() const -> int override {return Type;} enum {Type = UserType + static_cast(Vis::ToolArc)}; static auto CorrectAngle(qreal angle) -> qreal; auto StickyEnd(qreal angle) const -> qreal; + private: Q_DISABLE_COPY_MOVE(VisToolArc) // NOLINT VScaledEllipse *m_arcCenter{nullptr}; @@ -63,6 +68,13 @@ private: qreal m_radius{0}; qreal m_f1{-1}; qreal m_f2{-1}; + quint32 m_centerId{NULL_ID}; }; +//--------------------------------------------------------------------------------------------------------------------- +inline void VisToolArc::SetCenterId(quint32 newCenterId) +{ + m_centerId = newCenterId; +} + #endif // VISTOOLARC_H diff --git a/src/libs/vtools/visualization/path/vistoolarcwithlength.cpp b/src/libs/vtools/visualization/path/vistoolarcwithlength.cpp index 15f8e8d09..322fd9181 100644 --- a/src/libs/vtools/visualization/path/vistoolarcwithlength.cpp +++ b/src/libs/vtools/visualization/path/vistoolarcwithlength.cpp @@ -48,23 +48,23 @@ VisToolArcWithLength::VisToolArcWithLength(const VContainer *data, QGraphicsItem *parent) :VisPath(data, parent) { - arcCenter = InitPoint(mainColor, this); - f1Point = InitPoint(supportColor, this); + m_arcCenter = InitPoint(Color(VColor::MainColor), this); + m_f1Point = InitPoint(Color(VColor::SupportColor), this); } //--------------------------------------------------------------------------------------------------------------------- void VisToolArcWithLength::RefreshGeometry() { - if (object1Id > NULL_ID) + if (m_centerId > NULL_ID) { - f1Point->setVisible(false); + m_f1Point->setVisible(false); - const QSharedPointer first = Visualization::data->GeometricObject(object1Id); - DrawPoint(arcCenter, static_cast(*first), supportColor); + const QSharedPointer first = GetData()->GeometricObject(m_centerId); + DrawPoint(m_arcCenter, static_cast(*first), Color(VColor::SupportColor)); - if (mode == Mode::Creation) + if (GetMode() == Mode::Creation) { - QLineF r = QLineF(static_cast(*first), Visualization::scenePos); + QLineF r = QLineF(static_cast(*first), ScenePos()); auto Angle = [r]() { @@ -80,84 +80,95 @@ void VisToolArcWithLength::RefreshGeometry() static const QString prefix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true); - if (qFuzzyIsNull(radius)) + if (qFuzzyIsNull(m_radius)) { VArc arc = VArc (*first, r.length(), r.angle(), r.angle()); - arc.SetApproximationScale(m_approximationScale); - DrawPath(this, arc.GetPath(), QVector(), supportColor, Qt::DashLine, Qt::RoundCap); + arc.SetApproximationScale(ApproximationScale()); + DrawPath(this, arc.GetPath(), QVector(), Color(VColor::SupportColor), Qt::DashLine, + Qt::RoundCap); - Visualization::toolTip = tr("Arc: radius = %1%2; " - "Mouse click - finish selecting the radius, " - "%3 - skip") - .arg(NumberToUser(r.length()), prefix, VModifierKey::EnterKey()); + SetToolTip(tr("Arc: radius = %1%2; " + "Mouse click - finish selecting the radius, " + "%3 - skip").arg(NumberToUser(r.length()), prefix, VModifierKey::EnterKey())); } - else if (f1 < 0) + else if (m_f1 < 0) { qreal f1Angle = Angle(); - VArc arc = VArc (*first, radius, f1Angle, f1Angle); - arc.SetApproximationScale(m_approximationScale); - DrawPath(this, arc.GetPath(), QVector(), supportColor, Qt::DashLine, Qt::RoundCap); + VArc arc = VArc (*first, m_radius, f1Angle, f1Angle); + arc.SetApproximationScale(ApproximationScale()); + DrawPath(this, arc.GetPath(), QVector(), Color(VColor::SupportColor), Qt::DashLine, + Qt::RoundCap); QLineF f1Line = r; - f1Line.setLength(radius); + f1Line.setLength(m_radius); f1Line.setAngle(f1Angle); - DrawPoint(f1Point, f1Line.p2(), supportColor); + DrawPoint(m_f1Point, f1Line.p2(), Color(VColor::SupportColor)); - Visualization::toolTip = tr("Arc: radius = %1%2, first angle = %3°; " - "Mouse click - finish selecting the first angle, " - "%4 - sticking angle, " - "%5 - skip") - .arg(NumberToUser(radius), prefix) - .arg(f1Angle) - .arg(VModifierKey::Shift(), VModifierKey::EnterKey()); + SetToolTip(tr("Arc: radius = %1%2, first angle = %3°; " + "Mouse click - finish selecting the first angle, " + "%4 - sticking angle, " + "%5 - skip") + .arg(NumberToUser(m_radius), prefix) + .arg(f1Angle) + .arg(VModifierKey::Shift(), VModifierKey::EnterKey())); } - else if (f1 >= 0) + else if (m_f1 >= 0) { - VArc arc = VArc (*first, radius, f1, r.angle()); - arc.SetApproximationScale(m_approximationScale); - DrawPath(this, arc.GetPath(), arc.DirectionArrows(), mainColor, lineStyle, Qt::RoundCap); + VArc arc = VArc (*first, m_radius, m_f1, r.angle()); + arc.SetApproximationScale(ApproximationScale()); + DrawPath(this, arc.GetPath(), arc.DirectionArrows(), Color(VColor::MainColor), LineStyle(), + Qt::RoundCap); - Visualization::toolTip = tr("Arc: radius = %1%2, first angle = %3°, arc length = %4%2; " - "Mouse click - finish creating, " - "%5 - skip") - .arg(NumberToUser(radius), prefix) - .arg(f1) - .arg(NumberToUser(arc.GetLength()), VModifierKey::EnterKey()); + SetToolTip(tr("Arc: radius = %1%2, first angle = %3°, arc length = %4%2; " + "Mouse click - finish creating, " + "%5 - skip") + .arg(NumberToUser(m_radius), prefix) + .arg(m_f1) + .arg(NumberToUser(arc.GetLength()), VModifierKey::EnterKey())); } } else { - if (not qFuzzyIsNull(radius) && f1 >= 0 && not qFuzzyIsNull(length)) + if (not qFuzzyIsNull(m_radius) && m_f1 >= 0 && not qFuzzyIsNull(m_length)) { - VArc arc = VArc (length, *first, radius, f1); - arc.SetApproximationScale(m_approximationScale); - DrawPath(this, arc.GetPath(), arc.DirectionArrows(), mainColor, lineStyle, Qt::RoundCap); + VArc arc = VArc (m_length, *first, m_radius, m_f1); + arc.SetApproximationScale(ApproximationScale()); + DrawPath(this, arc.GetPath(), arc.DirectionArrows(), Color(VColor::MainColor), LineStyle(), + Qt::RoundCap); } else { - DrawPath(this, QPainterPath(), QVector(), mainColor, lineStyle, Qt::RoundCap); + DrawPath(this, QPainterPath(), QVector(), Color(VColor::MainColor), LineStyle(), + Qt::RoundCap); } } } } //--------------------------------------------------------------------------------------------------------------------- -void VisToolArcWithLength::setRadius(const QString &expression) +void VisToolArcWithLength::VisualMode(quint32 id) { - radius = FindLengthFromUser(expression, Visualization::data->DataVariables()); + m_centerId = id; + StartVisualMode(); } //--------------------------------------------------------------------------------------------------------------------- -void VisToolArcWithLength::setF1(const QString &expression) +void VisToolArcWithLength::SetRadius(const QString &expression) { - f1 = FindValFromUser(expression, Visualization::data->DataVariables()); + m_radius = FindLengthFromUser(expression, GetData()->DataVariables()); } //--------------------------------------------------------------------------------------------------------------------- -void VisToolArcWithLength::setLength(const QString &expression) +void VisToolArcWithLength::SetF1(const QString &expression) { - length = FindLengthFromUser(expression, Visualization::data->DataVariables()); + m_f1 = FindValFromUser(expression, GetData()->DataVariables()); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VisToolArcWithLength::SetLength(const QString &expression) +{ + m_length = FindLengthFromUser(expression, GetData()->DataVariables()); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/visualization/path/vistoolarcwithlength.h b/src/libs/vtools/visualization/path/vistoolarcwithlength.h index 5b746f8d7..c4493e11b 100644 --- a/src/libs/vtools/visualization/path/vistoolarcwithlength.h +++ b/src/libs/vtools/visualization/path/vistoolarcwithlength.h @@ -48,20 +48,31 @@ public: ~VisToolArcWithLength() override =default; void RefreshGeometry() override; - void setRadius(const QString &expression); - void setF1(const QString &expression); - void setLength(const QString &expression); + void VisualMode(quint32 id) override; + + void SetCenterId(quint32 newCenterId); + void SetRadius(const QString &expression); + void SetF1(const QString &expression); + void SetLength(const QString &expression); + auto type() const -> int override {return Type;} enum {Type = UserType + static_cast(Vis::ToolArcWithLength)}; static auto CorrectAngle(qreal angle) -> qreal; private: Q_DISABLE_COPY_MOVE(VisToolArcWithLength) // NOLINT - VScaledEllipse *arcCenter{nullptr}; - VScaledEllipse *f1Point{nullptr}; - qreal radius{0}; - qreal f1{-1}; - qreal length{0}; + VScaledEllipse *m_arcCenter{nullptr}; + VScaledEllipse *m_f1Point{nullptr}; + qreal m_radius{0}; + qreal m_f1{-1}; + qreal m_length{0}; + quint32 m_centerId{NULL_ID}; }; +//--------------------------------------------------------------------------------------------------------------------- +inline void VisToolArcWithLength::SetCenterId(quint32 newCenterId) +{ + m_centerId = newCenterId; +} + #endif // VISTOOLARCWITHLENGTH_H diff --git a/src/libs/vtools/visualization/path/vistoolcubicbezier.cpp b/src/libs/vtools/visualization/path/vistoolcubicbezier.cpp index a3743c87f..b033eebfc 100644 --- a/src/libs/vtools/visualization/path/vistoolcubicbezier.cpp +++ b/src/libs/vtools/visualization/path/vistoolcubicbezier.cpp @@ -36,7 +36,6 @@ #include #include -#include "../ifc/ifcdef.h" #include "../vgeometry/vabstractcurve.h" #include "../vgeometry/vcubicbezier.h" #include "../vgeometry/vpointf.h" @@ -47,75 +46,67 @@ //--------------------------------------------------------------------------------------------------------------------- VisToolCubicBezier::VisToolCubicBezier(const VContainer *data, QGraphicsItem *parent) - : VisPath(data, parent), - object2Id(NULL_ID), - object3Id(NULL_ID), - object4Id(NULL_ID), - point1(nullptr), - point2(nullptr), - point3(nullptr), - point4(nullptr), - helpLine1(nullptr), - helpLine2(nullptr) + : VisPath(data, parent) { - helpLine1 = InitItem(mainColor, this); - helpLine2 = InitItem(mainColor, this); + m_helpLine1 = InitItem(Color(VColor::MainColor), this); + m_helpLine2 = InitItem(Color(VColor::MainColor), this); - point1 = InitPoint(supportColor, this); - point2 = InitPoint(supportColor, this); //-V656 - point3 = InitPoint(supportColor, this); //-V656 - point4 = InitPoint(supportColor, this); //-V656 + m_point1 = InitPoint(Color(VColor::SupportColor), this); + m_point2 = InitPoint(Color(VColor::SupportColor), this); //-V656 + m_point3 = InitPoint(Color(VColor::SupportColor), this); //-V656 + m_point4 = InitPoint(Color(VColor::SupportColor), this); //-V656 } //--------------------------------------------------------------------------------------------------------------------- void VisToolCubicBezier::RefreshGeometry() { - if (object1Id > NULL_ID) + if (m_point1Id > NULL_ID) { - const auto first = Visualization::data->GeometricObject(object1Id); - DrawPoint(point1, static_cast(*first), Qt::DashLine); + const auto first = GetData()->GeometricObject(m_point1Id); + DrawPoint(m_point1, static_cast(*first), Qt::DashLine); - if (object2Id <= NULL_ID) + if (m_point2Id <= NULL_ID) { - DrawLine(helpLine1, QLineF(static_cast(*first), Visualization::scenePos), mainColor, Qt::DashLine); + DrawLine(m_helpLine1, QLineF(static_cast(*first), ScenePos()), Color(VColor::MainColor), + Qt::DashLine); } else { - const auto second = Visualization::data->GeometricObject(object2Id); - DrawPoint(point2, static_cast(*second), supportColor); - DrawLine(helpLine1, QLineF(static_cast(*first), static_cast(*second)), mainColor, - Qt::DashLine); + const auto second = GetData()->GeometricObject(m_point2Id); + DrawPoint(m_point2, static_cast(*second), Color(VColor::SupportColor)); + DrawLine(m_helpLine1, QLineF(static_cast(*first), static_cast(*second)), + Color(VColor::MainColor), Qt::DashLine); - if (object3Id <= NULL_ID) + if (m_point3Id <= NULL_ID) { - VCubicBezier spline(*first, *second, VPointF(Visualization::scenePos), - VPointF(Visualization::scenePos)); - spline.SetApproximationScale(m_approximationScale); - DrawPath(this, spline.GetPath(), mainColor, lineStyle, Qt::RoundCap); + VCubicBezier spline(*first, *second, VPointF(ScenePos()), VPointF(ScenePos())); + spline.SetApproximationScale(ApproximationScale()); + DrawPath(this, spline.GetPath(), Color(VColor::MainColor), LineStyle(), Qt::RoundCap); } else { - const auto third = Visualization::data->GeometricObject(object3Id); - DrawPoint(point3, static_cast(*third), supportColor); + const auto third = GetData()->GeometricObject(m_point3Id); + DrawPoint(m_point3, static_cast(*third), Color(VColor::SupportColor)); - if (object4Id <= NULL_ID) + if (m_point4Id <= NULL_ID) { - VCubicBezier spline(*first, *second, *third, VPointF(Visualization::scenePos)); - spline.SetApproximationScale(m_approximationScale); - DrawPath(this, spline.GetPath(), mainColor, lineStyle, Qt::RoundCap); - DrawLine(helpLine2, QLineF(static_cast(*third), Visualization::scenePos), mainColor, + VCubicBezier spline(*first, *second, *third, VPointF(ScenePos())); + spline.SetApproximationScale(ApproximationScale()); + DrawPath(this, spline.GetPath(), Color(VColor::MainColor), LineStyle(), Qt::RoundCap); + DrawLine(m_helpLine2, QLineF(static_cast(*third), ScenePos()), Color(VColor::MainColor), Qt::DashLine); } else { - const auto fourth = Visualization::data->GeometricObject(object4Id); - DrawPoint(point4, static_cast(*fourth), supportColor); - DrawLine(helpLine2, QLineF(static_cast(*fourth), static_cast(*third)), mainColor, - Qt::DashLine); + const auto fourth = GetData()->GeometricObject(m_point4Id); + DrawPoint(m_point4, static_cast(*fourth), Color(VColor::SupportColor)); + DrawLine(m_helpLine2, QLineF(static_cast(*fourth), static_cast(*third)), + Color(VColor::MainColor), Qt::DashLine); VCubicBezier spline(*first, *second, *third, *fourth); - spline.SetApproximationScale(m_approximationScale); - DrawPath(this, spline.GetPath(), spline.DirectionArrows(), mainColor, lineStyle, Qt::RoundCap); + spline.SetApproximationScale(ApproximationScale()); + DrawPath(this, spline.GetPath(), spline.DirectionArrows(), Color(VColor::MainColor), LineStyle(), + Qt::RoundCap); } } } @@ -123,19 +114,8 @@ void VisToolCubicBezier::RefreshGeometry() } //--------------------------------------------------------------------------------------------------------------------- -void VisToolCubicBezier::setObject2Id(const quint32 &value) +void VisToolCubicBezier::VisualMode(quint32 id) { - object2Id = value; -} - -//--------------------------------------------------------------------------------------------------------------------- -void VisToolCubicBezier::setObject3Id(const quint32 &value) -{ - object3Id = value; -} - -//--------------------------------------------------------------------------------------------------------------------- -void VisToolCubicBezier::setObject4Id(const quint32 &value) -{ - object4Id = value; + m_point1Id = id; + StartVisualMode(); } diff --git a/src/libs/vtools/visualization/path/vistoolcubicbezier.h b/src/libs/vtools/visualization/path/vistoolcubicbezier.h index d1c89ea07..0fa440bec 100644 --- a/src/libs/vtools/visualization/path/vistoolcubicbezier.h +++ b/src/libs/vtools/visualization/path/vistoolcubicbezier.h @@ -44,27 +44,53 @@ class VisToolCubicBezier : public VisPath Q_OBJECT // NOLINT public: explicit VisToolCubicBezier(const VContainer *data, QGraphicsItem *parent = nullptr); - virtual ~VisToolCubicBezier() Q_DECL_EQ_DEFAULT; + ~VisToolCubicBezier() override = default; - virtual void RefreshGeometry() override; + void RefreshGeometry() override; + void VisualMode(quint32 id) override; - void setObject2Id(const quint32 &value); - void setObject3Id(const quint32 &value); - void setObject4Id(const quint32 &value); + void SetPoint1Id(quint32 value); + void SetPoint2Id(quint32 value); + void SetPoint3Id(quint32 value); + void SetPoint4Id(quint32 value); - virtual int type() const override {return Type;} - enum { Type = UserType + static_cast(Vis::ToolCubicBezier)}; -protected: + auto type() const -> int override {return Type;} + enum {Type = UserType + static_cast(Vis::ToolCubicBezier)}; +private: Q_DISABLE_COPY_MOVE(VisToolCubicBezier) // NOLINT - quint32 object2Id; - quint32 object3Id; - quint32 object4Id; - VScaledEllipse *point1; - VScaledEllipse *point2; - VScaledEllipse *point3; - VScaledEllipse *point4; - VScaledLine *helpLine1; - VScaledLine *helpLine2; + quint32 m_point1Id{NULL_ID}; + quint32 m_point2Id{NULL_ID}; + quint32 m_point3Id{NULL_ID}; + quint32 m_point4Id{NULL_ID}; + VScaledEllipse *m_point1{nullptr}; + VScaledEllipse *m_point2{nullptr}; + VScaledEllipse *m_point3{nullptr}; + VScaledEllipse *m_point4{nullptr}; + VScaledLine *m_helpLine1{nullptr}; + VScaledLine *m_helpLine2{nullptr}; }; +//--------------------------------------------------------------------------------------------------------------------- +inline void VisToolCubicBezier::SetPoint1Id(quint32 value) +{ + m_point1Id = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline void VisToolCubicBezier::SetPoint2Id(quint32 value) +{ + m_point2Id = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline void VisToolCubicBezier::SetPoint3Id(quint32 value) +{ + m_point3Id = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline void VisToolCubicBezier::SetPoint4Id(quint32 value) +{ + m_point4Id = value; +} #endif // VISTOOLCUBICBEZIER_H diff --git a/src/libs/vtools/visualization/path/vistoolcubicbezierpath.cpp b/src/libs/vtools/visualization/path/vistoolcubicbezierpath.cpp index 776d987b3..15198149d 100644 --- a/src/libs/vtools/visualization/path/vistoolcubicbezierpath.cpp +++ b/src/libs/vtools/visualization/path/vistoolcubicbezierpath.cpp @@ -47,19 +47,12 @@ //--------------------------------------------------------------------------------------------------------------------- VisToolCubicBezierPath::VisToolCubicBezierPath(const VContainer *data, QGraphicsItem *parent) - : VisPath(data, parent), - mainPoints(), - ctrlPoints(), - lines(), - newCurveSegment(nullptr), - path(), - helpLine1(nullptr), - helpLine2(nullptr) + : VisPath(data, parent) { - helpLine1 = InitItem(mainColor, this); - helpLine2 = InitItem(mainColor, this); + helpLine1 = InitItem(Color(VColor::MainColor), this); + helpLine2 = InitItem(Color(VColor::MainColor), this); - newCurveSegment = InitItem(mainColor, this); + newCurveSegment = InitItem(Color(VColor::MainColor), this); } //--------------------------------------------------------------------------------------------------------------------- @@ -80,11 +73,11 @@ void VisToolCubicBezierPath::RefreshGeometry() for (int i = 0; i < size; ++i) { - VScaledEllipse *point = this->getPoint(mainPoints, static_cast(i), 1/*zValue*/); - DrawPoint(point, static_cast(pathPoints.at(i)), supportColor); + VScaledEllipse *point = this->GetPoint(mainPoints, static_cast(i), 1/*zValue*/); + DrawPoint(point, static_cast(pathPoints.at(i)), Color(VColor::SupportColor)); } - if (mode == Mode::Creation) + if (GetMode() == Mode::Creation) { if (countSubSpl < 1) { @@ -99,7 +92,7 @@ void VisToolCubicBezierPath::RefreshGeometry() if (countSubSpl >= 1) { - DrawPath(this, path.GetPath(), path.DirectionArrows(), mainColor, lineStyle, Qt::RoundCap); + DrawPath(this, path.GetPath(), path.DirectionArrows(), Color(VColor::MainColor), LineStyle(), Qt::RoundCap); for (qint32 i = 1; i<=countSubSpl; ++i) { @@ -108,18 +101,18 @@ void VisToolCubicBezierPath::RefreshGeometry() const VSpline spl = path.GetSpline(i); - VScaledLine *ctrlLine1 = this->getLine(static_cast(preLastPoint)); + VScaledLine *ctrlLine1 = this->GetLine(static_cast(preLastPoint)); DrawLine(ctrlLine1, QLineF(static_cast(spl.GetP1()), static_cast(spl.GetP2())), - mainColor, Qt::DashLine); + Color(VColor::MainColor), Qt::DashLine); - VScaledEllipse *p2 = this->getPoint(ctrlPoints, static_cast(preLastPoint)); + VScaledEllipse *p2 = this->GetPoint(ctrlPoints, static_cast(preLastPoint)); DrawPoint(p2, static_cast(spl.GetP2()), Qt::green); - VScaledLine *ctrlLine2 = this->getLine(static_cast(lastPoint)); + VScaledLine *ctrlLine2 = this->GetLine(static_cast(lastPoint)); DrawLine(ctrlLine2, QLineF(static_cast(spl.GetP4()), static_cast(spl.GetP3())), - mainColor, Qt::DashLine); + Color(VColor::MainColor), Qt::DashLine); - VScaledEllipse *p3 = this->getPoint(ctrlPoints, static_cast(lastPoint)); + VScaledEllipse *p3 = this->GetPoint(ctrlPoints, static_cast(lastPoint)); DrawPoint(p3, static_cast(spl.GetP3()), Qt::green); } } @@ -129,7 +122,14 @@ void VisToolCubicBezierPath::RefreshGeometry() } //--------------------------------------------------------------------------------------------------------------------- -void VisToolCubicBezierPath::setPath(const VCubicBezierPath &value) +void VisToolCubicBezierPath::VisualMode(quint32 id) +{ + Q_UNUSED(id) + StartVisualMode(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VisToolCubicBezierPath::SetPath(const VCubicBezierPath &value) { path = value; @@ -137,41 +137,29 @@ void VisToolCubicBezierPath::setPath(const VCubicBezierPath &value) } //--------------------------------------------------------------------------------------------------------------------- -// cppcheck-suppress unusedFunction -VCubicBezierPath VisToolCubicBezierPath::getPath() -{ - return path; -} - -//--------------------------------------------------------------------------------------------------------------------- -VScaledEllipse *VisToolCubicBezierPath::getPoint(QVector &points, quint32 i, qreal z) +auto VisToolCubicBezierPath::GetPoint(QVector &points, quint32 i, qreal z) -> VScaledEllipse * { if (not points.isEmpty() && static_cast(points.size() - 1) >= i) { return points.at(static_cast(i)); } - else - { - auto point = InitPoint(supportColor, this, z); - points.append(point); - return point; - } + + auto *point = InitPoint(Color(VColor::SupportColor), this, z); + points.append(point); + return point; } //--------------------------------------------------------------------------------------------------------------------- -VScaledLine *VisToolCubicBezierPath::getLine(quint32 i) +auto VisToolCubicBezierPath::GetLine(quint32 i) -> VScaledLine * { - if (static_cast(lines.size() - 1) >= i && lines.isEmpty() == false) + if (static_cast(lines.size() - 1) >= i && not lines.isEmpty()) { return lines.at(static_cast(i)); } - else - { - auto line = InitItem(mainColor, this); - lines.append(line); - return line; - } - return nullptr; + + auto *line = InitItem(Color(VColor::MainColor), this); + lines.append(line); + return line; } //--------------------------------------------------------------------------------------------------------------------- @@ -197,31 +185,32 @@ void VisToolCubicBezierPath::Creating(const QVector &pathPoints, int po const VPointF &p1 = ConstLast(pathPoints); if (pathPoints.size() >= 4) { - QLineF p1p2(static_cast(p1), Visualization::scenePos); + QLineF p1p2(static_cast(p1), ScenePos()); QLineF prP3p1(static_cast(pathPoints.at(size-2)), static_cast(p1)); p1p2.setAngle(prP3p1.angle()); const QPointF p2 = p1p2.p2(); - VSpline spline(p1, p2, Visualization::scenePos, VPointF(Visualization::scenePos)); - DrawPath(newCurveSegment, spline.GetPath(), mainColor, Qt::SolidLine, Qt::RoundCap); + VSpline spline(p1, p2, ScenePos(), VPointF(ScenePos())); + DrawPath(newCurveSegment, spline.GetPath(), Color(VColor::MainColor), Qt::SolidLine, Qt::RoundCap); - DrawLine(helpLine1, p1p2, mainColor, Qt::DashLine); + DrawLine(helpLine1, p1p2, Color(VColor::MainColor), Qt::DashLine); const int preLastPoint = subSplCount * 2; - VScaledEllipse *p2Ctrl = this->getPoint(ctrlPoints, static_cast(preLastPoint)); + VScaledEllipse *p2Ctrl = this->GetPoint(ctrlPoints, static_cast(preLastPoint)); DrawPoint(p2Ctrl, p2, Qt::green); } else { - DrawLine(helpLine1, QLineF(static_cast(p1), Visualization::scenePos), mainColor, Qt::DashLine); + DrawLine(helpLine1, QLineF(static_cast(p1), ScenePos()), Color(VColor::MainColor), + Qt::DashLine); } break; } case 1: { - const VPointF p1 = pathPoints.at(subSplPoints + pointsLeft-1); - QPointF p2 = static_cast(pathPoints.at(subSplPoints + pointsLeft)); + const VPointF& p1 = pathPoints.at(subSplPoints + pointsLeft-1); + auto p2 = static_cast(pathPoints.at(subSplPoints + pointsLeft)); if (subSplCount >= 1) { @@ -232,20 +221,20 @@ void VisToolCubicBezierPath::Creating(const QVector &pathPoints, int po p2 = p1p2.p2(); } - DrawLine(helpLine1, QLineF(static_cast(p1), p2), mainColor, Qt::DashLine); + DrawLine(helpLine1, QLineF(static_cast(p1), p2), Color(VColor::MainColor), Qt::DashLine); - VSpline spline(p1, p2, Visualization::scenePos, VPointF(Visualization::scenePos)); - DrawPath(newCurveSegment, spline.GetPath(), mainColor, Qt::SolidLine, Qt::RoundCap); + VSpline spline(p1, p2, ScenePos(), VPointF(ScenePos())); + DrawPath(newCurveSegment, spline.GetPath(), Color(VColor::MainColor), Qt::SolidLine, Qt::RoundCap); const int preLastPoint = subSplCount * 2; - VScaledEllipse *p2Ctrl = this->getPoint(ctrlPoints, static_cast(preLastPoint)); + VScaledEllipse *p2Ctrl = this->GetPoint(ctrlPoints, static_cast(preLastPoint)); DrawPoint(p2Ctrl, p2, Qt::green); break; } case 2: { - const VPointF p1 = pathPoints.at(subSplPoints + pointsLeft-2); - QPointF p2 = static_cast(pathPoints.at(subSplPoints + pointsLeft-1)); + const VPointF& p1 = pathPoints.at(subSplPoints + pointsLeft-2); + auto p2 = static_cast(pathPoints.at(subSplPoints + pointsLeft-1)); const QPointF p3 = static_cast(pathPoints.at(subSplPoints + pointsLeft)); if (subSplCount >= 1) @@ -257,14 +246,14 @@ void VisToolCubicBezierPath::Creating(const QVector &pathPoints, int po p2 = p1p2.p2(); } - DrawLine(helpLine1, QLineF(static_cast(p1), p2), mainColor, Qt::DashLine); - DrawLine(helpLine2, QLineF(p3, Visualization::scenePos), mainColor, Qt::DashLine); + DrawLine(helpLine1, QLineF(static_cast(p1), p2), Color(VColor::MainColor), Qt::DashLine); + DrawLine(helpLine2, QLineF(p3, ScenePos()), Color(VColor::MainColor), Qt::DashLine); - VSpline spline(p1, p2, p3, VPointF(Visualization::scenePos)); - DrawPath(newCurveSegment, spline.GetPath(), mainColor, Qt::SolidLine, Qt::RoundCap); + VSpline spline(p1, p2, p3, VPointF(ScenePos())); + DrawPath(newCurveSegment, spline.GetPath(), Color(VColor::MainColor), Qt::SolidLine, Qt::RoundCap); const int preLastPoint = subSplCount * 2; - VScaledEllipse *p2Ctrl = this->getPoint(ctrlPoints, static_cast(preLastPoint)); + VScaledEllipse *p2Ctrl = this->GetPoint(ctrlPoints, static_cast(preLastPoint)); DrawPoint(p2Ctrl, p2, Qt::green); break; } @@ -283,23 +272,22 @@ void VisToolCubicBezierPath::RefreshToolTip() if (size < 7) { - Visualization::toolTip = tr("Curved path: select seven or more points"); + SetToolTip(tr("Curved path: select seven or more points")); } else if (size - VCubicBezierPath::SubSplPointsCount(countSubSpl) == 0) { - Visualization::toolTip = tr("Curved path: select seven or more points, " - "%1 - finish creation") - .arg(VModifierKey::EnterKey()); + SetToolTip(tr("Curved path: select seven or more points, " + "%1 - finish creation").arg(VModifierKey::EnterKey())); } else { - Visualization::toolTip = tr("Curved path: select more points for complete segment"); + SetToolTip(tr("Curved path: select more points for complete segment")); } - if (mode == Mode::Show) + if (GetMode() == Mode::Show) { - Visualization::toolTip = QString(); + SetToolTip(QString()); } - emit ToolTip(Visualization::toolTip); + emit ToolTip(CurrentToolTip()); } } diff --git a/src/libs/vtools/visualization/path/vistoolcubicbezierpath.h b/src/libs/vtools/visualization/path/vistoolcubicbezierpath.h index 8c93a281c..98c27cdf5 100644 --- a/src/libs/vtools/visualization/path/vistoolcubicbezierpath.h +++ b/src/libs/vtools/visualization/path/vistoolcubicbezierpath.h @@ -46,30 +46,36 @@ class VisToolCubicBezierPath : public VisPath Q_OBJECT // NOLINT public: explicit VisToolCubicBezierPath(const VContainer *data, QGraphicsItem *parent = nullptr); - virtual ~VisToolCubicBezierPath(); + ~VisToolCubicBezierPath() override; - virtual void RefreshGeometry() override; + void RefreshGeometry() override; + void VisualMode(quint32 id = NULL_ID) override; - void setPath(const VCubicBezierPath &value); - VCubicBezierPath getPath(); - - virtual int type() const override {return Type;} - enum { Type = UserType + static_cast(Vis::ToolCubicBezierPath)}; -protected: - Q_DISABLE_COPY_MOVE(VisToolCubicBezierPath) // NOLINT - QVector mainPoints; - QVector ctrlPoints; - QVector lines; - VCurvePathItem *newCurveSegment; - VCubicBezierPath path; - VScaledLine *helpLine1; - VScaledLine *helpLine2; + void SetPath(const VCubicBezierPath &value); + auto GetPath() const -> VCubicBezierPath; + auto type() const -> int override {return Type;} + enum {Type = UserType + static_cast(Vis::ToolCubicBezierPath)}; private: - VScaledEllipse *getPoint(QVector &points, quint32 i, qreal z = 0); - VScaledLine *getLine(quint32 i); + Q_DISABLE_COPY_MOVE(VisToolCubicBezierPath) // NOLINT + QVector mainPoints{}; + QVector ctrlPoints{}; + QVector lines{}; + VCurvePathItem *newCurveSegment{nullptr}; + VCubicBezierPath path{}; + VScaledLine *helpLine1{nullptr}; + VScaledLine *helpLine2{nullptr}; + + auto GetPoint(QVector &points, quint32 i, qreal z = 0) -> VScaledEllipse *; + auto GetLine(quint32 i) -> VScaledLine *; void Creating(const QVector &pathPoints , int pointsLeft); void RefreshToolTip(); }; +//--------------------------------------------------------------------------------------------------------------------- +inline auto VisToolCubicBezierPath::GetPath() const -> VCubicBezierPath +{ + return path; +} + #endif // VISTOOLCUBICBEZIERPATH_H diff --git a/src/libs/vtools/visualization/path/vistoolcutarc.cpp b/src/libs/vtools/visualization/path/vistoolcutarc.cpp index 36f5180c9..13574772c 100644 --- a/src/libs/vtools/visualization/path/vistoolcutarc.cpp +++ b/src/libs/vtools/visualization/path/vistoolcutarc.cpp @@ -53,7 +53,7 @@ VisToolCutArc::VisToolCutArc(const VContainer *data, QGraphicsItem *parent) m_arc2 = InitItem(Qt::darkRed, this); m_arc2->setFlag(QGraphicsItem::ItemStacksBehindParent, false); - m_point = InitPoint(mainColor, this); + m_point = InitPoint(Color(VColor::MainColor), this); m_point->setZValue(2); m_point->setFlag(QGraphicsItem::ItemStacksBehindParent, false); } @@ -61,39 +61,45 @@ VisToolCutArc::VisToolCutArc(const VContainer *data, QGraphicsItem *parent) //--------------------------------------------------------------------------------------------------------------------- void VisToolCutArc::RefreshGeometry() { - if (object1Id > NULL_ID) + if (m_arcId > NULL_ID) { - const QSharedPointer arc = Visualization::data->GeometricObject(object1Id); - DrawPath(this, arc->GetPath(), arc->DirectionArrows(), supportColor, lineStyle, Qt::RoundCap); + const QSharedPointer arc = GetData()->GeometricObject(m_arcId); + DrawPath(this, arc->GetPath(), arc->DirectionArrows(), Color(VColor::SupportColor), LineStyle(), Qt::RoundCap); if (not qFuzzyIsNull(m_length)) { VArc ar1; VArc ar2; QPointF p = arc->CutArc(m_length, ar1, ar2, QString()); - DrawPoint(m_point, p, mainColor); + DrawPoint(m_point, p, Color(VColor::MainColor)); - DrawPath(m_arc1, ar1.GetPath(), ar1.DirectionArrows(), Qt::darkGreen, lineStyle, Qt::RoundCap); - DrawPath(m_arc2, ar2.GetPath(), ar2.DirectionArrows(), Qt::darkRed, lineStyle, Qt::RoundCap); + DrawPath(m_arc1, ar1.GetPath(), ar1.DirectionArrows(), Qt::darkGreen, LineStyle(), Qt::RoundCap); + DrawPath(m_arc2, ar2.GetPath(), ar2.DirectionArrows(), Qt::darkRed, LineStyle(), Qt::RoundCap); } - else if (mode == Mode::Creation) + else if (GetMode() == Mode::Creation) { - QPointF p = arc->ClosestPoint(Visualization::scenePos); + QPointF p = arc->ClosestPoint(ScenePos()); qreal length = arc->GetLengthByPoint(p); - DrawPoint(m_point, p, mainColor); + DrawPoint(m_point, p, Color(VColor::MainColor)); const QString prefix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true); - Visualization::toolTip = tr("Length = %1%2; " - "Mouse click - finish selecting the length, " - "%3 - skip") - .arg(NumberToUser(length), prefix, VModifierKey::EnterKey()); + SetToolTip(tr("Length = %1%2; " + "Mouse click - finish selecting the length, " + "%3 - skip").arg(NumberToUser(length), prefix, VModifierKey::EnterKey())); } } } //--------------------------------------------------------------------------------------------------------------------- -void VisToolCutArc::setLength(const QString &expression) +void VisToolCutArc::SetLength(const QString &expression) { - m_length = FindLengthFromUser(expression, Visualization::data->DataVariables()); + m_length = FindLengthFromUser(expression, GetData()->DataVariables()); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VisToolCutArc::VisualMode(quint32 id) +{ + m_arcId = id; + StartVisualMode(); } diff --git a/src/libs/vtools/visualization/path/vistoolcutarc.h b/src/libs/vtools/visualization/path/vistoolcutarc.h index a8d22e330..a7928bad4 100644 --- a/src/libs/vtools/visualization/path/vistoolcutarc.h +++ b/src/libs/vtools/visualization/path/vistoolcutarc.h @@ -47,15 +47,27 @@ public: ~VisToolCutArc() override = default; void RefreshGeometry() override; - void setLength(const QString &expression); + void VisualMode(quint32 id) override; + + void SetArcId(quint32 newArcId); + void SetLength(const QString &expression); + auto type() const -> int override {return Type;} enum {Type = UserType + static_cast(Vis::ToolCutArc)}; + private: Q_DISABLE_COPY_MOVE(VisToolCutArc) // NOLINT VScaledEllipse *m_point{nullptr}; VCurvePathItem *m_arc1{nullptr}; VCurvePathItem *m_arc2{nullptr}; qreal m_length{0}; + quint32 m_arcId{NULL_ID}; }; +//--------------------------------------------------------------------------------------------------------------------- +inline void VisToolCutArc::SetArcId(quint32 newArcId) +{ + m_arcId = newArcId; +} + #endif // VISTOOLCUTARC_H diff --git a/src/libs/vtools/visualization/path/vistoolcutspline.cpp b/src/libs/vtools/visualization/path/vistoolcutspline.cpp index 45589e2f1..91cf35d4c 100644 --- a/src/libs/vtools/visualization/path/vistoolcutspline.cpp +++ b/src/libs/vtools/visualization/path/vistoolcutspline.cpp @@ -55,7 +55,7 @@ VisToolCutSpline::VisToolCutSpline(const VContainer *data, QGraphicsItem *parent m_spl2 = InitItem(Qt::darkRed, this); m_spl2->setFlag(QGraphicsItem::ItemStacksBehindParent, false); - m_point = InitPoint(mainColor, this); + m_point = InitPoint(Color(VColor::MainColor), this); m_point->setZValue(2); m_point->setFlag(QGraphicsItem::ItemStacksBehindParent, false); } @@ -63,10 +63,10 @@ VisToolCutSpline::VisToolCutSpline(const VContainer *data, QGraphicsItem *parent //--------------------------------------------------------------------------------------------------------------------- void VisToolCutSpline::RefreshGeometry() { - if (object1Id > NULL_ID) + if (m_splineId > NULL_ID) { - const auto spl = Visualization::data->GeometricObject(object1Id); - DrawPath(this, spl->GetPath(), spl->DirectionArrows(), supportColor, lineStyle, Qt::RoundCap); + const auto spl = GetData()->GeometricObject(m_splineId); + DrawPath(this, spl->GetPath(), spl->DirectionArrows(), Color(VColor::SupportColor), LineStyle(), Qt::RoundCap); if (not qFuzzyIsNull(m_length)) { @@ -81,29 +81,35 @@ void VisToolCutSpline::RefreshGeometry() VSpline sp2 = VSpline(VPointF(p), spl2p2, spl2p3, spl->GetP4()); sp2.SetApproximationScale(spl->GetApproximationScale()); - DrawPoint(m_point, p, mainColor); + DrawPoint(m_point, p, Color(VColor::MainColor)); - DrawPath(m_spl1, sp1.GetPath(), sp1.DirectionArrows(), Qt::darkGreen, lineStyle, Qt::RoundCap); - DrawPath(m_spl2, sp2.GetPath(), sp2.DirectionArrows(), Qt::darkRed, lineStyle, Qt::RoundCap); + DrawPath(m_spl1, sp1.GetPath(), sp1.DirectionArrows(), Qt::darkGreen, LineStyle(), Qt::RoundCap); + DrawPath(m_spl2, sp2.GetPath(), sp2.DirectionArrows(), Qt::darkRed, LineStyle(), Qt::RoundCap); } - else if (mode == Mode::Creation) + else if (GetMode() == Mode::Creation) { - QPointF p = spl->ClosestPoint(Visualization::scenePos); + QPointF p = spl->ClosestPoint(ScenePos()); qreal length = spl->GetLengthByPoint(p); - DrawPoint(m_point, p, mainColor); + DrawPoint(m_point, p, Color(VColor::MainColor)); const QString prefix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true); - Visualization::toolTip = tr("Length = %1%2; " - "Mouse click - finish selecting the length, " - "%3 - skip") - .arg(NumberToUser(length), prefix, VModifierKey::EnterKey()); + SetToolTip(tr("Length = %1%2; " + "Mouse click - finish selecting the length, " + "%3 - skip").arg(NumberToUser(length), prefix, VModifierKey::EnterKey())); } } } //--------------------------------------------------------------------------------------------------------------------- -void VisToolCutSpline::setLength(const QString &expression) +void VisToolCutSpline::VisualMode(quint32 id) { - m_length = FindLengthFromUser(expression, Visualization::data->DataVariables()); + m_splineId = id; + StartVisualMode(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VisToolCutSpline::SetLength(const QString &expression) +{ + m_length = FindLengthFromUser(expression, GetData()->DataVariables()); } diff --git a/src/libs/vtools/visualization/path/vistoolcutspline.h b/src/libs/vtools/visualization/path/vistoolcutspline.h index c599b0ccc..1d0dbf5a4 100644 --- a/src/libs/vtools/visualization/path/vistoolcutspline.h +++ b/src/libs/vtools/visualization/path/vistoolcutspline.h @@ -47,7 +47,11 @@ public: ~VisToolCutSpline() override = default; void RefreshGeometry() override; - void setLength(const QString &expression); + void VisualMode(quint32 id) override; + + void SetSplineId(quint32 id); + void SetLength(const QString &expression); + auto type() const -> int override {return Type;} enum {Type = UserType + static_cast(Vis::ToolCutSpline)}; private: @@ -56,6 +60,13 @@ private: VCurvePathItem *m_spl1{nullptr}; VCurvePathItem *m_spl2{nullptr}; qreal m_length{0}; + quint32 m_splineId{NULL_ID}; }; +//--------------------------------------------------------------------------------------------------------------------- +inline void VisToolCutSpline::SetSplineId(quint32 id) +{ + m_splineId = id; +} + #endif // VISTOOLCUTSPLINE_H diff --git a/src/libs/vtools/visualization/path/vistoolcutsplinepath.cpp b/src/libs/vtools/visualization/path/vistoolcutsplinepath.cpp index bd168da77..80321be74 100644 --- a/src/libs/vtools/visualization/path/vistoolcutsplinepath.cpp +++ b/src/libs/vtools/visualization/path/vistoolcutsplinepath.cpp @@ -54,7 +54,7 @@ VisToolCutSplinePath::VisToolCutSplinePath(const VContainer *data, QGraphicsItem m_splPath2 = InitItem(Qt::darkRed, this); m_splPath2->setFlag(QGraphicsItem::ItemStacksBehindParent, false); - m_point = InitPoint(mainColor, this); + m_point = InitPoint(Color(VColor::MainColor), this); m_point->setZValue(2); m_point->setFlag(QGraphicsItem::ItemStacksBehindParent, false); } @@ -62,10 +62,11 @@ VisToolCutSplinePath::VisToolCutSplinePath(const VContainer *data, QGraphicsItem //--------------------------------------------------------------------------------------------------------------------- void VisToolCutSplinePath::RefreshGeometry() { - if (object1Id > NULL_ID) + if (m_splinePathId > NULL_ID) { - const auto splPath = Visualization::data->GeometricObject(object1Id); - DrawPath(this, splPath->GetPath(), splPath->DirectionArrows(), supportColor, lineStyle, Qt::RoundCap); + const auto splPath = GetData()->GeometricObject(m_splinePathId); + DrawPath(this, splPath->GetPath(), splPath->DirectionArrows(), Color(VColor::SupportColor), LineStyle(), + Qt::RoundCap); if (not qFuzzyIsNull(m_length)) { @@ -76,34 +77,42 @@ void VisToolCutSplinePath::RefreshGeometry() SCASSERT(spPath1 != nullptr) SCASSERT(spPath2 != nullptr) - DrawPoint(m_point, static_cast(*p), mainColor); + DrawPoint(m_point, static_cast(*p), Color(VColor::MainColor)); delete p; - DrawPath(m_splPath1, spPath1->GetPath(), spPath1->DirectionArrows(), Qt::darkGreen, lineStyle, + DrawPath(m_splPath1, spPath1->GetPath(), spPath1->DirectionArrows(), Qt::darkGreen, LineStyle(), + Qt::RoundCap); + DrawPath(m_splPath2, spPath2->GetPath(), spPath2->DirectionArrows(), Qt::darkRed, LineStyle(), Qt::RoundCap); - DrawPath(m_splPath2, spPath2->GetPath(), spPath2->DirectionArrows(), Qt::darkRed, lineStyle, Qt::RoundCap); delete spPath1; delete spPath2; } - else if (mode == Mode::Creation) + else if (GetMode() == Mode::Creation) { - QPointF p = splPath->ClosestPoint(Visualization::scenePos); + QPointF p = splPath->ClosestPoint(ScenePos()); qreal length = splPath->GetLengthByPoint(p); - DrawPoint(m_point, p, mainColor); + DrawPoint(m_point, p, Color(VColor::MainColor)); const QString prefix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true); - Visualization::toolTip = tr("Length = %1%2; " - "Mouse click - finish selecting the length, " - "%3 - skip") - .arg(NumberToUser(length), prefix, VModifierKey::EnterKey()); + SetToolTip(tr("Length = %1%2; " + "Mouse click - finish selecting the length, " + "%3 - skip") + .arg(NumberToUser(length), prefix, VModifierKey::EnterKey())); } } } //--------------------------------------------------------------------------------------------------------------------- -void VisToolCutSplinePath::setLength(const QString &expression) +void VisToolCutSplinePath::VisualMode(quint32 id) { - m_length = FindLengthFromUser(expression, Visualization::data->DataVariables()); + m_splinePathId = id; + StartVisualMode(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VisToolCutSplinePath::SetLength(const QString &expression) +{ + m_length = FindLengthFromUser(expression, GetData()->DataVariables()); } diff --git a/src/libs/vtools/visualization/path/vistoolcutsplinepath.h b/src/libs/vtools/visualization/path/vistoolcutsplinepath.h index 6f1664a5d..2cea3b851 100644 --- a/src/libs/vtools/visualization/path/vistoolcutsplinepath.h +++ b/src/libs/vtools/visualization/path/vistoolcutsplinepath.h @@ -47,7 +47,11 @@ public: ~VisToolCutSplinePath() override = default; void RefreshGeometry() override; - void setLength(const QString &expression); + void VisualMode(quint32 id) override; + + void SetSplinePathId(quint32 newSplineId); + void SetLength(const QString &expression); + auto type() const -> int override {return Type;} enum {Type = UserType + static_cast(Vis::ToolCutSpline)}; private: @@ -56,6 +60,13 @@ private: VCurvePathItem *m_splPath1{nullptr}; VCurvePathItem *m_splPath2{nullptr}; qreal m_length{0}; + quint32 m_splinePathId{NULL_ID}; }; +//--------------------------------------------------------------------------------------------------------------------- +inline void VisToolCutSplinePath::SetSplinePathId(quint32 newSplineId) +{ + m_splinePathId = newSplineId; +} + #endif // VISTOOLCUTSPLINEPATH_H diff --git a/src/libs/vtools/visualization/path/vistoolduplicatedetail.cpp b/src/libs/vtools/visualization/path/vistoolduplicatedetail.cpp index dff971417..70bb48e59 100644 --- a/src/libs/vtools/visualization/path/vistoolduplicatedetail.cpp +++ b/src/libs/vtools/visualization/path/vistoolduplicatedetail.cpp @@ -30,42 +30,44 @@ //--------------------------------------------------------------------------------------------------------------------- VisToolDuplicateDetail::VisToolDuplicateDetail(const VContainer *data, QGraphicsItem *parent) - : VisPath(data, parent), - m_start(), - m_started(false), - m_diff() + : VisPath(data, parent) {} //--------------------------------------------------------------------------------------------------------------------- void VisToolDuplicateDetail::RefreshGeometry() { - const VPiece piece = Visualization::data->GetPiece(object1Id); + const VPiece piece = GetData()->GetPiece(m_pieceId); if (not m_started) { - m_start = Visualization::scenePos; + m_start = ScenePos(); m_started = true; setPos(QPointF(piece.GetMx(), piece.GetMy())); } else { - m_diff = Visualization::scenePos - m_start; + m_diff = ScenePos() - m_start; m_diff = QPointF(m_diff.x() + piece.GetMx(), m_diff.y() + piece.GetMy()); setPos(m_diff); } - DrawPath(this, PiecePath(piece), mainColor, Qt::SolidLine, Qt::RoundCap); + DrawPath(this, PiecePath(piece), Color(VColor::MainColor), Qt::SolidLine, Qt::RoundCap); } //--------------------------------------------------------------------------------------------------------------------- -QPainterPath VisToolDuplicateDetail::PiecePath(const VPiece &piece) const +void VisToolDuplicateDetail::VisualMode(quint32 id) +{ + m_pieceId = id; + StartVisualMode(); +} + +//--------------------------------------------------------------------------------------------------------------------- +auto VisToolDuplicateDetail::PiecePath(const VPiece &piece) const -> QPainterPath { if (not piece.IsHideMainPath() || not piece.IsSeamAllowance() || piece.IsSeamAllowanceBuiltIn()) { - return piece.MainPathPath(Visualization::data); - } - else - { - return piece.SeamAllowancePath(Visualization::data); + return piece.MainPathPath(GetData()); } + + return piece.SeamAllowancePath(GetData()); } diff --git a/src/libs/vtools/visualization/path/vistoolduplicatedetail.h b/src/libs/vtools/visualization/path/vistoolduplicatedetail.h index 4080dc98f..31b827a8d 100644 --- a/src/libs/vtools/visualization/path/vistoolduplicatedetail.h +++ b/src/libs/vtools/visualization/path/vistoolduplicatedetail.h @@ -35,34 +35,45 @@ class VisToolDuplicateDetail : public VisPath { Q_OBJECT // NOLINT public: - VisToolDuplicateDetail(const VContainer *data, QGraphicsItem *parent = nullptr); - virtual ~VisToolDuplicateDetail() = default; + explicit VisToolDuplicateDetail(const VContainer *data, QGraphicsItem *parent = nullptr); + ~VisToolDuplicateDetail() override = default; - qreal Mx() const; - qreal My() const; + auto Mx() const -> qreal; + auto My() const -> qreal; - virtual void RefreshGeometry() override; - virtual int type() const override {return Type;} - enum { Type = UserType + static_cast(Vis::ToolDuplicateDetail)}; + void RefreshGeometry() override; + void VisualMode(quint32 id) override; + + void SetPieceId(quint32 newPieceId); + + auto type() const -> int override {return Type;} + enum {Type = UserType + static_cast(Vis::ToolDuplicateDetail)}; private: Q_DISABLE_COPY_MOVE(VisToolDuplicateDetail) // NOLINT - QPointF m_start; - bool m_started; - QPointF m_diff; + QPointF m_start{}; + bool m_started{false}; + QPointF m_diff{}; + quint32 m_pieceId{NULL_ID}; - QPainterPath PiecePath(const VPiece &piece) const; + auto PiecePath(const VPiece &piece) const -> QPainterPath; }; //--------------------------------------------------------------------------------------------------------------------- -inline qreal VisToolDuplicateDetail::Mx() const +inline auto VisToolDuplicateDetail::Mx() const -> qreal { return m_diff.x(); } //--------------------------------------------------------------------------------------------------------------------- -inline qreal VisToolDuplicateDetail::My() const +inline auto VisToolDuplicateDetail::My() const -> qreal { return m_diff.y(); } +//--------------------------------------------------------------------------------------------------------------------- +inline void VisToolDuplicateDetail::SetPieceId(quint32 newPieceId) +{ + m_pieceId = newPieceId; +} + #endif // VISTOOLDUPLICATEDETAIL_H diff --git a/src/libs/vtools/visualization/path/vistoolellipticalarc.cpp b/src/libs/vtools/visualization/path/vistoolellipticalarc.cpp index 8df839d31..ee12387ed 100644 --- a/src/libs/vtools/visualization/path/vistoolellipticalarc.cpp +++ b/src/libs/vtools/visualization/path/vistoolellipticalarc.cpp @@ -32,7 +32,6 @@ #include #include -#include "../ifc/ifcdef.h" #include "../vgeometry/vabstractcurve.h" #include "../vgeometry/vellipticalarc.h" #include "../vgeometry/vpointf.h" @@ -41,54 +40,63 @@ #include "../vwidgets/scalesceneitems.h" #include "vispath.h" +//--------------------------------------------------------------------------------------------------------------------- VisToolEllipticalArc::VisToolEllipticalArc(const VContainer *data, QGraphicsItem *parent) - :VisPath(data, parent), arcCenter(nullptr), radius1(0), radius2(0), f1(0), f2(0), rotationAngle(0) + :VisPath(data, parent) { - arcCenter = InitPoint(mainColor, this); + m_arcCenter = InitPoint(Color(VColor::MainColor), this); } //--------------------------------------------------------------------------------------------------------------------- void VisToolEllipticalArc::RefreshGeometry() { - if (object1Id > NULL_ID) + if (m_centerId > NULL_ID) { - const QSharedPointer first = Visualization::data->GeometricObject(object1Id); - DrawPoint(arcCenter, static_cast(*first), supportColor); + const QSharedPointer first = GetData()->GeometricObject(m_centerId); + DrawPoint(m_arcCenter, static_cast(*first), Color(VColor::SupportColor)); - if (not qFuzzyIsNull(radius1) && not qFuzzyIsNull(radius2) && f1 >= 0 && f2 >= 0 && rotationAngle >= 0) + if (not qFuzzyIsNull(m_radius1) && not qFuzzyIsNull(m_radius2) && m_f1 >= 0 && m_f2 >= 0 && m_rotationAngle >= 0) { - VEllipticalArc elArc = VEllipticalArc(*first, radius1, radius2, f1, f2, rotationAngle); - DrawPath(this, elArc.GetPath(), elArc.DirectionArrows(), mainColor, lineStyle, Qt::RoundCap); + VEllipticalArc elArc = VEllipticalArc(*first, m_radius1, m_radius2, m_f1, m_f2, m_rotationAngle); + DrawPath(this, elArc.GetPath(), elArc.DirectionArrows(), Color(VColor::MainColor), LineStyle(), + Qt::RoundCap); } } } //--------------------------------------------------------------------------------------------------------------------- -void VisToolEllipticalArc::setRadius1(const QString &expression) +void VisToolEllipticalArc::VisualMode(quint32 id) { - radius1 = FindLengthFromUser(expression, Visualization::data->DataVariables()); + m_centerId = id; + StartVisualMode(); } //--------------------------------------------------------------------------------------------------------------------- -void VisToolEllipticalArc::setRadius2(const QString &expression) +void VisToolEllipticalArc::SetRadius1(const QString &expression) { - radius2 = FindLengthFromUser(expression, Visualization::data->DataVariables()); + m_radius1 = FindLengthFromUser(expression, GetData()->DataVariables()); } //--------------------------------------------------------------------------------------------------------------------- -void VisToolEllipticalArc::setF1(const QString &expression) +void VisToolEllipticalArc::SetRadius2(const QString &expression) { - f1 = FindValFromUser(expression, Visualization::data->DataVariables()); + m_radius2 = FindLengthFromUser(expression, GetData()->DataVariables()); } //--------------------------------------------------------------------------------------------------------------------- -void VisToolEllipticalArc::setF2(const QString &expression) +void VisToolEllipticalArc::SetF1(const QString &expression) { - f2 = FindValFromUser(expression, Visualization::data->DataVariables()); + m_f1 = FindValFromUser(expression, GetData()->DataVariables()); } //--------------------------------------------------------------------------------------------------------------------- -void VisToolEllipticalArc::setRotationAngle(const QString &expression) +void VisToolEllipticalArc::SetF2(const QString &expression) { - rotationAngle = FindValFromUser(expression, Visualization::data->DataVariables()); + m_f2 = FindValFromUser(expression, GetData()->DataVariables()); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VisToolEllipticalArc::SetRotationAngle(const QString &expression) +{ + m_rotationAngle = FindValFromUser(expression, GetData()->DataVariables()); } diff --git a/src/libs/vtools/visualization/path/vistoolellipticalarc.h b/src/libs/vtools/visualization/path/vistoolellipticalarc.h index 4dafe3b9f..ba6f27648 100644 --- a/src/libs/vtools/visualization/path/vistoolellipticalarc.h +++ b/src/libs/vtools/visualization/path/vistoolellipticalarc.h @@ -43,25 +43,35 @@ class VisToolEllipticalArc : public VisPath Q_OBJECT // NOLINT public: explicit VisToolEllipticalArc(const VContainer *data, QGraphicsItem *parent = nullptr); - virtual ~VisToolEllipticalArc() Q_DECL_EQ_DEFAULT; + ~VisToolEllipticalArc() override = default; - virtual void RefreshGeometry() override; - void setRadius1(const QString &expression); - void setRadius2(const QString &expression); - void setF1(const QString &expression); - void setF2(const QString &expression); - void setRotationAngle(const QString &expression); + void RefreshGeometry() override; + void VisualMode(quint32 id) override; - virtual int type() const override {return Type;} - enum { Type = UserType + static_cast(Vis::ToolEllipticalArc)}; + void SetCenterId(quint32 newCenterId); + void SetRadius1(const QString &expression); + void SetRadius2(const QString &expression); + void SetF1(const QString &expression); + void SetF2(const QString &expression); + void SetRotationAngle(const QString &expression); + + auto type() const -> int override {return Type;} + enum {Type = UserType + static_cast(Vis::ToolEllipticalArc)}; private: Q_DISABLE_COPY_MOVE(VisToolEllipticalArc) // NOLINT - VScaledEllipse *arcCenter; - qreal radius1; - qreal radius2; - qreal f1; - qreal f2; - qreal rotationAngle; + VScaledEllipse *m_arcCenter{nullptr}; + qreal m_radius1{0}; + qreal m_radius2{0}; + qreal m_f1{0}; + qreal m_f2{0}; + qreal m_rotationAngle{0}; + quint32 m_centerId{NULL_ID}; }; +//--------------------------------------------------------------------------------------------------------------------- +inline void VisToolEllipticalArc::SetCenterId(quint32 newCenterId) +{ + m_centerId = newCenterId; +} + #endif // VISTOOLELLIPTICALARC_H diff --git a/src/libs/vtools/visualization/path/vistoolpiece.cpp b/src/libs/vtools/visualization/path/vistoolpiece.cpp index 1510e4091..29b148e95 100644 --- a/src/libs/vtools/visualization/path/vistoolpiece.cpp +++ b/src/libs/vtools/visualization/path/vistoolpiece.cpp @@ -33,20 +33,10 @@ //--------------------------------------------------------------------------------------------------------------------- VisToolPiece::VisToolPiece(const VContainer *data, QGraphicsItem *parent) - : VisPath(data, parent), - m_points(), - m_curves(), - m_line1(nullptr), - m_line2(nullptr), - m_piece(), - m_pieceCached(false), - m_cachedMainPath(), - m_cachedNodes(), - m_cachedMainPathPoints(), - m_cachedCurvesPath() + : VisPath(data, parent) { - m_line1 = InitItem(supportColor, this); - m_line2 = InitItem(supportColor, this); + m_line1 = InitItem(Color(VColor::SupportColor), this); + m_line2 = InitItem(Color(VColor::SupportColor), this); } //--------------------------------------------------------------------------------------------------------------------- @@ -58,48 +48,55 @@ void VisToolPiece::RefreshGeometry() { if (not m_pieceCached) { - m_cachedNodes = m_piece.MainPathNodePoints(Visualization::data); - if (mode == Mode::Creation) + m_cachedNodes = m_piece.MainPathNodePoints(GetData()); + if (GetMode() == Mode::Creation) { - m_cachedCurvesPath = m_piece.CurvesPainterPath(Visualization::data); - m_cachedMainPathPoints = m_piece.MainPathPoints(Visualization::data); + m_cachedCurvesPath = m_piece.CurvesPainterPath(GetData()); + m_cachedMainPathPoints = m_piece.MainPathPoints(GetData()); m_cachedMainPath = VPiece::MainPathPath(m_cachedMainPathPoints); } else { - m_cachedMainPath = m_piece.MainPathPath(Visualization::data); + m_cachedMainPath = m_piece.MainPathPath(GetData()); } m_pieceCached = true; } - DrawPath(this, m_cachedMainPath, mainColor, Qt::SolidLine, Qt::RoundCap); + DrawPath(this, m_cachedMainPath, Color(VColor::MainColor), Qt::SolidLine, Qt::RoundCap); for (int i = 0; i < m_cachedNodes.size(); ++i) { - VScaledEllipse *point = GetPoint(static_cast(i), supportColor); - DrawPoint(point, m_cachedNodes.at(i).toQPointF(), supportColor); + VScaledEllipse *point = GetPoint(static_cast(i), Color(VColor::SupportColor)); + DrawPoint(point, m_cachedNodes.at(i).toQPointF(), Color(VColor::SupportColor)); } - if (mode == Mode::Creation) + if (GetMode() == Mode::Creation) { for (int i = 0; i < m_cachedCurvesPath.size(); ++i) { - VCurvePathItem *path = GetCurve(static_cast(i), supportColor); - DrawPath(path, m_cachedCurvesPath.at(i), supportColor); + VCurvePathItem *path = GetCurve(static_cast(i), Color(VColor::SupportColor)); + DrawPath(path, m_cachedCurvesPath.at(i), Color(VColor::SupportColor)); } - DrawLine(m_line1, QLineF(ConstFirst(m_cachedMainPathPoints), Visualization::scenePos), supportColor, + DrawLine(m_line1, QLineF(ConstFirst(m_cachedMainPathPoints), ScenePos()), Color(VColor::SupportColor), Qt::DashLine); if (m_cachedMainPathPoints.size() > 1) { - DrawLine(m_line2, QLineF(ConstLast(m_cachedMainPathPoints), Visualization::scenePos), supportColor, + DrawLine(m_line2, QLineF(ConstLast(m_cachedMainPathPoints), ScenePos()), Color(VColor::SupportColor), Qt::DashLine); } } } } +//--------------------------------------------------------------------------------------------------------------------- +void VisToolPiece::VisualMode(quint32 id) +{ + Q_UNUSED(id) + StartVisualMode(); +} + //--------------------------------------------------------------------------------------------------------------------- void VisToolPiece::SetPiece(const VPiece &piece) { @@ -108,13 +105,13 @@ void VisToolPiece::SetPiece(const VPiece &piece) } //--------------------------------------------------------------------------------------------------------------------- -VScaledEllipse *VisToolPiece::GetPoint(quint32 i, const QColor &color) +auto VisToolPiece::GetPoint(quint32 i, const QColor &color) -> VScaledEllipse * { return GetPointItem(m_points, i, color, this); } //--------------------------------------------------------------------------------------------------------------------- -VCurvePathItem *VisToolPiece::GetCurve(quint32 i, const QColor &color) +auto VisToolPiece::GetCurve(quint32 i, const QColor &color) -> VCurvePathItem * { return GetCurveItem(m_curves, i, color, this); } diff --git a/src/libs/vtools/visualization/path/vistoolpiece.h b/src/libs/vtools/visualization/path/vistoolpiece.h index d857aefe0..e5b15f789 100644 --- a/src/libs/vtools/visualization/path/vistoolpiece.h +++ b/src/libs/vtools/visualization/path/vistoolpiece.h @@ -40,29 +40,32 @@ class VisToolPiece : public VisPath { Q_OBJECT // NOLINT public: - VisToolPiece(const VContainer *data, QGraphicsItem *parent = nullptr); - virtual ~VisToolPiece() Q_DECL_EQ_DEFAULT; + explicit VisToolPiece(const VContainer *data, QGraphicsItem *parent = nullptr); + ~VisToolPiece() override = default; - virtual void RefreshGeometry() override; - void SetPiece(const VPiece &piece); - virtual int type() const override {return Type;} - enum { Type = UserType + static_cast(Vis::ToolPiece)}; + void RefreshGeometry() override; + void VisualMode(quint32 id = NULL_ID) override; + + void SetPiece(const VPiece &piece); + + auto type() const -> int override {return Type;} + enum {Type = UserType + static_cast(Vis::ToolPiece)}; private: Q_DISABLE_COPY_MOVE(VisToolPiece) // NOLINT - QVector m_points; - QVector m_curves; + QVector m_points{}; + QVector m_curves{}; - VScaledLine *m_line1; - VScaledLine *m_line2; - VPiece m_piece; - bool m_pieceCached; - QPainterPath m_cachedMainPath; - QVector m_cachedNodes; - QVector m_cachedMainPathPoints; - QVector m_cachedCurvesPath; + VScaledLine *m_line1{nullptr}; + VScaledLine *m_line2{nullptr}; + VPiece m_piece{}; + bool m_pieceCached{false}; + QPainterPath m_cachedMainPath{}; + QVector m_cachedNodes{}; + QVector m_cachedMainPathPoints{}; + QVector m_cachedCurvesPath{}; - VScaledEllipse* GetPoint(quint32 i, const QColor &color); - VCurvePathItem *GetCurve(quint32 i, const QColor &color); + auto GetPoint(quint32 i, const QColor &color) -> VScaledEllipse *; + auto GetCurve(quint32 i, const QColor &color) -> VCurvePathItem *; void HideAllItems(); }; diff --git a/src/libs/vtools/visualization/path/vistoolpiecepath.cpp b/src/libs/vtools/visualization/path/vistoolpiecepath.cpp index c810468db..6df763354 100644 --- a/src/libs/vtools/visualization/path/vistoolpiecepath.cpp +++ b/src/libs/vtools/visualization/path/vistoolpiecepath.cpp @@ -36,13 +36,9 @@ //--------------------------------------------------------------------------------------------------------------------- VisToolPiecePath::VisToolPiecePath(const VContainer *data, QGraphicsItem *parent) - : VisPath(data, parent), - m_points(), - m_line(nullptr), - m_path(), - m_cuttingPath() + : VisPath(data, parent) { - m_line = InitItem(supportColor, this); + m_line = InitItem(Color(VColor::SupportColor), this); } //--------------------------------------------------------------------------------------------------------------------- @@ -52,40 +48,35 @@ void VisToolPiecePath::RefreshGeometry() if (m_path.CountNodes() > 0) { - DrawPath(this, m_path.PainterPath(Visualization::data, m_cuttingPath), mainColor, m_path.GetPenType(), + DrawPath(this, m_path.PainterPath(GetData(), m_cuttingPath), Color(VColor::MainColor), m_path.GetPenType(), Qt::RoundCap); - const QVector nodes = m_path.PathNodePoints(Visualization::data); + const QVector nodes = m_path.PathNodePoints(GetData()); for (int i = 0; i < nodes.size(); ++i) { - VSimplePoint *point = GetPoint(static_cast(i), supportColor); + VSimplePoint *point = GetPoint(static_cast(i), Color(VColor::SupportColor)); point->RefreshPointGeometry(nodes.at(i)); // Keep first, you can hide only objects those have shape - point->SetOnlyPoint(mode == Mode::Creation); + point->SetOnlyPoint(GetMode() == Mode::Creation); point->setVisible(true); } - if (mode == Mode::Creation) + if (GetMode() == Mode::Creation) { - const QVector points = m_path.PathPoints(Visualization::data); - if (points.size() > 0) + const QVector points = m_path.PathPoints(GetData()); + if (not points.empty()) { - DrawLine(m_line, QLineF(ConstLast(points), Visualization::scenePos), supportColor, Qt::DashLine); + DrawLine(m_line, QLineF(ConstLast(points), ScenePos()), Color(VColor::SupportColor), Qt::DashLine); } } } } //--------------------------------------------------------------------------------------------------------------------- -void VisToolPiecePath::SetPath(const VPiecePath &path) +void VisToolPiecePath::VisualMode(quint32 id) { - m_path = path; -} - -//--------------------------------------------------------------------------------------------------------------------- -void VisToolPiecePath::SetCuttingPath(const QVector &cuttingPath) -{ - m_cuttingPath = cuttingPath; + Q_UNUSED(id) + StartVisualMode(); } //--------------------------------------------------------------------------------------------------------------------- @@ -95,7 +86,7 @@ void VisToolPiecePath::mousePressEvent(QGraphicsSceneMouseEvent *event) } //--------------------------------------------------------------------------------------------------------------------- -VSimplePoint *VisToolPiecePath::GetPoint(quint32 i, const QColor &color) +auto VisToolPiecePath::GetPoint(quint32 i, const QColor &color) -> VSimplePoint * { return VisPath::GetPoint(m_points, i, color); } @@ -108,7 +99,7 @@ void VisToolPiecePath::HideAllItems() m_line->setVisible(false); } - for (auto item : qAsConst(m_points)) + for (auto *item : qAsConst(m_points)) { if (item) { diff --git a/src/libs/vtools/visualization/path/vistoolpiecepath.h b/src/libs/vtools/visualization/path/vistoolpiecepath.h index 838a1a5b9..368c58771 100644 --- a/src/libs/vtools/visualization/path/vistoolpiecepath.h +++ b/src/libs/vtools/visualization/path/vistoolpiecepath.h @@ -41,30 +41,45 @@ class VisToolPiecePath : public VisPath { Q_OBJECT // NOLINT public: - VisToolPiecePath(const VContainer *data, QGraphicsItem *parent = nullptr); - virtual ~VisToolPiecePath() Q_DECL_EQ_DEFAULT; + explicit VisToolPiecePath(const VContainer *data, QGraphicsItem *parent = nullptr); + ~VisToolPiecePath() override = default; - virtual void RefreshGeometry() override; - void SetPath(const VPiecePath &path); - void SetCuttingPath(const QVector &cuttingPath); - virtual int type() const override {return Type;} - enum { Type = UserType + static_cast(Vis::ToolPiecePath)}; + void RefreshGeometry() override; + void VisualMode(quint32 id = NULL_ID) override; + + void SetPath(const VPiecePath &path); + void SetCuttingPath(const QVector &cuttingPath); + + auto type() const -> int override {return Type;} + enum {Type = UserType + static_cast(Vis::ToolPiecePath)}; protected: - virtual void mousePressEvent( QGraphicsSceneMouseEvent * event ) override; + void mousePressEvent( QGraphicsSceneMouseEvent * event ) override; private: Q_DISABLE_COPY_MOVE(VisToolPiecePath) // NOLINT - QVector m_points; + QVector m_points{}; - VScaledLine *m_line; + VScaledLine *m_line{nullptr}; - VPiecePath m_path; + VPiecePath m_path{}; - QVector m_cuttingPath; + QVector m_cuttingPath{}; - VSimplePoint *GetPoint(quint32 i, const QColor &color); + auto GetPoint(quint32 i, const QColor &color) -> VSimplePoint *; void HideAllItems(); }; +//--------------------------------------------------------------------------------------------------------------------- +inline void VisToolPiecePath::SetPath(const VPiecePath &path) +{ + m_path = path; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline void VisToolPiecePath::SetCuttingPath(const QVector &cuttingPath) +{ + m_cuttingPath = cuttingPath; +} + #endif // VISTOOLPIECEPATH_H diff --git a/src/libs/vtools/visualization/path/vistoolpointofintersectioncurves.cpp b/src/libs/vtools/visualization/path/vistoolpointofintersectioncurves.cpp index c2383eb62..8d570ffbd 100644 --- a/src/libs/vtools/visualization/path/vistoolpointofintersectioncurves.cpp +++ b/src/libs/vtools/visualization/path/vistoolpointofintersectioncurves.cpp @@ -36,77 +36,46 @@ #include #include "../../tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncurves.h" -#include "../ifc/ifcdef.h" #include "../vgeometry/vabstractcurve.h" -#include "../vmisc/vabstractapplication.h" #include "../vpatterndb/vcontainer.h" -#include "../vwidgets/vmaingraphicsscene.h" #include "../vwidgets/scalesceneitems.h" #include "../visualization.h" #include "visualization/path/vispath.h" //--------------------------------------------------------------------------------------------------------------------- VisToolPointOfIntersectionCurves::VisToolPointOfIntersectionCurves(const VContainer *data, QGraphicsItem *parent) - :VisPath(data, parent), - object2Id(NULL_ID), - vCrossPoint(VCrossCurvesPoint::HighestPoint), - hCrossPoint(HCrossCurvesPoint::LeftmostPoint), - point(nullptr), - visCurve2(nullptr) + :VisPath(data, parent) { - visCurve2 = InitItem(supportColor, this); - point = InitPoint(mainColor, this); + m_visCurve2 = InitItem(Color(VColor::SupportColor), this); + m_point = InitPoint(Color(VColor::MainColor), this); } //--------------------------------------------------------------------------------------------------------------------- void VisToolPointOfIntersectionCurves::RefreshGeometry() { - if (object1Id > NULL_ID) + if (m_curve1Id > NULL_ID) { - auto curve1 = Visualization::data->GeometricObject(object1Id); - DrawPath(this, curve1->GetPath(), curve1->DirectionArrows(), supportColor, Qt::SolidLine, Qt::RoundCap); + auto curve1 = GetData()->GeometricObject(m_curve1Id); + DrawPath(this, curve1->GetPath(), curve1->DirectionArrows(), Color(VColor::SupportColor), Qt::SolidLine, + Qt::RoundCap); - if (object2Id > NULL_ID) + if (m_curve2Id > NULL_ID) { - auto curve2 = Visualization::data->GeometricObject(object2Id); - DrawPath(visCurve2, curve2->GetPath(), curve2->DirectionArrows(), supportColor, Qt::SolidLine, - Qt::RoundCap); + auto curve2 = GetData()->GeometricObject(m_curve2Id); + DrawPath(m_visCurve2, curve2->GetPath(), curve2->DirectionArrows(), Color(VColor::SupportColor), + Qt::SolidLine, Qt::RoundCap); QPointF p; - VToolPointOfIntersectionCurves::FindPoint(curve1->GetPoints(), curve2->GetPoints(), vCrossPoint, - hCrossPoint, &p); - DrawPoint(point, p, mainColor); + VToolPointOfIntersectionCurves::FindPoint(curve1->GetPoints(), curve2->GetPoints(), m_vCrossPoint, + m_hCrossPoint, &p); + DrawPoint(m_point, p, Color(VColor::MainColor)); } } } //--------------------------------------------------------------------------------------------------------------------- -void VisToolPointOfIntersectionCurves::VisualMode(const quint32 &id) +void VisToolPointOfIntersectionCurves::VisualMode(quint32 id) { - auto scene = qobject_cast(VAbstractValApplication::VApp()->getCurrentScene()); - SCASSERT(scene != nullptr) - - this->object1Id = id; - Visualization::scenePos = scene->getScenePos(); - RefreshGeometry(); - - AddOnScene(); -} - -//--------------------------------------------------------------------------------------------------------------------- -void VisToolPointOfIntersectionCurves::setObject2Id(const quint32 &value) -{ - object2Id = value; -} - -//--------------------------------------------------------------------------------------------------------------------- -void VisToolPointOfIntersectionCurves::setVCrossPoint(const VCrossCurvesPoint &value) -{ - vCrossPoint = value; -} - -//--------------------------------------------------------------------------------------------------------------------- -void VisToolPointOfIntersectionCurves::setHCrossPoint(const HCrossCurvesPoint &value) -{ - hCrossPoint = value; + m_curve1Id = id; + StartVisualMode(); } diff --git a/src/libs/vtools/visualization/path/vistoolpointofintersectioncurves.h b/src/libs/vtools/visualization/path/vistoolpointofintersectioncurves.h index 86a1d8ec7..a450538e3 100644 --- a/src/libs/vtools/visualization/path/vistoolpointofintersectioncurves.h +++ b/src/libs/vtools/visualization/path/vistoolpointofintersectioncurves.h @@ -45,25 +45,50 @@ class VisToolPointOfIntersectionCurves : public VisPath Q_OBJECT // NOLINT public: explicit VisToolPointOfIntersectionCurves(const VContainer *data, QGraphicsItem *parent = nullptr); - virtual ~VisToolPointOfIntersectionCurves() Q_DECL_EQ_DEFAULT; + ~VisToolPointOfIntersectionCurves() override = default; - virtual void RefreshGeometry() override; - virtual void VisualMode(const quint32 &id) override; + void RefreshGeometry() override; + void VisualMode(quint32 id) override; - void setObject2Id(const quint32 &value); - void setVCrossPoint(const VCrossCurvesPoint &value); - void setHCrossPoint(const HCrossCurvesPoint &value); + void SetCurve1Id(quint32 value); + void SetCurve2Id(quint32 value); + void SetVCrossPoint(VCrossCurvesPoint value); + void SetHCrossPoint(HCrossCurvesPoint value); - virtual int type() const override {return Type;} - enum { Type = UserType + static_cast(Vis::ToolPointOfIntersectionCurves)}; + auto type() const -> int override {return Type;} + enum {Type = UserType + static_cast(Vis::ToolPointOfIntersectionCurves)}; private: Q_DISABLE_COPY_MOVE(VisToolPointOfIntersectionCurves) // NOLINT - quint32 object2Id; - VCrossCurvesPoint vCrossPoint; - HCrossCurvesPoint hCrossPoint; - VScaledEllipse *point; - VCurvePathItem *visCurve2; - + quint32 m_curve1Id{NULL_ID}; + quint32 m_curve2Id{NULL_ID}; + VCrossCurvesPoint m_vCrossPoint{VCrossCurvesPoint::HighestPoint}; + HCrossCurvesPoint m_hCrossPoint{HCrossCurvesPoint::LeftmostPoint}; + VScaledEllipse *m_point{nullptr}; + VCurvePathItem *m_visCurve2{nullptr}; }; +//--------------------------------------------------------------------------------------------------------------------- +inline void VisToolPointOfIntersectionCurves::SetCurve1Id(quint32 value) +{ + m_curve1Id = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline void VisToolPointOfIntersectionCurves::SetCurve2Id(quint32 value) +{ + m_curve2Id = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline void VisToolPointOfIntersectionCurves::SetVCrossPoint(VCrossCurvesPoint value) +{ + m_vCrossPoint = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline void VisToolPointOfIntersectionCurves::SetHCrossPoint(HCrossCurvesPoint value) +{ + m_hCrossPoint = value; +} + #endif // VISTOOLPOINTOFINTERSECTIONCURVES_H diff --git a/src/libs/vtools/visualization/path/vistoolspline.cpp b/src/libs/vtools/visualization/path/vistoolspline.cpp index c9ba2905c..bc554c564 100644 --- a/src/libs/vtools/visualization/path/vistoolspline.cpp +++ b/src/libs/vtools/visualization/path/vistoolspline.cpp @@ -62,8 +62,8 @@ VisToolSpline::VisToolSpline(const VContainer *data, QGraphicsItem *parent) m_angle1(EMPTY_ANGLE), m_angle2(EMPTY_ANGLE) { - m_point1 = InitPoint(supportColor, this); - m_point4 = InitPoint(supportColor, this); //-V656 + m_point1 = InitPoint(Color(VColor::SupportColor), this); + m_point4 = InitPoint(Color(VColor::SupportColor), this); //-V656 auto *controlPoint1 = new VControlPointSpline(1, SplinePointPosition::FirstPoint, this); controlPoint1->hide(); @@ -83,28 +83,28 @@ VisToolSpline::~VisToolSpline() //--------------------------------------------------------------------------------------------------------------------- void VisToolSpline::RefreshGeometry() { - if (object1Id > NULL_ID) + if (m_point1Id > NULL_ID) { - const auto first = Visualization::data->GeometricObject(object1Id); - DrawPoint(m_point1, static_cast(*first), supportColor); + const auto first = GetData()->GeometricObject(m_point1Id); + DrawPoint(m_point1, static_cast(*first), Color(VColor::SupportColor)); - if (mode == Mode::Creation) + if (GetMode() == Mode::Creation) { DragFirstControlPoint(static_cast(*first)); } - if (m_object4Id <= NULL_ID) + if (m_point4Id <= NULL_ID) { - VSpline spline(*first, m_p2, Visualization::scenePos, VPointF(Visualization::scenePos)); - spline.SetApproximationScale(m_approximationScale); - DrawPath(this, spline.GetPath(), mainColor, lineStyle, Qt::RoundCap); + VSpline spline(*first, m_p2, ScenePos(), VPointF(ScenePos())); + spline.SetApproximationScale(ApproximationScale()); + DrawPath(this, spline.GetPath(), Color(VColor::MainColor), LineStyle(), Qt::RoundCap); } else { - const auto second = Visualization::data->GeometricObject(m_object4Id); - DrawPoint(m_point4, static_cast(*second), supportColor); + const auto second = GetData()->GeometricObject(m_point4Id); + DrawPoint(m_point4, static_cast(*second), Color(VColor::SupportColor)); - if (mode == Mode::Creation) + if (GetMode() == Mode::Creation) { DragLastControlPoint(static_cast(*second)); } @@ -112,74 +112,33 @@ void VisToolSpline::RefreshGeometry() if (VFuzzyComparePossibleNulls(m_angle1, EMPTY_ANGLE) || VFuzzyComparePossibleNulls(m_angle2, EMPTY_ANGLE)) { VSpline spline(*first, m_p2, m_p3, *second); - spline.SetApproximationScale(m_approximationScale); - DrawPath(this, spline.GetPath(), mainColor, lineStyle, Qt::RoundCap); + spline.SetApproximationScale(ApproximationScale()); + DrawPath(this, spline.GetPath(), Color(VColor::MainColor), LineStyle(), Qt::RoundCap); } else { VSpline spline(*first, *second, m_angle1, m_angle2, m_kAsm1, m_kAsm2, m_kCurve); - spline.SetApproximationScale(m_approximationScale); - DrawPath(this, spline.GetPath(), spline.DirectionArrows(), mainColor, lineStyle, Qt::RoundCap); - Visualization::toolTip = tr("Use %1 for sticking angle!") - .arg(VModifierKey::Shift()); - emit ToolTip(Visualization::toolTip); + spline.SetApproximationScale(ApproximationScale()); + DrawPath(this, spline.GetPath(), spline.DirectionArrows(), Color(VColor::MainColor), LineStyle(), + Qt::RoundCap); + SetToolTip(tr("Use %1 for sticking angle!").arg(VModifierKey::Shift())); + emit ToolTip(CurrentToolTip()); } } } } //--------------------------------------------------------------------------------------------------------------------- -void VisToolSpline::SetObject4Id(quint32 value) +void VisToolSpline::VisualMode(quint32 id) { - m_object4Id = value; -} - -//--------------------------------------------------------------------------------------------------------------------- -void VisToolSpline::SetAngle1(qreal value) -{ - m_angle1 = value; -} - -//--------------------------------------------------------------------------------------------------------------------- -void VisToolSpline::SetAngle2(qreal value) -{ - m_angle2 = value; -} - -//--------------------------------------------------------------------------------------------------------------------- -void VisToolSpline::SetKAsm1(qreal value) -{ - m_kAsm1 = value; -} - -//--------------------------------------------------------------------------------------------------------------------- -void VisToolSpline::SetKAsm2(qreal value) -{ - m_kAsm2 = value; -} - -//--------------------------------------------------------------------------------------------------------------------- -void VisToolSpline::SetKCurve(qreal value) -{ - m_kCurve = value; -} - -//--------------------------------------------------------------------------------------------------------------------- -auto VisToolSpline::GetP2() const -> QPointF -{ - return m_p2; -} - -//--------------------------------------------------------------------------------------------------------------------- -auto VisToolSpline::GetP3() const -> QPointF -{ - return m_p3; + m_point1Id = id; + StartVisualMode(); } //--------------------------------------------------------------------------------------------------------------------- void VisToolSpline::MouseLeftPressed() { - if (mode == Mode::Creation) + if (GetMode() == Mode::Creation) { m_isLeftMousePressed = true; } @@ -188,7 +147,7 @@ void VisToolSpline::MouseLeftPressed() //--------------------------------------------------------------------------------------------------------------------- void VisToolSpline::MouseLeftReleased() { - if (mode == Mode::Creation) + if (GetMode() == Mode::Creation) { m_isLeftMousePressed = false; RefreshGeometry(); @@ -200,7 +159,7 @@ void VisToolSpline::DragFirstControlPoint(const QPointF &point) { if (m_isLeftMousePressed && not m_p2Selected) { - m_p2 = Visualization::scenePos; + m_p2 = ScenePos(); m_controlPoints.at(0)->RefreshCtrlPoint(1, SplinePointPosition::FirstPoint, m_p2, point); if (not m_controlPoints.at(0)->isVisible()) @@ -226,7 +185,7 @@ void VisToolSpline::DragLastControlPoint(const QPointF &point) { if (m_isLeftMousePressed && not m_p3Selected) { - m_p3 = Visualization::scenePos; + m_p3 = ScenePos(); m_controlPoints.at(1)->RefreshCtrlPoint(1, SplinePointPosition::LastPoint, m_p3, point); if (not m_controlPoints.at(1)->isVisible()) diff --git a/src/libs/vtools/visualization/path/vistoolspline.h b/src/libs/vtools/visualization/path/vistoolspline.h index 4fee2f43d..b52b37c9f 100644 --- a/src/libs/vtools/visualization/path/vistoolspline.h +++ b/src/libs/vtools/visualization/path/vistoolspline.h @@ -55,8 +55,10 @@ public: ~VisToolSpline() override; void RefreshGeometry() override; + void VisualMode(quint32 id) override; - void SetObject4Id(quint32 value); + void SetPoint1Id(quint32 value); + void SetPoint4Id(quint32 value); void SetAngle1(qreal value); void SetAngle2(qreal value); void SetKAsm1(qreal value); @@ -67,14 +69,15 @@ public: auto GetP3() const -> QPointF; auto type() const -> int override {return Type;} - enum { Type = UserType + static_cast(Vis::ToolSpline)}; + enum {Type = UserType + static_cast(Vis::ToolSpline)}; public slots: void MouseLeftPressed(); void MouseLeftReleased(); private: Q_DISABLE_COPY_MOVE(VisToolSpline) // NOLINT - quint32 m_object4Id{NULL_ID}; + quint32 m_point1Id{NULL_ID}; + quint32 m_point4Id{NULL_ID}; VScaledEllipse *m_point1{nullptr}; VScaledEllipse *m_point4{nullptr}; qreal m_angle1; @@ -96,4 +99,58 @@ private: void DragLastControlPoint(const QPointF &point); }; +//--------------------------------------------------------------------------------------------------------------------- +inline void VisToolSpline::SetPoint1Id(quint32 value) +{ + m_point1Id = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline void VisToolSpline::SetPoint4Id(quint32 value) +{ + m_point4Id = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline void VisToolSpline::SetAngle1(qreal value) +{ + m_angle1 = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline void VisToolSpline::SetAngle2(qreal value) +{ + m_angle2 = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline void VisToolSpline::SetKAsm1(qreal value) +{ + m_kAsm1 = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline void VisToolSpline::SetKAsm2(qreal value) +{ + m_kAsm2 = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline void VisToolSpline::SetKCurve(qreal value) +{ + m_kCurve = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline auto VisToolSpline::GetP2() const -> QPointF +{ + return m_p2; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline auto VisToolSpline::GetP3() const -> QPointF +{ + return m_p3; +} + #endif // VISTOOLSPLINE_H diff --git a/src/libs/vtools/visualization/path/vistoolsplinepath.cpp b/src/libs/vtools/visualization/path/vistoolsplinepath.cpp index 31f07c0fb..6a6cb4525 100644 --- a/src/libs/vtools/visualization/path/vistoolsplinepath.cpp +++ b/src/libs/vtools/visualization/path/vistoolsplinepath.cpp @@ -60,7 +60,7 @@ inline auto TriggerRadius() -> qreal VisToolSplinePath::VisToolSplinePath(const VContainer *data, QGraphicsItem *parent) : VisPath(data, parent) { - m_newCurveSegment = InitItem(mainColor, this); + m_newCurveSegment = InitItem(Color(VColor::MainColor), this); } //--------------------------------------------------------------------------------------------------------------------- @@ -83,10 +83,10 @@ void VisToolSplinePath::RefreshGeometry() for (int i = 0; i < size; ++i) { VScaledEllipse *point = GetPoint(static_cast(i)); - DrawPoint(point, static_cast(pathPoints.at(i).P()), supportColor); + DrawPoint(point, static_cast(pathPoints.at(i).P()), Color(VColor::SupportColor)); } - if (mode == Mode::Creation) + if (GetMode() == Mode::Creation) { if (size > 1) { @@ -111,50 +111,42 @@ void VisToolSplinePath::RefreshGeometry() if (size == 1) { - VSpline spline(pathPoints.at(0).P(), m_ctrlPoint, Visualization::scenePos, VPointF(Visualization::scenePos)); - spline.SetApproximationScale(m_approximationScale); - DrawPath(this, spline.GetPath(), mainColor, lineStyle, Qt::RoundCap); + VSpline spline(pathPoints.at(0).P(), m_ctrlPoint, ScenePos(), VPointF(ScenePos())); + spline.SetApproximationScale(ApproximationScale()); + DrawPath(this, spline.GetPath(), Color(VColor::MainColor), LineStyle(), Qt::RoundCap); } else if (size > 1) { - DrawPath(this, m_path.GetPath(), m_path.DirectionArrows(), mainColor, lineStyle, Qt::RoundCap); + DrawPath(this, m_path.GetPath(), m_path.DirectionArrows(), Color(VColor::MainColor), LineStyle(), Qt::RoundCap); } if (m_path.CountPoints() < 3) { - Visualization::toolTip = tr("Curved path: select three or more points"); + SetToolTip(tr("Curved path: select three or more points")); } else { - Visualization::toolTip = tr("Curved path: select three or more points, " - "%1 - finish creation") - .arg(VModifierKey::EnterKey()); + SetToolTip(tr("Curved path: select three or more points, " + "%1 - finish creation").arg(VModifierKey::EnterKey())); } - if (mode == Mode::Show) + if (GetMode() == Mode::Show) { - Visualization::toolTip = tr("Use %1 for sticking angle!") - .arg(VModifierKey::Shift()); - emit ToolTip(Visualization::toolTip); + SetToolTip(tr("Use %1 for sticking angle!").arg(VModifierKey::Shift())); + emit ToolTip(CurrentToolTip()); } } //--------------------------------------------------------------------------------------------------------------------- -void VisToolSplinePath::SetPath(const VSplinePath &value) +void VisToolSplinePath::VisualMode(quint32 id) { - m_path = value; -} - -//--------------------------------------------------------------------------------------------------------------------- -// cppcheck-suppress unusedFunction -auto VisToolSplinePath::GetPath() -> VSplinePath -{ - return m_path; + Q_UNUSED(id) + StartVisualMode(); } //--------------------------------------------------------------------------------------------------------------------- void VisToolSplinePath::MouseLeftPressed() { - if (mode == Mode::Creation) + if (GetMode() == Mode::Creation) { m_isLeftMousePressed = true; } @@ -163,7 +155,7 @@ void VisToolSplinePath::MouseLeftPressed() //--------------------------------------------------------------------------------------------------------------------- void VisToolSplinePath::MouseLeftReleased() { - if (mode == Mode::Creation) + if (GetMode() == Mode::Creation) { m_isLeftMousePressed = false; RefreshGeometry(); @@ -180,7 +172,7 @@ auto VisToolSplinePath::GetPoint(quint32 i) -> VScaledEllipse * m_pointSelected = false; - auto *point = InitPoint(supportColor, this); + auto *point = InitPoint(Color(VColor::SupportColor), this); m_points.append(point); if (m_points.size() == 1) @@ -227,7 +219,7 @@ void VisToolSplinePath::DragControlPoint(int lastPoint, int preLastPoint, const } } - QLineF ctrlLine (pSpl, Visualization::scenePos); + QLineF ctrlLine (pSpl, ScenePos()); ctrlLine.setAngle(ctrlLine.angle()+180); if (size == 1) @@ -240,7 +232,7 @@ void VisToolSplinePath::DragControlPoint(int lastPoint, int preLastPoint, const m_ctrlPoints.at(lastPoint)->RefreshCtrlPoint(size, SplinePointPosition::FirstPoint, m_ctrlPoint, pSpl); } - VSpline spline(VPointF(pSpl), m_ctrlPoint, Visualization::scenePos, VPointF(Visualization::scenePos)); + VSpline spline(VPointF(pSpl), m_ctrlPoint, ScenePos(), VPointF(ScenePos())); if (size == 1) { @@ -265,7 +257,7 @@ void VisToolSplinePath::DragControlPoint(int lastPoint, int preLastPoint, const emit PathChanged(m_path); } - DrawPath(m_newCurveSegment, spline.GetPath(), mainColor, Qt::SolidLine, Qt::RoundCap); + DrawPath(m_newCurveSegment, spline.GetPath(), Color(VColor::MainColor), Qt::SolidLine, Qt::RoundCap); } //--------------------------------------------------------------------------------------------------------------------- @@ -299,7 +291,7 @@ void VisToolSplinePath::Creating(const QPointF &pSpl, int size) if (m_isLeftMousePressed && not m_pointSelected) { m_newCurveSegment->hide(); - m_ctrlPoint = Visualization::scenePos; + m_ctrlPoint = ScenePos(); DragControlPoint(lastPoint, preLastPoint, pSpl, size); } @@ -307,8 +299,8 @@ void VisToolSplinePath::Creating(const QPointF &pSpl, int size) { m_pointSelected = true; - VSpline spline(VPointF(pSpl), m_ctrlPoint, Visualization::scenePos, VPointF(Visualization::scenePos)); + VSpline spline(VPointF(pSpl), m_ctrlPoint, ScenePos(), VPointF(ScenePos())); NewCurveSegment(spline, pSpl, size); - DrawPath(m_newCurveSegment, spline.GetPath(), mainColor, Qt::SolidLine, Qt::RoundCap); + DrawPath(m_newCurveSegment, spline.GetPath(), Color(VColor::MainColor), Qt::SolidLine, Qt::RoundCap); } } diff --git a/src/libs/vtools/visualization/path/vistoolsplinepath.h b/src/libs/vtools/visualization/path/vistoolsplinepath.h index dbc670ace..1ea846e63 100644 --- a/src/libs/vtools/visualization/path/vistoolsplinepath.h +++ b/src/libs/vtools/visualization/path/vistoolsplinepath.h @@ -56,12 +56,13 @@ public: ~VisToolSplinePath() override; void RefreshGeometry() override; + void VisualMode(quint32 id) override; void SetPath(const VSplinePath &value); auto GetPath() -> VSplinePath; auto type() const -> int override {return Type;} - enum { Type = UserType + static_cast(Vis::ToolSplinePath)}; + enum {Type = UserType + static_cast(Vis::ToolSplinePath)}; signals: void PathChanged(const VSplinePath &path); @@ -87,4 +88,16 @@ private: void Creating(const QPointF &pSpl, int size); }; +//--------------------------------------------------------------------------------------------------------------------- +inline void VisToolSplinePath::SetPath(const VSplinePath &value) +{ + m_path = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline auto VisToolSplinePath::GetPath() -> VSplinePath +{ + return m_path; +} + #endif // VISTOOLSPLINEPATH_H diff --git a/src/libs/vtools/visualization/visualization.cpp b/src/libs/vtools/visualization/visualization.cpp index a2dff1123..c37c16d38 100644 --- a/src/libs/vtools/visualization/visualization.cpp +++ b/src/libs/vtools/visualization/visualization.cpp @@ -67,9 +67,9 @@ QT_WARNING_POP namespace { //--------------------------------------------------------------------------------------------------------------------- -VScaledEllipse *InitPointItem(const QColor &color, QGraphicsItem *parent, qreal z = 0) +auto InitPointItem(const QColor &color, QGraphicsItem *parent, qreal z = 0) -> VScaledEllipse * { - VScaledEllipse *point = new VScaledEllipse(parent); + auto *point = new VScaledEllipse(parent); point->setZValue(1); point->setBrush(QBrush(Qt::NoBrush)); @@ -86,9 +86,9 @@ VScaledEllipse *InitPointItem(const QColor &color, QGraphicsItem *parent, qreal } //--------------------------------------------------------------------------------------------------------------------- -VCurvePathItem *InitCurveItem(const QColor &color, QGraphicsItem *parent, qreal z = 0) +auto InitCurveItem(const QColor &color, QGraphicsItem *parent, qreal z = 0) -> VCurvePathItem * { - VCurvePathItem *curve = new VCurvePathItem(parent); + auto *curve = new VCurvePathItem(parent); curve->setBrush(QBrush(Qt::NoBrush)); QPen visPen = curve->pen(); @@ -100,98 +100,66 @@ VCurvePathItem *InitCurveItem(const QColor &color, QGraphicsItem *parent, qreal curve->setVisible(false); return curve; } -} +} // namespace //--------------------------------------------------------------------------------------------------------------------- Visualization::Visualization(const VContainer *data) - :QObject(), - data(data), - scenePos(QPointF()), - mainColor(Qt::red), - supportColor(Qt::magenta), - lineStyle(Qt::SolidLine), - object1Id(NULL_ID), - toolTip(QString()), - mode(Mode::Creation) + :m_data(data) {} //--------------------------------------------------------------------------------------------------------------------- -void Visualization::setObject1Id(const quint32 &value) +void Visualization::SetLineStyle(const Qt::PenStyle &value) { - object1Id = value; -} - -//--------------------------------------------------------------------------------------------------------------------- -void Visualization::setLineStyle(const Qt::PenStyle &value) -{ - lineStyle = value; + m_lineStyle = value; InitPen(); } //--------------------------------------------------------------------------------------------------------------------- // cppcheck-suppress unusedFunction -void Visualization::setScenePos(const QPointF &value) +void Visualization::SetMainColor(const QColor &value) { - scenePos = value; + SetColor(VColor::MainColor, value); + InitPen(); } //--------------------------------------------------------------------------------------------------------------------- -void Visualization::VisualMode(const quint32 &pointId) +void Visualization::StartVisualMode() { - VMainGraphicsScene *scene = qobject_cast(VAbstractValApplication::VApp()->getCurrentScene()); + auto *scene = qobject_cast(VAbstractValApplication::VApp()->getCurrentScene()); SCASSERT(scene != nullptr) - this->object1Id = pointId; - this->scenePos = scene->getScenePos(); + this->m_scenePos = scene->getScenePos(); RefreshGeometry(); AddOnScene(); } -//--------------------------------------------------------------------------------------------------------------------- -// cppcheck-suppress unusedFunction -void Visualization::setMainColor(const QColor &value) -{ - mainColor = value; - InitPen(); -} - -//--------------------------------------------------------------------------------------------------------------------- -const VContainer *Visualization::GetData() const -{ - return data; -} - -//--------------------------------------------------------------------------------------------------------------------- -void Visualization::SetData(const VContainer *data) -{ - this->data = data; -} - //--------------------------------------------------------------------------------------------------------------------- void Visualization::MousePos(const QPointF &scenePos) { - this->scenePos = scenePos; + this->m_scenePos = scenePos; RefreshGeometry(); RefreshToolTip(); } //--------------------------------------------------------------------------------------------------------------------- -VScaledEllipse *Visualization::InitPoint(const QColor &color, QGraphicsItem *parent, qreal z) const +auto Visualization::InitPoint(const QColor &color, QGraphicsItem *parent, qreal z) -> VScaledEllipse * { return InitPointItem(color, parent, z); } //--------------------------------------------------------------------------------------------------------------------- -qreal Visualization::FindLengthFromUser(const QString &expression, - const QHash > *vars, bool fromUser) +auto Visualization::FindLengthFromUser(const QString &expression, + const QHash > *vars, + bool fromUser) -> qreal { return VAbstractValApplication::VApp()->toPixel(FindValFromUser(expression, vars, fromUser)); } //--------------------------------------------------------------------------------------------------------------------- -qreal Visualization::FindValFromUser(const QString &expression, - const QHash > *vars, bool fromUser) +auto Visualization::FindValFromUser(const QString &expression, + const QHash > *vars, + bool fromUser) -> qreal { qreal val = 0; if (expression.isEmpty()) @@ -234,9 +202,9 @@ qreal Visualization::FindValFromUser(const QString &expression, //--------------------------------------------------------------------------------------------------------------------- void Visualization::RefreshToolTip() const { - if (!toolTip.isEmpty()) + if (!m_toolTip.isEmpty()) { - emit ToolTip(toolTip); + emit ToolTip(m_toolTip); } } @@ -299,39 +267,35 @@ void Visualization::DrawPath(VCurvePathItem *pathItem, const QPainterPath &path, } //--------------------------------------------------------------------------------------------------------------------- -VScaledEllipse *Visualization::GetPointItem(QVector &points, quint32 i, - const QColor &color, QGraphicsItem *parent) +auto Visualization::GetPointItem(QVector &points, quint32 i, const QColor &color, + QGraphicsItem *parent) -> VScaledEllipse * { if (not points.isEmpty() && static_cast(points.size() - 1) >= i) { return points.at(static_cast(i)); } - else - { - auto point = InitPointItem(color, parent); - points.append(point); - return point; - } + + auto *point = InitPointItem(color, parent); + points.append(point); + return point; } //--------------------------------------------------------------------------------------------------------------------- -VCurvePathItem *Visualization::GetCurveItem(QVector &curves, quint32 i, const QColor &color, - QGraphicsItem *parent) +auto Visualization::GetCurveItem(QVector &curves, quint32 i, const QColor &color, + QGraphicsItem *parent) -> VCurvePathItem * { if (not curves.isEmpty() && static_cast(curves.size() - 1) >= i) { return curves.at(static_cast(i)); } - else - { - auto point = InitCurveItem(color, parent); - curves.append(point); - return point; - } + + auto *point = InitCurveItem(color, parent); + curves.append(point); + return point; } //--------------------------------------------------------------------------------------------------------------------- -QString Visualization::NumberToUser(qreal value) +auto Visualization::NumberToUser(qreal value) -> QString { return VAbstractApplication::VApp()->TrVars() ->FormulaToUser(QString::number(VAbstractValApplication::VApp()->fromPixel(value)), @@ -339,13 +303,13 @@ QString Visualization::NumberToUser(qreal value) } //--------------------------------------------------------------------------------------------------------------------- -Mode Visualization::GetMode() const +void Visualization::SetColor(VColor type, const QColor& color) { - return mode; + m_colorShema.insert(type, color); } //--------------------------------------------------------------------------------------------------------------------- -void Visualization::SetMode(const Mode &value) +auto Visualization::Color(VColor type) const -> QColor { - mode = value; + return m_colorShema.value(type, Qt::black); } diff --git a/src/libs/vtools/visualization/visualization.h b/src/libs/vtools/visualization/visualization.h index 514283b2c..1fb687db1 100644 --- a/src/libs/vtools/visualization/visualization.h +++ b/src/libs/vtools/visualization/visualization.h @@ -41,7 +41,7 @@ #include "../vwidgets/vcurvepathitem.h" #include "../vgeometry/vabstractcurve.h" -Q_DECLARE_LOGGING_CATEGORY(vVis) +Q_DECLARE_LOGGING_CATEGORY(vVis) // NOLINT class VScaledEllipse; class VScaledLine; @@ -50,6 +50,13 @@ class VInternalVariable; enum class Mode : qint8 {Creation, Show}; +enum class VColor : qint8 {MainColor, SupportColor, SupportColor2, SupportColor3}; + +inline auto qHash(VColor key) noexcept -> size_t +{ + return ::qHash(static_cast(key)); +} + QT_WARNING_PUSH QT_WARNING_DISABLE_GCC("-Wsuggest-final-types") QT_WARNING_DISABLE_GCC("-Wsuggest-final-methods") @@ -59,72 +66,81 @@ class Visualization : public QObject Q_OBJECT // NOLINT public: explicit Visualization(const VContainer *data); - virtual ~Visualization() Q_DECL_EQ_DEFAULT; + ~Visualization() override = default; virtual void RefreshGeometry()=0; + virtual void VisualMode(quint32 id)=0; - void setObject1Id(const quint32 &value); - void setLineStyle(const Qt::PenStyle &value); - void setScenePos(const QPointF &value); - virtual void VisualMode(const quint32 &pointId); - void setMainColor(const QColor &value); + void SetLineStyle(const Qt::PenStyle &value); + auto LineStyle() const -> Qt::PenStyle; - const VContainer *GetData() const; - void SetData(const VContainer *data); + auto GetData() const -> const VContainer *; + void SetData(const VContainer *data); - Mode GetMode() const; + auto GetMode() const -> Mode; void SetMode(const Mode &value); - static qreal FindLengthFromUser(const QString &expression, const QHash > *vars, bool fromUser = true); - static qreal FindValFromUser(const QString &expression, const QHash > *vars, bool fromUser = true); + static auto FindLengthFromUser(const QString &expression, const QHash > *vars, bool fromUser = true) -> qreal; + static auto FindValFromUser(const QString &expression, const QHash > *vars, bool fromUser = true) -> qreal; - QString CurrentToolTip() const {return toolTip;} + auto CurrentToolTip() const -> QString; void RefreshToolTip() const; signals: - void ToolTip(const QString &toolTip) const; + void ToolTip(const QString &toolTip) const; // clazy:exclude=const-signal-or-slot public slots: - void MousePos(const QPointF &scenePos); + void MousePos(const QPointF &scenePos); protected: - const VContainer *data; - QPointF scenePos; - QColor mainColor; - QColor supportColor; - Qt::PenStyle lineStyle; - quint32 object1Id; - QString toolTip; - Mode mode; - virtual void InitPen()=0; virtual void AddOnScene()=0; - VScaledEllipse *InitPoint(const QColor &color, QGraphicsItem *parent, qreal z = 0) const; - void DrawPoint(QGraphicsEllipseItem *point, const QPointF &pos, const QColor &color, - Qt::PenStyle style = Qt::SolidLine); + static auto InitPoint(const QColor &color, QGraphicsItem *parent, qreal z = 0) -> VScaledEllipse *; + static void DrawPoint(QGraphicsEllipseItem *point, const QPointF &pos, const QColor &color, + Qt::PenStyle style = Qt::SolidLine); virtual void DrawLine(VScaledLine *lineItem, const QLineF &line, const QColor &color, Qt::PenStyle style = Qt::SolidLine); - void DrawPath(VCurvePathItem *pathItem, const QPainterPath &path, const QColor &color, - Qt::PenStyle style = Qt::SolidLine, Qt::PenCapStyle cap = Qt::SquareCap); - void DrawPath(VCurvePathItem *pathItem, const QPainterPath &path, - const QVector &directionArrows, const QColor &color, - Qt::PenStyle style = Qt::SolidLine, Qt::PenCapStyle cap = Qt::SquareCap); + static void DrawPath(VCurvePathItem *pathItem, const QPainterPath &path, const QColor &color, + Qt::PenStyle style = Qt::SolidLine, Qt::PenCapStyle cap = Qt::SquareCap); + static void DrawPath(VCurvePathItem *pathItem, const QPainterPath &path, + const QVector &directionArrows, + const QColor &color, Qt::PenStyle style = Qt::SolidLine, Qt::PenCapStyle cap = Qt::SquareCap); template - void AddItem(Item *item); + void AddItem(Item *item); template - Item *InitItem(const QColor &color, QGraphicsItem *parent); + auto InitItem(const QColor &color, QGraphicsItem *parent) -> Item *; - static VScaledEllipse *GetPointItem(QVector &points, quint32 i, const QColor &color, - QGraphicsItem *parent); - static VCurvePathItem *GetCurveItem(QVector &curves, quint32 i, const QColor &color, - QGraphicsItem *parent); + static auto GetPointItem(QVector &points, quint32 i, const QColor &color, + QGraphicsItem *parent) -> VScaledEllipse *; + static auto GetCurveItem(QVector &curves, quint32 i, const QColor &color, + QGraphicsItem *parent) -> VCurvePathItem *; static auto NumberToUser(qreal value) -> QString; + + void SetColor(VColor type, const QColor& color); + + auto Color(VColor type) const -> QColor; + + void SetScenePos(QPointF pos); + auto ScenePos() const -> QPointF; + + void SetMainColor(const QColor &value); + + void SetToolTip(const QString &tooltip); + + void StartVisualMode(); private: Q_DISABLE_COPY_MOVE(Visualization) // NOLINT + + const VContainer *m_data; + QPointF m_scenePos{}; + Qt::PenStyle m_lineStyle{Qt::SolidLine}; + QString m_toolTip{}; + Mode m_mode{Mode::Creation}; + QHash m_colorShema{{VColor::MainColor, Qt::red}, {VColor::SupportColor, Qt::magenta}}; }; // cppcheck-suppress unknownMacro @@ -135,7 +151,7 @@ template inline void Visualization::AddItem(Item *item) { SCASSERT(item != nullptr) - VMainGraphicsScene *scene = qobject_cast(VAbstractValApplication::VApp()->getCurrentScene()); + auto *scene = qobject_cast(VAbstractValApplication::VApp()->getCurrentScene()); SCASSERT(scene != nullptr) scene->addItem(item); @@ -144,7 +160,7 @@ inline void Visualization::AddItem(Item *item) //--------------------------------------------------------------------------------------------------------------------- template -inline Item *Visualization::InitItem(const QColor &color, QGraphicsItem *parent) +inline auto Visualization::InitItem(const QColor &color, QGraphicsItem *parent) -> Item * { Item *item = new Item(parent); @@ -158,4 +174,58 @@ inline Item *Visualization::InitItem(const QColor &color, QGraphicsItem *parent) return item; } +//--------------------------------------------------------------------------------------------------------------------- +inline auto Visualization::GetMode() const -> Mode +{ + return m_mode; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline void Visualization::SetMode(const Mode &value) +{ + m_mode = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline auto Visualization::CurrentToolTip() const -> QString +{ + return m_toolTip; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline void Visualization::SetScenePos(QPointF pos) +{ + m_scenePos = pos; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline auto Visualization::ScenePos() const -> QPointF +{ + return m_scenePos; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline void Visualization::SetToolTip(const QString &tooltip) +{ + this->m_toolTip = tooltip; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline auto Visualization::LineStyle() const -> Qt::PenStyle +{ + return m_lineStyle; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline auto Visualization::GetData() const -> const VContainer * +{ + return m_data; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline void Visualization::SetData(const VContainer *data) +{ + this->m_data = data; +} + #endif // VISUALIZATION_H diff --git a/src/libs/vwidgets/scalesceneitems.cpp b/src/libs/vwidgets/scalesceneitems.cpp index 59366c5e0..4bc9888c2 100644 --- a/src/libs/vwidgets/scalesceneitems.cpp +++ b/src/libs/vwidgets/scalesceneitems.cpp @@ -34,14 +34,12 @@ //--------------------------------------------------------------------------------------------------------------------- VScaledLine::VScaledLine(QGraphicsItem *parent) - : QGraphicsLineItem(parent), - m_isBoldLine(true) + : QGraphicsLineItem(parent) {} //--------------------------------------------------------------------------------------------------------------------- VScaledLine::VScaledLine(const QLineF &line, QGraphicsItem *parent) - : QGraphicsLineItem(line, parent), - m_isBoldLine(true) + : QGraphicsLineItem(line, parent) {} //--------------------------------------------------------------------------------------------------------------------- @@ -57,18 +55,6 @@ void VScaledLine::paint(QPainter *painter, const QStyleOptionGraphicsItem *optio PaintWithFixItemHighlightSelected(this, painter, option, widget); } -//--------------------------------------------------------------------------------------------------------------------- -bool VScaledLine::IsBoldLine() const -{ - return m_isBoldLine; -} - -//--------------------------------------------------------------------------------------------------------------------- -void VScaledLine::SetBoldLine(bool bold) -{ - m_isBoldLine = bold; -} - //--------------------------------------------------------------------------------------------------------------------- VScaledEllipse::VScaledEllipse(QGraphicsItem *parent) : QGraphicsEllipseItem(parent) @@ -91,15 +77,3 @@ void VScaledEllipse::paint(QPainter *painter, const QStyleOptionGraphicsItem *op PaintWithFixItemHighlightSelected(this, painter, option, widget); } - -//--------------------------------------------------------------------------------------------------------------------- -bool VScaledEllipse::PointMode() const -{ - return m_pointMode; -} - -//--------------------------------------------------------------------------------------------------------------------- -void VScaledEllipse::SetPointMode(bool newHoldSize) -{ - m_pointMode = newHoldSize; -} diff --git a/src/libs/vwidgets/scalesceneitems.h b/src/libs/vwidgets/scalesceneitems.h index 66694cd50..b483fd112 100644 --- a/src/libs/vwidgets/scalesceneitems.h +++ b/src/libs/vwidgets/scalesceneitems.h @@ -37,37 +37,46 @@ class VScaledLine : public QGraphicsLineItem { public: explicit VScaledLine(QGraphicsItem * parent = nullptr); - VScaledLine(const QLineF &line, QGraphicsItem * parent = nullptr); - virtual ~VScaledLine() = default; + explicit VScaledLine(const QLineF &line, QGraphicsItem * parent = nullptr); + ~VScaledLine() override = default; - virtual int type() const override {return Type;} - enum { Type = UserType + static_cast(Vis::ScaledLine)}; + auto type() const -> int override {return Type;} + enum {Type = UserType + static_cast(Vis::ScaledLine)}; - virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, - QWidget *widget = nullptr) override; + void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = nullptr) override; - bool IsBoldLine() const; + auto IsBoldLine() const -> bool; void SetBoldLine(bool bold); -protected: - bool m_isBoldLine; - private: Q_DISABLE_COPY_MOVE(VScaledLine) // NOLINT + + bool m_isBoldLine{true}; }; +//--------------------------------------------------------------------------------------------------------------------- +inline auto VScaledLine::IsBoldLine() const -> bool +{ + return m_isBoldLine; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline void VScaledLine::SetBoldLine(bool bold) +{ + m_isBoldLine = bold; +} + class VScaledEllipse : public QGraphicsEllipseItem { public: explicit VScaledEllipse(QGraphicsItem * parent = nullptr); - virtual ~VScaledEllipse() = default; + ~VScaledEllipse() override = default; - virtual int type() const override {return Type;} - enum { Type = UserType + static_cast(Vis::ScaledEllipse)}; + auto type() const -> int override {return Type;} + enum {Type = UserType + static_cast(Vis::ScaledEllipse)}; - virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, - QWidget *widget = nullptr) override; - bool PointMode() const; + void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = nullptr) override; + auto PointMode() const -> bool; void SetPointMode(bool newPointMode); private: @@ -76,4 +85,16 @@ private: bool m_pointMode{true}; }; +//--------------------------------------------------------------------------------------------------------------------- +inline auto VScaledEllipse::PointMode() const -> bool +{ + return m_pointMode; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline void VScaledEllipse::SetPointMode(bool newPointMode) +{ + m_pointMode = newPointMode; +} + #endif // SCALESCENEITEMS_H