Refactoring.
This commit is contained in:
parent
0f78ef8b05
commit
b1d7177952
|
@ -41,7 +41,6 @@
|
||||||
#include "../../visualization/path/vistoolcutspline.h"
|
#include "../../visualization/path/vistoolcutspline.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 @@
|
||||||
DialogCutSpline::DialogCutSpline(const VContainer *data, quint32 toolId, QWidget *parent)
|
DialogCutSpline::DialogCutSpline(const VContainer *data, quint32 toolId, QWidget *parent)
|
||||||
: DialogTool(data, toolId, parent),
|
: DialogTool(data, toolId, parent),
|
||||||
ui(new Ui::DialogCutSpline),
|
ui(new Ui::DialogCutSpline),
|
||||||
formula(),
|
m_timerFormula(new QTimer(this))
|
||||||
formulaBaseHeight(0),
|
|
||||||
pointName(),
|
|
||||||
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, &DialogCutSpline::EvalFormula);
|
connect(m_timerFormula, &QTimer::timeout, this, &DialogCutSpline::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);
|
||||||
|
@ -84,12 +78,12 @@ DialogCutSpline::DialogCutSpline(const VContainer *data, quint32 toolId, QWidget
|
||||||
connect(ui->toolButtonExprLength, &QPushButton::clicked, this, &DialogCutSpline::FXLength);
|
connect(ui->toolButtonExprLength, &QPushButton::clicked, this, &DialogCutSpline::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, &DialogCutSpline::DeployFormulaTextEdit);
|
connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogCutSpline::DeployFormulaTextEdit);
|
||||||
connect(ui->comboBoxSpline, &QComboBox::currentTextChanged, this, &DialogCutSpline::SplineChanged);
|
connect(ui->comboBoxSpline, &QComboBox::currentTextChanged, this, &DialogCutSpline::SplineChanged);
|
||||||
|
@ -110,9 +104,9 @@ DialogCutSpline::~DialogCutSpline()
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QString DialogCutSpline::GetPointName() const
|
auto DialogCutSpline::GetPointName() const -> QString
|
||||||
{
|
{
|
||||||
return pointName;
|
return m_pointName;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -122,8 +116,8 @@ QString DialogCutSpline::GetPointName() const
|
||||||
*/
|
*/
|
||||||
void DialogCutSpline::SetPointName(const QString &value)
|
void DialogCutSpline::SetPointName(const QString &value)
|
||||||
{
|
{
|
||||||
pointName = value;
|
m_pointName = value;
|
||||||
ui->lineEditNamePoint->setText(pointName);
|
ui->lineEditNamePoint->setText(m_pointName);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -133,19 +127,19 @@ void DialogCutSpline::SetPointName(const QString &value)
|
||||||
*/
|
*/
|
||||||
void DialogCutSpline::SetFormula(const QString &value)
|
void DialogCutSpline::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. TODO : see if I can get the max number of caracters in one line
|
// increase height if needed. TODO : see if I can get the max number of caracters in one line
|
||||||
// of this PlainTextEdit to change 80 to this value
|
// of this PlainTextEdit to change 80 to this value
|
||||||
if (formula.length() > 80)
|
if (m_formula.length() > 80)
|
||||||
{
|
{
|
||||||
this->DeployFormulaTextEdit();
|
this->DeployFormulaTextEdit();
|
||||||
}
|
}
|
||||||
ui->plainTextEditFormula->setPlainText(formula);
|
ui->plainTextEditFormula->setPlainText(m_formula);
|
||||||
|
|
||||||
VisToolCutSpline *path = qobject_cast<VisToolCutSpline *>(vis);
|
auto *path = qobject_cast<VisToolCutSpline *>(vis);
|
||||||
SCASSERT(path != nullptr)
|
SCASSERT(path != nullptr)
|
||||||
path->setLength(formula);
|
path->setLength(m_formula);
|
||||||
|
|
||||||
MoveCursorToEnd(ui->plainTextEditFormula);
|
MoveCursorToEnd(ui->plainTextEditFormula);
|
||||||
}
|
}
|
||||||
|
@ -159,7 +153,7 @@ void DialogCutSpline::setSplineId(quint32 value)
|
||||||
{
|
{
|
||||||
setCurrentSplineId(ui->comboBoxSpline, value);
|
setCurrentSplineId(ui->comboBoxSpline, value);
|
||||||
|
|
||||||
VisToolCutSpline *path = qobject_cast<VisToolCutSpline *>(vis);
|
auto *path = qobject_cast<VisToolCutSpline *>(vis);
|
||||||
SCASSERT(path != nullptr)
|
SCASSERT(path != nullptr)
|
||||||
path->setObject1Id(value);
|
path->setObject1Id(value);
|
||||||
}
|
}
|
||||||
|
@ -172,8 +166,11 @@ void DialogCutSpline::setSplineId(quint32 value)
|
||||||
*/
|
*/
|
||||||
void DialogCutSpline::ChosenObject(quint32 id, const SceneObject &type)
|
void DialogCutSpline::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::Spline)
|
if (type == SceneObject::Spline)
|
||||||
{
|
{
|
||||||
if (SetObject(id, ui->comboBoxSpline, QString()))
|
if (SetObject(id, ui->comboBoxSpline, QString()))
|
||||||
|
@ -187,20 +184,19 @@ void DialogCutSpline::ChosenObject(quint32 id, const SceneObject &type)
|
||||||
this->show();
|
this->show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogCutSpline::SaveData()
|
void DialogCutSpline::SaveData()
|
||||||
{
|
{
|
||||||
pointName = ui->lineEditNamePoint->text();
|
m_pointName = ui->lineEditNamePoint->text();
|
||||||
formula = ui->plainTextEditFormula->toPlainText();
|
m_formula = ui->plainTextEditFormula->toPlainText();
|
||||||
|
|
||||||
VisToolCutSpline *path = qobject_cast<VisToolCutSpline *>(vis);
|
auto *path = qobject_cast<VisToolCutSpline *>(vis);
|
||||||
SCASSERT(path != nullptr)
|
SCASSERT(path != nullptr)
|
||||||
|
|
||||||
path->setObject1Id(getSplineId());
|
path->setObject1Id(getSplineId());
|
||||||
path->setLength(formula);
|
path->setLength(m_formula);
|
||||||
path->RefreshGeometry();
|
path->RefreshGeometry();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -230,29 +226,29 @@ void DialogCutSpline::ValidateAlias()
|
||||||
|
|
||||||
if (not GetAliasSuffix1().isEmpty() &&
|
if (not GetAliasSuffix1().isEmpty() &&
|
||||||
(not rx.match(spl1.GetAlias()).hasMatch() ||
|
(not rx.match(spl1.GetAlias()).hasMatch() ||
|
||||||
(originAliasSuffix1 != GetAliasSuffix1() && not data->IsUnique(spl1.GetAlias())) ||
|
(m_originAliasSuffix1 != GetAliasSuffix1() && not data->IsUnique(spl1.GetAlias())) ||
|
||||||
spl1.GetAlias() == spl2.GetAlias()))
|
spl1.GetAlias() == spl2.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(spl2.GetAlias()).hasMatch() ||
|
(not rx.match(spl2.GetAlias()).hasMatch() ||
|
||||||
(originAliasSuffix2 != GetAliasSuffix2() && not data->IsUnique(spl2.GetAlias())) ||
|
(m_originAliasSuffix2 != GetAliasSuffix2() && not data->IsUnique(spl2.GetAlias())) ||
|
||||||
spl1.GetAlias() == spl2.GetAlias()))
|
spl1.GetAlias() == spl2.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));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -262,13 +258,13 @@ void DialogCutSpline::ValidateAlias()
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogCutSpline::DeployFormulaTextEdit()
|
void DialogCutSpline::DeployFormulaTextEdit()
|
||||||
{
|
{
|
||||||
DeployFormula(this, ui->plainTextEditFormula, ui->pushButtonGrowLength, formulaBaseHeight);
|
DeployFormula(this, ui->plainTextEditFormula, ui->pushButtonGrowLength, m_formulaBaseHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogCutSpline::FXLength()
|
void DialogCutSpline::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));
|
||||||
|
@ -290,7 +286,7 @@ void DialogCutSpline::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);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -304,9 +300,9 @@ void DialogCutSpline::ShowVisualization()
|
||||||
* @brief GetFormula return string of formula
|
* @brief GetFormula return string of formula
|
||||||
* @return formula
|
* @return formula
|
||||||
*/
|
*/
|
||||||
QString DialogCutSpline::GetFormula() const
|
auto DialogCutSpline::GetFormula() const -> QString
|
||||||
{
|
{
|
||||||
return VTranslateVars::TryFormulaFromUser(formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator());
|
return VTranslateVars::TryFormulaFromUser(m_formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator());
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -326,7 +322,7 @@ void DialogCutSpline::SetNotes(const QString ¬es)
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QString DialogCutSpline::GetNotes() const
|
auto DialogCutSpline::GetNotes() const -> QString
|
||||||
{
|
{
|
||||||
return ui->plainTextEditToolNotes->toPlainText();
|
return ui->plainTextEditToolNotes->toPlainText();
|
||||||
}
|
}
|
||||||
|
@ -334,13 +330,13 @@ QString DialogCutSpline::GetNotes() const
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogCutSpline::SetAliasSuffix1(const QString &alias)
|
void DialogCutSpline::SetAliasSuffix1(const QString &alias)
|
||||||
{
|
{
|
||||||
originAliasSuffix1 = alias;
|
m_originAliasSuffix1 = alias;
|
||||||
ui->lineEditAlias1->setText(originAliasSuffix1);
|
ui->lineEditAlias1->setText(m_originAliasSuffix1);
|
||||||
ValidateAlias();
|
ValidateAlias();
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QString DialogCutSpline::GetAliasSuffix1() const
|
auto DialogCutSpline::GetAliasSuffix1() const -> QString
|
||||||
{
|
{
|
||||||
return ui->lineEditAlias1->text();
|
return ui->lineEditAlias1->text();
|
||||||
}
|
}
|
||||||
|
@ -348,13 +344,13 @@ QString DialogCutSpline::GetAliasSuffix1() const
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogCutSpline::SetAliasSuffix2(const QString &alias)
|
void DialogCutSpline::SetAliasSuffix2(const QString &alias)
|
||||||
{
|
{
|
||||||
originAliasSuffix2 = alias;
|
m_originAliasSuffix2 = alias;
|
||||||
ui->lineEditAlias2->setText(originAliasSuffix2);
|
ui->lineEditAlias2->setText(m_originAliasSuffix2);
|
||||||
ValidateAlias();
|
ValidateAlias();
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QString DialogCutSpline::GetAliasSuffix2() const
|
auto DialogCutSpline::GetAliasSuffix2() const -> QString
|
||||||
{
|
{
|
||||||
return ui->lineEditAlias2->text();
|
return ui->lineEditAlias2->text();
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,27 +51,27 @@ class DialogCutSpline final : public DialogTool
|
||||||
Q_OBJECT // NOLINT
|
Q_OBJECT // NOLINT
|
||||||
public:
|
public:
|
||||||
DialogCutSpline(const VContainer *data, quint32 toolId, QWidget *parent = nullptr);
|
DialogCutSpline(const VContainer *data, quint32 toolId, QWidget *parent = nullptr);
|
||||||
virtual ~DialogCutSpline() override;
|
~DialogCutSpline() 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 getSplineId() const;
|
auto getSplineId() const -> quint32;
|
||||||
void setSplineId(quint32 value);
|
void setSplineId(quint32 value);
|
||||||
|
|
||||||
void SetNotes(const QString ¬es);
|
void SetNotes(const QString ¬es);
|
||||||
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
|
||||||
*/
|
*/
|
||||||
|
@ -79,13 +79,13 @@ public slots:
|
||||||
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 SplineChanged();
|
void SplineChanged();
|
||||||
void ValidateAlias();
|
void ValidateAlias();
|
||||||
|
@ -96,28 +96,28 @@ private:
|
||||||
Ui::DialogCutSpline *ui;
|
Ui::DialogCutSpline *ui;
|
||||||
|
|
||||||
/** @brief formula string with formula */
|
/** @brief formula string with formula */
|
||||||
QString formula;
|
QString m_formula{};
|
||||||
|
|
||||||
/** @brief formulaBaseHeight base height defined by dialogui */
|
/** @brief formulaBaseHeight base height defined by dialogui */
|
||||||
int formulaBaseHeight;
|
int m_formulaBaseHeight{0};
|
||||||
|
|
||||||
QString pointName;
|
QString m_pointName{};
|
||||||
|
|
||||||
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 DialogCutSpline::IsValid() const
|
inline auto DialogCutSpline::IsValid() const -> bool
|
||||||
{
|
{
|
||||||
return flagFormula && flagName && flagAlias1 && flagAlias2;
|
return m_flagFormula && m_flagName && m_flagAlias1 && m_flagAlias2;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // DIALOGCUTSPLINE_H
|
#endif // DIALOGCUTSPLINE_H
|
||||||
|
|
|
@ -36,7 +36,6 @@
|
||||||
#include <Qt>
|
#include <Qt>
|
||||||
#include <new>
|
#include <new>
|
||||||
|
|
||||||
#include "../ifc/ifcdef.h"
|
|
||||||
#include "../vgeometry/vabstractcubicbezier.h"
|
#include "../vgeometry/vabstractcubicbezier.h"
|
||||||
#include "../vgeometry/vabstractcurve.h"
|
#include "../vgeometry/vabstractcurve.h"
|
||||||
#include "../vgeometry/vpointf.h"
|
#include "../vgeometry/vpointf.h"
|
||||||
|
@ -48,16 +47,16 @@
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VisToolCutSpline::VisToolCutSpline(const VContainer *data, QGraphicsItem *parent)
|
VisToolCutSpline::VisToolCutSpline(const VContainer *data, QGraphicsItem *parent)
|
||||||
:VisPath(data, parent), point(nullptr), spl1(nullptr), spl2(nullptr), length(0)
|
:VisPath(data, parent)
|
||||||
{
|
{
|
||||||
spl1 = InitItem<VCurvePathItem>(Qt::darkGreen, this);
|
m_spl1 = InitItem<VCurvePathItem>(Qt::darkGreen, this);
|
||||||
spl1->setFlag(QGraphicsItem::ItemStacksBehindParent, false);
|
m_spl1->setFlag(QGraphicsItem::ItemStacksBehindParent, false);
|
||||||
spl2 = InitItem<VCurvePathItem>(Qt::darkRed, this);
|
m_spl2 = InitItem<VCurvePathItem>(Qt::darkRed, this);
|
||||||
spl2->setFlag(QGraphicsItem::ItemStacksBehindParent, false);
|
m_spl2->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);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -68,23 +67,23 @@ void VisToolCutSpline::RefreshGeometry()
|
||||||
const auto spl = Visualization::data->GeometricObject<VAbstractCubicBezier>(object1Id);
|
const auto spl = Visualization::data->GeometricObject<VAbstractCubicBezier>(object1Id);
|
||||||
DrawPath(this, spl->GetPath(), spl->DirectionArrows(), supportColor, lineStyle, Qt::RoundCap);
|
DrawPath(this, spl->GetPath(), spl->DirectionArrows(), supportColor, lineStyle, Qt::RoundCap);
|
||||||
|
|
||||||
if (not qFuzzyIsNull(length))
|
if (not qFuzzyIsNull(m_length))
|
||||||
{
|
{
|
||||||
QPointF spl1p2;
|
QPointF spl1p2;
|
||||||
QPointF spl1p3;
|
QPointF spl1p3;
|
||||||
QPointF spl2p2;
|
QPointF spl2p2;
|
||||||
QPointF spl2p3;
|
QPointF spl2p3;
|
||||||
const QPointF p = spl->CutSpline(length, spl1p2, spl1p3, spl2p2, spl2p3, QString());
|
const QPointF p = spl->CutSpline(m_length, spl1p2, spl1p3, spl2p2, spl2p3, QString());
|
||||||
|
|
||||||
VSpline sp1 = VSpline(spl->GetP1(), spl1p2, spl1p3, VPointF(p));
|
VSpline sp1 = VSpline(spl->GetP1(), spl1p2, spl1p3, VPointF(p));
|
||||||
sp1.SetApproximationScale(spl->GetApproximationScale());
|
sp1.SetApproximationScale(spl->GetApproximationScale());
|
||||||
VSpline sp2 = VSpline(VPointF(p), spl2p2, spl2p3, spl->GetP4());
|
VSpline sp2 = VSpline(VPointF(p), spl2p2, spl2p3, spl->GetP4());
|
||||||
sp2.SetApproximationScale(spl->GetApproximationScale());
|
sp2.SetApproximationScale(spl->GetApproximationScale());
|
||||||
|
|
||||||
DrawPoint(point, p, mainColor);
|
DrawPoint(m_point, p, mainColor);
|
||||||
|
|
||||||
DrawPath(spl1, sp1.GetPath(), sp1.DirectionArrows(), Qt::darkGreen, lineStyle, Qt::RoundCap);
|
DrawPath(m_spl1, sp1.GetPath(), sp1.DirectionArrows(), Qt::darkGreen, lineStyle, Qt::RoundCap);
|
||||||
DrawPath(spl2, sp2.GetPath(), sp2.DirectionArrows(), Qt::darkRed, lineStyle, Qt::RoundCap);
|
DrawPath(m_spl2, sp2.GetPath(), sp2.DirectionArrows(), Qt::darkRed, lineStyle, Qt::RoundCap);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -92,5 +91,5 @@ void VisToolCutSpline::RefreshGeometry()
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VisToolCutSpline::setLength(const QString &expression)
|
void VisToolCutSpline::setLength(const QString &expression)
|
||||||
{
|
{
|
||||||
length = FindLengthFromUser(expression, Visualization::data->DataVariables());
|
m_length = FindLengthFromUser(expression, Visualization::data->DataVariables());
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,18 +44,18 @@ class VisToolCutSpline final : public VisPath
|
||||||
Q_OBJECT // NOLINT
|
Q_OBJECT // NOLINT
|
||||||
public:
|
public:
|
||||||
explicit VisToolCutSpline(const VContainer *data, QGraphicsItem *parent = nullptr);
|
explicit VisToolCutSpline(const VContainer *data, QGraphicsItem *parent = nullptr);
|
||||||
virtual ~VisToolCutSpline() Q_DECL_EQ_DEFAULT;
|
~VisToolCutSpline() 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::ToolCutSpline)};
|
enum {Type = UserType + static_cast<int>(Vis::ToolCutSpline)};
|
||||||
protected:
|
private:
|
||||||
Q_DISABLE_COPY_MOVE(VisToolCutSpline) // NOLINT
|
Q_DISABLE_COPY_MOVE(VisToolCutSpline) // NOLINT
|
||||||
VScaledEllipse *point;
|
VScaledEllipse *m_point{nullptr};
|
||||||
VCurvePathItem *spl1;
|
VCurvePathItem *m_spl1{nullptr};
|
||||||
VCurvePathItem *spl2;
|
VCurvePathItem *m_spl2{nullptr};
|
||||||
qreal length;
|
qreal m_length{0};
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // VISTOOLCUTSPLINE_H
|
#endif // VISTOOLCUTSPLINE_H
|
||||||
|
|
Loading…
Reference in New Issue
Block a user