Refactoring.
This commit is contained in:
parent
714a4e1715
commit
9a28166539
|
@ -45,7 +45,6 @@
|
|||
#include "../../visualization/line/vistoolalongline.h"
|
||||
#include "../../visualization/visualization.h"
|
||||
#include "../ifc/xml/vabstractpattern.h"
|
||||
#include "../ifc/xml/vdomdocument.h"
|
||||
#include "../support/dialogeditwrongformula.h"
|
||||
#include "../vgeometry/../ifc/ifcdef.h"
|
||||
#include "../vgeometry/vpointf.h"
|
||||
|
@ -65,26 +64,19 @@
|
|||
DialogAlongLine::DialogAlongLine(const VContainer *data, quint32 toolId, QWidget *parent)
|
||||
: DialogTool(data, toolId, parent),
|
||||
ui(new Ui::DialogAlongLine),
|
||||
formula(),
|
||||
pointName(),
|
||||
formulaBaseHeight(0),
|
||||
buildMidpoint(false),
|
||||
timerFormula(new QTimer(this)),
|
||||
flagFormula(false),
|
||||
flagError(true),
|
||||
flagName(true)
|
||||
m_timerFormula(new QTimer(this))
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
timerFormula->setSingleShot(true);
|
||||
connect(timerFormula, &QTimer::timeout, this, &DialogAlongLine::EvalFormula);
|
||||
m_timerFormula->setSingleShot(true);
|
||||
connect(m_timerFormula, &QTimer::timeout, this, &DialogAlongLine::EvalFormula);
|
||||
|
||||
ui->lineEditNamePoint->setClearButtonEnabled(true);
|
||||
|
||||
ui->lineEditNamePoint->setText(
|
||||
VAbstractValApplication::VApp()->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
|
||||
|
||||
this->formulaBaseHeight = ui->plainTextEditFormula->height();
|
||||
this->m_formulaBaseHeight = ui->plainTextEditFormula->height();
|
||||
ui->plainTextEditFormula->installEventFilter(this);
|
||||
|
||||
InitOkCancelApply(ui);
|
||||
|
@ -97,12 +89,12 @@ DialogAlongLine::DialogAlongLine(const VContainer *data, quint32 toolId, QWidget
|
|||
connect(ui->toolButtonExprLength, &QPushButton::clicked, this, &DialogAlongLine::FXLength);
|
||||
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, [this]()
|
||||
{
|
||||
CheckPointLabel(this, ui->lineEditNamePoint, ui->labelEditNamePoint, pointName, this->data, flagName);
|
||||
CheckPointLabel(this, ui->lineEditNamePoint, ui->labelEditNamePoint, m_pointName, this->data, m_flagName);
|
||||
CheckState();
|
||||
});
|
||||
connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, [this]()
|
||||
{
|
||||
timerFormula->start(formulaTimerTimeout);
|
||||
m_timerFormula->start(formulaTimerTimeout);
|
||||
});
|
||||
connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogAlongLine::DeployFormulaTextEdit);
|
||||
connect(ui->comboBoxFirstPoint, &QComboBox::currentTextChanged,
|
||||
|
@ -125,12 +117,12 @@ void DialogAlongLine::PointChanged()
|
|||
QColor color;
|
||||
if (GetFirstPointId() == GetSecondPointId())
|
||||
{
|
||||
flagError = false;
|
||||
m_flagError = false;
|
||||
color = errorColor;
|
||||
}
|
||||
else
|
||||
{
|
||||
flagError = true;
|
||||
m_flagError = true;
|
||||
color = OkColor(this);
|
||||
}
|
||||
SetCurrentLength();
|
||||
|
@ -142,7 +134,7 @@ void DialogAlongLine::PointChanged()
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogAlongLine::FXLength()
|
||||
{
|
||||
DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this);
|
||||
auto *dialog = new DialogEditWrongFormula(data, toolId, this);
|
||||
dialog->setWindowTitle(tr("Edit length"));
|
||||
dialog->SetFormula(GetFormula());
|
||||
dialog->setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true));
|
||||
|
@ -164,7 +156,7 @@ void DialogAlongLine::EvalFormula()
|
|||
formulaData.postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true);
|
||||
formulaData.checkZero = false;
|
||||
|
||||
Eval(formulaData, flagFormula);
|
||||
Eval(formulaData, m_flagFormula);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -176,7 +168,7 @@ void DialogAlongLine::ShowVisualization()
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogAlongLine::DeployFormulaTextEdit()
|
||||
{
|
||||
DeployFormula(this, ui->plainTextEditFormula, ui->pushButtonGrowLength, formulaBaseHeight);
|
||||
DeployFormula(this, ui->plainTextEditFormula, ui->pushButtonGrowLength, m_formulaBaseHeight);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -196,11 +188,14 @@ DialogAlongLine::~DialogAlongLine()
|
|||
*/
|
||||
void DialogAlongLine::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)
|
||||
{
|
||||
VisToolAlongLine *line = qobject_cast<VisToolAlongLine *>(vis);
|
||||
auto *line = qobject_cast<VisToolAlongLine *>(vis);
|
||||
SCASSERT(line != nullptr)
|
||||
|
||||
const QString toolTip = tr("Select second point of line");
|
||||
|
@ -216,10 +211,10 @@ void DialogAlongLine::ChosenObject(quint32 id, const SceneObject &type)
|
|||
case 1:
|
||||
if (SetObject(id, ui->comboBoxSecondPoint, QString()))
|
||||
{
|
||||
if (flagError)
|
||||
if (m_flagError)
|
||||
{
|
||||
line->setObject2Id(id);
|
||||
if (buildMidpoint)
|
||||
if (m_buildMidpoint)
|
||||
{
|
||||
SetFormula(currentLength + QStringLiteral("/2"));
|
||||
}
|
||||
|
@ -238,22 +233,21 @@ void DialogAlongLine::ChosenObject(quint32 id, const SceneObject &type)
|
|||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogAlongLine::SaveData()
|
||||
{
|
||||
pointName = ui->lineEditNamePoint->text();
|
||||
m_pointName = ui->lineEditNamePoint->text();
|
||||
|
||||
formula = ui->plainTextEditFormula->toPlainText();
|
||||
m_formula = ui->plainTextEditFormula->toPlainText();
|
||||
|
||||
VisToolAlongLine *line = qobject_cast<VisToolAlongLine *>(vis);
|
||||
auto *line = qobject_cast<VisToolAlongLine *>(vis);
|
||||
SCASSERT(line != nullptr)
|
||||
|
||||
line->setObject1Id(GetFirstPointId());
|
||||
line->setObject2Id(GetSecondPointId());
|
||||
line->setLength(formula);
|
||||
line->setLength(m_formula);
|
||||
line->setLineStyle(LineStyleToPenStyle(GetTypeLine()));
|
||||
line->RefreshGeometry();
|
||||
}
|
||||
|
@ -299,7 +293,7 @@ void DialogAlongLine::SetSecondPointId(quint32 value)
|
|||
{
|
||||
setCurrentPointId(ui->comboBoxSecondPoint, value);
|
||||
|
||||
VisToolAlongLine *line = qobject_cast<VisToolAlongLine *>(vis);
|
||||
auto *line = qobject_cast<VisToolAlongLine *>(vis);
|
||||
SCASSERT(line != nullptr)
|
||||
line->setObject2Id(value);
|
||||
}
|
||||
|
@ -311,7 +305,7 @@ void DialogAlongLine::SetNotes(const QString ¬es)
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString DialogAlongLine::GetNotes() const
|
||||
auto DialogAlongLine::GetNotes() const -> QString
|
||||
{
|
||||
return ui->plainTextEditToolNotes->toPlainText();
|
||||
}
|
||||
|
@ -321,10 +315,10 @@ void DialogAlongLine::Build(const Tool &type)
|
|||
{
|
||||
if (type == Tool::Midpoint)
|
||||
{
|
||||
buildMidpoint = true;
|
||||
VisToolAlongLine *line = qobject_cast<VisToolAlongLine *>(vis);
|
||||
m_buildMidpoint = true;
|
||||
auto *line = qobject_cast<VisToolAlongLine *>(vis);
|
||||
SCASSERT(line != nullptr)
|
||||
line->setMidPointMode(buildMidpoint);
|
||||
line->setMidPointMode(m_buildMidpoint);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -337,7 +331,7 @@ void DialogAlongLine::SetFirstPointId(quint32 value)
|
|||
{
|
||||
setCurrentPointId(ui->comboBoxFirstPoint, value);
|
||||
|
||||
VisToolAlongLine *line = qobject_cast<VisToolAlongLine *>(vis);
|
||||
auto *line = qobject_cast<VisToolAlongLine *>(vis);
|
||||
SCASSERT(line != nullptr)
|
||||
line->setObject1Id(value);
|
||||
}
|
||||
|
@ -349,18 +343,18 @@ void DialogAlongLine::SetFirstPointId(quint32 value)
|
|||
*/
|
||||
void DialogAlongLine::SetFormula(const QString &value)
|
||||
{
|
||||
formula = VAbstractApplication::VApp()->TrVars()
|
||||
m_formula = VAbstractApplication::VApp()->TrVars()
|
||||
->FormulaToUser(value, VAbstractApplication::VApp()->Settings()->GetOsSeparator());
|
||||
// increase height if needed.
|
||||
if (formula.length() > 80)
|
||||
if (m_formula.length() > 80)
|
||||
{
|
||||
this->DeployFormulaTextEdit();
|
||||
}
|
||||
ui->plainTextEditFormula->setPlainText(formula);
|
||||
ui->plainTextEditFormula->setPlainText(m_formula);
|
||||
|
||||
VisToolAlongLine *line = qobject_cast<VisToolAlongLine *>(vis);
|
||||
auto *line = qobject_cast<VisToolAlongLine *>(vis);
|
||||
SCASSERT(line != nullptr)
|
||||
line->setLength(formula);
|
||||
line->setLength(m_formula);
|
||||
|
||||
MoveCursorToEnd(ui->plainTextEditFormula);
|
||||
}
|
||||
|
@ -377,7 +371,7 @@ void DialogAlongLine::SetTypeLine(const QString &value)
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString DialogAlongLine::GetLineColor() const
|
||||
auto DialogAlongLine::GetLineColor() const -> QString
|
||||
{
|
||||
return GetComboBoxCurrentData(ui->comboBoxLineColor, ColorBlack);
|
||||
}
|
||||
|
@ -389,9 +383,9 @@ void DialogAlongLine::SetLineColor(const QString &value)
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString DialogAlongLine::GetPointName() const
|
||||
auto DialogAlongLine::GetPointName() const -> QString
|
||||
{
|
||||
return pointName;
|
||||
return m_pointName;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -401,8 +395,8 @@ QString DialogAlongLine::GetPointName() const
|
|||
*/
|
||||
void DialogAlongLine::SetPointName(const QString &value)
|
||||
{
|
||||
pointName = value;
|
||||
ui->lineEditNamePoint->setText(pointName);
|
||||
m_pointName = value;
|
||||
ui->lineEditNamePoint->setText(m_pointName);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -410,7 +404,7 @@ void DialogAlongLine::SetPointName(const QString &value)
|
|||
* @brief GetTypeLine return type of line
|
||||
* @return type
|
||||
*/
|
||||
QString DialogAlongLine::GetTypeLine() const
|
||||
auto DialogAlongLine::GetTypeLine() const -> QString
|
||||
{
|
||||
return GetComboBoxCurrentData(ui->comboBoxLineType, TypeLineLine);
|
||||
}
|
||||
|
@ -420,9 +414,9 @@ QString DialogAlongLine::GetTypeLine() const
|
|||
* @brief GetFormula return string of formula
|
||||
* @return formula
|
||||
*/
|
||||
QString DialogAlongLine::GetFormula() const
|
||||
auto DialogAlongLine::GetFormula() const -> QString
|
||||
{
|
||||
return VTranslateVars::TryFormulaFromUser(formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator());
|
||||
return VTranslateVars::TryFormulaFromUser(m_formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator());
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -430,7 +424,7 @@ QString DialogAlongLine::GetFormula() const
|
|||
* @brief GetFirstPointId return id first point of line
|
||||
* @return id
|
||||
*/
|
||||
quint32 DialogAlongLine::GetFirstPointId() const
|
||||
auto DialogAlongLine::GetFirstPointId() const -> quint32
|
||||
{
|
||||
return getCurrentObjectId(ui->comboBoxFirstPoint);
|
||||
}
|
||||
|
@ -440,7 +434,7 @@ quint32 DialogAlongLine::GetFirstPointId() const
|
|||
* @brief GetSecondPointId return id second point of line
|
||||
* @return id
|
||||
*/
|
||||
quint32 DialogAlongLine::GetSecondPointId() const
|
||||
auto DialogAlongLine::GetSecondPointId() const -> quint32
|
||||
{
|
||||
return getCurrentObjectId(ui->comboBoxSecondPoint);
|
||||
}
|
||||
|
|
|
@ -51,32 +51,32 @@ class DialogAlongLine final : public DialogTool
|
|||
Q_OBJECT // NOLINT
|
||||
public:
|
||||
DialogAlongLine(const VContainer *data, quint32 toolId, QWidget *parent = nullptr);
|
||||
virtual ~DialogAlongLine() override;
|
||||
~DialogAlongLine() override;
|
||||
|
||||
QString GetPointName() const;
|
||||
auto GetPointName() const -> QString;
|
||||
void SetPointName(const QString &value);
|
||||
|
||||
QString GetTypeLine() const;
|
||||
auto GetTypeLine() const -> QString;
|
||||
void SetTypeLine(const QString &value);
|
||||
|
||||
QString GetLineColor() const;
|
||||
auto GetLineColor() const -> QString;
|
||||
void SetLineColor(const QString &value);
|
||||
|
||||
QString GetFormula() const;
|
||||
auto GetFormula() const -> QString;
|
||||
void SetFormula(const QString &value);
|
||||
|
||||
quint32 GetFirstPointId() const;
|
||||
auto GetFirstPointId() const -> quint32;
|
||||
void SetFirstPointId(quint32 value);
|
||||
|
||||
quint32 GetSecondPointId() const;
|
||||
auto GetSecondPointId() const -> quint32;
|
||||
void SetSecondPointId(quint32 value);
|
||||
|
||||
void SetNotes(const QString ¬es);
|
||||
QString GetNotes() const;
|
||||
auto GetNotes() const -> QString;
|
||||
|
||||
virtual void Build(const Tool &type) override;
|
||||
void Build(const Tool &type) override;
|
||||
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
|
||||
*/
|
||||
|
@ -86,13 +86,13 @@ public slots:
|
|||
void FXLength();
|
||||
void EvalFormula();
|
||||
protected:
|
||||
virtual void ShowVisualization() override;
|
||||
void ShowVisualization() override;
|
||||
/**
|
||||
* @brief SaveData Put dialog data in local variables
|
||||
*/
|
||||
virtual void SaveData() override;
|
||||
virtual void closeEvent(QCloseEvent *event) override;
|
||||
virtual bool IsValid() const final;
|
||||
void SaveData() override;
|
||||
void closeEvent(QCloseEvent *event) override;
|
||||
auto IsValid() const -> bool final;
|
||||
private:
|
||||
Q_DISABLE_COPY_MOVE(DialogAlongLine) // NOLINT
|
||||
|
||||
|
@ -100,28 +100,28 @@ private:
|
|||
Ui::DialogAlongLine *ui;
|
||||
|
||||
/** @brief formula formula */
|
||||
QString formula;
|
||||
QString m_formula{};
|
||||
|
||||
QString pointName;
|
||||
QString m_pointName{};
|
||||
|
||||
/** @brief formulaBaseHeight base height defined by dialogui */
|
||||
int formulaBaseHeight;
|
||||
int m_formulaBaseHeight{0};
|
||||
|
||||
bool buildMidpoint;
|
||||
bool m_buildMidpoint{false};
|
||||
|
||||
QTimer *timerFormula;
|
||||
QTimer *m_timerFormula;
|
||||
|
||||
bool flagFormula;
|
||||
bool flagError;
|
||||
bool flagName;
|
||||
bool m_flagFormula{false};
|
||||
bool m_flagError{true};
|
||||
bool m_flagName{true};
|
||||
|
||||
void SetCurrentLength();
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
inline bool DialogAlongLine::IsValid() const
|
||||
inline auto DialogAlongLine::IsValid() const -> bool
|
||||
{
|
||||
return flagName &&flagFormula && flagError;
|
||||
return m_flagName &&m_flagFormula && m_flagError;
|
||||
}
|
||||
|
||||
#endif // DIALOGALONGLINE_H
|
||||
|
|
Loading…
Reference in New Issue
Block a user