Refactoring.

This commit is contained in:
Roman Telezhynskyi 2022-08-20 18:49:32 +03:00
parent 94d46a4530
commit a5c8bab097
8 changed files with 208 additions and 214 deletions

View File

@ -38,7 +38,6 @@
#include <QToolButton> #include <QToolButton>
#include <Qt> #include <Qt>
#include "../ifc/xml/vdomdocument.h"
#include "../vpatterndb/vtranslatevars.h" #include "../vpatterndb/vtranslatevars.h"
#include "../vpatterndb/vcontainer.h" #include "../vpatterndb/vcontainer.h"
#include "../../visualization/path/vistoolarc.h" #include "../../visualization/path/vistoolarc.h"
@ -60,30 +59,30 @@
DialogArc::DialogArc(const VContainer *data, quint32 toolId, QWidget *parent) DialogArc::DialogArc(const VContainer *data, quint32 toolId, QWidget *parent)
: DialogTool(data, toolId, parent), : DialogTool(data, toolId, parent),
ui(new Ui::DialogArc), ui(new Ui::DialogArc),
timerRadius(new QTimer(this)), m_timerRadius(new QTimer(this)),
timerF1(new QTimer(this)), m_timerF1(new QTimer(this)),
timerF2(new QTimer(this)) m_timerF2(new QTimer(this))
{ {
ui->setupUi(this); ui->setupUi(this);
ui->doubleSpinBoxApproximationScale->setMaximum(maxCurveApproximationScale); ui->doubleSpinBoxApproximationScale->setMaximum(maxCurveApproximationScale);
this->formulaBaseHeight = ui->plainTextEditFormula->height(); this->m_formulaBaseHeight = ui->plainTextEditFormula->height();
this->formulaBaseHeightF1 = ui->plainTextEditF1->height(); this->m_formulaBaseHeightF1 = ui->plainTextEditF1->height();
this->formulaBaseHeightF2 = ui->plainTextEditF2->height(); this->m_formulaBaseHeightF2 = ui->plainTextEditF2->height();
ui->plainTextEditFormula->installEventFilter(this); ui->plainTextEditFormula->installEventFilter(this);
ui->plainTextEditF1->installEventFilter(this); ui->plainTextEditF1->installEventFilter(this);
ui->plainTextEditF2->installEventFilter(this); ui->plainTextEditF2->installEventFilter(this);
timerRadius->setSingleShot(true); m_timerRadius->setSingleShot(true);
connect(timerRadius, &QTimer::timeout, this, &DialogArc::EvalRadius); connect(m_timerRadius, &QTimer::timeout, this, &DialogArc::EvalRadius);
timerF1->setSingleShot(true); m_timerF1->setSingleShot(true);
connect(timerF1, &QTimer::timeout, this, &DialogArc::EvalF); connect(m_timerF1, &QTimer::timeout, this, &DialogArc::EvalF);
timerF2->setSingleShot(true); m_timerF2->setSingleShot(true);
connect(timerF2, &QTimer::timeout, this, &DialogArc::EvalF); connect(m_timerF2, &QTimer::timeout, this, &DialogArc::EvalF);
InitOkCancelApply(ui); InitOkCancelApply(ui);
@ -97,17 +96,17 @@ DialogArc::DialogArc(const VContainer *data, quint32 toolId, QWidget *parent)
connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, [this]() connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, [this]()
{ {
timerRadius->start(formulaTimerTimeout); m_timerRadius->start(formulaTimerTimeout);
}); });
connect(ui->plainTextEditF1, &QPlainTextEdit::textChanged, this, [this]() connect(ui->plainTextEditF1, &QPlainTextEdit::textChanged, this, [this]()
{ {
timerF1->start(formulaTimerTimeout); m_timerF1->start(formulaTimerTimeout);
}); });
connect(ui->plainTextEditF2, &QPlainTextEdit::textChanged, this, [this]() connect(ui->plainTextEditF2, &QPlainTextEdit::textChanged, this, [this]()
{ {
timerF2->start(formulaTimerTimeout); m_timerF2->start(formulaTimerTimeout);
}); });
connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogArc::DeployFormulaTextEdit); connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogArc::DeployFormulaTextEdit);
@ -125,19 +124,19 @@ DialogArc::DialogArc(const VContainer *data, quint32 toolId, QWidget *parent)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogArc::DeployFormulaTextEdit() void DialogArc::DeployFormulaTextEdit()
{ {
DeployFormula(this, ui->plainTextEditFormula, ui->pushButtonGrowLength, formulaBaseHeight); DeployFormula(this, ui->plainTextEditFormula, ui->pushButtonGrowLength, m_formulaBaseHeight);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogArc::DeployF1TextEdit() void DialogArc::DeployF1TextEdit()
{ {
DeployFormula(this, ui->plainTextEditF1, ui->pushButtonGrowLengthF1, formulaBaseHeightF1); DeployFormula(this, ui->plainTextEditF1, ui->pushButtonGrowLengthF1, m_formulaBaseHeightF1);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogArc::DeployF2TextEdit() void DialogArc::DeployF2TextEdit()
{ {
DeployFormula(this, ui->plainTextEditF2, ui->pushButtonGrowLengthF2, formulaBaseHeightF2); DeployFormula(this, ui->plainTextEditF2, ui->pushButtonGrowLengthF2, m_formulaBaseHeightF2);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -164,18 +163,18 @@ void DialogArc::SetCenter(const quint32 &value)
*/ */
void DialogArc::SetF2(const QString &value) void DialogArc::SetF2(const QString &value)
{ {
f2 = VAbstractApplication::VApp()->TrVars() m_f2 = VAbstractApplication::VApp()->TrVars()
->FormulaToUser(value, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); ->FormulaToUser(value, VAbstractApplication::VApp()->Settings()->GetOsSeparator());
// increase height if needed. // increase height if needed.
if (f2.length() > 80) if (m_f2.length() > 80)
{ {
this->DeployF2TextEdit(); this->DeployF2TextEdit();
} }
ui->plainTextEditF2->setPlainText(f2); ui->plainTextEditF2->setPlainText(m_f2);
auto *path = qobject_cast<VisToolArc *>(vis); auto *path = qobject_cast<VisToolArc *>(vis);
SCASSERT(path != nullptr) SCASSERT(path != nullptr)
path->setF2(f2); path->setF2(m_f2);
MoveCursorToEnd(ui->plainTextEditF2); MoveCursorToEnd(ui->plainTextEditF2);
} }
@ -235,8 +234,8 @@ auto DialogArc::GetNotes() const -> QString
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogArc::SetAliasSuffix(const QString &alias) void DialogArc::SetAliasSuffix(const QString &alias)
{ {
originAliasSuffix = alias; m_originAliasSuffix = alias;
ui->lineEditAlias->setText(originAliasSuffix); ui->lineEditAlias->setText(m_originAliasSuffix);
ValidateAlias(); ValidateAlias();
} }
@ -293,7 +292,7 @@ void DialogArc::ShowDialog(bool click)
return line.angle(); return line.angle();
}; };
if (stageRadius) if (m_stageRadius)
{ {
//Radius of point circle, but little bigger. Need handle with hover sizes. //Radius of point circle, but little bigger. Need handle with hover sizes.
if (line.length() <= ScaledRadius(SceneScale(VAbstractValApplication::VApp()->getCurrentScene()))*1.5) if (line.length() <= ScaledRadius(SceneScale(VAbstractValApplication::VApp()->getCurrentScene()))*1.5)
@ -303,14 +302,14 @@ void DialogArc::ShowDialog(bool click)
SetRadius(QString::number(VAbstractValApplication::VApp()->fromPixel(line.length()))); SetRadius(QString::number(VAbstractValApplication::VApp()->fromPixel(line.length())));
arcVis->RefreshGeometry(); arcVis->RefreshGeometry();
stageRadius = false; m_stageRadius = false;
stageF1 = true; m_stageF1 = true;
} }
else if (stageF1) else if (m_stageF1)
{ {
SetF1(QString::number(Angle())); SetF1(QString::number(Angle()));
arcVis->RefreshGeometry(); arcVis->RefreshGeometry();
stageF1 = false; m_stageF1 = false;
} }
else else
{ {
@ -332,18 +331,18 @@ void DialogArc::ShowDialog(bool click)
*/ */
void DialogArc::SetF1(const QString &value) void DialogArc::SetF1(const QString &value)
{ {
f1 = VAbstractApplication::VApp()->TrVars() m_f1 = VAbstractApplication::VApp()->TrVars()
->FormulaToUser(value, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); ->FormulaToUser(value, VAbstractApplication::VApp()->Settings()->GetOsSeparator());
// increase height if needed. // increase height if needed.
if (f1.length() > 80) if (m_f1.length() > 80)
{ {
this->DeployF1TextEdit(); this->DeployF1TextEdit();
} }
ui->plainTextEditF1->setPlainText(f1); ui->plainTextEditF1->setPlainText(m_f1);
auto *path = qobject_cast<VisToolArc *>(vis); auto *path = qobject_cast<VisToolArc *>(vis);
SCASSERT(path != nullptr) SCASSERT(path != nullptr)
path->setF1(f1); path->setF1(m_f1);
MoveCursorToEnd(ui->plainTextEditF1); MoveCursorToEnd(ui->plainTextEditF1);
} }
@ -355,18 +354,18 @@ void DialogArc::SetF1(const QString &value)
*/ */
void DialogArc::SetRadius(const QString &value) void DialogArc::SetRadius(const QString &value)
{ {
radius = VAbstractApplication::VApp()->TrVars() m_radius = VAbstractApplication::VApp()->TrVars()
->FormulaToUser(value, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); ->FormulaToUser(value, VAbstractApplication::VApp()->Settings()->GetOsSeparator());
// increase height if needed. // increase height if needed.
if (radius.length() > 80) if (m_radius.length() > 80)
{ {
this->DeployFormulaTextEdit(); this->DeployFormulaTextEdit();
} }
ui->plainTextEditFormula->setPlainText(radius); ui->plainTextEditFormula->setPlainText(m_radius);
auto *path = qobject_cast<VisToolArc *>(vis); auto *path = qobject_cast<VisToolArc *>(vis);
SCASSERT(path != nullptr) SCASSERT(path != nullptr)
path->setRadius(radius); path->setRadius(m_radius);
MoveCursorToEnd(ui->plainTextEditFormula); MoveCursorToEnd(ui->plainTextEditFormula);
} }
@ -411,17 +410,17 @@ void DialogArc::ShowVisualization()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogArc::SaveData() void DialogArc::SaveData()
{ {
radius = ui->plainTextEditFormula->toPlainText(); m_radius = ui->plainTextEditFormula->toPlainText();
f1 = ui->plainTextEditF1->toPlainText(); m_f1 = ui->plainTextEditF1->toPlainText();
f2 = ui->plainTextEditF2->toPlainText(); m_f2 = ui->plainTextEditF2->toPlainText();
auto *path = qobject_cast<VisToolArc *>(vis); auto *path = qobject_cast<VisToolArc *>(vis);
SCASSERT(path != nullptr) SCASSERT(path != nullptr)
path->setObject1Id(GetCenter()); path->setObject1Id(GetCenter());
path->setRadius(radius); path->setRadius(m_radius);
path->setF1(f1); path->setF1(m_f1);
path->setF2(f2); path->setF2(m_f2);
path->setApproximationScale(ui->doubleSpinBoxApproximationScale->value()); path->setApproximationScale(ui->doubleSpinBoxApproximationScale->value());
path->RefreshGeometry(); path->RefreshGeometry();
} }
@ -443,14 +442,14 @@ void DialogArc::ValidateAlias()
arc.SetAliasSuffix(GetAliasSuffix()); arc.SetAliasSuffix(GetAliasSuffix());
if (not GetAliasSuffix().isEmpty() && if (not GetAliasSuffix().isEmpty() &&
(not rx.match(arc.GetAlias()).hasMatch() || (not rx.match(arc.GetAlias()).hasMatch() ||
(originAliasSuffix != GetAliasSuffix() && not data->IsUnique(arc.GetAlias())))) (m_originAliasSuffix != GetAliasSuffix() && not data->IsUnique(arc.GetAlias()))))
{ {
flagAlias = false; m_flagAlias = false;
ChangeColor(ui->labelAlias, errorColor); ChangeColor(ui->labelAlias, errorColor);
} }
else else
{ {
flagAlias = true; m_flagAlias = true;
ChangeColor(ui->labelAlias, OkColor(this)); ChangeColor(ui->labelAlias, OkColor(this));
} }
@ -512,11 +511,11 @@ void DialogArc::EvalRadius()
formulaData.labelResult = ui->labelResultRadius; formulaData.labelResult = ui->labelResultRadius;
formulaData.postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true); formulaData.postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true);
const qreal radius = Eval(formulaData, flagRadius); const qreal radius = Eval(formulaData, m_flagRadius);
if (radius < 0) if (radius < 0)
{ {
flagRadius = false; m_flagRadius = false;
ChangeColor(ui->labelEditRadius, errorColor); ChangeColor(ui->labelEditRadius, errorColor);
ui->labelResultRadius->setText(tr("Error")); ui->labelResultRadius->setText(tr("Error"));
ui->labelResultRadius->setToolTip(tr("Radius can't be negative")); ui->labelResultRadius->setToolTip(tr("Radius can't be negative"));
@ -539,13 +538,13 @@ void DialogArc::EvalF()
formulaData.postfix = degreeSymbol; formulaData.postfix = degreeSymbol;
formulaData.checkZero = false; formulaData.checkZero = false;
angleF1 = Eval(formulaData, flagF1); m_angleF1 = Eval(formulaData, m_flagF1);
formulaData.formula = ui->plainTextEditF2->toPlainText(); formulaData.formula = ui->plainTextEditF2->toPlainText();
formulaData.labelEditFormula = ui->labelEditF2; formulaData.labelEditFormula = ui->labelEditF2;
formulaData.labelResult = ui->labelResultF2; formulaData.labelResult = ui->labelResultF2;
angleF2 = Eval(formulaData, flagF2); m_angleF2 = Eval(formulaData, m_flagF2);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -565,7 +564,7 @@ auto DialogArc::GetCenter() const -> quint32
*/ */
auto DialogArc::GetRadius() const -> QString auto DialogArc::GetRadius() const -> QString
{ {
return VTranslateVars::TryFormulaFromUser(radius, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); return VTranslateVars::TryFormulaFromUser(m_radius, VAbstractApplication::VApp()->Settings()->GetOsSeparator());
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -575,7 +574,7 @@ auto DialogArc::GetRadius() const -> QString
*/ */
auto DialogArc::GetF1() const -> QString auto DialogArc::GetF1() const -> QString
{ {
return VTranslateVars::TryFormulaFromUser(f1, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); return VTranslateVars::TryFormulaFromUser(m_f1, VAbstractApplication::VApp()->Settings()->GetOsSeparator());
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -585,5 +584,5 @@ auto DialogArc::GetF1() const -> QString
*/ */
auto DialogArc::GetF2() const -> QString auto DialogArc::GetF2() const -> QString
{ {
return VTranslateVars::TryFormulaFromUser(f2, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); return VTranslateVars::TryFormulaFromUser(m_f2, VAbstractApplication::VApp()->Settings()->GetOsSeparator());
} }

View File

@ -112,46 +112,46 @@ private:
Ui::DialogArc *ui; Ui::DialogArc *ui;
/** @brief flagRadius true if value of radius is correct */ /** @brief flagRadius true if value of radius is correct */
bool flagRadius{false}; bool m_flagRadius{false};
/** @brief flagF1 true if value of first angle is correct */ /** @brief flagF1 true if value of first angle is correct */
bool flagF1{false}; bool m_flagF1{false};
/** @brief flagF2 true if value of second angle is correct */ /** @brief flagF2 true if value of second angle is correct */
bool flagF2{false}; bool m_flagF2{false};
bool flagAlias{true}; bool m_flagAlias{true};
/** @brief timerRadius timer of check formula of radius */ /** @brief timerRadius timer of check formula of radius */
QTimer *timerRadius; QTimer *m_timerRadius;
/** @brief timerF1 timer of check formula of first angle */ /** @brief timerF1 timer of check formula of first angle */
QTimer *timerF1; QTimer *m_timerF1;
/** @brief timerF2 timer of check formula of second angle */ /** @brief timerF2 timer of check formula of second angle */
QTimer *timerF2; QTimer *m_timerF2;
/** @brief radius formula of radius */ /** @brief radius formula of radius */
QString radius{}; QString m_radius{};
/** @brief f1 formula of first angle */ /** @brief f1 formula of first angle */
QString f1{}; QString m_f1{};
/** @brief f2 formula of second angle */ /** @brief f2 formula of second angle */
QString f2{}; QString m_f2{};
/** @brief formulaBaseHeight base height defined by dialogui */ /** @brief formulaBaseHeight base height defined by dialogui */
int formulaBaseHeight{0}; int m_formulaBaseHeight{0};
int formulaBaseHeightF1{0}; int m_formulaBaseHeightF1{0};
int formulaBaseHeightF2{0}; int m_formulaBaseHeightF2{0};
qreal angleF1{INT_MIN}; qreal m_angleF1{INT_MIN};
qreal angleF2{INT_MIN}; qreal m_angleF2{INT_MIN};
QString originAliasSuffix{}; QString m_originAliasSuffix{};
bool stageRadius{true}; bool m_stageRadius{true};
bool stageF1{false}; bool m_stageF1{false};
bool m_firstRelease{false}; bool m_firstRelease{false};
@ -162,7 +162,7 @@ private:
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
inline auto DialogArc::IsValid() const -> bool inline auto DialogArc::IsValid() const -> bool
{ {
return flagRadius && flagF1 && flagF2 && flagAlias; return m_flagRadius && m_flagF1 && m_flagF2 && m_flagAlias;
} }
#endif // DIALOGARC_H #endif // DIALOGARC_H

View File

@ -41,7 +41,6 @@
#include "../../visualization/path/vistoolcutarc.h" #include "../../visualization/path/vistoolcutarc.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"
@ -58,23 +57,18 @@
DialogCutArc::DialogCutArc(const VContainer *data, quint32 toolId, QWidget *parent) DialogCutArc::DialogCutArc(const VContainer *data, quint32 toolId, QWidget *parent)
: DialogTool(data, toolId, parent), : DialogTool(data, toolId, parent),
ui(new Ui::DialogCutArc), ui(new Ui::DialogCutArc),
formula(), m_timerFormula(new QTimer(this))
pointName(),
formulaBaseHeight(0),
timerFormula(new QTimer(this)),
flagFormula(false),
flagName(true)
{ {
ui->setupUi(this); ui->setupUi(this);
timerFormula->setSingleShot(true); m_timerFormula->setSingleShot(true);
connect(timerFormula, &QTimer::timeout, this, &DialogCutArc::EvalFormula); connect(m_timerFormula, &QTimer::timeout, this, &DialogCutArc::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);
@ -84,12 +78,12 @@ DialogCutArc::DialogCutArc(const VContainer *data, quint32 toolId, QWidget *pare
connect(ui->toolButtonExprLength, &QPushButton::clicked, this, &DialogCutArc::FXLength); connect(ui->toolButtonExprLength, &QPushButton::clicked, this, &DialogCutArc::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, &DialogCutArc::DeployFormulaTextEdit); connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogCutArc::DeployFormulaTextEdit);
@ -107,7 +101,7 @@ DialogCutArc::DialogCutArc(const VContainer *data, quint32 toolId, QWidget *pare
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogCutArc::FXLength() void DialogCutArc::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));
@ -129,7 +123,7 @@ void DialogCutArc::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);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -141,7 +135,7 @@ void DialogCutArc::ShowVisualization()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogCutArc::DeployFormulaTextEdit() void DialogCutArc::DeployFormulaTextEdit()
{ {
DeployFormula(this, ui->plainTextEditFormula, ui->pushButtonGrowLength, formulaBaseHeight); DeployFormula(this, ui->plainTextEditFormula, ui->pushButtonGrowLength, m_formulaBaseHeight);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -151,9 +145,9 @@ DialogCutArc::~DialogCutArc()
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QString DialogCutArc::GetPointName() const auto DialogCutArc::GetPointName() const -> QString
{ {
return pointName; return m_pointName;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -164,20 +158,22 @@ QString DialogCutArc::GetPointName() const
*/ */
void DialogCutArc::ChosenObject(quint32 id, const SceneObject &type) void DialogCutArc::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::Arc) return;
}
if (type == SceneObject::Arc)
{
if (SetObject(id, ui->comboBoxArc, QString()))
{ {
if (SetObject(id, ui->comboBoxArc, QString())) if (vis != nullptr)
{ {
if (vis != nullptr) vis->VisualMode(id);
{
vis->VisualMode(id);
}
prepare = true;
this->setModal(true);
this->show();
} }
prepare = true;
this->setModal(true);
this->show();
} }
} }
} }
@ -185,14 +181,14 @@ void DialogCutArc::ChosenObject(quint32 id, const SceneObject &type)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogCutArc::SaveData() void DialogCutArc::SaveData()
{ {
pointName = ui->lineEditNamePoint->text(); m_pointName = ui->lineEditNamePoint->text();
formula = ui->plainTextEditFormula->toPlainText(); m_formula = ui->plainTextEditFormula->toPlainText();
VisToolCutArc *path = qobject_cast<VisToolCutArc *>(vis); auto *path = qobject_cast<VisToolCutArc *>(vis);
SCASSERT(path != nullptr) SCASSERT(path != nullptr)
path->setObject1Id(getArcId()); path->setObject1Id(getArcId());
path->setLength(formula); path->setLength(m_formula);
path->RefreshGeometry(); path->RefreshGeometry();
} }
@ -222,29 +218,29 @@ void DialogCutArc::ValidateAlias()
if (not GetAliasSuffix1().isEmpty() && if (not GetAliasSuffix1().isEmpty() &&
(not rx.match(arc1.GetAlias()).hasMatch() || (not rx.match(arc1.GetAlias()).hasMatch() ||
(originAliasSuffix1 != GetAliasSuffix1() && not data->IsUnique(arc1.GetAlias())) || (m_originAliasSuffix1 != GetAliasSuffix1() && not data->IsUnique(arc1.GetAlias())) ||
arc1.GetAlias() == arc2.GetAlias())) arc1.GetAlias() == arc2.GetAlias()))
{ {
flagAlias1 = false; m_flagAlias1 = false;
ChangeColor(ui->labelAlias1, errorColor); ChangeColor(ui->labelAlias1, errorColor);
} }
else else
{ {
flagAlias1 = true; m_flagAlias1 = true;
ChangeColor(ui->labelAlias1, OkColor(this)); ChangeColor(ui->labelAlias1, OkColor(this));
} }
if (not GetAliasSuffix2().isEmpty() && if (not GetAliasSuffix2().isEmpty() &&
(not rx.match(arc2.GetAlias()).hasMatch() || (not rx.match(arc2.GetAlias()).hasMatch() ||
(originAliasSuffix2 != GetAliasSuffix2() && not data->IsUnique(arc2.GetAlias())) || (m_originAliasSuffix2 != GetAliasSuffix2() && not data->IsUnique(arc2.GetAlias())) ||
arc1.GetAlias() == arc2.GetAlias())) arc1.GetAlias() == arc2.GetAlias()))
{ {
flagAlias2 = false; m_flagAlias2 = false;
ChangeColor(ui->labelAlias2, errorColor); ChangeColor(ui->labelAlias2, errorColor);
} }
else else
{ {
flagAlias2 = true; m_flagAlias2 = true;
ChangeColor(ui->labelAlias2, OkColor(this)); ChangeColor(ui->labelAlias2, OkColor(this));
} }
@ -260,7 +256,7 @@ void DialogCutArc::setArcId(quint32 value)
{ {
setCurrentArcId(ui->comboBoxArc, value); setCurrentArcId(ui->comboBoxArc, value);
VisToolCutArc *path = qobject_cast<VisToolCutArc *>(vis); auto *path = qobject_cast<VisToolCutArc *>(vis);
SCASSERT(path != nullptr) SCASSERT(path != nullptr)
path->setObject1Id(value); path->setObject1Id(value);
} }
@ -272,18 +268,18 @@ void DialogCutArc::setArcId(quint32 value)
*/ */
void DialogCutArc::SetFormula(const QString &value) void DialogCutArc::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);
VisToolCutArc *path = qobject_cast<VisToolCutArc *>(vis); auto *path = qobject_cast<VisToolCutArc *>(vis);
SCASSERT(path != nullptr) SCASSERT(path != nullptr)
path->setLength(formula); path->setLength(m_formula);
MoveCursorToEnd(ui->plainTextEditFormula); MoveCursorToEnd(ui->plainTextEditFormula);
} }
@ -295,8 +291,8 @@ void DialogCutArc::SetFormula(const QString &value)
*/ */
void DialogCutArc::SetPointName(const QString &value) void DialogCutArc::SetPointName(const QString &value)
{ {
pointName = value; m_pointName = value;
ui->lineEditNamePoint->setText(pointName); ui->lineEditNamePoint->setText(m_pointName);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -304,9 +300,9 @@ void DialogCutArc::SetPointName(const QString &value)
* @brief GetFormula return string with formula length * @brief GetFormula return string with formula length
* @return formula * @return formula
*/ */
QString DialogCutArc::GetFormula() const auto DialogCutArc::GetFormula() const -> QString
{ {
return VTranslateVars::TryFormulaFromUser(formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); return VTranslateVars::TryFormulaFromUser(m_formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator());
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -314,7 +310,7 @@ QString DialogCutArc::GetFormula() const
* @brief getArcId return id of arc * @brief getArcId return id of arc
* @return id * @return id
*/ */
quint32 DialogCutArc::getArcId() const auto DialogCutArc::getArcId() const -> quint32
{ {
return getCurrentObjectId(ui->comboBoxArc); return getCurrentObjectId(ui->comboBoxArc);
} }
@ -326,7 +322,7 @@ void DialogCutArc::SetNotes(const QString &notes)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QString DialogCutArc::GetNotes() const auto DialogCutArc::GetNotes() const -> QString
{ {
return ui->plainTextEditToolNotes->toPlainText(); return ui->plainTextEditToolNotes->toPlainText();
} }
@ -334,13 +330,13 @@ QString DialogCutArc::GetNotes() const
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogCutArc::SetAliasSuffix1(const QString &alias) void DialogCutArc::SetAliasSuffix1(const QString &alias)
{ {
originAliasSuffix1 = alias; m_originAliasSuffix1 = alias;
ui->lineEditAlias1->setText(originAliasSuffix1); ui->lineEditAlias1->setText(m_originAliasSuffix1);
ValidateAlias(); ValidateAlias();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QString DialogCutArc::GetAliasSuffix1() const auto DialogCutArc::GetAliasSuffix1() const -> QString
{ {
return ui->lineEditAlias1->text(); return ui->lineEditAlias1->text();
} }
@ -348,13 +344,13 @@ QString DialogCutArc::GetAliasSuffix1() const
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogCutArc::SetAliasSuffix2(const QString &alias) void DialogCutArc::SetAliasSuffix2(const QString &alias)
{ {
originAliasSuffix2 = alias; m_originAliasSuffix2 = alias;
ui->lineEditAlias2->setText(originAliasSuffix2); ui->lineEditAlias2->setText(m_originAliasSuffix2);
ValidateAlias(); ValidateAlias();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QString DialogCutArc::GetAliasSuffix2() const auto DialogCutArc::GetAliasSuffix2() const -> QString
{ {
return ui->lineEditAlias2->text(); return ui->lineEditAlias2->text();
} }

View File

@ -52,43 +52,43 @@ class DialogCutArc final : public DialogTool
public: public:
DialogCutArc(const VContainer *data, quint32 toolId, QWidget *parent = nullptr); DialogCutArc(const VContainer *data, quint32 toolId, QWidget *parent = nullptr);
virtual ~DialogCutArc() override; ~DialogCutArc() override;
QString GetPointName() const; auto GetPointName() const -> QString;
void SetPointName(const QString &value); void SetPointName(const QString &value);
QString GetFormula() const; auto GetFormula() const -> QString;
void SetFormula(const QString &value); void SetFormula(const QString &value);
quint32 getArcId() const; auto getArcId() const -> quint32;
void setArcId(quint32 value); void setArcId(quint32 value);
void SetNotes(const QString &notes); void SetNotes(const QString &notes);
QString GetNotes() const; auto GetNotes() const -> QString;
void SetAliasSuffix1(const QString &alias); void SetAliasSuffix1(const QString &alias);
QString GetAliasSuffix1() const; auto GetAliasSuffix1() const -> QString;
void SetAliasSuffix2(const QString &alias); void SetAliasSuffix2(const QString &alias);
QString GetAliasSuffix2() const; auto GetAliasSuffix2() 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();
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 slots: private slots:
void ArcChanged(); void ArcChanged();
void ValidateAlias(); void ValidateAlias();
@ -98,27 +98,27 @@ private:
Ui::DialogCutArc *ui; Ui::DialogCutArc *ui;
/** @brief formula string with formula */ /** @brief formula string with 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 flagName; bool m_flagName{true};
bool flagAlias1{true}; bool m_flagAlias1{true};
bool flagAlias2{true}; bool m_flagAlias2{true};
QString originAliasSuffix1{}; QString m_originAliasSuffix1{};
QString originAliasSuffix2{}; QString m_originAliasSuffix2{};
}; };
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
inline bool DialogCutArc::IsValid() const inline auto DialogCutArc::IsValid() const -> bool
{ {
return flagFormula && flagName && flagAlias1 && flagAlias2; return m_flagFormula && m_flagName && m_flagAlias1 && m_flagAlias2;
} }
#endif // DIALOGCUTARC_H #endif // DIALOGCUTARC_H

View File

@ -51,8 +51,8 @@
VisToolArc::VisToolArc(const VContainer *data, QGraphicsItem *parent) VisToolArc::VisToolArc(const VContainer *data, QGraphicsItem *parent)
:VisPath(data, parent) :VisPath(data, parent)
{ {
arcCenter = InitPoint(mainColor, this); m_arcCenter = InitPoint(mainColor, this);
f1Point = InitPoint(supportColor, this); m_f1Point = InitPoint(supportColor, this);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -60,10 +60,10 @@ void VisToolArc::RefreshGeometry()
{ {
if (object1Id > NULL_ID) if (object1Id > NULL_ID)
{ {
f1Point->setVisible(false); m_f1Point->setVisible(false);
const QSharedPointer<VPointF> first = Visualization::data->GeometricObject<VPointF>(object1Id); const QSharedPointer<VPointF> first = Visualization::data->GeometricObject<VPointF>(object1Id);
DrawPoint(arcCenter, static_cast<QPointF>(*first), supportColor); DrawPoint(m_arcCenter, static_cast<QPointF>(*first), supportColor);
if (mode == Mode::Creation) if (mode == Mode::Creation)
{ {
@ -83,7 +83,7 @@ void VisToolArc::RefreshGeometry()
static const QString prefix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true); static const QString prefix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true);
if (qFuzzyIsNull(radius)) if (qFuzzyIsNull(m_radius))
{ {
VArc arc = VArc (*first, r.length(), r.angle(), r.angle()); VArc arc = VArc (*first, r.length(), r.angle(), r.angle());
arc.SetApproximationScale(m_approximationScale); arc.SetApproximationScale(m_approximationScale);
@ -94,31 +94,31 @@ void VisToolArc::RefreshGeometry()
"<b>%3</b> - skip") "<b>%3</b> - skip")
.arg(NumberToUser(r.length()), prefix, VModifierKey::EnterKey()); .arg(NumberToUser(r.length()), prefix, VModifierKey::EnterKey());
} }
else if (f1 < 0) else if (m_f1 < 0)
{ {
qreal f1Angle = Angle(); qreal f1Angle = Angle();
VArc arc = VArc (*first, radius, f1Angle, f1Angle); VArc arc = VArc (*first, m_radius, f1Angle, f1Angle);
arc.SetApproximationScale(m_approximationScale); arc.SetApproximationScale(m_approximationScale);
DrawPath(this, arc.GetPath(), QVector<DirectionArrow>(), supportColor, Qt::DashLine, Qt::RoundCap); DrawPath(this, arc.GetPath(), QVector<DirectionArrow>(), supportColor, Qt::DashLine, Qt::RoundCap);
QLineF f1Line = r; QLineF f1Line = r;
f1Line.setLength(radius); f1Line.setLength(m_radius);
f1Line.setAngle(f1Angle); f1Line.setAngle(f1Angle);
DrawPoint(f1Point, f1Line.p2(), supportColor); DrawPoint(m_f1Point, f1Line.p2(), supportColor);
Visualization::toolTip = tr("<b>Arc</b>: radius = %1%2, first angle = %3°; " Visualization::toolTip = tr("<b>Arc</b>: radius = %1%2, first angle = %3°; "
"<b>Mouse click</b> - finish selecting the first angle, " "<b>Mouse click</b> - finish selecting the first angle, "
"<b>%4</b> - sticking angle, " "<b>%4</b> - sticking angle, "
"<b>%5</b> - skip") "<b>%5</b> - skip")
.arg(NumberToUser(radius), prefix) .arg(NumberToUser(m_radius), prefix)
.arg(f1Angle) .arg(f1Angle)
.arg(VModifierKey::Shift(), VModifierKey::EnterKey()); .arg(VModifierKey::Shift(), VModifierKey::EnterKey());
} }
else if (f1 >= 0) else if (m_f1 >= 0)
{ {
qreal f2Angle = StickyEnd(Angle()); qreal f2Angle = StickyEnd(Angle());
VArc arc = VArc (*first, radius, f1, f2Angle); VArc arc = VArc (*first, m_radius, m_f1, f2Angle);
arc.SetApproximationScale(m_approximationScale); arc.SetApproximationScale(m_approximationScale);
DrawPath(this, arc.GetPath(), arc.DirectionArrows(), mainColor, lineStyle, Qt::RoundCap); DrawPath(this, arc.GetPath(), arc.DirectionArrows(), mainColor, lineStyle, Qt::RoundCap);
@ -127,17 +127,17 @@ void VisToolArc::RefreshGeometry()
"<b>%5</b> - sticking angle, " "<b>%5</b> - sticking angle, "
"<b>%6</b> - sticking end, " "<b>%6</b> - sticking end, "
"<b>%7</b> - skip") "<b>%7</b> - skip")
.arg(NumberToUser(radius), prefix) .arg(NumberToUser(m_radius), prefix)
.arg(f1) .arg(m_f1)
.arg(f2Angle) .arg(f2Angle)
.arg(VModifierKey::Shift(), VModifierKey::Control(), VModifierKey::EnterKey()); .arg(VModifierKey::Shift(), VModifierKey::Control(), VModifierKey::EnterKey());
} }
} }
else else
{ {
if (not qFuzzyIsNull(radius) && f1 >= 0 && f2 >= 0) if (not qFuzzyIsNull(m_radius) && m_f1 >= 0 && m_f2 >= 0)
{ {
VArc arc = VArc (*first, radius, f1, f2); VArc arc = VArc (*first, m_radius, m_f1, m_f2);
arc.SetApproximationScale(m_approximationScale); arc.SetApproximationScale(m_approximationScale);
DrawPath(this, arc.GetPath(), arc.DirectionArrows(), mainColor, lineStyle, Qt::RoundCap); DrawPath(this, arc.GetPath(), arc.DirectionArrows(), mainColor, lineStyle, Qt::RoundCap);
} }
@ -152,19 +152,19 @@ void VisToolArc::RefreshGeometry()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VisToolArc::setRadius(const QString &expression) void VisToolArc::setRadius(const QString &expression)
{ {
radius = FindLengthFromUser(expression, Visualization::data->DataVariables()); m_radius = FindLengthFromUser(expression, Visualization::data->DataVariables());
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VisToolArc::setF1(const QString &expression) void VisToolArc::setF1(const QString &expression)
{ {
f1 = FindValFromUser(expression, Visualization::data->DataVariables()); m_f1 = FindValFromUser(expression, Visualization::data->DataVariables());
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VisToolArc::setF2(const QString &expression) void VisToolArc::setF2(const QString &expression)
{ {
f2 = FindValFromUser(expression, Visualization::data->DataVariables()); m_f2 = FindValFromUser(expression, Visualization::data->DataVariables());
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -185,16 +185,16 @@ auto VisToolArc::StickyEnd(qreal angle) const -> qreal
if (QGuiApplication::keyboardModifiers() == Qt::ControlModifier) if (QGuiApplication::keyboardModifiers() == Qt::ControlModifier)
{ {
QLineF line(10, 10, 100, 10); QLineF line(10, 10, 100, 10);
line.setLength(radius); line.setLength(m_radius);
QLineF line2 = line; QLineF line2 = line;
line.setAngle(f1); line.setAngle(m_f1);
line2.setAngle(angle); line2.setAngle(angle);
if (VFuzzyComparePoints(line.p2(), line2.p2(), UnitConvertor(5, Unit::Mm, Unit::Px))) if (VFuzzyComparePoints(line.p2(), line2.p2(), UnitConvertor(5, Unit::Mm, Unit::Px)))
{ {
return f1; return m_f1;
} }
} }

View File

@ -52,17 +52,17 @@ public:
void setF1(const QString &expression); void setF1(const QString &expression);
void setF2(const QString &expression); void setF2(const QString &expression);
auto type() const -> int override {return Type;} auto type() const -> int override {return Type;}
enum { Type = UserType + static_cast<int>(Vis::ToolArc)}; enum {Type = UserType + static_cast<int>(Vis::ToolArc)};
static auto CorrectAngle(qreal angle) -> qreal; static auto CorrectAngle(qreal angle) -> qreal;
auto StickyEnd(qreal angle) const -> qreal; auto StickyEnd(qreal angle) const -> qreal;
private: private:
Q_DISABLE_COPY_MOVE(VisToolArc) // NOLINT Q_DISABLE_COPY_MOVE(VisToolArc) // NOLINT
VScaledEllipse *arcCenter{nullptr}; VScaledEllipse *m_arcCenter{nullptr};
VScaledEllipse *f1Point{nullptr}; VScaledEllipse *m_f1Point{nullptr};
qreal radius{0}; qreal m_radius{0};
qreal f1{-1}; qreal m_f1{-1};
qreal f2{-1}; qreal m_f2{-1};
}; };
#endif // VISTOOLARC_H #endif // VISTOOLARC_H

View File

@ -36,7 +36,6 @@
#include <Qt> #include <Qt>
#include <new> #include <new>
#include "../ifc/ifcdef.h"
#include "../vgeometry/vabstractcurve.h" #include "../vgeometry/vabstractcurve.h"
#include "../vgeometry/varc.h" #include "../vgeometry/varc.h"
#include "../vpatterndb/vcontainer.h" #include "../vpatterndb/vcontainer.h"
@ -46,16 +45,16 @@
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VisToolCutArc::VisToolCutArc(const VContainer *data, QGraphicsItem *parent) VisToolCutArc::VisToolCutArc(const VContainer *data, QGraphicsItem *parent)
:VisPath(data, parent), point(nullptr), arc1(nullptr), arc2(nullptr), length(0) :VisPath(data, parent)
{ {
arc1 = InitItem<VCurvePathItem>(Qt::darkGreen, this); m_arc1 = InitItem<VCurvePathItem>(Qt::darkGreen, this);
arc1->setFlag(QGraphicsItem::ItemStacksBehindParent, false); m_arc1->setFlag(QGraphicsItem::ItemStacksBehindParent, false);
arc2 = InitItem<VCurvePathItem>(Qt::darkRed, this); m_arc2 = InitItem<VCurvePathItem>(Qt::darkRed, this);
arc2->setFlag(QGraphicsItem::ItemStacksBehindParent, false); m_arc2->setFlag(QGraphicsItem::ItemStacksBehindParent, false);
point = InitPoint(mainColor, this); m_point = InitPoint(mainColor, this);
point->setZValue(2); m_point->setZValue(2);
point->setFlag(QGraphicsItem::ItemStacksBehindParent, false); m_point->setFlag(QGraphicsItem::ItemStacksBehindParent, false);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -66,15 +65,15 @@ void VisToolCutArc::RefreshGeometry()
const QSharedPointer<VArc> arc = Visualization::data->GeometricObject<VArc>(object1Id); const QSharedPointer<VArc> arc = Visualization::data->GeometricObject<VArc>(object1Id);
DrawPath(this, arc->GetPath(), arc->DirectionArrows(), supportColor, lineStyle, Qt::RoundCap); DrawPath(this, arc->GetPath(), arc->DirectionArrows(), supportColor, lineStyle, Qt::RoundCap);
if (not qFuzzyIsNull(length)) if (not qFuzzyIsNull(m_length))
{ {
VArc ar1; VArc ar1;
VArc ar2; VArc ar2;
QPointF p = arc->CutArc(length, ar1, ar2, QString()); QPointF p = arc->CutArc(m_length, ar1, ar2, QString());
DrawPoint(point, p, mainColor); DrawPoint(m_point, p, mainColor);
DrawPath(arc1, ar1.GetPath(), ar1.DirectionArrows(), Qt::darkGreen, lineStyle, Qt::RoundCap); DrawPath(m_arc1, ar1.GetPath(), ar1.DirectionArrows(), Qt::darkGreen, lineStyle, Qt::RoundCap);
DrawPath(arc2, ar2.GetPath(), ar2.DirectionArrows(), Qt::darkRed, lineStyle, Qt::RoundCap); DrawPath(m_arc2, ar2.GetPath(), ar2.DirectionArrows(), Qt::darkRed, lineStyle, Qt::RoundCap);
} }
} }
} }
@ -82,5 +81,5 @@ void VisToolCutArc::RefreshGeometry()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VisToolCutArc::setLength(const QString &expression) void VisToolCutArc::setLength(const QString &expression)
{ {
length = FindLengthFromUser(expression, Visualization::data->DataVariables()); m_length = FindLengthFromUser(expression, Visualization::data->DataVariables());
} }

View File

@ -44,18 +44,18 @@ class VisToolCutArc final : public VisPath
Q_OBJECT // NOLINT Q_OBJECT // NOLINT
public: public:
explicit VisToolCutArc(const VContainer *data, QGraphicsItem *parent = nullptr); explicit VisToolCutArc(const VContainer *data, QGraphicsItem *parent = nullptr);
virtual ~VisToolCutArc() Q_DECL_EQ_DEFAULT; ~VisToolCutArc() override = default;
virtual void RefreshGeometry() override; void RefreshGeometry() override;
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::ToolCutArc)}; enum {Type = UserType + static_cast<int>(Vis::ToolCutArc)};
protected: private:
Q_DISABLE_COPY_MOVE(VisToolCutArc) // NOLINT Q_DISABLE_COPY_MOVE(VisToolCutArc) // NOLINT
VScaledEllipse *point; VScaledEllipse *m_point{nullptr};
VCurvePathItem *arc1; VCurvePathItem *m_arc1{nullptr};
VCurvePathItem *arc2; VCurvePathItem *m_arc2{nullptr};
qreal length; qreal m_length{0};
}; };
#endif // VISTOOLCUTARC_H #endif // VISTOOLCUTARC_H