Refactoring.

This commit is contained in:
Roman Telezhynskyi 2022-08-19 16:25:38 +03:00
parent de3179a37c
commit 0aac23ec8e
6 changed files with 203 additions and 200 deletions

View File

@ -43,13 +43,15 @@
#include "../../visualization/line/vistoolbisector.h" #include "../../visualization/line/vistoolbisector.h"
#include "../../visualization/visualization.h" #include "../../visualization/visualization.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 "../vpatterndb/vtranslatevars.h" #include "../vpatterndb/vtranslatevars.h"
#include "../vpatterndb/vcontainer.h" #include "../vpatterndb/vcontainer.h"
#include "ui_dialogbisector.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) DialogBisector::DialogBisector(const VContainer *data, quint32 toolId, QWidget *parent)
: DialogTool(data, toolId, parent), : DialogTool(data, toolId, parent),
ui(new Ui::DialogBisector), ui(new Ui::DialogBisector),
formula(), m_timerFormula(new QTimer(this))
pointName(),
formulaBaseHeight(0),
timerFormula(new QTimer(this)),
flagFormula(false),
flagError(true),
flagName(true)
{ {
ui->setupUi(this); ui->setupUi(this);
timerFormula->setSingleShot(true); m_timerFormula->setSingleShot(true);
connect(timerFormula, &QTimer::timeout, this, &DialogBisector::EvalFormula); connect(m_timerFormula, &QTimer::timeout, this, &DialogBisector::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));
this->formulaBaseHeight = ui->plainTextEditFormula->height(); this->m_formulaBaseHeight = ui->plainTextEditFormula->height();
ui->plainTextEditFormula->installEventFilter(this); ui->plainTextEditFormula->installEventFilter(this);
InitOkCancelApply(ui); InitOkCancelApply(ui);
@ -91,12 +87,12 @@ DialogBisector::DialogBisector(const VContainer *data, quint32 toolId, QWidget *
connect(ui->toolButtonExprLength, &QPushButton::clicked, this, &DialogBisector::FXLength); connect(ui->toolButtonExprLength, &QPushButton::clicked, this, &DialogBisector::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, &DialogBisector::DeployFormulaTextEdit); connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogBisector::DeployFormulaTextEdit);
connect(ui->comboBoxFirstPoint, &QComboBox::currentTextChanged, connect(ui->comboBoxFirstPoint, &QComboBox::currentTextChanged,
@ -123,12 +119,12 @@ void DialogBisector::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 +136,7 @@ void DialogBisector::PointNameChanged()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogBisector::FXLength() void DialogBisector::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));
@ -162,7 +158,7 @@ void DialogBisector::EvalFormula()
formulaData.postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true); formulaData.postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true);
formulaData.checkZero = false; formulaData.checkZero = false;
Eval(formulaData, flagFormula); Eval(formulaData, m_flagFormula);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -174,7 +170,7 @@ void DialogBisector::ShowVisualization()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogBisector::DeployFormulaTextEdit() 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,11 +193,14 @@ QString DialogBisector::GetPointName() const
*/ */
void DialogBisector::ChosenObject(quint32 id, const SceneObject &type) 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
{ {
return;
}
if (type == SceneObject::Point) if (type == SceneObject::Point)
{ {
VisToolBisector *line = qobject_cast<VisToolBisector *>(vis); auto *line = qobject_cast<VisToolBisector *>(vis);
SCASSERT(line != nullptr) SCASSERT(line != nullptr)
switch (number) switch (number)
@ -225,31 +224,13 @@ void DialogBisector::ChosenObject(quint32 id, const SceneObject &type)
} }
break; break;
case 2: case 2:
{ ChosenThirdPoint(id);
QSet<quint32> 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();
}
}
}
break; break;
default: default:
break; break;
} }
} }
} }
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
@ -258,8 +239,8 @@ void DialogBisector::ChosenObject(quint32 id, const SceneObject &type)
*/ */
void DialogBisector::SetPointName(const QString &value) void DialogBisector::SetPointName(const QString &value)
{ {
pointName = value; m_pointName = value;
ui->lineEditNamePoint->setText(pointName); ui->lineEditNamePoint->setText(m_pointName);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -280,18 +261,18 @@ void DialogBisector::SetTypeLine(const QString &value)
*/ */
void DialogBisector::SetFormula(const QString &value) void DialogBisector::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);
VisToolBisector *line = qobject_cast<VisToolBisector *>(vis); auto *line = qobject_cast<VisToolBisector *>(vis);
SCASSERT(line != nullptr) SCASSERT(line != nullptr)
line->setLength(formula); line->setLength(m_formula);
MoveCursorToEnd(ui->plainTextEditFormula); MoveCursorToEnd(ui->plainTextEditFormula);
} }
@ -305,7 +286,7 @@ void DialogBisector::SetFirstPointId(const quint32 &value)
{ {
setCurrentPointId(ui->comboBoxFirstPoint, value); setCurrentPointId(ui->comboBoxFirstPoint, value);
VisToolBisector *line = qobject_cast<VisToolBisector *>(vis); auto *line = qobject_cast<VisToolBisector *>(vis);
SCASSERT(line != nullptr) SCASSERT(line != nullptr)
line->setObject1Id(value); line->setObject1Id(value);
} }
@ -319,7 +300,7 @@ void DialogBisector::SetSecondPointId(const quint32 &value)
{ {
setCurrentPointId(ui->comboBoxSecondPoint, value); setCurrentPointId(ui->comboBoxSecondPoint, value);
VisToolBisector *line = qobject_cast<VisToolBisector *>(vis); auto *line = qobject_cast<VisToolBisector *>(vis);
SCASSERT(line != nullptr) SCASSERT(line != nullptr)
line->setObject2Id(value); line->setObject2Id(value);
} }
@ -333,13 +314,13 @@ void DialogBisector::SetThirdPointId(const quint32 &value)
{ {
setCurrentPointId(ui->comboBoxThirdPoint, value); setCurrentPointId(ui->comboBoxThirdPoint, value);
VisToolBisector *line = qobject_cast<VisToolBisector *>(vis); auto *line = qobject_cast<VisToolBisector *>(vis);
SCASSERT(line != nullptr) SCASSERT(line != nullptr)
line->setObject3Id(value); line->setObject3Id(value);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QString DialogBisector::GetLineColor() const auto DialogBisector::GetLineColor() const -> QString
{ {
return GetComboBoxCurrentData(ui->comboBoxLineColor, ColorBlack); return GetComboBoxCurrentData(ui->comboBoxLineColor, ColorBlack);
} }
@ -357,7 +338,7 @@ void DialogBisector::SetNotes(const QString &notes)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QString DialogBisector::GetNotes() const auto DialogBisector::GetNotes() const -> QString
{ {
return ui->plainTextEditToolNotes->toPlainText(); return ui->plainTextEditToolNotes->toPlainText();
} }
@ -365,16 +346,16 @@ QString DialogBisector::GetNotes() const
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogBisector::SaveData() void DialogBisector::SaveData()
{ {
pointName = ui->lineEditNamePoint->text(); m_pointName = ui->lineEditNamePoint->text();
formula = ui->plainTextEditFormula->toPlainText(); m_formula = ui->plainTextEditFormula->toPlainText();
VisToolBisector *line = qobject_cast<VisToolBisector *>(vis); auto *line = qobject_cast<VisToolBisector *>(vis);
SCASSERT(line != nullptr) SCASSERT(line != nullptr)
line->setObject1Id(GetFirstPointId()); line->setObject1Id(GetFirstPointId());
line->setObject2Id(GetSecondPointId()); line->setObject2Id(GetSecondPointId());
line->setObject3Id(GetThirdPointId()); line->setObject3Id(GetThirdPointId());
line->setLength(formula); line->setLength(m_formula);
line->setLineStyle(LineStyleToPenStyle(GetTypeLine())); line->setLineStyle(LineStyleToPenStyle(GetTypeLine()));
line->RefreshGeometry(); line->RefreshGeometry();
} }
@ -386,12 +367,33 @@ void DialogBisector::closeEvent(QCloseEvent *event)
DialogTool::closeEvent(event); DialogTool::closeEvent(event);
} }
//---------------------------------------------------------------------------------------------------------------------
void DialogBisector::ChosenThirdPoint(quint32 id)
{
QSet<quint32> 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 * @brief GetTypeLine return type of line
* @return type * @return type
*/ */
QString DialogBisector::GetTypeLine() const auto DialogBisector::GetTypeLine() const -> QString
{ {
return GetComboBoxCurrentData(ui->comboBoxLineType, TypeLineLine); return GetComboBoxCurrentData(ui->comboBoxLineType, TypeLineLine);
} }
@ -401,9 +403,9 @@ QString DialogBisector::GetTypeLine() const
* @brief GetFormula return string of formula * @brief GetFormula return string of formula
* @return 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 * @brief GetFirstPointId return id of first point
* @return id * @return id
*/ */
quint32 DialogBisector::GetFirstPointId() const auto DialogBisector::GetFirstPointId() const -> quint32
{ {
return getCurrentObjectId(ui->comboBoxFirstPoint); return getCurrentObjectId(ui->comboBoxFirstPoint);
} }
@ -421,7 +423,7 @@ quint32 DialogBisector::GetFirstPointId() const
* @brief GetSecondPointId return id of second point * @brief GetSecondPointId return id of second point
* @return id * @return id
*/ */
quint32 DialogBisector::GetSecondPointId() const auto DialogBisector::GetSecondPointId() const -> quint32
{ {
return getCurrentObjectId(ui->comboBoxSecondPoint); return getCurrentObjectId(ui->comboBoxSecondPoint);
} }
@ -431,7 +433,7 @@ quint32 DialogBisector::GetSecondPointId() const
* @brief GetThirdPointId return id of third point * @brief GetThirdPointId return id of third point
* @return id * @return id
*/ */
quint32 DialogBisector::GetThirdPointId() const auto DialogBisector::GetThirdPointId() const -> quint32
{ {
return getCurrentObjectId(ui->comboBoxThirdPoint); return getCurrentObjectId(ui->comboBoxThirdPoint);
} }

View File

@ -52,49 +52,49 @@ class DialogBisector final : public DialogTool
public: public:
DialogBisector(const VContainer *data, quint32 toolId, QWidget *parent = nullptr); DialogBisector(const VContainer *data, quint32 toolId, QWidget *parent = nullptr);
virtual ~DialogBisector() override; ~DialogBisector() 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 GetFirstPointId() const; auto GetFirstPointId() const -> quint32;
void SetFirstPointId(const quint32 &value); void SetFirstPointId(const quint32 &value);
quint32 GetSecondPointId() const; auto GetSecondPointId() const -> quint32;
void SetSecondPointId(const quint32 &value); void SetSecondPointId(const quint32 &value);
quint32 GetThirdPointId() const; auto GetThirdPointId() const -> quint32;
void SetThirdPointId(const quint32 &value); void SetThirdPointId(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(DialogBisector) // NOLINT Q_DISABLE_COPY_MOVE(DialogBisector) // NOLINT
@ -102,23 +102,27 @@ private:
Ui::DialogBisector *ui; Ui::DialogBisector *ui;
/** @brief formula formula */ /** @brief formula formula */
QString formula; QString m_formula{};
QString pointName; QString m_pointName{};
/** @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;
bool flagFormula; bool m_flagFormula{false};
bool flagError; bool m_flagError{true};
bool flagName; 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 #endif // DIALOGBISECTOR_H

View File

@ -35,7 +35,6 @@
#include <new> #include <new>
#include "../../tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolbisector.h" #include "../../tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolbisector.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"
@ -44,35 +43,34 @@
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VisToolBisector::VisToolBisector(const VContainer *data, QGraphicsItem *parent) VisToolBisector::VisToolBisector(const VContainer *data, QGraphicsItem *parent)
:VisLine(data, parent), object2Id(NULL_ID), object3Id(NULL_ID), point(nullptr), line1P1(nullptr), line1P2(nullptr), :VisLine(data, parent)
line1(nullptr), line2P2(nullptr), line2(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);
point = InitPoint(mainColor, this); m_point = InitPoint(mainColor, this);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VisToolBisector::setObject2Id(const quint32 &value) void VisToolBisector::setObject2Id(const quint32 &value)
{ {
object2Id = value; m_object2Id = value;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VisToolBisector::setObject3Id(const quint32 &value) void VisToolBisector::setObject3Id(const quint32 &value)
{ {
object3Id = value; m_object3Id = value;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VisToolBisector::setLength(const QString &expression) 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) 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 (object2Id <= NULL_ID) if (m_object2Id <= 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>(object2Id); const QSharedPointer<VPointF> second = Visualization::data->GeometricObject<VPointF>(m_object2Id);
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 (object3Id <= NULL_ID) if (m_object3Id <= 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>(object3Id); const QSharedPointer<VPointF> third = Visualization::data->GeometricObject<VPointF>(m_object3Id);
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))
{ {
qreal angle = VToolBisector::BisectorAngle(static_cast<QPointF>(*first), qreal angle = VToolBisector::BisectorAngle(static_cast<QPointF>(*first),
static_cast<QPointF>(*second), static_cast<QPointF>(*second),
static_cast<QPointF>(*third)); static_cast<QPointF>(*third));
QLineF mainLine = VGObject::BuildLine(static_cast<QPointF>(*second), length, angle); QLineF mainLine = VGObject::BuildLine(static_cast<QPointF>(*second), m_length, angle);
DrawLine(this, mainLine, mainColor, lineStyle); DrawLine(this, mainLine, mainColor, lineStyle);
DrawPoint(point, mainLine.p2(), mainColor); DrawPoint(m_point, mainLine.p2(), mainColor);
} }
else else
{ {

View File

@ -44,26 +44,26 @@ class VisToolBisector :public VisLine
Q_OBJECT // NOLINT Q_OBJECT // NOLINT
public: public:
explicit VisToolBisector(const VContainer *data, QGraphicsItem *parent = nullptr); explicit VisToolBisector(const VContainer *data, QGraphicsItem *parent = nullptr);
virtual ~VisToolBisector() = default; ~VisToolBisector() override = default;
virtual void RefreshGeometry() override; void RefreshGeometry() override;
void setObject2Id(const quint32 &value); void setObject2Id(const quint32 &value);
void setObject3Id(const quint32 &value); void setObject3Id(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::ToolBisector)}; enum {Type = UserType + static_cast<int>(Vis::ToolBisector)};
private: private:
// cppcheck-suppress unknownMacro // cppcheck-suppress unknownMacro
Q_DISABLE_COPY_MOVE(VisToolBisector) // NOLINT Q_DISABLE_COPY_MOVE(VisToolBisector) // NOLINT
quint32 object2Id; quint32 m_object2Id{NULL_ID};
quint32 object3Id; quint32 m_object3Id{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};
qreal length; qreal m_length{0};
}; };
#endif // VISTOOLBISECTOR_H #endif // VISTOOLBISECTOR_H

View File

@ -45,16 +45,15 @@
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VisToolNormal::VisToolNormal(const VContainer *data, QGraphicsItem *parent) VisToolNormal::VisToolNormal(const VContainer *data, QGraphicsItem *parent)
: VisLine(data, parent), object2Id(NULL_ID), point(nullptr), lineP1(nullptr), lineP2(nullptr), line(nullptr), : VisLine(data, parent)
length(0), angle(0)
{ {
this->mainColor = Qt::red; this->mainColor = Qt::red;
lineP1 = InitPoint(supportColor, this); m_lineP1 = InitPoint(supportColor, this);
lineP2 = InitPoint(supportColor, this); //-V656 m_lineP2 = InitPoint(supportColor, this); //-V656
line = InitItem<VScaledLine>(supportColor, this); m_line = InitItem<VScaledLine>(supportColor, this);
point = InitPoint(mainColor, this); m_point = InitPoint(mainColor, this);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -63,12 +62,12 @@ void VisToolNormal::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(lineP1, static_cast<QPointF>(*first), supportColor); DrawPoint(m_lineP1, static_cast<QPointF>(*first), supportColor);
if (object2Id <= NULL_ID) if (m_object2Id <= NULL_ID)
{ {
QLineF line_mouse(static_cast<QPointF>(*first), Visualization::scenePos); QLineF line_mouse(static_cast<QPointF>(*first), Visualization::scenePos);
DrawLine(line, line_mouse, supportColor); DrawLine(m_line, line_mouse, supportColor);
QLineF normal = line_mouse.normalVector(); QLineF normal = line_mouse.normalVector();
QPointF endRay = Ray(normal.p1(), normal.angle()); QPointF endRay = Ray(normal.p1(), normal.angle());
@ -76,20 +75,20 @@ void VisToolNormal::RefreshGeometry()
} }
else else
{ {
const QSharedPointer<VPointF> second = Visualization::data->GeometricObject<VPointF>(object2Id); const QSharedPointer<VPointF> second = Visualization::data->GeometricObject<VPointF>(m_object2Id);
DrawPoint(lineP2, static_cast<QPointF>(*second), supportColor); DrawPoint(m_lineP2, static_cast<QPointF>(*second), supportColor);
QLineF line_mouse(static_cast<QPointF>(*first), static_cast<QPointF>(*second)); QLineF line_mouse(static_cast<QPointF>(*first), static_cast<QPointF>(*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<QPointF>(*first), static_cast<QPointF>(*second), QPointF fPoint = VToolNormal::FindPoint(static_cast<QPointF>(*first), static_cast<QPointF>(*second),
length, angle); m_length, m_angle);
QLineF mainLine = QLineF(static_cast<QPointF>(*first), fPoint); QLineF mainLine = QLineF(static_cast<QPointF>(*first), fPoint);
DrawLine(this, mainLine, mainColor, lineStyle); DrawLine(this, mainLine, mainColor, lineStyle);
DrawPoint(point, mainLine.p2(), mainColor); DrawPoint(m_point, mainLine.p2(), mainColor);
} }
else if (mode == Mode::Creation) else if (mode == Mode::Creation)
{ {
@ -104,11 +103,11 @@ void VisToolNormal::RefreshGeometry()
} }
QPointF fPoint = VToolNormal::FindPoint(static_cast<QPointF>(*first), static_cast<QPointF>(*second), QPointF fPoint = VToolNormal::FindPoint(static_cast<QPointF>(*first), static_cast<QPointF>(*second),
len, angle); len, m_angle);
QLineF mainLine = QLineF(static_cast<QPointF>(*first), fPoint); QLineF mainLine = QLineF(static_cast<QPointF>(*first), fPoint);
DrawLine(this, mainLine, mainColor, lineStyle); DrawLine(this, mainLine, mainColor, lineStyle);
DrawPoint(point, mainLine.p2(), mainColor); DrawPoint(m_point, mainLine.p2(), mainColor);
const QString prefix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true); const QString prefix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true);
Visualization::toolTip = tr("Length = %1%2; " Visualization::toolTip = tr("Length = %1%2; "
@ -129,23 +128,23 @@ void VisToolNormal::RefreshGeometry()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VisToolNormal::setObject2Id(const quint32 &value) void VisToolNormal::setObject2Id(const quint32 &value)
{ {
object2Id = value; m_object2Id = value;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VisToolNormal::setLength(const QString &expression) 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) void VisToolNormal::SetAngle(const qreal &value)
{ {
angle = value; m_angle = value;
} }

View File

@ -44,27 +44,27 @@ class VisToolNormal : public VisLine
Q_OBJECT // NOLINT Q_OBJECT // NOLINT
public: public:
explicit VisToolNormal(const VContainer *data, QGraphicsItem *parent = nullptr); 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 setObject2Id(const quint32 &value);
void setLength(const QString &expression); void setLength(const QString &expression);
qreal GetAngle() const; auto GetAngle() const -> qreal;
void SetAngle(const qreal &value); void SetAngle(const qreal &value);
virtual int type() const override {return Type;} auto type() const -> int override {return Type;}
enum {Type = UserType + static_cast<int>(Vis::ToolNormal)}; enum {Type = UserType + static_cast<int>(Vis::ToolNormal)};
private: private:
// cppcheck-suppress unknownMacro // cppcheck-suppress unknownMacro
Q_DISABLE_COPY_MOVE(VisToolNormal) // NOLINT Q_DISABLE_COPY_MOVE(VisToolNormal) // NOLINT
quint32 object2Id; quint32 m_object2Id{NULL_ID};
VScaledEllipse *point; VScaledEllipse *m_point{nullptr};
VScaledEllipse *lineP1; VScaledEllipse *m_lineP1{nullptr};
VScaledEllipse *lineP2; VScaledEllipse *m_lineP2{nullptr};
VScaledLine *line; VScaledLine *m_line{nullptr};
qreal length; qreal m_length{0};
qreal angle; qreal m_angle{0};
}; };