Refactoring.

This commit is contained in:
Roman Telezhynskyi 2022-08-20 18:21:20 +03:00
parent 63cd0e7b5d
commit c136a716f6
9 changed files with 126 additions and 145 deletions

View File

@ -351,13 +351,10 @@ void DialogAlongLine::ShowDialog(bool click)
return; return;
} }
auto *lineVis = qobject_cast<VisToolAlongLine *>(vis); auto FinishCreating = [this]()
SCASSERT(lineVis != nullptr)
auto FinishCreating = [this, lineVis]()
{ {
lineVis->SetMode(Mode::Show); vis->SetMode(Mode::Show);
lineVis->RefreshGeometry(); vis->RefreshGeometry();
emit ToolTip(QString()); emit ToolTip(QString());

View File

@ -282,13 +282,10 @@ void DialogArcWithLength::ShowDialog(bool click)
{ {
if (prepare) if (prepare)
{ {
auto *arcVis = qobject_cast<VisToolArcWithLength *>(vis); auto FinishCreating = [this]()
SCASSERT(arcVis != nullptr)
auto FinishCreating = [this, arcVis]()
{ {
arcVis->SetMode(Mode::Show); vis->SetMode(Mode::Show);
arcVis->RefreshGeometry(); vis->RefreshGeometry();
emit ToolTip(QString()); emit ToolTip(QString());
@ -333,7 +330,7 @@ void DialogArcWithLength::ShowDialog(bool click)
} }
SetRadius(QString::number(VAbstractValApplication::VApp()->fromPixel(line.length()))); SetRadius(QString::number(VAbstractValApplication::VApp()->fromPixel(line.length())));
arcVis->RefreshGeometry(); vis->RefreshGeometry();
stageRadius = false; stageRadius = false;
stageF1 = true; stageF1 = true;
@ -342,7 +339,7 @@ void DialogArcWithLength::ShowDialog(bool click)
{ {
SetF1(QString::number(Angle())); SetF1(QString::number(Angle()));
arcVis->RefreshGeometry(); vis->RefreshGeometry();
stageF1 = false; stageF1 = false;
} }

View File

@ -351,13 +351,10 @@ void DialogBisector::ShowDialog(bool click)
return; return;
} }
auto *lineVis = qobject_cast<VisToolBisector *>(vis); auto FinishCreating = [this]()
SCASSERT(lineVis != nullptr)
auto FinishCreating = [this, lineVis]()
{ {
lineVis->SetMode(Mode::Show); vis->SetMode(Mode::Show);
lineVis->RefreshGeometry(); vis->RefreshGeometry();
emit ToolTip(QString()); emit ToolTip(QString());

View File

@ -41,7 +41,6 @@
#include "../../visualization/path/vistoolcutsplinepath.h" #include "../../visualization/path/vistoolcutsplinepath.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 @@
DialogCutSplinePath::DialogCutSplinePath(const VContainer *data, quint32 toolId, QWidget *parent) DialogCutSplinePath::DialogCutSplinePath(const VContainer *data, quint32 toolId, QWidget *parent)
: DialogTool(data, toolId, parent), : DialogTool(data, toolId, parent),
ui(new Ui::DialogCutSplinePath), ui(new Ui::DialogCutSplinePath),
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, &DialogCutSplinePath::EvalFormula); connect(m_timerFormula, &QTimer::timeout, this, &DialogCutSplinePath::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 @@ DialogCutSplinePath::DialogCutSplinePath(const VContainer *data, quint32 toolId,
connect(ui->toolButtonExprLength, &QPushButton::clicked, this, &DialogCutSplinePath::FXLength); connect(ui->toolButtonExprLength, &QPushButton::clicked, this, &DialogCutSplinePath::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, &DialogCutSplinePath::DeployFormulaTextEdit); connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogCutSplinePath::DeployFormulaTextEdit);
connect(ui->comboBoxSplinePath, &QComboBox::currentTextChanged, this, &DialogCutSplinePath::SplinePathChanged); connect(ui->comboBoxSplinePath, &QComboBox::currentTextChanged, this, &DialogCutSplinePath::SplinePathChanged);
@ -110,9 +104,9 @@ DialogCutSplinePath::~DialogCutSplinePath()
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QString DialogCutSplinePath::GetPointName() const auto DialogCutSplinePath::GetPointName() const -> QString
{ {
return pointName; return m_pointName;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -122,8 +116,8 @@ QString DialogCutSplinePath::GetPointName() const
*/ */
void DialogCutSplinePath::SetPointName(const QString &value) void DialogCutSplinePath::SetPointName(const QString &value)
{ {
pointName = value; m_pointName = value;
ui->lineEditNamePoint->setText(pointName); ui->lineEditNamePoint->setText(m_pointName);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -133,19 +127,19 @@ void DialogCutSplinePath::SetPointName(const QString &value)
*/ */
void DialogCutSplinePath::SetFormula(const QString &value) void DialogCutSplinePath::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);
VisToolCutSplinePath *path = qobject_cast<VisToolCutSplinePath *>(vis); auto *path = qobject_cast<VisToolCutSplinePath *>(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 DialogCutSplinePath::setSplinePathId(quint32 value)
{ {
setCurrentSplinePathId(ui->comboBoxSplinePath, value); setCurrentSplinePathId(ui->comboBoxSplinePath, value);
VisToolCutSplinePath *path = qobject_cast<VisToolCutSplinePath *>(vis); auto *path = qobject_cast<VisToolCutSplinePath *>(vis);
SCASSERT(path != nullptr) SCASSERT(path != nullptr)
path->setObject1Id(value); path->setObject1Id(value);
} }
@ -172,8 +166,11 @@ void DialogCutSplinePath::setSplinePathId(quint32 value)
*/ */
void DialogCutSplinePath::ChosenObject(quint32 id, const SceneObject &type) void DialogCutSplinePath::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::SplinePath) if (type == SceneObject::SplinePath)
{ {
if (SetObject(id, ui->comboBoxSplinePath, QString())) if (SetObject(id, ui->comboBoxSplinePath, QString()))
@ -188,19 +185,18 @@ void DialogCutSplinePath::ChosenObject(quint32 id, const SceneObject &type)
} }
} }
} }
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogCutSplinePath::SaveData() void DialogCutSplinePath::SaveData()
{ {
pointName = ui->lineEditNamePoint->text(); m_pointName = ui->lineEditNamePoint->text();
formula = ui->plainTextEditFormula->toPlainText(); m_formula = ui->plainTextEditFormula->toPlainText();
VisToolCutSplinePath *path = qobject_cast<VisToolCutSplinePath *>(vis); auto *path = qobject_cast<VisToolCutSplinePath *>(vis);
SCASSERT(path != nullptr) SCASSERT(path != nullptr)
path->setObject1Id(getSplinePathId()); path->setObject1Id(getSplinePathId());
path->setLength(formula); path->setLength(m_formula);
path->RefreshGeometry(); path->RefreshGeometry();
} }
@ -230,29 +226,29 @@ void DialogCutSplinePath::ValidateAlias()
if (not GetAliasSuffix1().isEmpty() && if (not GetAliasSuffix1().isEmpty() &&
(not rx.match(path1.GetAlias()).hasMatch() || (not rx.match(path1.GetAlias()).hasMatch() ||
(originAliasSuffix1 != GetAliasSuffix1() && not data->IsUnique(path1.GetAlias())) || (m_originAliasSuffix1 != GetAliasSuffix1() && not data->IsUnique(path1.GetAlias())) ||
path1.GetAlias() == path2.GetAlias())) path1.GetAlias() == path2.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(path2.GetAlias()).hasMatch() || (not rx.match(path2.GetAlias()).hasMatch() ||
(originAliasSuffix2 != GetAliasSuffix2() && not data->IsUnique(path2.GetAlias())) || (m_originAliasSuffix2 != GetAliasSuffix2() && not data->IsUnique(path2.GetAlias())) ||
path1.GetAlias() == path2.GetAlias())) path1.GetAlias() == path2.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 DialogCutSplinePath::ValidateAlias()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogCutSplinePath::DeployFormulaTextEdit() void DialogCutSplinePath::DeployFormulaTextEdit()
{ {
DeployFormula(this, ui->plainTextEditFormula, ui->pushButtonGrowLength, formulaBaseHeight); DeployFormula(this, ui->plainTextEditFormula, ui->pushButtonGrowLength, m_formulaBaseHeight);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogCutSplinePath::FXLength() void DialogCutSplinePath::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 DialogCutSplinePath::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 DialogCutSplinePath::ShowVisualization()
* @brief GetFormula return string of formula * @brief GetFormula return string of formula
* @return formula * @return formula
*/ */
QString DialogCutSplinePath::GetFormula() const auto DialogCutSplinePath::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 DialogCutSplinePath::GetFormula() const
* @brief getSplineId return id base point of line * @brief getSplineId return id base point of line
* @return id * @return id
*/ */
quint32 DialogCutSplinePath::getSplinePathId() const auto DialogCutSplinePath::getSplinePathId() const -> quint32
{ {
return getCurrentObjectId(ui->comboBoxSplinePath); return getCurrentObjectId(ui->comboBoxSplinePath);
} }
@ -326,7 +322,7 @@ void DialogCutSplinePath::SetNotes(const QString &notes)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QString DialogCutSplinePath::GetNotes() const auto DialogCutSplinePath::GetNotes() const -> QString
{ {
return ui->plainTextEditToolNotes->toPlainText(); return ui->plainTextEditToolNotes->toPlainText();
} }
@ -334,13 +330,13 @@ QString DialogCutSplinePath::GetNotes() const
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogCutSplinePath::SetAliasSuffix1(const QString &alias) void DialogCutSplinePath::SetAliasSuffix1(const QString &alias)
{ {
originAliasSuffix1 = alias; m_originAliasSuffix1 = alias;
ui->lineEditAlias1->setText(originAliasSuffix1); ui->lineEditAlias1->setText(m_originAliasSuffix1);
ValidateAlias(); ValidateAlias();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QString DialogCutSplinePath::GetAliasSuffix1() const auto DialogCutSplinePath::GetAliasSuffix1() const -> QString
{ {
return ui->lineEditAlias1->text(); return ui->lineEditAlias1->text();
} }
@ -348,13 +344,13 @@ QString DialogCutSplinePath::GetAliasSuffix1() const
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogCutSplinePath::SetAliasSuffix2(const QString &alias) void DialogCutSplinePath::SetAliasSuffix2(const QString &alias)
{ {
originAliasSuffix2 = alias; m_originAliasSuffix2 = alias;
ui->lineEditAlias2->setText(originAliasSuffix2); ui->lineEditAlias2->setText(m_originAliasSuffix2);
ValidateAlias(); ValidateAlias();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QString DialogCutSplinePath::GetAliasSuffix2() const auto DialogCutSplinePath::GetAliasSuffix2() const -> QString
{ {
return ui->lineEditAlias2->text(); return ui->lineEditAlias2->text();
} }

View File

@ -51,27 +51,27 @@ class DialogCutSplinePath final : public DialogTool
Q_OBJECT // NOLINT Q_OBJECT // NOLINT
public: public:
DialogCutSplinePath(const VContainer *data, quint32 toolId, QWidget *parent = nullptr); DialogCutSplinePath(const VContainer *data, quint32 toolId, QWidget *parent = nullptr);
virtual ~DialogCutSplinePath() override; ~DialogCutSplinePath() 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 getSplinePathId() const; auto getSplinePathId() const -> quint32;
void setSplinePathId(quint32 value); void setSplinePathId(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
*/ */
@ -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 SplinePathChanged(); void SplinePathChanged();
void ValidateAlias(); void ValidateAlias();
@ -96,27 +96,27 @@ private:
Ui::DialogCutSplinePath *ui; Ui::DialogCutSplinePath *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 DialogCutSplinePath::IsValid() const inline auto DialogCutSplinePath::IsValid() const -> bool
{ {
return flagFormula && flagAlias1 && flagAlias2 && flagName; return m_flagFormula && m_flagAlias1 && m_flagAlias2 && m_flagName;
} }
#endif // DIALOGCUTSPLINEPATH_H #endif // DIALOGCUTSPLINEPATH_H

View File

@ -429,13 +429,10 @@ void DialogNormal::ShowDialog(bool click)
return; return;
} }
auto *lineVis = qobject_cast<VisToolNormal *>(vis); auto FinishCreating = [this]()
SCASSERT(lineVis != nullptr)
auto FinishCreating = [this, lineVis]()
{ {
lineVis->SetMode(Mode::Show); vis->SetMode(Mode::Show);
lineVis->RefreshGeometry(); vis->RefreshGeometry();
emit ToolTip(QString()); emit ToolTip(QString());

View File

@ -449,13 +449,10 @@ void DialogShoulderPoint::ShowDialog(bool click)
return; return;
} }
auto *lineVis = qobject_cast<VisToolShoulderPoint *>(vis); auto FinishCreating = [this]()
SCASSERT(lineVis != nullptr)
auto FinishCreating = [this, lineVis]()
{ {
lineVis->SetMode(Mode::Show); vis->SetMode(Mode::Show);
lineVis->RefreshGeometry(); vis->RefreshGeometry();
emit ToolTip(QString()); emit ToolTip(QString());

View File

@ -36,7 +36,6 @@
#include <new> #include <new>
#include "../../tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutsplinepath.h" #include "../../tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutsplinepath.h"
#include "../ifc/ifcdef.h"
#include "../vgeometry/vabstractcubicbezierpath.h" #include "../vgeometry/vabstractcubicbezierpath.h"
#include "../vgeometry/vabstractcurve.h" #include "../vgeometry/vabstractcurve.h"
#include "../vgeometry/vpointf.h" #include "../vgeometry/vpointf.h"
@ -47,16 +46,16 @@
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VisToolCutSplinePath::VisToolCutSplinePath(const VContainer *data, QGraphicsItem *parent) VisToolCutSplinePath::VisToolCutSplinePath(const VContainer *data, QGraphicsItem *parent)
:VisPath(data, parent), point(nullptr), splPath1(nullptr), splPath2(nullptr), length(0) :VisPath(data, parent)
{ {
splPath1 = InitItem<VCurvePathItem>(Qt::darkGreen, this); m_splPath1 = InitItem<VCurvePathItem>(Qt::darkGreen, this);
splPath1->setFlag(QGraphicsItem::ItemStacksBehindParent, false); m_splPath1->setFlag(QGraphicsItem::ItemStacksBehindParent, false);
splPath2 = InitItem<VCurvePathItem>(Qt::darkRed, this); m_splPath2 = InitItem<VCurvePathItem>(Qt::darkRed, this);
splPath2->setFlag(QGraphicsItem::ItemStacksBehindParent, false); m_splPath2->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);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -67,20 +66,21 @@ void VisToolCutSplinePath::RefreshGeometry()
const auto splPath = Visualization::data->GeometricObject<VAbstractCubicBezierPath>(object1Id); const auto splPath = Visualization::data->GeometricObject<VAbstractCubicBezierPath>(object1Id);
DrawPath(this, splPath->GetPath(), splPath->DirectionArrows(), supportColor, lineStyle, Qt::RoundCap); DrawPath(this, splPath->GetPath(), splPath->DirectionArrows(), supportColor, lineStyle, Qt::RoundCap);
if (not qFuzzyIsNull(length)) if (not qFuzzyIsNull(m_length))
{ {
VSplinePath *spPath1 = nullptr; VSplinePath *spPath1 = nullptr;
VSplinePath *spPath2 = nullptr; VSplinePath *spPath2 = nullptr;
VPointF *p = VToolCutSplinePath::CutSplinePath(length, splPath, "X", &spPath1, &spPath2); VPointF *p = VToolCutSplinePath::CutSplinePath(m_length, splPath, QChar('X'), &spPath1, &spPath2);
SCASSERT(p != nullptr) SCASSERT(p != nullptr)
SCASSERT(spPath1 != nullptr) SCASSERT(spPath1 != nullptr)
SCASSERT(spPath2 != nullptr) SCASSERT(spPath2 != nullptr)
DrawPoint(point, static_cast<QPointF>(*p), mainColor); DrawPoint(m_point, static_cast<QPointF>(*p), mainColor);
delete p; delete p;
DrawPath(splPath1, spPath1->GetPath(), spPath1->DirectionArrows(), Qt::darkGreen, lineStyle, Qt::RoundCap); DrawPath(m_splPath1, spPath1->GetPath(), spPath1->DirectionArrows(), Qt::darkGreen, lineStyle,
DrawPath(splPath2, spPath2->GetPath(), spPath2->DirectionArrows(), Qt::darkRed, lineStyle, Qt::RoundCap); Qt::RoundCap);
DrawPath(m_splPath2, spPath2->GetPath(), spPath2->DirectionArrows(), Qt::darkRed, lineStyle, Qt::RoundCap);
delete spPath1; delete spPath1;
delete spPath2; delete spPath2;
@ -91,5 +91,5 @@ void VisToolCutSplinePath::RefreshGeometry()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VisToolCutSplinePath::setLength(const QString &expression) void VisToolCutSplinePath::setLength(const QString &expression)
{ {
length = FindLengthFromUser(expression, Visualization::data->DataVariables()); m_length = FindLengthFromUser(expression, Visualization::data->DataVariables());
} }

View File

@ -44,18 +44,18 @@ class VisToolCutSplinePath final : public VisPath
Q_OBJECT // NOLINT Q_OBJECT // NOLINT
public: public:
explicit VisToolCutSplinePath(const VContainer *data, QGraphicsItem *parent = nullptr); explicit VisToolCutSplinePath(const VContainer *data, QGraphicsItem *parent = nullptr);
virtual ~VisToolCutSplinePath() Q_DECL_EQ_DEFAULT; ~VisToolCutSplinePath() 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(VisToolCutSplinePath) // NOLINT Q_DISABLE_COPY_MOVE(VisToolCutSplinePath) // NOLINT
VScaledEllipse *point; VScaledEllipse *m_point{nullptr};
VCurvePathItem *splPath1; VCurvePathItem *m_splPath1{nullptr};
VCurvePathItem *splPath2; VCurvePathItem *m_splPath2{nullptr};
qreal length; qreal m_length{0};
}; };
#endif // VISTOOLCUTSPLINEPATH_H #endif // VISTOOLCUTSPLINEPATH_H