From 0aac23ec8e67741cdf079c42631a72f86f192ab5 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Fri, 19 Aug 2022 16:25:38 +0300 Subject: [PATCH] Refactoring. --- .../vtools/dialogs/tools/dialogbisector.cpp | 174 +++++++++--------- .../vtools/dialogs/tools/dialogbisector.h | 74 ++++---- .../visualization/line/vistoolbisector.cpp | 50 +++-- .../visualization/line/vistoolbisector.h | 32 ++-- .../visualization/line/vistoolnormal.cpp | 43 +++-- .../vtools/visualization/line/vistoolnormal.h | 30 +-- 6 files changed, 203 insertions(+), 200 deletions(-) diff --git a/src/libs/vtools/dialogs/tools/dialogbisector.cpp b/src/libs/vtools/dialogs/tools/dialogbisector.cpp index 9c23ca3af..66b228553 100644 --- a/src/libs/vtools/dialogs/tools/dialogbisector.cpp +++ b/src/libs/vtools/dialogs/tools/dialogbisector.cpp @@ -43,13 +43,15 @@ #include "../../visualization/line/vistoolbisector.h" #include "../../visualization/visualization.h" #include "../ifc/xml/vabstractpattern.h" -#include "../ifc/xml/vdomdocument.h" #include "../support/dialogeditwrongformula.h" #include "../vmisc/vabstractapplication.h" #include "../vmisc/vcommonsettings.h" #include "../vpatterndb/vtranslatevars.h" #include "../vpatterndb/vcontainer.h" #include "ui_dialogbisector.h" +#include "../vwidgets/vabstractmainwindow.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolbisector.h" +#include "../vgeometry/vpointf.h" //--------------------------------------------------------------------------------------------------------------------- /** @@ -60,24 +62,18 @@ DialogBisector::DialogBisector(const VContainer *data, quint32 toolId, QWidget *parent) : DialogTool(data, toolId, parent), ui(new Ui::DialogBisector), - formula(), - pointName(), - formulaBaseHeight(0), - timerFormula(new QTimer(this)), - flagFormula(false), - flagError(true), - flagName(true) + m_timerFormula(new QTimer(this)) { ui->setupUi(this); - timerFormula->setSingleShot(true); - connect(timerFormula, &QTimer::timeout, this, &DialogBisector::EvalFormula); + m_timerFormula->setSingleShot(true); + connect(m_timerFormula, &QTimer::timeout, this, &DialogBisector::EvalFormula); ui->lineEditNamePoint->setClearButtonEnabled(true); ui->lineEditNamePoint->setText( VAbstractValApplication::VApp()->getCurrentDocument()->GenerateLabel(LabelType::NewLabel)); - this->formulaBaseHeight = ui->plainTextEditFormula->height(); + this->m_formulaBaseHeight = ui->plainTextEditFormula->height(); ui->plainTextEditFormula->installEventFilter(this); InitOkCancelApply(ui); @@ -91,12 +87,12 @@ DialogBisector::DialogBisector(const VContainer *data, quint32 toolId, QWidget * connect(ui->toolButtonExprLength, &QPushButton::clicked, this, &DialogBisector::FXLength); connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, [this]() { - CheckPointLabel(this, ui->lineEditNamePoint, ui->labelEditNamePoint, pointName, this->data, flagName); + CheckPointLabel(this, ui->lineEditNamePoint, ui->labelEditNamePoint, m_pointName, this->data, m_flagName); CheckState(); }); connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, [this]() { - timerFormula->start(formulaTimerTimeout); + m_timerFormula->start(formulaTimerTimeout); }); connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogBisector::DeployFormulaTextEdit); connect(ui->comboBoxFirstPoint, &QComboBox::currentTextChanged, @@ -123,12 +119,12 @@ void DialogBisector::PointNameChanged() QColor color; if (set.size() != 3) { - flagError = false; + m_flagError = false; color = errorColor; } else { - flagError = true; + m_flagError = true; color = OkColor(this); } ChangeColor(ui->labelFirstPoint, color); @@ -140,7 +136,7 @@ void DialogBisector::PointNameChanged() //--------------------------------------------------------------------------------------------------------------------- void DialogBisector::FXLength() { - DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this); + auto *dialog = new DialogEditWrongFormula(data, toolId, this); dialog->setWindowTitle(tr("Edit length")); dialog->SetFormula(GetFormula()); dialog->setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true)); @@ -162,7 +158,7 @@ void DialogBisector::EvalFormula() formulaData.postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true); formulaData.checkZero = false; - Eval(formulaData, flagFormula); + Eval(formulaData, m_flagFormula); } //--------------------------------------------------------------------------------------------------------------------- @@ -174,7 +170,7 @@ void DialogBisector::ShowVisualization() //--------------------------------------------------------------------------------------------------------------------- void DialogBisector::DeployFormulaTextEdit() { - DeployFormula(this, ui->plainTextEditFormula, ui->pushButtonGrowLength, formulaBaseHeight); + DeployFormula(this, ui->plainTextEditFormula, ui->pushButtonGrowLength, m_formulaBaseHeight); } //--------------------------------------------------------------------------------------------------------------------- @@ -184,9 +180,9 @@ DialogBisector::~DialogBisector() } //--------------------------------------------------------------------------------------------------------------------- -QString DialogBisector::GetPointName() const +auto DialogBisector::GetPointName() const -> QString { - return pointName; + return m_pointName; } //--------------------------------------------------------------------------------------------------------------------- @@ -197,56 +193,41 @@ QString DialogBisector::GetPointName() const */ void DialogBisector::ChosenObject(quint32 id, const SceneObject &type) { - if (prepare == false)// After first choose we ignore all objects + if (prepare)// After first choose we ignore all objects { - if (type == SceneObject::Point) - { - VisToolBisector *line = qobject_cast(vis); - SCASSERT(line != nullptr) + return; + } - switch (number) - { - case 0: - if (SetObject(id, ui->comboBoxFirstPoint, tr("Select second point of angle"))) + if (type == SceneObject::Point) + { + auto *line = qobject_cast(vis); + SCASSERT(line != nullptr) + + switch (number) + { + case 0: + if (SetObject(id, ui->comboBoxFirstPoint, tr("Select second point of angle"))) + { + number++; + line->VisualMode(id); + } + break; + case 1: + if (getCurrentObjectId(ui->comboBoxFirstPoint) != id) + { + if (SetObject(id, ui->comboBoxSecondPoint, tr("Select third point of angle"))) { number++; - line->VisualMode(id); - } - break; - case 1: - if (getCurrentObjectId(ui->comboBoxFirstPoint) != id) - { - if (SetObject(id, ui->comboBoxSecondPoint, tr("Select third point of angle"))) - { - number++; - line->setObject2Id(id); - line->RefreshGeometry(); - } - } - break; - case 2: - { - QSet set; - set.insert(getCurrentObjectId(ui->comboBoxFirstPoint)); - set.insert(getCurrentObjectId(ui->comboBoxSecondPoint)); - set.insert(id); - - if (set.size() == 3) - { - if (SetObject(id, ui->comboBoxThirdPoint, QString())) - { - line->setObject3Id(id); - line->RefreshGeometry(); - prepare = true; - this->setModal(true); - this->show(); - } + line->setObject2Id(id); + line->RefreshGeometry(); } } - break; - default: - break; - } + break; + case 2: + ChosenThirdPoint(id); + break; + default: + break; } } } @@ -258,8 +239,8 @@ void DialogBisector::ChosenObject(quint32 id, const SceneObject &type) */ void DialogBisector::SetPointName(const QString &value) { - pointName = value; - ui->lineEditNamePoint->setText(pointName); + m_pointName = value; + ui->lineEditNamePoint->setText(m_pointName); } //--------------------------------------------------------------------------------------------------------------------- @@ -280,18 +261,18 @@ void DialogBisector::SetTypeLine(const QString &value) */ void DialogBisector::SetFormula(const QString &value) { - formula = VAbstractApplication::VApp()->TrVars() + m_formula = VAbstractApplication::VApp()->TrVars() ->FormulaToUser(value, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); // increase height if needed. - if (formula.length() > 80) + if (m_formula.length() > 80) { this->DeployFormulaTextEdit(); } - ui->plainTextEditFormula->setPlainText(formula); + ui->plainTextEditFormula->setPlainText(m_formula); - VisToolBisector *line = qobject_cast(vis); + auto *line = qobject_cast(vis); SCASSERT(line != nullptr) - line->setLength(formula); + line->setLength(m_formula); MoveCursorToEnd(ui->plainTextEditFormula); } @@ -305,7 +286,7 @@ void DialogBisector::SetFirstPointId(const quint32 &value) { setCurrentPointId(ui->comboBoxFirstPoint, value); - VisToolBisector *line = qobject_cast(vis); + auto *line = qobject_cast(vis); SCASSERT(line != nullptr) line->setObject1Id(value); } @@ -319,7 +300,7 @@ void DialogBisector::SetSecondPointId(const quint32 &value) { setCurrentPointId(ui->comboBoxSecondPoint, value); - VisToolBisector *line = qobject_cast(vis); + auto *line = qobject_cast(vis); SCASSERT(line != nullptr) line->setObject2Id(value); } @@ -333,13 +314,13 @@ void DialogBisector::SetThirdPointId(const quint32 &value) { setCurrentPointId(ui->comboBoxThirdPoint, value); - VisToolBisector *line = qobject_cast(vis); + auto *line = qobject_cast(vis); SCASSERT(line != nullptr) line->setObject3Id(value); } //--------------------------------------------------------------------------------------------------------------------- -QString DialogBisector::GetLineColor() const +auto DialogBisector::GetLineColor() const -> QString { return GetComboBoxCurrentData(ui->comboBoxLineColor, ColorBlack); } @@ -357,7 +338,7 @@ void DialogBisector::SetNotes(const QString ¬es) } //--------------------------------------------------------------------------------------------------------------------- -QString DialogBisector::GetNotes() const +auto DialogBisector::GetNotes() const -> QString { return ui->plainTextEditToolNotes->toPlainText(); } @@ -365,16 +346,16 @@ QString DialogBisector::GetNotes() const //--------------------------------------------------------------------------------------------------------------------- void DialogBisector::SaveData() { - pointName = ui->lineEditNamePoint->text(); - formula = ui->plainTextEditFormula->toPlainText(); + m_pointName = ui->lineEditNamePoint->text(); + m_formula = ui->plainTextEditFormula->toPlainText(); - VisToolBisector *line = qobject_cast(vis); + auto *line = qobject_cast(vis); SCASSERT(line != nullptr) line->setObject1Id(GetFirstPointId()); line->setObject2Id(GetSecondPointId()); line->setObject3Id(GetThirdPointId()); - line->setLength(formula); + line->setLength(m_formula); line->setLineStyle(LineStyleToPenStyle(GetTypeLine())); line->RefreshGeometry(); } @@ -386,12 +367,33 @@ void DialogBisector::closeEvent(QCloseEvent *event) DialogTool::closeEvent(event); } +//--------------------------------------------------------------------------------------------------------------------- +void DialogBisector::ChosenThirdPoint(quint32 id) +{ + QSet set; + set.insert(getCurrentObjectId(ui->comboBoxFirstPoint)); + set.insert(getCurrentObjectId(ui->comboBoxSecondPoint)); + set.insert(id); + + if (set.size() == 3) + { + if (SetObject(id, ui->comboBoxThirdPoint, QString())) + { + line->setObject3Id(id); + line->RefreshGeometry(); + prepare = true; + this->setModal(true); + this->show(); + } + } +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief GetTypeLine return type of line * @return type */ -QString DialogBisector::GetTypeLine() const +auto DialogBisector::GetTypeLine() const -> QString { return GetComboBoxCurrentData(ui->comboBoxLineType, TypeLineLine); } @@ -401,9 +403,9 @@ QString DialogBisector::GetTypeLine() const * @brief GetFormula return string of formula * @return formula */ -QString DialogBisector::GetFormula() const +auto DialogBisector::GetFormula() const -> QString { - return VTranslateVars::TryFormulaFromUser(formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); + return VTranslateVars::TryFormulaFromUser(m_formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); } //--------------------------------------------------------------------------------------------------------------------- @@ -411,7 +413,7 @@ QString DialogBisector::GetFormula() const * @brief GetFirstPointId return id of first point * @return id */ -quint32 DialogBisector::GetFirstPointId() const +auto DialogBisector::GetFirstPointId() const -> quint32 { return getCurrentObjectId(ui->comboBoxFirstPoint); } @@ -421,7 +423,7 @@ quint32 DialogBisector::GetFirstPointId() const * @brief GetSecondPointId return id of second point * @return id */ -quint32 DialogBisector::GetSecondPointId() const +auto DialogBisector::GetSecondPointId() const -> quint32 { return getCurrentObjectId(ui->comboBoxSecondPoint); } @@ -431,7 +433,7 @@ quint32 DialogBisector::GetSecondPointId() const * @brief GetThirdPointId return id of third point * @return id */ -quint32 DialogBisector::GetThirdPointId() const +auto DialogBisector::GetThirdPointId() const -> quint32 { return getCurrentObjectId(ui->comboBoxThirdPoint); } diff --git a/src/libs/vtools/dialogs/tools/dialogbisector.h b/src/libs/vtools/dialogs/tools/dialogbisector.h index 2d213350f..b692022de 100644 --- a/src/libs/vtools/dialogs/tools/dialogbisector.h +++ b/src/libs/vtools/dialogs/tools/dialogbisector.h @@ -52,49 +52,49 @@ class DialogBisector final : public DialogTool public: DialogBisector(const VContainer *data, quint32 toolId, QWidget *parent = nullptr); - virtual ~DialogBisector() override; + ~DialogBisector() override; - QString GetPointName() const; - void SetPointName(const QString &value); + auto GetPointName() const -> QString; + void SetPointName(const QString &value); - QString GetTypeLine() const; - void SetTypeLine(const QString &value); + auto GetTypeLine() const -> QString; + void SetTypeLine(const QString &value); - QString GetFormula() const; - void SetFormula(const QString &value); + auto GetFormula() const -> QString; + void SetFormula(const QString &value); - quint32 GetFirstPointId() const; - void SetFirstPointId(const quint32 &value); + auto GetFirstPointId() const -> quint32; + void SetFirstPointId(const quint32 &value); - quint32 GetSecondPointId() const; - void SetSecondPointId(const quint32 &value); + auto GetSecondPointId() const -> quint32; + void SetSecondPointId(const quint32 &value); - quint32 GetThirdPointId() const; - void SetThirdPointId(const quint32 &value); + auto GetThirdPointId() const -> quint32; + void SetThirdPointId(const quint32 &value); - QString GetLineColor() const; - void SetLineColor(const QString &value); + auto GetLineColor() const -> QString; + void SetLineColor(const QString &value); - void SetNotes(const QString ¬es); - QString GetNotes() const; + void SetNotes(const QString ¬es); + auto GetNotes() const -> QString; public slots: - virtual void ChosenObject(quint32 id, const SceneObject &type) override; + void ChosenObject(quint32 id, const SceneObject &type) override; /** * @brief DeployFormulaTextEdit grow or shrink formula input */ - void DeployFormulaTextEdit(); + void DeployFormulaTextEdit(); - virtual void PointNameChanged() override; - void FXLength(); - void EvalFormula(); + void PointNameChanged() override; + void FXLength(); + void EvalFormula(); protected: - virtual void ShowVisualization() override; + void ShowVisualization() override; /** * @brief SaveData Put dialog data in local variables */ - virtual void SaveData() override; - virtual void closeEvent(QCloseEvent *event) override; - virtual bool IsValid() const final; + void SaveData() override; + void closeEvent(QCloseEvent *event) override; + auto IsValid() const -> bool final; private: Q_DISABLE_COPY_MOVE(DialogBisector) // NOLINT @@ -102,23 +102,27 @@ private: Ui::DialogBisector *ui; /** @brief formula formula */ - QString formula; - QString pointName; + QString m_formula{}; + QString m_pointName{}; /** @brief formulaBaseHeight base height defined by dialogui */ - int formulaBaseHeight; + int m_formulaBaseHeight{0}; - QTimer *timerFormula; + QTimer *m_timerFormula; - bool flagFormula; - bool flagError; - bool flagName; + bool m_flagFormula{false}; + bool m_flagError{true}; + bool m_flagName{true}; + + bool m_firstRelease{false}; + + void ChosenThirdPoint(quint32 id); }; //--------------------------------------------------------------------------------------------------------------------- -inline bool DialogBisector::IsValid() const +inline auto DialogBisector::IsValid() const -> bool { - return flagFormula && flagError && flagName; + return m_flagFormula && m_flagError && m_flagName; } #endif // DIALOGBISECTOR_H diff --git a/src/libs/vtools/visualization/line/vistoolbisector.cpp b/src/libs/vtools/visualization/line/vistoolbisector.cpp index e09471147..3dda0dde0 100644 --- a/src/libs/vtools/visualization/line/vistoolbisector.cpp +++ b/src/libs/vtools/visualization/line/vistoolbisector.cpp @@ -35,7 +35,6 @@ #include #include "../../tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolbisector.h" -#include "../ifc/ifcdef.h" #include "../vgeometry/vgobject.h" #include "../vgeometry/vpointf.h" #include "../vpatterndb/vcontainer.h" @@ -44,35 +43,34 @@ //--------------------------------------------------------------------------------------------------------------------- VisToolBisector::VisToolBisector(const VContainer *data, QGraphicsItem *parent) - :VisLine(data, parent), object2Id(NULL_ID), object3Id(NULL_ID), point(nullptr), line1P1(nullptr), line1P2(nullptr), - line1(nullptr), line2P2(nullptr), line2(nullptr), length(0) + :VisLine(data, parent) { - line1P1 = InitPoint(supportColor, this); - line1P2 = InitPoint(supportColor, this); //-V656 - line1 = InitItem(supportColor, this); + m_line1P1 = InitPoint(supportColor, this); + m_line1P2 = InitPoint(supportColor, this); //-V656 + m_line1 = InitItem(supportColor, this); - line2P2 = InitPoint(supportColor, this); - line2 = InitItem(supportColor, this); + m_line2P2 = InitPoint(supportColor, this); + m_line2 = InitItem(supportColor, this); - point = InitPoint(mainColor, this); + m_point = InitPoint(mainColor, this); } //--------------------------------------------------------------------------------------------------------------------- void VisToolBisector::setObject2Id(const quint32 &value) { - object2Id = value; + m_object2Id = value; } //--------------------------------------------------------------------------------------------------------------------- void VisToolBisector::setObject3Id(const quint32 &value) { - object3Id = value; + m_object3Id = value; } //--------------------------------------------------------------------------------------------------------------------- void VisToolBisector::setLength(const QString &expression) { - length = FindLengthFromUser(expression, Visualization::data->DataVariables()); + m_length = FindLengthFromUser(expression, Visualization::data->DataVariables()); } //--------------------------------------------------------------------------------------------------------------------- @@ -81,39 +79,39 @@ void VisToolBisector::RefreshGeometry() if (object1Id > NULL_ID) { const QSharedPointer first = Visualization::data->GeometricObject(object1Id); - DrawPoint(line1P1, static_cast(*first), supportColor); + DrawPoint(m_line1P1, static_cast(*first), supportColor); - if (object2Id <= NULL_ID) + if (m_object2Id <= NULL_ID) { - DrawLine(line1, QLineF(static_cast(*first), Visualization::scenePos), supportColor); + DrawLine(m_line1, QLineF(static_cast(*first), Visualization::scenePos), supportColor); } else { - const QSharedPointer second = Visualization::data->GeometricObject(object2Id); - DrawPoint(line1P2, static_cast(*second), supportColor); + const QSharedPointer second = Visualization::data->GeometricObject(m_object2Id); + DrawPoint(m_line1P2, static_cast(*second), supportColor); - DrawLine(line1, QLineF(static_cast(*first), static_cast(*second)), supportColor); + DrawLine(m_line1, QLineF(static_cast(*first), static_cast(*second)), supportColor); - if (object3Id <= NULL_ID) + if (m_object3Id <= NULL_ID) { - DrawLine(line2, QLineF(static_cast(*second), Visualization::scenePos), supportColor); + DrawLine(m_line2, QLineF(static_cast(*second), Visualization::scenePos), supportColor); } else { - const QSharedPointer third = Visualization::data->GeometricObject(object3Id); - DrawPoint(line2P2, static_cast(*third), supportColor); + const QSharedPointer third = Visualization::data->GeometricObject(m_object3Id); + DrawPoint(m_line2P2, static_cast(*third), supportColor); - DrawLine(line2, QLineF(static_cast(*second), static_cast(*third)), supportColor); + DrawLine(m_line2, QLineF(static_cast(*second), static_cast(*third)), supportColor); - if (not qFuzzyIsNull(length)) + if (not qFuzzyIsNull(m_length)) { qreal angle = VToolBisector::BisectorAngle(static_cast(*first), static_cast(*second), static_cast(*third)); - QLineF mainLine = VGObject::BuildLine(static_cast(*second), length, angle); + QLineF mainLine = VGObject::BuildLine(static_cast(*second), m_length, angle); DrawLine(this, mainLine, mainColor, lineStyle); - DrawPoint(point, mainLine.p2(), mainColor); + DrawPoint(m_point, mainLine.p2(), mainColor); } else { diff --git a/src/libs/vtools/visualization/line/vistoolbisector.h b/src/libs/vtools/visualization/line/vistoolbisector.h index 61c08cc26..946b90140 100644 --- a/src/libs/vtools/visualization/line/vistoolbisector.h +++ b/src/libs/vtools/visualization/line/vistoolbisector.h @@ -44,26 +44,26 @@ class VisToolBisector :public VisLine Q_OBJECT // NOLINT public: explicit VisToolBisector(const VContainer *data, QGraphicsItem *parent = nullptr); - virtual ~VisToolBisector() = default; + ~VisToolBisector() override = default; - virtual void RefreshGeometry() override; - void setObject2Id(const quint32 &value); - void setObject3Id(const quint32 &value); - void setLength(const QString &expression); - virtual int type() const override {return Type;} - enum { Type = UserType + static_cast(Vis::ToolBisector)}; + void RefreshGeometry() override; + void setObject2Id(const quint32 &value); + void setObject3Id(const 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 object2Id; - quint32 object3Id; - VScaledEllipse *point; - VScaledEllipse *line1P1; - VScaledEllipse *line1P2; - VScaledLine *line1; - VScaledEllipse *line2P2; - VScaledLine *line2; - qreal length; + quint32 m_object2Id{NULL_ID}; + quint32 m_object3Id{NULL_ID}; + VScaledEllipse *m_point{nullptr}; + VScaledEllipse *m_line1P1{nullptr}; + VScaledEllipse *m_line1P2{nullptr}; + VScaledLine *m_line1{nullptr}; + VScaledEllipse *m_line2P2{nullptr}; + VScaledLine *m_line2{nullptr}; + qreal m_length{0}; }; #endif // VISTOOLBISECTOR_H diff --git a/src/libs/vtools/visualization/line/vistoolnormal.cpp b/src/libs/vtools/visualization/line/vistoolnormal.cpp index 078d4acf4..51076014f 100644 --- a/src/libs/vtools/visualization/line/vistoolnormal.cpp +++ b/src/libs/vtools/visualization/line/vistoolnormal.cpp @@ -45,16 +45,15 @@ //--------------------------------------------------------------------------------------------------------------------- VisToolNormal::VisToolNormal(const VContainer *data, QGraphicsItem *parent) - : VisLine(data, parent), object2Id(NULL_ID), point(nullptr), lineP1(nullptr), lineP2(nullptr), line(nullptr), - length(0), angle(0) + : VisLine(data, parent) { this->mainColor = Qt::red; - lineP1 = InitPoint(supportColor, this); - lineP2 = InitPoint(supportColor, this); //-V656 - line = InitItem(supportColor, this); + m_lineP1 = InitPoint(supportColor, this); + m_lineP2 = InitPoint(supportColor, this); //-V656 + m_line = InitItem(supportColor, this); - point = InitPoint(mainColor, this); + m_point = InitPoint(mainColor, this); } //--------------------------------------------------------------------------------------------------------------------- @@ -63,12 +62,12 @@ void VisToolNormal::RefreshGeometry() if (object1Id > NULL_ID) { const QSharedPointer first = Visualization::data->GeometricObject(object1Id); - DrawPoint(lineP1, static_cast(*first), supportColor); + DrawPoint(m_lineP1, static_cast(*first), supportColor); - if (object2Id <= NULL_ID) + if (m_object2Id <= NULL_ID) { QLineF line_mouse(static_cast(*first), Visualization::scenePos); - DrawLine(line, line_mouse, supportColor); + DrawLine(m_line, line_mouse, supportColor); QLineF normal = line_mouse.normalVector(); QPointF endRay = Ray(normal.p1(), normal.angle()); @@ -76,20 +75,20 @@ void VisToolNormal::RefreshGeometry() } else { - const QSharedPointer second = Visualization::data->GeometricObject(object2Id); - DrawPoint(lineP2, static_cast(*second), supportColor); + const QSharedPointer second = Visualization::data->GeometricObject(m_object2Id); + DrawPoint(m_lineP2, static_cast(*second), supportColor); QLineF line_mouse(static_cast(*first), static_cast(*second)); - DrawLine(line, line_mouse, supportColor); + DrawLine(m_line, line_mouse, supportColor); - if (not qFuzzyIsNull(length)) + if (not qFuzzyIsNull(m_length)) { QPointF fPoint = VToolNormal::FindPoint(static_cast(*first), static_cast(*second), - length, angle); + m_length, m_angle); QLineF mainLine = QLineF(static_cast(*first), fPoint); DrawLine(this, mainLine, mainColor, lineStyle); - DrawPoint(point, mainLine.p2(), mainColor); + DrawPoint(m_point, mainLine.p2(), mainColor); } else if (mode == Mode::Creation) { @@ -104,11 +103,11 @@ void VisToolNormal::RefreshGeometry() } QPointF fPoint = VToolNormal::FindPoint(static_cast(*first), static_cast(*second), - len, angle); + len, m_angle); QLineF mainLine = QLineF(static_cast(*first), fPoint); DrawLine(this, mainLine, mainColor, lineStyle); - DrawPoint(point, mainLine.p2(), mainColor); + DrawPoint(m_point, mainLine.p2(), mainColor); const QString prefix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true); Visualization::toolTip = tr("Length = %1%2; " @@ -129,23 +128,23 @@ void VisToolNormal::RefreshGeometry() //--------------------------------------------------------------------------------------------------------------------- void VisToolNormal::setObject2Id(const quint32 &value) { - object2Id = value; + m_object2Id = value; } //--------------------------------------------------------------------------------------------------------------------- void VisToolNormal::setLength(const QString &expression) { - length = FindLengthFromUser(expression, Visualization::data->DataVariables()); + m_length = FindLengthFromUser(expression, Visualization::data->DataVariables()); } //--------------------------------------------------------------------------------------------------------------------- -qreal VisToolNormal::GetAngle() const +auto VisToolNormal::GetAngle() const -> qreal { - return angle; + return m_angle; } //--------------------------------------------------------------------------------------------------------------------- void VisToolNormal::SetAngle(const qreal &value) { - angle = value; + m_angle = value; } diff --git a/src/libs/vtools/visualization/line/vistoolnormal.h b/src/libs/vtools/visualization/line/vistoolnormal.h index ec1d1d74f..a4aa0c2ef 100644 --- a/src/libs/vtools/visualization/line/vistoolnormal.h +++ b/src/libs/vtools/visualization/line/vistoolnormal.h @@ -44,27 +44,27 @@ class VisToolNormal : public VisLine Q_OBJECT // NOLINT public: explicit VisToolNormal(const VContainer *data, QGraphicsItem *parent = nullptr); - virtual ~VisToolNormal() = default; + ~VisToolNormal() override = default; - virtual void RefreshGeometry() override; + void RefreshGeometry() override; - void setObject2Id(const quint32 &value); - void setLength(const QString &expression); - qreal GetAngle() const; - void SetAngle(const qreal &value); - virtual int type() const override {return Type;} - enum { Type = UserType + static_cast(Vis::ToolNormal)}; + void setObject2Id(const 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 object2Id; - VScaledEllipse *point; - VScaledEllipse *lineP1; - VScaledEllipse *lineP2; - VScaledLine *line; - qreal length; - qreal angle; + quint32 m_object2Id{NULL_ID}; + VScaledEllipse *m_point{nullptr}; + VScaledEllipse *m_lineP1{nullptr}; + VScaledEllipse *m_lineP2{nullptr}; + VScaledLine *m_line{nullptr}; + qreal m_length{0}; + qreal m_angle{0}; };