Refactoring.
This commit is contained in:
parent
d7fc36e0d4
commit
165da734e3
|
@ -56,14 +56,7 @@
|
||||||
DialogPointFromCircleAndTangent::DialogPointFromCircleAndTangent(const VContainer *data, quint32 toolId,
|
DialogPointFromCircleAndTangent::DialogPointFromCircleAndTangent(const VContainer *data, quint32 toolId,
|
||||||
QWidget *parent)
|
QWidget *parent)
|
||||||
: DialogTool(data, toolId, parent),
|
: DialogTool(data, toolId, parent),
|
||||||
ui(new Ui::DialogPointFromCircleAndTangent),
|
ui(new Ui::DialogPointFromCircleAndTangent)
|
||||||
timerCircleRadius(nullptr),
|
|
||||||
circleRadius(),
|
|
||||||
formulaBaseHeightCircleRadius(0),
|
|
||||||
pointName(),
|
|
||||||
flagCircleRadius(false),
|
|
||||||
flagName(true),
|
|
||||||
flagError(true)
|
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
@ -72,12 +65,12 @@ DialogPointFromCircleAndTangent::DialogPointFromCircleAndTangent(const VContaine
|
||||||
ui->lineEditNamePoint->setText(
|
ui->lineEditNamePoint->setText(
|
||||||
VAbstractValApplication::VApp()->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
|
VAbstractValApplication::VApp()->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
|
||||||
|
|
||||||
this->formulaBaseHeightCircleRadius = ui->plainTextEditRadius->height();
|
this->m_formulaBaseHeightCircleRadius = ui->plainTextEditRadius->height();
|
||||||
|
|
||||||
ui->plainTextEditRadius->installEventFilter(this);
|
ui->plainTextEditRadius->installEventFilter(this);
|
||||||
|
|
||||||
timerCircleRadius = new QTimer(this);
|
m_timerCircleRadius = new QTimer(this);
|
||||||
connect(timerCircleRadius, &QTimer::timeout, this, &DialogPointFromCircleAndTangent::EvalCircleRadius);
|
connect(m_timerCircleRadius, &QTimer::timeout, this, &DialogPointFromCircleAndTangent::EvalCircleRadius);
|
||||||
|
|
||||||
InitOkCancelApply(ui);
|
InitOkCancelApply(ui);
|
||||||
|
|
||||||
|
@ -87,7 +80,7 @@ DialogPointFromCircleAndTangent::DialogPointFromCircleAndTangent(const VContaine
|
||||||
|
|
||||||
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->comboBoxCircleCenter, &QComboBox::currentTextChanged,
|
connect(ui->comboBoxCircleCenter, &QComboBox::currentTextChanged,
|
||||||
|
@ -98,7 +91,7 @@ DialogPointFromCircleAndTangent::DialogPointFromCircleAndTangent(const VContaine
|
||||||
|
|
||||||
connect(ui->plainTextEditRadius, &QPlainTextEdit::textChanged, this, [this]()
|
connect(ui->plainTextEditRadius, &QPlainTextEdit::textChanged, this, [this]()
|
||||||
{
|
{
|
||||||
timerCircleRadius->start(formulaTimerTimeout);
|
m_timerCircleRadius->start(formulaTimerTimeout);
|
||||||
});
|
});
|
||||||
|
|
||||||
connect(ui->pushButtonGrowRadius, &QPushButton::clicked, this,
|
connect(ui->pushButtonGrowRadius, &QPushButton::clicked, this,
|
||||||
|
@ -117,20 +110,20 @@ DialogPointFromCircleAndTangent::~DialogPointFromCircleAndTangent()
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QString DialogPointFromCircleAndTangent::GetPointName() const
|
auto DialogPointFromCircleAndTangent::GetPointName() const -> QString
|
||||||
{
|
{
|
||||||
return pointName;
|
return m_pointName;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogPointFromCircleAndTangent::SetPointName(const QString &value)
|
void DialogPointFromCircleAndTangent::SetPointName(const QString &value)
|
||||||
{
|
{
|
||||||
pointName = value;
|
m_pointName = value;
|
||||||
ui->lineEditNamePoint->setText(pointName);
|
ui->lineEditNamePoint->setText(m_pointName);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
quint32 DialogPointFromCircleAndTangent::GetCircleCenterId() const
|
auto DialogPointFromCircleAndTangent::GetCircleCenterId() const -> quint32
|
||||||
{
|
{
|
||||||
return getCurrentObjectId(ui->comboBoxCircleCenter);
|
return getCurrentObjectId(ui->comboBoxCircleCenter);
|
||||||
}
|
}
|
||||||
|
@ -140,13 +133,13 @@ void DialogPointFromCircleAndTangent::SetCircleCenterId(const quint32 &value)
|
||||||
{
|
{
|
||||||
setCurrentPointId(ui->comboBoxCircleCenter, value);
|
setCurrentPointId(ui->comboBoxCircleCenter, value);
|
||||||
|
|
||||||
VisToolPointFromCircleAndTangent *point = qobject_cast<VisToolPointFromCircleAndTangent *>(vis);
|
auto *point = qobject_cast<VisToolPointFromCircleAndTangent *>(vis);
|
||||||
SCASSERT(point != nullptr)
|
SCASSERT(point != nullptr)
|
||||||
point->SetCenterId(value);
|
point->SetCenterId(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QString DialogPointFromCircleAndTangent::GetCircleRadius() const
|
auto DialogPointFromCircleAndTangent::GetCircleRadius() const -> QString
|
||||||
{
|
{
|
||||||
return VTranslateVars::TryFormulaFromUser(ui->plainTextEditRadius->toPlainText(),
|
return VTranslateVars::TryFormulaFromUser(ui->plainTextEditRadius->toPlainText(),
|
||||||
VAbstractApplication::VApp()->Settings()->GetOsSeparator());
|
VAbstractApplication::VApp()->Settings()->GetOsSeparator());
|
||||||
|
@ -164,7 +157,7 @@ void DialogPointFromCircleAndTangent::SetCircleRadius(const QString &value)
|
||||||
}
|
}
|
||||||
ui->plainTextEditRadius->setPlainText(formula);
|
ui->plainTextEditRadius->setPlainText(formula);
|
||||||
|
|
||||||
VisToolPointFromCircleAndTangent *point = qobject_cast<VisToolPointFromCircleAndTangent *>(vis);
|
auto *point = qobject_cast<VisToolPointFromCircleAndTangent *>(vis);
|
||||||
SCASSERT(point != nullptr)
|
SCASSERT(point != nullptr)
|
||||||
point->SetCRadius(formula);
|
point->SetCRadius(formula);
|
||||||
|
|
||||||
|
@ -172,36 +165,36 @@ void DialogPointFromCircleAndTangent::SetCircleRadius(const QString &value)
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
quint32 DialogPointFromCircleAndTangent::GetTangentPointId() const
|
auto DialogPointFromCircleAndTangent::GetTangentPointId() const -> quint32
|
||||||
{
|
{
|
||||||
return getCurrentObjectId(ui->comboBoxTangentPoint);
|
return getCurrentObjectId(ui->comboBoxTangentPoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogPointFromCircleAndTangent::SetTangentPointId(const quint32 &value)
|
void DialogPointFromCircleAndTangent::SetTangentPointId(quint32 value)
|
||||||
{
|
{
|
||||||
setCurrentPointId(ui->comboBoxTangentPoint, value);
|
setCurrentPointId(ui->comboBoxTangentPoint, value);
|
||||||
|
|
||||||
VisToolPointFromCircleAndTangent *point = qobject_cast<VisToolPointFromCircleAndTangent *>(vis);
|
auto *point = qobject_cast<VisToolPointFromCircleAndTangent *>(vis);
|
||||||
SCASSERT(point != nullptr)
|
SCASSERT(point != nullptr)
|
||||||
point->SetPointId(value);
|
point->SetPointId(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
CrossCirclesPoint DialogPointFromCircleAndTangent::GetCrossCirclesPoint() const
|
auto DialogPointFromCircleAndTangent::GetCrossCirclesPoint() const -> CrossCirclesPoint
|
||||||
{
|
{
|
||||||
return getCurrentCrossPoint<CrossCirclesPoint>(ui->comboBoxResult);
|
return getCurrentCrossPoint<CrossCirclesPoint>(ui->comboBoxResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogPointFromCircleAndTangent::SetCrossCirclesPoint(const CrossCirclesPoint &p)
|
void DialogPointFromCircleAndTangent::SetCrossCirclesPoint(CrossCirclesPoint p)
|
||||||
{
|
{
|
||||||
const qint32 index = ui->comboBoxResult->findData(static_cast<int>(p));
|
const qint32 index = ui->comboBoxResult->findData(static_cast<int>(p));
|
||||||
if (index != -1)
|
if (index != -1)
|
||||||
{
|
{
|
||||||
ui->comboBoxResult->setCurrentIndex(index);
|
ui->comboBoxResult->setCurrentIndex(index);
|
||||||
|
|
||||||
VisToolPointFromCircleAndTangent *point = qobject_cast<VisToolPointFromCircleAndTangent *>(vis);
|
auto *point = qobject_cast<VisToolPointFromCircleAndTangent *>(vis);
|
||||||
SCASSERT(point != nullptr)
|
SCASSERT(point != nullptr)
|
||||||
point->SetCrossPoint(p);
|
point->SetCrossPoint(p);
|
||||||
}
|
}
|
||||||
|
@ -263,12 +256,12 @@ void DialogPointFromCircleAndTangent::ChosenObject(quint32 id, const SceneObject
|
||||||
auto *point = qobject_cast<VisToolPointFromCircleAndTangent *>(vis);
|
auto *point = qobject_cast<VisToolPointFromCircleAndTangent *>(vis);
|
||||||
SCASSERT(point != nullptr)
|
SCASSERT(point != nullptr)
|
||||||
|
|
||||||
switch (number)
|
switch (m_number)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
if (SetObject(id, ui->comboBoxTangentPoint, tr("Select a circle center")))
|
if (SetObject(id, ui->comboBoxTangentPoint, tr("Select a circle center")))
|
||||||
{
|
{
|
||||||
number++;
|
m_number++;
|
||||||
point->VisualMode(id);
|
point->VisualMode(id);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -282,7 +275,7 @@ void DialogPointFromCircleAndTangent::ChosenObject(quint32 id, const SceneObject
|
||||||
SCASSERT(window != nullptr)
|
SCASSERT(window != nullptr)
|
||||||
connect(vis.data(), &Visualization::ToolTip, window, &VAbstractMainWindow::ShowToolTip);
|
connect(vis.data(), &Visualization::ToolTip, window, &VAbstractMainWindow::ShowToolTip);
|
||||||
|
|
||||||
number = 0;
|
m_number = 0;
|
||||||
point->SetCenterId(id);
|
point->SetCenterId(id);
|
||||||
point->RefreshGeometry();
|
point->RefreshGeometry();
|
||||||
prepare = true;
|
prepare = true;
|
||||||
|
@ -301,12 +294,12 @@ void DialogPointFromCircleAndTangent::PointChanged()
|
||||||
QColor color;
|
QColor color;
|
||||||
if (getCurrentObjectId(ui->comboBoxCircleCenter) == getCurrentObjectId(ui->comboBoxTangentPoint))
|
if (getCurrentObjectId(ui->comboBoxCircleCenter) == getCurrentObjectId(ui->comboBoxTangentPoint))
|
||||||
{
|
{
|
||||||
flagError = false;
|
m_flagError = false;
|
||||||
color = errorColor;
|
color = errorColor;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
flagError = true;
|
m_flagError = true;
|
||||||
color = OkColor(this);
|
color = OkColor(this);
|
||||||
}
|
}
|
||||||
ChangeColor(ui->labelCircleCenter, color);
|
ChangeColor(ui->labelCircleCenter, color);
|
||||||
|
@ -317,13 +310,13 @@ void DialogPointFromCircleAndTangent::PointChanged()
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogPointFromCircleAndTangent::DeployCircleRadiusTextEdit()
|
void DialogPointFromCircleAndTangent::DeployCircleRadiusTextEdit()
|
||||||
{
|
{
|
||||||
DeployFormula(this, ui->plainTextEditRadius, ui->pushButtonGrowRadius, formulaBaseHeightCircleRadius);
|
DeployFormula(this, ui->plainTextEditRadius, ui->pushButtonGrowRadius, m_formulaBaseHeightCircleRadius);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogPointFromCircleAndTangent::FXCircleRadius()
|
void DialogPointFromCircleAndTangent::FXCircleRadius()
|
||||||
{
|
{
|
||||||
DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this);
|
auto *dialog = new DialogEditWrongFormula(data, toolId, this);
|
||||||
dialog->setWindowTitle(tr("Edit radius"));
|
dialog->setWindowTitle(tr("Edit radius"));
|
||||||
dialog->SetFormula(GetCircleRadius());
|
dialog->SetFormula(GetCircleRadius());
|
||||||
dialog->setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true));
|
dialog->setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true));
|
||||||
|
@ -344,11 +337,11 @@ void DialogPointFromCircleAndTangent::EvalCircleRadius()
|
||||||
formulaData.labelResult = ui->labelResultCircleRadius;
|
formulaData.labelResult = ui->labelResultCircleRadius;
|
||||||
formulaData.postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true);
|
formulaData.postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true);
|
||||||
|
|
||||||
const qreal radius = Eval(formulaData, flagCircleRadius);
|
const qreal radius = Eval(formulaData, m_flagCircleRadius);
|
||||||
|
|
||||||
if (radius < 0)
|
if (radius < 0)
|
||||||
{
|
{
|
||||||
flagCircleRadius = false;
|
m_flagCircleRadius = false;
|
||||||
ChangeColor(ui->labelEditRadius, errorColor);
|
ChangeColor(ui->labelEditRadius, errorColor);
|
||||||
ui->labelResultCircleRadius->setText(tr("Error"));
|
ui->labelResultCircleRadius->setText(tr("Error"));
|
||||||
ui->labelResultCircleRadius->setToolTip(tr("Radius can't be negative"));
|
ui->labelResultCircleRadius->setToolTip(tr("Radius can't be negative"));
|
||||||
|
@ -366,9 +359,9 @@ void DialogPointFromCircleAndTangent::ShowVisualization()
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogPointFromCircleAndTangent::SaveData()
|
void DialogPointFromCircleAndTangent::SaveData()
|
||||||
{
|
{
|
||||||
pointName = ui->lineEditNamePoint->text();
|
m_pointName = ui->lineEditNamePoint->text();
|
||||||
|
|
||||||
VisToolPointFromCircleAndTangent *point = qobject_cast<VisToolPointFromCircleAndTangent *>(vis);
|
auto *point = qobject_cast<VisToolPointFromCircleAndTangent *>(vis);
|
||||||
SCASSERT(point != nullptr)
|
SCASSERT(point != nullptr)
|
||||||
|
|
||||||
point->SetPointId(GetTangentPointId());
|
point->SetPointId(GetTangentPointId());
|
||||||
|
@ -392,7 +385,7 @@ void DialogPointFromCircleAndTangent::SetNotes(const QString ¬es)
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QString DialogPointFromCircleAndTangent::GetNotes() const
|
auto DialogPointFromCircleAndTangent::GetNotes() const -> QString
|
||||||
{
|
{
|
||||||
return ui->plainTextEditToolNotes->toPlainText();
|
return ui->plainTextEditToolNotes->toPlainText();
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,65 +50,65 @@ class DialogPointFromCircleAndTangent : public DialogTool
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DialogPointFromCircleAndTangent(const VContainer *data, quint32 toolId, QWidget *parent = nullptr);
|
DialogPointFromCircleAndTangent(const VContainer *data, quint32 toolId, QWidget *parent = nullptr);
|
||||||
~DialogPointFromCircleAndTangent();
|
~DialogPointFromCircleAndTangent() override;
|
||||||
|
|
||||||
QString GetPointName() const;
|
auto GetPointName() const -> QString;
|
||||||
void SetPointName(const QString &value);
|
void SetPointName(const QString &value);
|
||||||
|
|
||||||
quint32 GetCircleCenterId() const;
|
auto GetCircleCenterId() const -> quint32;
|
||||||
void SetCircleCenterId(const quint32 &value);
|
void SetCircleCenterId(const quint32 &value);
|
||||||
|
|
||||||
QString GetCircleRadius() const;
|
auto GetCircleRadius() const -> QString;
|
||||||
void SetCircleRadius(const QString &value);
|
void SetCircleRadius(const QString &value);
|
||||||
|
|
||||||
quint32 GetTangentPointId() const;
|
auto GetTangentPointId() const -> quint32;
|
||||||
void SetTangentPointId(const quint32 &value);
|
void SetTangentPointId(quint32 value);
|
||||||
|
|
||||||
CrossCirclesPoint GetCrossCirclesPoint() const;
|
auto GetCrossCirclesPoint() const -> CrossCirclesPoint;
|
||||||
void SetCrossCirclesPoint(const CrossCirclesPoint &p);
|
void SetCrossCirclesPoint(CrossCirclesPoint p);
|
||||||
|
|
||||||
void SetNotes(const QString ¬es);
|
void SetNotes(const QString ¬es);
|
||||||
QString GetNotes() const;
|
auto GetNotes() const -> QString;
|
||||||
|
|
||||||
void ShowDialog(bool click) override;
|
void ShowDialog(bool click) override;
|
||||||
public slots:
|
public slots:
|
||||||
virtual void ChosenObject(quint32 id, const SceneObject &type) override;
|
void ChosenObject(quint32 id, const SceneObject &type) override;
|
||||||
void PointChanged();
|
void PointChanged();
|
||||||
|
|
||||||
void DeployCircleRadiusTextEdit();
|
void DeployCircleRadiusTextEdit();
|
||||||
void FXCircleRadius();
|
void FXCircleRadius();
|
||||||
void EvalCircleRadius();
|
void EvalCircleRadius();
|
||||||
|
|
||||||
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(DialogPointFromCircleAndTangent) // NOLINT
|
Q_DISABLE_COPY_MOVE(DialogPointFromCircleAndTangent) // NOLINT
|
||||||
|
|
||||||
Ui::DialogPointFromCircleAndTangent *ui;
|
Ui::DialogPointFromCircleAndTangent *ui;
|
||||||
|
|
||||||
QTimer* timerCircleRadius;
|
QTimer* m_timerCircleRadius{nullptr};
|
||||||
QString circleRadius;
|
QString m_circleRadius{};
|
||||||
int formulaBaseHeightCircleRadius;
|
int m_formulaBaseHeightCircleRadius{0};
|
||||||
QString pointName;
|
QString m_pointName{};
|
||||||
bool flagCircleRadius;
|
bool m_flagCircleRadius{false};
|
||||||
bool flagName;
|
bool m_flagName{true};
|
||||||
bool flagError;
|
bool m_flagError{true};
|
||||||
/** @brief number number of handled objects */
|
/** @brief number number of handled objects */
|
||||||
qint32 number{0};
|
qint32 m_number{0};
|
||||||
bool m_firstRelease{false};
|
bool m_firstRelease{false};
|
||||||
};
|
};
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
inline bool DialogPointFromCircleAndTangent::IsValid() const
|
inline auto DialogPointFromCircleAndTangent::IsValid() const -> bool
|
||||||
{
|
{
|
||||||
return flagCircleRadius && flagName && flagError;
|
return m_flagCircleRadius && m_flagName && m_flagError;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // DIALOGPOINTFROMCIRCLEANDTANGENT_H
|
#endif // DIALOGPOINTFROMCIRCLEANDTANGENT_H
|
||||||
|
|
Loading…
Reference in New Issue
Block a user