Refactoring.

This commit is contained in:
Roman Telezhynskyi 2022-08-19 16:53:44 +03:00
parent dd2eacd0d5
commit b9dd7d0ee9
4 changed files with 159 additions and 166 deletions

View File

@ -41,15 +41,14 @@
#include <QToolButton> #include <QToolButton>
#include "../vpatterndb/vtranslatevars.h" #include "../vpatterndb/vtranslatevars.h"
#include "../../tools/vabstracttool.h"
#include "../../visualization/visualization.h" #include "../../visualization/visualization.h"
#include "../../visualization/line/vistoolshoulderpoint.h" #include "../../visualization/line/vistoolshoulderpoint.h"
#include "../ifc/xml/vabstractpattern.h" #include "../ifc/xml/vabstractpattern.h"
#include "../ifc/xml/vdomdocument.h"
#include "../support/dialogeditwrongformula.h" #include "../support/dialogeditwrongformula.h"
#include "../vmisc/vabstractapplication.h" #include "../vmisc/vabstractapplication.h"
#include "../vmisc/vcommonsettings.h" #include "../vmisc/vcommonsettings.h"
#include "ui_dialogshoulderpoint.h" #include "ui_dialogshoulderpoint.h"
#include "../vpatterndb/vcontainer.h"
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
@ -60,24 +59,18 @@
DialogShoulderPoint::DialogShoulderPoint(const VContainer *data, quint32 toolId, QWidget *parent) DialogShoulderPoint::DialogShoulderPoint(const VContainer *data, quint32 toolId, QWidget *parent)
: DialogTool(data, toolId, parent), : DialogTool(data, toolId, parent),
ui(new Ui::DialogShoulderPoint), ui(new Ui::DialogShoulderPoint),
formula(), m_timerFormula(new QTimer(this))
formulaBaseHeight(0),
timerFormula(new QTimer(this)),
pointName(),
flagFormula(false),
flagName(true),
flagError(true)
{ {
ui->setupUi(this); ui->setupUi(this);
timerFormula->setSingleShot(true); m_timerFormula->setSingleShot(true);
connect(timerFormula, &QTimer::timeout, this, &DialogShoulderPoint::EvalFormula); connect(m_timerFormula, &QTimer::timeout, this, &DialogShoulderPoint::EvalFormula);
ui->lineEditNamePoint->setClearButtonEnabled(true); ui->lineEditNamePoint->setClearButtonEnabled(true);
ui->lineEditNamePoint->setText( ui->lineEditNamePoint->setText(
VAbstractValApplication::VApp()->getCurrentDocument()->GenerateLabel(LabelType::NewLabel)); VAbstractValApplication::VApp()->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
formulaBaseHeight = ui->plainTextEditFormula->height(); m_formulaBaseHeight = ui->plainTextEditFormula->height();
ui->plainTextEditFormula->installEventFilter(this); ui->plainTextEditFormula->installEventFilter(this);
InitOkCancelApply(ui); InitOkCancelApply(ui);
@ -91,12 +84,12 @@ DialogShoulderPoint::DialogShoulderPoint(const VContainer *data, quint32 toolId,
connect(ui->toolButtonExprLength, &QPushButton::clicked, this, &DialogShoulderPoint::FXLength); connect(ui->toolButtonExprLength, &QPushButton::clicked, this, &DialogShoulderPoint::FXLength);
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, [this]() 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(); CheckState();
}); });
connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, [this]() connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, [this]()
{ {
timerFormula->start(formulaTimerTimeout); m_timerFormula->start(formulaTimerTimeout);
}); });
connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogShoulderPoint::DeployFormulaTextEdit); connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogShoulderPoint::DeployFormulaTextEdit);
connect(ui->comboBoxP1Line, &QComboBox::currentTextChanged, connect(ui->comboBoxP1Line, &QComboBox::currentTextChanged,
@ -123,12 +116,12 @@ void DialogShoulderPoint::PointNameChanged()
QColor color; QColor color;
if (set.size() != 3) if (set.size() != 3)
{ {
flagError = false; m_flagError = false;
color = errorColor; color = errorColor;
} }
else else
{ {
flagError = true; m_flagError = true;
color = OkColor(this); color = OkColor(this);
} }
ChangeColor(ui->labelFirstPoint, color); ChangeColor(ui->labelFirstPoint, color);
@ -140,7 +133,7 @@ void DialogShoulderPoint::PointNameChanged()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogShoulderPoint::FXLength() void DialogShoulderPoint::FXLength()
{ {
DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this); auto *dialog = new DialogEditWrongFormula(data, toolId, this);
dialog->setWindowTitle(tr("Edit length")); dialog->setWindowTitle(tr("Edit length"));
dialog->SetFormula(GetFormula()); dialog->SetFormula(GetFormula());
dialog->setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true)); dialog->setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true));
@ -161,7 +154,7 @@ void DialogShoulderPoint::EvalFormula()
formulaData.labelResult = ui->labelResultCalculation; formulaData.labelResult = ui->labelResultCalculation;
formulaData.postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true); formulaData.postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true);
Eval(formulaData, flagFormula); Eval(formulaData, m_flagFormula);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -173,7 +166,7 @@ void DialogShoulderPoint::ShowVisualization()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogShoulderPoint::DeployFormulaTextEdit() void DialogShoulderPoint::DeployFormulaTextEdit()
{ {
DeployFormula(this, ui->plainTextEditFormula, ui->pushButtonGrowLength, formulaBaseHeight); DeployFormula(this, ui->plainTextEditFormula, ui->pushButtonGrowLength, m_formulaBaseHeight);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -183,9 +176,9 @@ DialogShoulderPoint::~DialogShoulderPoint()
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QString DialogShoulderPoint::GetPointName() const auto DialogShoulderPoint::GetPointName() const -> QString
{ {
return pointName; return m_pointName;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -196,56 +189,58 @@ QString DialogShoulderPoint::GetPointName() const
*/ */
void DialogShoulderPoint::ChosenObject(quint32 id, const SceneObject &type) void DialogShoulderPoint::ChosenObject(quint32 id, const SceneObject &type)
{ {
if (prepare == false) if (prepare)
{ {
if (type == SceneObject::Point) return;
{ }
VisToolShoulderPoint *line = qobject_cast<VisToolShoulderPoint *>(vis);
SCASSERT(line != nullptr)
switch (number) if (type == SceneObject::Point)
{ {
case 0: auto *line = qobject_cast<VisToolShoulderPoint *>(vis);
if (SetObject(id, ui->comboBoxP3, tr("Select first point of line"))) SCASSERT(line != nullptr)
switch (number)
{
case 0:
if (SetObject(id, ui->comboBoxP3, tr("Select first point of line")))
{
number++;
line->VisualMode(id);
}
break;
case 1:
if (getCurrentObjectId(ui->comboBoxP3) != id)
{
if (SetObject(id, ui->comboBoxP1Line, tr("Select second point of line")))
{ {
number++; number++;
line->VisualMode(id); line->setLineP1Id(id);
} line->RefreshGeometry();
break; }
case 1: }
if (getCurrentObjectId(ui->comboBoxP3) != id) break;
{ case 2:
if (SetObject(id, ui->comboBoxP1Line, tr("Select second point of line"))) {
{ QSet<quint32> set;
number++; set.insert(getCurrentObjectId(ui->comboBoxP3));
line->setLineP1Id(id); set.insert(getCurrentObjectId(ui->comboBoxP1Line));
line->RefreshGeometry(); set.insert(id);
}
} if (set.size() == 3)
break; {
case 2: if (SetObject(id, ui->comboBoxP2Line, QString()))
{ {
QSet<quint32> set; line->setLineP2Id(id);
set.insert(getCurrentObjectId(ui->comboBoxP3)); line->RefreshGeometry();
set.insert(getCurrentObjectId(ui->comboBoxP1Line)); prepare = true;
set.insert(id); this->setModal(true);
this->show();
if (set.size() == 3)
{
if (SetObject(id, ui->comboBoxP2Line, QString()))
{
line->setLineP2Id(id);
line->RefreshGeometry();
prepare = true;
this->setModal(true);
this->show();
}
} }
} }
break;
default:
break;
} }
break;
default:
break;
} }
} }
} }
@ -253,16 +248,16 @@ void DialogShoulderPoint::ChosenObject(quint32 id, const SceneObject &type)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogShoulderPoint::SaveData() void DialogShoulderPoint::SaveData()
{ {
pointName = ui->lineEditNamePoint->text(); m_pointName = ui->lineEditNamePoint->text();
formula = ui->plainTextEditFormula->toPlainText(); m_formula = ui->plainTextEditFormula->toPlainText();
VisToolShoulderPoint *line = qobject_cast<VisToolShoulderPoint *>(vis); auto *line = qobject_cast<VisToolShoulderPoint *>(vis);
SCASSERT(line != nullptr) SCASSERT(line != nullptr)
line->setObject1Id(GetP3()); line->setObject1Id(GetP3());
line->setLineP1Id(GetP1Line()); line->setLineP1Id(GetP1Line());
line->setLineP2Id(GetP2Line()); line->setLineP2Id(GetP2Line());
line->setLength(formula); line->setLength(m_formula);
line->setLineStyle(LineStyleToPenStyle(GetTypeLine())); line->setLineStyle(LineStyleToPenStyle(GetTypeLine()));
line->RefreshGeometry(); line->RefreshGeometry();
} }
@ -283,13 +278,13 @@ void DialogShoulderPoint::SetP3(const quint32 &value)
{ {
setCurrentPointId(ui->comboBoxP3, value); setCurrentPointId(ui->comboBoxP3, value);
VisToolShoulderPoint *line = qobject_cast<VisToolShoulderPoint *>(vis); auto *line = qobject_cast<VisToolShoulderPoint *>(vis);
SCASSERT(line != nullptr) SCASSERT(line != nullptr)
line->setObject1Id(value); line->setObject1Id(value);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QString DialogShoulderPoint::GetLineColor() const auto DialogShoulderPoint::GetLineColor() const -> QString
{ {
return GetComboBoxCurrentData(ui->comboBoxLineColor, ColorBlack); return GetComboBoxCurrentData(ui->comboBoxLineColor, ColorBlack);
} }
@ -309,7 +304,7 @@ void DialogShoulderPoint::SetP2Line(const quint32 &value)
{ {
setCurrentPointId(ui->comboBoxP2Line, value); setCurrentPointId(ui->comboBoxP2Line, value);
VisToolShoulderPoint *line = qobject_cast<VisToolShoulderPoint *>(vis); auto *line = qobject_cast<VisToolShoulderPoint *>(vis);
SCASSERT(line != nullptr) SCASSERT(line != nullptr)
line->setLineP2Id(value); line->setLineP2Id(value);
} }
@ -323,7 +318,7 @@ void DialogShoulderPoint::SetP1Line(const quint32 &value)
{ {
setCurrentPointId(ui->comboBoxP1Line, value); setCurrentPointId(ui->comboBoxP1Line, value);
VisToolShoulderPoint *line = qobject_cast<VisToolShoulderPoint *>(vis); auto *line = qobject_cast<VisToolShoulderPoint *>(vis);
SCASSERT(line != nullptr) SCASSERT(line != nullptr)
line->setLineP1Id(value); line->setLineP1Id(value);
} }
@ -335,18 +330,18 @@ void DialogShoulderPoint::SetP1Line(const quint32 &value)
*/ */
void DialogShoulderPoint::SetFormula(const QString &value) void DialogShoulderPoint::SetFormula(const QString &value)
{ {
formula = VAbstractApplication::VApp()->TrVars() m_formula = VAbstractApplication::VApp()->TrVars()
->FormulaToUser(value, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); ->FormulaToUser(value, VAbstractApplication::VApp()->Settings()->GetOsSeparator());
// increase height if needed. // increase height if needed.
if (formula.length() > 80) if (m_formula.length() > 80)
{ {
this->DeployFormulaTextEdit(); this->DeployFormulaTextEdit();
} }
ui->plainTextEditFormula->setPlainText(formula); ui->plainTextEditFormula->setPlainText(m_formula);
VisToolShoulderPoint *line = qobject_cast<VisToolShoulderPoint *>(vis); auto *line = qobject_cast<VisToolShoulderPoint *>(vis);
SCASSERT(line != nullptr) SCASSERT(line != nullptr)
line->setLength(formula); line->setLength(m_formula);
MoveCursorToEnd(ui->plainTextEditFormula); MoveCursorToEnd(ui->plainTextEditFormula);
} }
@ -368,8 +363,8 @@ void DialogShoulderPoint::SetTypeLine(const QString &value)
*/ */
void DialogShoulderPoint::SetPointName(const QString &value) void DialogShoulderPoint::SetPointName(const QString &value)
{ {
pointName = value; m_pointName = value;
ui->lineEditNamePoint->setText(pointName); ui->lineEditNamePoint->setText(m_pointName);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -377,7 +372,7 @@ void DialogShoulderPoint::SetPointName(const QString &value)
* @brief GetTypeLine return type of line * @brief GetTypeLine return type of line
* @return type * @return type
*/ */
QString DialogShoulderPoint::GetTypeLine() const auto DialogShoulderPoint::GetTypeLine() const -> QString
{ {
return GetComboBoxCurrentData(ui->comboBoxLineType, TypeLineLine); return GetComboBoxCurrentData(ui->comboBoxLineType, TypeLineLine);
} }
@ -387,9 +382,9 @@ QString DialogShoulderPoint::GetTypeLine() const
* @brief GetFormula return string of formula * @brief GetFormula return string of formula
* @return formula * @return formula
*/ */
QString DialogShoulderPoint::GetFormula() const auto DialogShoulderPoint::GetFormula() const -> QString
{ {
return VTranslateVars::TryFormulaFromUser(formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); return VTranslateVars::TryFormulaFromUser(m_formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator());
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -397,7 +392,7 @@ QString DialogShoulderPoint::GetFormula() const
* @brief GetP1Line return id first point of line * @brief GetP1Line return id first point of line
* @return id * @return id
*/ */
quint32 DialogShoulderPoint::GetP1Line() const auto DialogShoulderPoint::GetP1Line() const -> quint32
{ {
return getCurrentObjectId(ui->comboBoxP1Line); return getCurrentObjectId(ui->comboBoxP1Line);
} }
@ -407,7 +402,7 @@ quint32 DialogShoulderPoint::GetP1Line() const
* @brief GetP2Line return id second point of line * @brief GetP2Line return id second point of line
* @return id * @return id
*/ */
quint32 DialogShoulderPoint::GetP2Line() const auto DialogShoulderPoint::GetP2Line() const -> quint32
{ {
return getCurrentObjectId(ui->comboBoxP2Line); return getCurrentObjectId(ui->comboBoxP2Line);
} }
@ -417,7 +412,7 @@ quint32 DialogShoulderPoint::GetP2Line() const
* @brief getPShoulder return id shoulder point * @brief getPShoulder return id shoulder point
* @return id * @return id
*/ */
quint32 DialogShoulderPoint::GetP3() const auto DialogShoulderPoint::GetP3() const -> quint32
{ {
return getCurrentObjectId(ui->comboBoxP3); return getCurrentObjectId(ui->comboBoxP3);
} }
@ -429,7 +424,7 @@ void DialogShoulderPoint::SetNotes(const QString &notes)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QString DialogShoulderPoint::GetNotes() const auto DialogShoulderPoint::GetNotes() const -> QString
{ {
return ui->plainTextEditToolNotes->toPlainText(); return ui->plainTextEditToolNotes->toPlainText();
} }

View File

@ -51,48 +51,48 @@ class DialogShoulderPoint : public DialogTool
Q_OBJECT // NOLINT Q_OBJECT // NOLINT
public: public:
DialogShoulderPoint(const VContainer *data, quint32 toolId, QWidget *parent = nullptr); DialogShoulderPoint(const VContainer *data, quint32 toolId, QWidget *parent = nullptr);
virtual ~DialogShoulderPoint() override; ~DialogShoulderPoint() override;
QString GetPointName() const; auto GetPointName() const -> QString;
void SetPointName(const QString &value); void SetPointName(const QString &value);
QString GetTypeLine() const; auto GetTypeLine() const -> QString;
void SetTypeLine(const QString &value); void SetTypeLine(const QString &value);
QString GetFormula() const; auto GetFormula() const -> QString;
void SetFormula(const QString &value); void SetFormula(const QString &value);
quint32 GetP1Line() const; auto GetP1Line() const -> quint32;
void SetP1Line(const quint32 &value); void SetP1Line(const quint32 &value);
quint32 GetP2Line() const; auto GetP2Line() const -> quint32;
void SetP2Line(const quint32 &value); void SetP2Line(const quint32 &value);
quint32 GetP3() const; auto GetP3() const -> quint32;
void SetP3(const quint32 &value); void SetP3(const quint32 &value);
QString GetLineColor() const; auto GetLineColor() const -> QString;
void SetLineColor(const QString &value); void SetLineColor(const QString &value);
void SetNotes(const QString &notes); void SetNotes(const QString &notes);
QString GetNotes() const; auto GetNotes() const -> QString;
public slots: 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 * @brief DeployFormulaTextEdit grow or shrink formula input
*/ */
void DeployFormulaTextEdit(); void DeployFormulaTextEdit();
virtual void PointNameChanged() override; void PointNameChanged() override;
void FXLength(); void FXLength();
void EvalFormula(); void EvalFormula();
protected: protected:
virtual void ShowVisualization() override; void ShowVisualization() override;
/** /**
* @brief SaveData Put dialog data in local variables * @brief SaveData Put dialog data in local variables
*/ */
virtual void SaveData() override; void SaveData() override;
virtual void closeEvent(QCloseEvent *event) override; void closeEvent(QCloseEvent *event) override;
virtual bool IsValid() const final; auto IsValid() const -> bool final;
private: private:
Q_DISABLE_COPY_MOVE(DialogShoulderPoint) // NOLINT Q_DISABLE_COPY_MOVE(DialogShoulderPoint) // NOLINT
@ -100,24 +100,24 @@ private:
Ui::DialogShoulderPoint *ui; Ui::DialogShoulderPoint *ui;
/** @brief formula formula */ /** @brief formula formula */
QString formula; QString m_formula{};
/** @brief formulaBaseHeight base height defined by dialogui */ /** @brief formulaBaseHeight base height defined by dialogui */
int formulaBaseHeight; int m_formulaBaseHeight{0};
QTimer *timerFormula; QTimer *m_timerFormula;
QString pointName; QString m_pointName{};
bool flagFormula; bool m_flagFormula{false};
bool flagName; bool m_flagName{true};
bool flagError; bool m_flagError{true};
}; };
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
inline bool DialogShoulderPoint::IsValid() const inline auto DialogShoulderPoint::IsValid() const -> bool
{ {
return flagFormula && flagName && flagError; return m_flagFormula && m_flagName && m_flagError;
} }
#endif // DIALOGSHOULDERPOINT_H #endif // DIALOGSHOULDERPOINT_H

View File

@ -36,7 +36,6 @@
#include <new> #include <new>
#include "../../tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolshoulderpoint.h" #include "../../tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolshoulderpoint.h"
#include "../ifc/ifcdef.h"
#include "../vgeometry/vgobject.h" #include "../vgeometry/vgobject.h"
#include "../vgeometry/vpointf.h" #include "../vgeometry/vpointf.h"
#include "../vpatterndb/vcontainer.h" #include "../vpatterndb/vcontainer.h"
@ -45,18 +44,17 @@
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VisToolShoulderPoint::VisToolShoulderPoint(const VContainer *data, QGraphicsItem *parent) VisToolShoulderPoint::VisToolShoulderPoint(const VContainer *data, QGraphicsItem *parent)
:VisLine(data, parent), lineP1Id(NULL_ID), lineP2Id(NULL_ID), point(nullptr), line1P1(nullptr), line1P2(nullptr), :VisLine(data, parent)
line1(nullptr), line2P2(nullptr), line2(nullptr), line3(nullptr), length(0)
{ {
line1P1 = InitPoint(supportColor, this); m_line1P1 = InitPoint(supportColor, this);
line1P2 = InitPoint(supportColor, this); //-V656 m_line1P2 = InitPoint(supportColor, this); //-V656
line1 = InitItem<VScaledLine>(supportColor, this); m_line1 = InitItem<VScaledLine>(supportColor, this);
line2P2 = InitPoint(supportColor, this); m_line2P2 = InitPoint(supportColor, this);
line2 = InitItem<VScaledLine>(supportColor, this); m_line2 = InitItem<VScaledLine>(supportColor, this);
line3 = InitItem<VScaledLine>(supportColor, this); //-V656 m_line3 = InitItem<VScaledLine>(supportColor, this); //-V656
point = InitPoint(mainColor, this); m_point = InitPoint(mainColor, this);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -65,40 +63,40 @@ void VisToolShoulderPoint::RefreshGeometry()
if (object1Id > NULL_ID) if (object1Id > NULL_ID)
{ {
const QSharedPointer<VPointF> first = Visualization::data->GeometricObject<VPointF>(object1Id); const QSharedPointer<VPointF> first = Visualization::data->GeometricObject<VPointF>(object1Id);
DrawPoint(line1P1, static_cast<QPointF>(*first), supportColor); DrawPoint(m_line1P1, static_cast<QPointF>(*first), supportColor);
if (lineP1Id <= NULL_ID) if (m_lineP1Id <= NULL_ID)
{ {
DrawLine(line1, QLineF(static_cast<QPointF>(*first), Visualization::scenePos), supportColor); DrawLine(m_line1, QLineF(static_cast<QPointF>(*first), Visualization::scenePos), supportColor);
} }
else else
{ {
const QSharedPointer<VPointF> second = Visualization::data->GeometricObject<VPointF>(lineP1Id); const QSharedPointer<VPointF> second = Visualization::data->GeometricObject<VPointF>(m_lineP1Id);
DrawPoint(line1P2, static_cast<QPointF>(*second), supportColor); DrawPoint(m_line1P2, static_cast<QPointF>(*second), supportColor);
DrawLine(line1, QLineF(static_cast<QPointF>(*first), static_cast<QPointF>(*second)), supportColor); DrawLine(m_line1, QLineF(static_cast<QPointF>(*first), static_cast<QPointF>(*second)), supportColor);
if (lineP2Id <= NULL_ID) if (m_lineP2Id <= NULL_ID)
{ {
DrawLine(line2, QLineF(static_cast<QPointF>(*second), Visualization::scenePos), supportColor); DrawLine(m_line2, QLineF(static_cast<QPointF>(*second), Visualization::scenePos), supportColor);
} }
else else
{ {
const QSharedPointer<VPointF> third = Visualization::data->GeometricObject<VPointF>(lineP2Id); const QSharedPointer<VPointF> third = Visualization::data->GeometricObject<VPointF>(m_lineP2Id);
DrawPoint(line2P2, static_cast<QPointF>(*third), supportColor); DrawPoint(m_line2P2, static_cast<QPointF>(*third), supportColor);
DrawLine(line2, QLineF(static_cast<QPointF>(*second), static_cast<QPointF>(*third)), supportColor); DrawLine(m_line2, QLineF(static_cast<QPointF>(*second), static_cast<QPointF>(*third)), supportColor);
if (not qFuzzyIsNull(length)) if (not qFuzzyIsNull(m_length))
{ {
QPointF fPoint = VToolShoulderPoint::FindPoint(static_cast<QPointF>(*second), QPointF fPoint = VToolShoulderPoint::FindPoint(static_cast<QPointF>(*second),
static_cast<QPointF>(*third), static_cast<QPointF>(*third),
static_cast<QPointF>(*first), length); static_cast<QPointF>(*first), m_length);
QLineF mainLine = QLineF(static_cast<QPointF>(*second), fPoint); QLineF mainLine = QLineF(static_cast<QPointF>(*second), fPoint);
DrawLine(this, mainLine, mainColor, lineStyle); DrawLine(this, mainLine, mainColor, lineStyle);
DrawPoint(point, mainLine.p2(), mainColor); DrawPoint(m_point, mainLine.p2(), mainColor);
DrawLine(line3, QLineF(static_cast<QPointF>(*first), mainLine.p2()), supportColor, Qt::DashLine); DrawLine(m_line3, QLineF(static_cast<QPointF>(*first), mainLine.p2()), supportColor, Qt::DashLine);
} }
else else
{ {
@ -117,17 +115,17 @@ void VisToolShoulderPoint::RefreshGeometry()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VisToolShoulderPoint::setLineP1Id(const quint32 &value) void VisToolShoulderPoint::setLineP1Id(const quint32 &value)
{ {
lineP1Id = value; m_lineP1Id = value;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VisToolShoulderPoint::setLineP2Id(const quint32 &value) void VisToolShoulderPoint::setLineP2Id(const quint32 &value)
{ {
lineP2Id = value; m_lineP2Id = value;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VisToolShoulderPoint::setLength(const QString &expression) void VisToolShoulderPoint::setLength(const QString &expression)
{ {
length = FindLengthFromUser(expression, Visualization::data->DataVariables()); m_length = FindLengthFromUser(expression, Visualization::data->DataVariables());
} }

View File

@ -44,27 +44,27 @@ class VisToolShoulderPoint : public VisLine
Q_OBJECT // NOLINT Q_OBJECT // NOLINT
public: public:
explicit VisToolShoulderPoint(const VContainer *data, QGraphicsItem *parent = nullptr); explicit VisToolShoulderPoint(const VContainer *data, QGraphicsItem *parent = nullptr);
virtual ~VisToolShoulderPoint() = default; ~VisToolShoulderPoint() override = default;
virtual void RefreshGeometry() override; void RefreshGeometry() override;
void setLineP1Id(const quint32 &value); void setLineP1Id(const quint32 &value);
void setLineP2Id(const quint32 &value); void setLineP2Id(const quint32 &value);
void setLength(const QString &expression); void setLength(const QString &expression);
virtual int type() const override {return Type;} auto type() const -> int override {return Type;}
enum { Type = UserType + static_cast<int>(Vis::ToolShoulderPoint)}; enum {Type = UserType + static_cast<int>(Vis::ToolShoulderPoint)};
private: private:
// cppcheck-suppress unknownMacro // cppcheck-suppress unknownMacro
Q_DISABLE_COPY_MOVE(VisToolShoulderPoint) // NOLINT Q_DISABLE_COPY_MOVE(VisToolShoulderPoint) // NOLINT
quint32 lineP1Id; quint32 m_lineP1Id{NULL_ID};
quint32 lineP2Id; quint32 m_lineP2Id{NULL_ID};
VScaledEllipse *point; VScaledEllipse *m_point{nullptr};
VScaledEllipse *line1P1; VScaledEllipse *m_line1P1{nullptr};
VScaledEllipse *line1P2; VScaledEllipse *m_line1P2{nullptr};
VScaledLine *line1; VScaledLine *m_line1{nullptr};
VScaledEllipse *line2P2; VScaledEllipse *m_line2P2{nullptr};
VScaledLine *line2; VScaledLine *m_line2{nullptr};
VScaledLine *line3; VScaledLine *m_line3{nullptr};
qreal length; qreal m_length{0};
}; };
#endif // VISTOOLSHOULDERPOINT_H #endif // VISTOOLSHOULDERPOINT_H