diff --git a/src/app/dialogs/tools/dialogalongline.cpp b/src/app/dialogs/tools/dialogalongline.cpp index f33b72ab8..d26e3e455 100644 --- a/src/app/dialogs/tools/dialogalongline.cpp +++ b/src/app/dialogs/tools/dialogalongline.cpp @@ -43,7 +43,7 @@ */ DialogAlongLine::DialogAlongLine(const VContainer *data, const quint32 &toolId, QWidget *parent) :DialogTool(data, toolId, parent), ui(new Ui::DialogAlongLine), - formula(QString()), formulaBaseHeight(0), line(nullptr) + formula(QString()), formulaBaseHeight(0) { ui->setupUi(this); InitFormulaUI(ui); @@ -71,7 +71,7 @@ DialogAlongLine::DialogAlongLine(const VContainer *data, const quint32 &toolId, connect(ui->comboBoxSecondPoint, static_cast(&QComboBox::currentIndexChanged), this, &DialogAlongLine::PointChanged); - line = new VisToolAlongLine(data); + vis = new VisToolAlongLine(data); } //--------------------------------------------------------------------------------------------------------------------- @@ -115,14 +115,7 @@ void DialogAlongLine::FXLength() //--------------------------------------------------------------------------------------------------------------------- void DialogAlongLine::ShowVisualization() { - if (prepare == false) - { - VMainGraphicsScene *scene = qobject_cast(qApp->getCurrentScene()); - SCASSERT(scene != nullptr) - connect(scene, &VMainGraphicsScene::NewFactor, line, &VisToolAlongLine::SetFactor); - scene->addItem(line); - line->RefreshGeometry(); - } + AddVisualization(); } //--------------------------------------------------------------------------------------------------------------------- @@ -134,10 +127,7 @@ void DialogAlongLine::DeployFormulaTextEdit() //--------------------------------------------------------------------------------------------------------------------- DialogAlongLine::~DialogAlongLine() { - if (qApp->getCurrentScene()->items().contains(line)) - { // In some cases scene delete object yourself. If not make check program will crash. - delete line; - } + DeleteVisualization(); delete ui; } @@ -153,6 +143,9 @@ void DialogAlongLine::ChosenObject(quint32 id, const SceneObject &type) { if (type == SceneObject::Point) { + VisToolAlongLine *line = qobject_cast(vis); + SCASSERT(line != nullptr); + const QString toolTip = tr("Select second point of line"); switch (number) { @@ -195,6 +188,9 @@ void DialogAlongLine::SaveData() formula = ui->plainTextEditFormula->toPlainText(); formula.replace("\n", " "); + VisToolAlongLine *line = qobject_cast(vis); + SCASSERT(line != nullptr); + line->setPoint1Id(GetFirstPointId()); line->setPoint2Id(GetSecondPointId()); line->setLength(formula); @@ -217,6 +213,9 @@ void DialogAlongLine::closeEvent(QCloseEvent *event) void DialogAlongLine::SetSecondPointId(const quint32 &value) { setCurrentPointId(ui->comboBoxSecondPoint, value); + + VisToolAlongLine *line = qobject_cast(vis); + SCASSERT(line != nullptr); line->setPoint2Id(value); } @@ -228,6 +227,9 @@ void DialogAlongLine::SetSecondPointId(const quint32 &value) void DialogAlongLine::SetFirstPointId(const quint32 &value) { setCurrentPointId(ui->comboBoxFirstPoint, value); + + VisToolAlongLine *line = qobject_cast(vis); + SCASSERT(line != nullptr); line->setPoint1Id(value); } @@ -245,7 +247,11 @@ void DialogAlongLine::SetFormula(const QString &value) this->DeployFormulaTextEdit(); } ui->plainTextEditFormula->setPlainText(formula); + + VisToolAlongLine *line = qobject_cast(vis); + SCASSERT(line != nullptr); line->setLength(formula); + MoveCursorToEnd(ui->plainTextEditFormula); } @@ -257,7 +263,7 @@ void DialogAlongLine::SetFormula(const QString &value) void DialogAlongLine::SetTypeLine(const QString &value) { ChangeCurrentData(ui->comboBoxLineType, value); - line->setLineStyle(VAbstractTool::LineStyleToPenStyle(value)); + vis->setLineStyle(VAbstractTool::LineStyleToPenStyle(value)); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/dialogs/tools/dialogalongline.h b/src/app/dialogs/tools/dialogalongline.h index 1ba3605f2..ef14c1eda 100644 --- a/src/app/dialogs/tools/dialogalongline.h +++ b/src/app/dialogs/tools/dialogalongline.h @@ -31,8 +31,6 @@ #include "dialogtool.h" -class VisToolAlongLine; - namespace Ui { class DialogAlongLine; @@ -46,7 +44,7 @@ class DialogAlongLine : public DialogTool Q_OBJECT public: DialogAlongLine(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr); - ~DialogAlongLine(); + virtual ~DialogAlongLine(); void SetPointName(const QString &value); @@ -95,7 +93,6 @@ private: /** @brief formulaBaseHeight base height defined by dialogui */ int formulaBaseHeight; - VisToolAlongLine *line; }; #endif // DIALOGALONGLINE_H diff --git a/src/app/dialogs/tools/dialogarc.cpp b/src/app/dialogs/tools/dialogarc.cpp index 3105693df..9b88f12fa 100644 --- a/src/app/dialogs/tools/dialogarc.cpp +++ b/src/app/dialogs/tools/dialogarc.cpp @@ -47,8 +47,7 @@ DialogArc::DialogArc(const VContainer *data, const quint32 &toolId, QWidget *parent) :DialogTool(data, toolId, parent), ui(new Ui::DialogArc), flagRadius(false), flagF1(false), flagF2(false), timerRadius(nullptr), timerF1(nullptr), timerF2(nullptr), radius(QString()), f1(QString()), f2(QString()), - formulaBaseHeight(0), formulaBaseHeightF1(0), formulaBaseHeightF2(0), path(nullptr), angleF1(INT_MIN), - angleF2(INT_MIN) + formulaBaseHeight(0), formulaBaseHeightF1(0), formulaBaseHeightF2(0), angleF1(INT_MIN), angleF2(INT_MIN) { ui->setupUi(this); @@ -89,7 +88,7 @@ DialogArc::DialogArc(const VContainer *data, const quint32 &toolId, QWidget *par connect(ui->pushButtonGrowLengthF1, &QPushButton::clicked, this, &DialogArc::DeployF1TextEdit); connect(ui->pushButtonGrowLengthF2, &QPushButton::clicked, this, &DialogArc::DeployF2TextEdit); - path = new VisToolArc(data); + vis = new VisToolArc(data); } //--------------------------------------------------------------------------------------------------------------------- @@ -113,10 +112,7 @@ void DialogArc::DeployF2TextEdit() //--------------------------------------------------------------------------------------------------------------------- DialogArc::~DialogArc() { - if (qApp->getCurrentScene()->items().contains(path)) - { // In some cases scene delete object yourself. If not make check program will crash. - delete path; - } + DeleteVisualization(); delete ui; } @@ -128,7 +124,7 @@ DialogArc::~DialogArc() void DialogArc::SetCenter(const quint32 &value) { ChangeCurrentData(ui->comboBoxBasePoint, value); - path->setPoint1Id(value); + vis->setPoint1Id(value); } //--------------------------------------------------------------------------------------------------------------------- @@ -145,7 +141,11 @@ void DialogArc::SetF2(const QString &value) this->DeployF2TextEdit(); } ui->plainTextEditF2->setPlainText(f2); + + VisToolArc *path = qobject_cast(vis); + SCASSERT(path != nullptr); path->setF2(f2); + MoveCursorToEnd(ui->plainTextEditF2); } @@ -175,7 +175,11 @@ void DialogArc::SetF1(const QString &value) this->DeployF1TextEdit(); } ui->plainTextEditF1->setPlainText(f1); + + VisToolArc *path = qobject_cast(vis); + SCASSERT(path != nullptr); path->setF1(f1); + MoveCursorToEnd(ui->plainTextEditF1); } @@ -193,7 +197,11 @@ void DialogArc::SetRadius(const QString &value) this->DeployFormulaTextEdit(); } ui->plainTextEditFormula->setPlainText(radius); + + VisToolArc *path = qobject_cast(vis); + SCASSERT(path != nullptr); path->setRadius(radius); + MoveCursorToEnd(ui->plainTextEditFormula); } @@ -211,7 +219,7 @@ void DialogArc::ChosenObject(quint32 id, const SceneObject &type) { if (SetObject(id, ui->comboBoxBasePoint, "")) { - path->VisualMode(id); + vis->VisualMode(id); prepare = true; this->setModal(true); this->show(); @@ -223,14 +231,7 @@ void DialogArc::ChosenObject(quint32 id, const SceneObject &type) //--------------------------------------------------------------------------------------------------------------------- void DialogArc::ShowVisualization() { - if (prepare == false) - { - VMainGraphicsScene *scene = qobject_cast(qApp->getCurrentScene()); - SCASSERT(scene != nullptr) - connect(scene, &VMainGraphicsScene::NewFactor, path, &Visualization::SetFactor); - scene->addItem(path); - path->RefreshGeometry(); - } + AddVisualization(); } //--------------------------------------------------------------------------------------------------------------------- @@ -243,6 +244,9 @@ void DialogArc::SaveData() f2 = ui->plainTextEditF2->toPlainText(); f2.replace("\n", " "); + VisToolArc *path = qobject_cast(vis); + SCASSERT(path != nullptr); + path->setPoint1Id(GetCenter()); path->setRadius(radius); path->setF1(f1); diff --git a/src/app/dialogs/tools/dialogarc.h b/src/app/dialogs/tools/dialogarc.h index d361e1579..ab5d707be 100644 --- a/src/app/dialogs/tools/dialogarc.h +++ b/src/app/dialogs/tools/dialogarc.h @@ -36,8 +36,6 @@ namespace Ui class DialogArc; } -class VisToolArc; - /** * @brief The DialogArc class dialog for ToolArc. Help create arc and edit option. */ @@ -46,7 +44,7 @@ class DialogArc : public DialogTool Q_OBJECT public: DialogArc(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr); - ~DialogArc(); + virtual ~DialogArc(); quint32 GetCenter() const; void SetCenter(const quint32 &value); @@ -123,8 +121,6 @@ private: int formulaBaseHeightF1; int formulaBaseHeightF2; - VisToolArc *path; - qreal angleF1; qreal angleF2; diff --git a/src/app/dialogs/tools/dialogbisector.cpp b/src/app/dialogs/tools/dialogbisector.cpp index c43a27d1a..402da2f1b 100644 --- a/src/app/dialogs/tools/dialogbisector.cpp +++ b/src/app/dialogs/tools/dialogbisector.cpp @@ -43,8 +43,7 @@ * @param parent parent widget */ DialogBisector::DialogBisector(const VContainer *data, const quint32 &toolId, QWidget *parent) - :DialogTool(data, toolId, parent), ui(new Ui::DialogBisector), formula(QString()), formulaBaseHeight(0), - line(nullptr) + :DialogTool(data, toolId, parent), ui(new Ui::DialogBisector), formula(QString()), formulaBaseHeight(0) { ui->setupUi(this); InitFormulaUI(ui); @@ -74,7 +73,7 @@ DialogBisector::DialogBisector(const VContainer *data, const quint32 &toolId, QW connect(ui->comboBoxThirdPoint, static_cast(&QComboBox::currentIndexChanged), this, &DialogBisector::PointNameChanged); - line = new VisToolBisector(data); + vis = new VisToolBisector(data); } //--------------------------------------------------------------------------------------------------------------------- @@ -124,14 +123,7 @@ void DialogBisector::FXLength() //--------------------------------------------------------------------------------------------------------------------- void DialogBisector::ShowVisualization() { - if (prepare == false) - { - VMainGraphicsScene *scene = qobject_cast(qApp->getCurrentScene()); - SCASSERT(scene != nullptr) - connect(scene, &VMainGraphicsScene::NewFactor, line, &VisToolBisector::SetFactor); - scene->addItem(line); - line->RefreshGeometry(); - } + AddVisualization(); } //--------------------------------------------------------------------------------------------------------------------- @@ -143,10 +135,7 @@ void DialogBisector::DeployFormulaTextEdit() //--------------------------------------------------------------------------------------------------------------------- DialogBisector::~DialogBisector() { - if (qApp->getCurrentScene()->items().contains(line)) - { // In some cases scene delete object yourself. If not make check program will crash. - delete line; - } + DeleteVisualization(); delete ui; } @@ -162,6 +151,9 @@ void DialogBisector::ChosenObject(quint32 id, const SceneObject &type) { if (type == SceneObject::Point) { + VisToolBisector *line = qobject_cast(vis); + SCASSERT(line != nullptr); + switch (number) { case 0: @@ -228,7 +220,7 @@ void DialogBisector::SetPointName(const QString &value) void DialogBisector::SetTypeLine(const QString &value) { ChangeCurrentData(ui->comboBoxLineType, value); - line->setLineStyle(VAbstractTool::LineStyleToPenStyle(value)); + vis->setLineStyle(VAbstractTool::LineStyleToPenStyle(value)); } //--------------------------------------------------------------------------------------------------------------------- @@ -245,7 +237,11 @@ void DialogBisector::SetFormula(const QString &value) this->DeployFormulaTextEdit(); } ui->plainTextEditFormula->setPlainText(formula); + + VisToolBisector *line = qobject_cast(vis); + SCASSERT(line != nullptr); line->setLength(formula); + MoveCursorToEnd(ui->plainTextEditFormula); } @@ -257,6 +253,9 @@ void DialogBisector::SetFormula(const QString &value) void DialogBisector::SetFirstPointId(const quint32 &value) { setCurrentPointId(ui->comboBoxFirstPoint, value); + + VisToolBisector *line = qobject_cast(vis); + SCASSERT(line != nullptr); line->setPoint1Id(value); } @@ -268,6 +267,9 @@ void DialogBisector::SetFirstPointId(const quint32 &value) void DialogBisector::SetSecondPointId(const quint32 &value) { setCurrentPointId(ui->comboBoxSecondPoint, value); + + VisToolBisector *line = qobject_cast(vis); + SCASSERT(line != nullptr); line->setPoint2Id(value); } @@ -279,6 +281,9 @@ void DialogBisector::SetSecondPointId(const quint32 &value) void DialogBisector::SetThirdPointId(const quint32 &value) { setCurrentPointId(ui->comboBoxThirdPoint, value); + + VisToolBisector *line = qobject_cast(vis); + SCASSERT(line != nullptr); line->setPoint3Id(value); } @@ -302,6 +307,9 @@ void DialogBisector::SaveData() formula = ui->plainTextEditFormula->toPlainText(); formula.replace("\n", " "); + VisToolBisector *line = qobject_cast(vis); + SCASSERT(line != nullptr); + line->setPoint1Id(GetFirstPointId()); line->setPoint2Id(GetSecondPointId()); line->setPoint3Id(GetThirdPointId()); diff --git a/src/app/dialogs/tools/dialogbisector.h b/src/app/dialogs/tools/dialogbisector.h index 1ff6df5b3..34f186b9a 100644 --- a/src/app/dialogs/tools/dialogbisector.h +++ b/src/app/dialogs/tools/dialogbisector.h @@ -36,8 +36,6 @@ namespace Ui class DialogBisector; } -class VisToolBisector; - /** * @brief The DialogBisector class dialog for ToolBisector. Help create point and edit option. */ @@ -47,7 +45,7 @@ class DialogBisector : public DialogTool public: DialogBisector(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr); - ~DialogBisector(); + virtual ~DialogBisector(); void SetPointName(const QString &value); @@ -98,8 +96,6 @@ private: /** @brief formulaBaseHeight base height defined by dialogui */ int formulaBaseHeight; - VisToolBisector *line; - }; #endif // DIALOGBISECTOR_H diff --git a/src/app/dialogs/tools/dialogcurveintersectaxis.cpp b/src/app/dialogs/tools/dialogcurveintersectaxis.cpp index 3476be2d2..f1febff37 100644 --- a/src/app/dialogs/tools/dialogcurveintersectaxis.cpp +++ b/src/app/dialogs/tools/dialogcurveintersectaxis.cpp @@ -40,8 +40,8 @@ //--------------------------------------------------------------------------------------------------------------------- DialogCurveIntersectAxis::DialogCurveIntersectAxis(const VContainer *data, const quint32 &toolId, QWidget *parent) - :DialogTool(data, toolId, parent), ui(new Ui::DialogCurveIntersectAxis), - formulaAngle(QString()), formulaBaseHeightAngle(0), line(nullptr) + :DialogTool(data, toolId, parent), ui(new Ui::DialogCurveIntersectAxis), formulaAngle(QString()), + formulaBaseHeightAngle(0) { ui->setupUi(this); @@ -66,16 +66,13 @@ DialogCurveIntersectAxis::DialogCurveIntersectAxis(const VContainer *data, const connect(ui->pushButtonGrowLengthAngle, &QPushButton::clicked, this, &DialogCurveIntersectAxis::DeployAngleTextEdit); connect(timerFormula, &QTimer::timeout, this, &DialogCurveIntersectAxis::EvalAngle); - line = new VisToolCurveIntersectAxis(data); + vis = new VisToolCurveIntersectAxis(data); } //--------------------------------------------------------------------------------------------------------------------- DialogCurveIntersectAxis::~DialogCurveIntersectAxis() { - if (qApp->getCurrentScene()->items().contains(line)) - { // In some cases scene delete object yourself. If not make check program will crash. - delete line; - } + DeleteVisualization(); delete ui; } @@ -96,7 +93,7 @@ QString DialogCurveIntersectAxis::GetTypeLine() const void DialogCurveIntersectAxis::SetTypeLine(const QString &value) { ChangeCurrentData(ui->comboBoxLineType, value); - line->setLineStyle(VAbstractTool::LineStyleToPenStyle(value)); + vis->setLineStyle(VAbstractTool::LineStyleToPenStyle(value)); } //--------------------------------------------------------------------------------------------------------------------- @@ -116,7 +113,11 @@ void DialogCurveIntersectAxis::SetAngle(const QString &value) this->DeployAngleTextEdit(); } ui->plainTextEditFormula->setPlainText(formulaAngle); + + VisToolCurveIntersectAxis *line = qobject_cast(vis); + SCASSERT(line != nullptr); line->SetAngle(formulaAngle); + MoveCursorToEnd(ui->plainTextEditFormula); } @@ -130,6 +131,9 @@ quint32 DialogCurveIntersectAxis::GetBasePointId() const void DialogCurveIntersectAxis::SetBasePointId(const quint32 &value) { setCurrentPointId(ui->comboBoxAxisPoint, value); + + VisToolCurveIntersectAxis *line = qobject_cast(vis); + SCASSERT(line != nullptr); line->setAxisPointId(value); } @@ -143,6 +147,9 @@ quint32 DialogCurveIntersectAxis::getCurveId() const void DialogCurveIntersectAxis::setCurveId(const quint32 &value) { setCurrentCurveId(ui->comboBoxCurve, value); + + VisToolCurveIntersectAxis *line = qobject_cast(vis); + SCASSERT(line != nullptr); line->setPoint1Id(value); } @@ -179,6 +186,10 @@ void DialogCurveIntersectAxis::ShowDialog(bool click) } } this->setModal(true); + + VisToolCurveIntersectAxis *line = qobject_cast(vis); + SCASSERT(line != nullptr); + this->SetAngle(line->Angle());//Show in dialog angle what user choose emit ToolTip(""); timerFormula->start(); @@ -191,6 +202,9 @@ void DialogCurveIntersectAxis::ChosenObject(quint32 id, const SceneObject &type) { if (prepare == false)// After first choose we ignore all objects { + VisToolCurveIntersectAxis *line = qobject_cast(vis); + SCASSERT(line != nullptr); + switch (number) { case (0): @@ -255,15 +269,7 @@ void DialogCurveIntersectAxis::FXAngle() //--------------------------------------------------------------------------------------------------------------------- void DialogCurveIntersectAxis::ShowVisualization() { - if (prepare == false) - { - //TODO move to parent class! - VMainGraphicsScene *scene = qobject_cast(qApp->getCurrentScene()); - SCASSERT(scene != nullptr) - connect(scene, &VMainGraphicsScene::NewFactor, line, &VisToolCurveIntersectAxis::SetFactor); - scene->addItem(line); - line->RefreshGeometry(); - } + AddVisualization(); } //--------------------------------------------------------------------------------------------------------------------- @@ -274,6 +280,9 @@ void DialogCurveIntersectAxis::SaveData() formulaAngle = ui->plainTextEditFormula->toPlainText(); formulaAngle.replace("\n", " "); + VisToolCurveIntersectAxis *line = qobject_cast(vis); + SCASSERT(line != nullptr); + line->setPoint1Id(getCurveId()); line->setAxisPointId(GetBasePointId()); line->SetAngle(formulaAngle); diff --git a/src/app/dialogs/tools/dialogcurveintersectaxis.h b/src/app/dialogs/tools/dialogcurveintersectaxis.h index 16e0d4246..5ed47fe49 100644 --- a/src/app/dialogs/tools/dialogcurveintersectaxis.h +++ b/src/app/dialogs/tools/dialogcurveintersectaxis.h @@ -36,15 +36,13 @@ namespace Ui class DialogCurveIntersectAxis; } -class VisToolCurveIntersectAxis; - class DialogCurveIntersectAxis : public DialogTool { Q_OBJECT public: DialogCurveIntersectAxis(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr); - ~DialogCurveIntersectAxis(); + virtual ~DialogCurveIntersectAxis(); void SetPointName(const QString &value); @@ -83,8 +81,6 @@ private: QString formulaAngle; int formulaBaseHeightAngle; - - VisToolCurveIntersectAxis *line; }; #endif // DIALOGCURVEINTERSECTAXIS_H diff --git a/src/app/dialogs/tools/dialogcutarc.cpp b/src/app/dialogs/tools/dialogcutarc.cpp index 7268423e9..3a4a8a279 100644 --- a/src/app/dialogs/tools/dialogcutarc.cpp +++ b/src/app/dialogs/tools/dialogcutarc.cpp @@ -43,8 +43,7 @@ * @param parent parent widget */ DialogCutArc::DialogCutArc(const VContainer *data, const quint32 &toolId, QWidget *parent) - : DialogTool(data, toolId, parent), ui(new Ui::DialogCutArc), formula(QString()), formulaBaseHeight(0), - path(nullptr) + : DialogTool(data, toolId, parent), ui(new Ui::DialogCutArc), formula(QString()), formulaBaseHeight(0) { ui->setupUi(this); InitFormulaUI(ui); @@ -65,7 +64,7 @@ DialogCutArc::DialogCutArc(const VContainer *data, const quint32 &toolId, QWidge connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, &DialogCutArc::FormulaTextChanged); connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogCutArc::DeployFormulaTextEdit); - path = new VisToolCutArc(data); + vis = new VisToolCutArc(data); } //--------------------------------------------------------------------------------------------------------------------- @@ -90,14 +89,7 @@ void DialogCutArc::FXLength() //--------------------------------------------------------------------------------------------------------------------- void DialogCutArc::ShowVisualization() { - if (prepare == false) - { - VMainGraphicsScene *scene = qobject_cast(qApp->getCurrentScene()); - SCASSERT(scene != nullptr) - connect(scene, &VMainGraphicsScene::NewFactor, path, &Visualization::SetFactor); - scene->addItem(path); - path->RefreshGeometry(); - } + AddVisualization(); } //--------------------------------------------------------------------------------------------------------------------- @@ -109,10 +101,7 @@ void DialogCutArc::DeployFormulaTextEdit() //--------------------------------------------------------------------------------------------------------------------- DialogCutArc::~DialogCutArc() { - if (qApp->getCurrentScene()->items().contains(path)) - { // In some cases scene delete object yourself. If not make check program will crash. - delete path; - } + DeleteVisualization(); delete ui; } @@ -130,7 +119,7 @@ void DialogCutArc::ChosenObject(quint32 id, const SceneObject &type) { if (SetObject(id, ui->comboBoxArc, "")) { - path->VisualMode(id); + vis->VisualMode(id); prepare = true; this->setModal(true); this->show(); @@ -146,6 +135,9 @@ void DialogCutArc::SaveData() formula = ui->plainTextEditFormula->toPlainText(); formula.replace("\n", " "); + VisToolCutArc *path = qobject_cast(vis); + SCASSERT(path != nullptr); + path->setPoint1Id(getArcId()); path->setLength(formula); path->RefreshGeometry(); @@ -166,6 +158,9 @@ void DialogCutArc::closeEvent(QCloseEvent *event) void DialogCutArc::setArcId(const quint32 &value) { setCurrentArcId(ui->comboBoxArc, value, ComboBoxCutArc::CutArc); + + VisToolCutArc *path = qobject_cast(vis); + SCASSERT(path != nullptr); path->setPoint1Id(value); } @@ -195,7 +190,11 @@ void DialogCutArc::SetFormula(const QString &value) this->DeployFormulaTextEdit(); } ui->plainTextEditFormula->setPlainText(formula); + + VisToolCutArc *path = qobject_cast(vis); + SCASSERT(path != nullptr); path->setLength(formula); + MoveCursorToEnd(ui->plainTextEditFormula); } diff --git a/src/app/dialogs/tools/dialogcutarc.h b/src/app/dialogs/tools/dialogcutarc.h index 5e426cd55..47273ab5a 100644 --- a/src/app/dialogs/tools/dialogcutarc.h +++ b/src/app/dialogs/tools/dialogcutarc.h @@ -36,8 +36,6 @@ namespace Ui class DialogCutArc; } -class VisToolCutArc; - /** * @brief The DialogCutArc class dialog for ToolCutArc. */ @@ -47,7 +45,7 @@ class DialogCutArc : public DialogTool public: DialogCutArc(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr); - ~DialogCutArc(); + virtual ~DialogCutArc(); void SetPointName(const QString &value); @@ -87,8 +85,6 @@ private: /** @brief formulaBaseHeight base height defined by dialogui */ int formulaBaseHeight; - - VisToolCutArc *path; }; #endif // DIALOGCUTARC_H diff --git a/src/app/dialogs/tools/dialogcutspline.cpp b/src/app/dialogs/tools/dialogcutspline.cpp index 8eefa1e0d..d2fae9c24 100644 --- a/src/app/dialogs/tools/dialogcutspline.cpp +++ b/src/app/dialogs/tools/dialogcutspline.cpp @@ -42,8 +42,7 @@ * @param parent parent widget */ DialogCutSpline::DialogCutSpline(const VContainer *data, const quint32 &toolId, QWidget *parent) - :DialogTool(data, toolId, parent), ui(new Ui::DialogCutSpline), formula(QString()), formulaBaseHeight(0), - path(nullptr) + :DialogTool(data, toolId, parent), ui(new Ui::DialogCutSpline), formula(QString()), formulaBaseHeight(0) { ui->setupUi(this); InitFormulaUI(ui); @@ -64,16 +63,13 @@ DialogCutSpline::DialogCutSpline(const VContainer *data, const quint32 &toolId, connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, &DialogCutSpline::FormulaChanged); connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogCutSpline::DeployFormulaTextEdit); - path = new VisToolCutSpline(data); + vis = new VisToolCutSpline(data); } //--------------------------------------------------------------------------------------------------------------------- DialogCutSpline::~DialogCutSpline() { - if (qApp->getCurrentScene()->items().contains(path)) - { // In some cases scene delete object yourself. If not make check program will crash. - delete path; - } + DeleteVisualization(); delete ui; } @@ -103,7 +99,11 @@ void DialogCutSpline::SetFormula(const QString &value) this->DeployFormulaTextEdit(); } ui->plainTextEditFormula->setPlainText(formula); + + VisToolCutSpline *path = qobject_cast(vis); + SCASSERT(path != nullptr); path->setLength(formula); + MoveCursorToEnd(ui->plainTextEditFormula); } @@ -115,6 +115,9 @@ void DialogCutSpline::SetFormula(const QString &value) void DialogCutSpline::setSplineId(const quint32 &value) { setCurrentSplineId(ui->comboBoxSpline, value, ComboBoxCutSpline::CutSpline); + + VisToolCutSpline *path = qobject_cast(vis); + SCASSERT(path != nullptr); path->setPoint1Id(value); } @@ -144,7 +147,7 @@ void DialogCutSpline::ChosenObject(quint32 id, const SceneObject &type) { if (SetObject(id, ui->comboBoxSpline, "")) { - path->VisualMode(id); + vis->VisualMode(id); prepare = true; this->setModal(true); this->show(); @@ -160,6 +163,9 @@ void DialogCutSpline::SaveData() formula = ui->plainTextEditFormula->toPlainText(); formula.replace("\n", " "); + VisToolCutSpline *path = qobject_cast(vis); + SCASSERT(path != nullptr); + path->setPoint1Id(getSplineId()); path->setLength(formula); path->RefreshGeometry(); @@ -194,14 +200,7 @@ void DialogCutSpline::FXLength() //--------------------------------------------------------------------------------------------------------------------- void DialogCutSpline::ShowVisualization() { - if (prepare == false) - { - VMainGraphicsScene *scene = qobject_cast(qApp->getCurrentScene()); - SCASSERT(scene != nullptr) - connect(scene, &VMainGraphicsScene::NewFactor, path, &Visualization::SetFactor); - scene->addItem(path); - path->RefreshGeometry(); - } + AddVisualization(); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/dialogs/tools/dialogcutspline.h b/src/app/dialogs/tools/dialogcutspline.h index 740ebc746..1ac8d2cce 100644 --- a/src/app/dialogs/tools/dialogcutspline.h +++ b/src/app/dialogs/tools/dialogcutspline.h @@ -36,8 +36,6 @@ namespace Ui class DialogCutSpline; } -class VisToolCutSpline; - /** * @brief The DialogCutSpline class dialog for ToolCutSpline. */ @@ -46,7 +44,7 @@ class DialogCutSpline : public DialogTool Q_OBJECT public: DialogCutSpline(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr); - ~DialogCutSpline(); + virtual ~DialogCutSpline(); void SetPointName(const QString &value); @@ -83,8 +81,6 @@ private: /** @brief formulaBaseHeight base height defined by dialogui */ int formulaBaseHeight; - - VisToolCutSpline *path; }; #endif // DIALOGCUTSPLINE_H diff --git a/src/app/dialogs/tools/dialogcutsplinepath.cpp b/src/app/dialogs/tools/dialogcutsplinepath.cpp index f2f06812d..993b856c4 100644 --- a/src/app/dialogs/tools/dialogcutsplinepath.cpp +++ b/src/app/dialogs/tools/dialogcutsplinepath.cpp @@ -42,8 +42,7 @@ * @param parent parent widget */ DialogCutSplinePath::DialogCutSplinePath(const VContainer *data, const quint32 &toolId, QWidget *parent) - :DialogTool(data, toolId, parent), ui(new Ui::DialogCutSplinePath), formula(QString()), formulaBaseHeight(0), - path(nullptr) + :DialogTool(data, toolId, parent), ui(new Ui::DialogCutSplinePath), formula(QString()), formulaBaseHeight(0) { ui->setupUi(this); InitFormulaUI(ui); @@ -64,16 +63,13 @@ DialogCutSplinePath::DialogCutSplinePath(const VContainer *data, const quint32 & connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, &DialogCutSplinePath::FormulaChanged); connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogCutSplinePath::DeployFormulaTextEdit); - path = new VisToolCutSplinePath(data); + vis = new VisToolCutSplinePath(data); } //--------------------------------------------------------------------------------------------------------------------- DialogCutSplinePath::~DialogCutSplinePath() { - if (qApp->getCurrentScene()->items().contains(path)) - { // In some cases scene delete object yourself. If not make check program will crash. - delete path; - } + DeleteVisualization(); delete ui; } @@ -103,7 +99,11 @@ void DialogCutSplinePath::SetFormula(const QString &value) this->DeployFormulaTextEdit(); } ui->plainTextEditFormula->setPlainText(formula); + + VisToolCutSplinePath *path = qobject_cast(vis); + SCASSERT(path != nullptr); path->setLength(formula); + MoveCursorToEnd(ui->plainTextEditFormula); } @@ -115,6 +115,9 @@ void DialogCutSplinePath::SetFormula(const QString &value) void DialogCutSplinePath::setSplinePathId(const quint32 &value) { setCurrentSplinePathId(ui->comboBoxSplinePath, value, ComboBoxCutSpline::CutSpline); + + VisToolCutSplinePath *path = qobject_cast(vis); + SCASSERT(path != nullptr); path->setPoint1Id(value); } @@ -144,7 +147,7 @@ void DialogCutSplinePath::ChosenObject(quint32 id, const SceneObject &type) { if (SetObject(id, ui->comboBoxSplinePath, "")) { - path->VisualMode(id); + vis->VisualMode(id); prepare = true; this->setModal(true); this->show(); @@ -160,6 +163,9 @@ void DialogCutSplinePath::SaveData() formula = ui->plainTextEditFormula->toPlainText(); formula.replace("\n", " "); + VisToolCutSplinePath *path = qobject_cast(vis); + SCASSERT(path != nullptr); + path->setPoint1Id(getSplinePathId()); path->setLength(formula); path->RefreshGeometry(); @@ -194,14 +200,7 @@ void DialogCutSplinePath::FXLength() //--------------------------------------------------------------------------------------------------------------------- void DialogCutSplinePath::ShowVisualization() { - if (prepare == false) - { - VMainGraphicsScene *scene = qobject_cast(qApp->getCurrentScene()); - SCASSERT(scene != nullptr) - connect(scene, &VMainGraphicsScene::NewFactor, path, &Visualization::SetFactor); - scene->addItem(path); - path->RefreshGeometry(); - } + AddVisualization(); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/dialogs/tools/dialogcutsplinepath.h b/src/app/dialogs/tools/dialogcutsplinepath.h index 892b70e33..b9bbc8727 100644 --- a/src/app/dialogs/tools/dialogcutsplinepath.h +++ b/src/app/dialogs/tools/dialogcutsplinepath.h @@ -36,8 +36,6 @@ namespace Ui class DialogCutSplinePath; } -class VisToolCutSplinePath; - /** * @brief The DialogCutSplinePath class dialog for ToolCutSplinePath. */ @@ -46,7 +44,7 @@ class DialogCutSplinePath : public DialogTool Q_OBJECT public: DialogCutSplinePath(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr); - ~DialogCutSplinePath(); + virtual ~DialogCutSplinePath(); void SetPointName(const QString &value); @@ -83,8 +81,6 @@ private: /** @brief formulaBaseHeight base height defined by dialogui */ int formulaBaseHeight; - - VisToolCutSplinePath *path; }; #endif // DIALOGCUTSPLINEPATH_H diff --git a/src/app/dialogs/tools/dialogeditwrongformula.h b/src/app/dialogs/tools/dialogeditwrongformula.h index fc6f9d16a..dffb9b228 100644 --- a/src/app/dialogs/tools/dialogeditwrongformula.h +++ b/src/app/dialogs/tools/dialogeditwrongformula.h @@ -49,7 +49,7 @@ class DialogEditWrongFormula : public DialogTool Q_OBJECT public: explicit DialogEditWrongFormula(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr); - ~DialogEditWrongFormula(); + virtual ~DialogEditWrongFormula(); QString GetFormula() const; void SetFormula(const QString &value); diff --git a/src/app/dialogs/tools/dialogendline.cpp b/src/app/dialogs/tools/dialogendline.cpp index 27b9891e0..57160defa 100644 --- a/src/app/dialogs/tools/dialogendline.cpp +++ b/src/app/dialogs/tools/dialogendline.cpp @@ -45,7 +45,7 @@ */ DialogEndLine::DialogEndLine(const VContainer *data, const quint32 &toolId, QWidget *parent) :DialogTool(data, toolId, parent), ui(new Ui::DialogEndLine), - formulaLength(QString()), formulaAngle(QString()), formulaBaseHeight(0), formulaBaseHeightAngle(0), line(nullptr) + formulaLength(QString()), formulaAngle(QString()), formulaBaseHeight(0), formulaBaseHeightAngle(0) { ui->setupUi(this); InitFormulaUI(ui); @@ -78,7 +78,7 @@ DialogEndLine::DialogEndLine(const VContainer *data, const quint32 &toolId, QWid connect(timerFormula, &QTimer::timeout, this, &DialogEndLine::EvalAngle); - line = new VisToolEndLine(data); + vis = new VisToolEndLine(data); } //--------------------------------------------------------------------------------------------------------------------- @@ -158,8 +158,8 @@ void DialogEndLine::ChosenObject(quint32 id, const SceneObject &type) { if (SetObject(id, ui->comboBoxBasePoint, "")) { - line->VisualMode(id); - connect(line, &VisToolEndLine::ToolTip, this, &DialogTool::ShowVisToolTip); + vis->VisualMode(id); + connect(vis, &Visualization::ToolTip, this, &DialogTool::ShowVisToolTip); prepare = true; } } @@ -185,7 +185,7 @@ void DialogEndLine::SetPointName(const QString &value) void DialogEndLine::SetTypeLine(const QString &value) { ChangeCurrentData(ui->comboBoxLineType, value); - line->setLineStyle(VAbstractTool::LineStyleToPenStyle(value)); + vis->setLineStyle(VAbstractTool::LineStyleToPenStyle(value)); } //--------------------------------------------------------------------------------------------------------------------- @@ -203,7 +203,11 @@ void DialogEndLine::SetFormula(const QString &value) this->DeployFormulaTextEdit(); } ui->plainTextEditFormula->setPlainText(formulaLength); + + VisToolEndLine *line = qobject_cast(vis); + SCASSERT(line != nullptr); line->setLength(formulaLength); + MoveCursorToEnd(ui->plainTextEditFormula); } @@ -222,7 +226,11 @@ void DialogEndLine::SetAngle(const QString &value) this->DeployAngleTextEdit(); } ui->plainTextEditAngle->setPlainText(formulaAngle); + + VisToolEndLine *line = qobject_cast(vis); + SCASSERT(line != nullptr); line->SetAngle(formulaAngle); + MoveCursorToEnd(ui->plainTextEditAngle); } @@ -234,6 +242,9 @@ void DialogEndLine::SetAngle(const QString &value) void DialogEndLine::SetBasePointId(const quint32 &value) { setCurrentPointId(ui->comboBoxBasePoint, value); + + VisToolEndLine *line = qobject_cast(vis); + SCASSERT(line != nullptr); line->setPoint1Id(value); } @@ -274,6 +285,10 @@ void DialogEndLine::ShowDialog(bool click) } } this->setModal(true); + + VisToolEndLine *line = qobject_cast(vis); + SCASSERT(line != nullptr); + this->SetAngle(line->Angle());//Show in dialog angle what user choose emit ToolTip(""); timerFormula->start(); @@ -284,15 +299,7 @@ void DialogEndLine::ShowDialog(bool click) //--------------------------------------------------------------------------------------------------------------------- void DialogEndLine::ShowVisualization() { - if (prepare == false) - { - //TODO move to parent class! - VMainGraphicsScene *scene = qobject_cast(qApp->getCurrentScene()); - SCASSERT(scene != nullptr) - connect(scene, &VMainGraphicsScene::NewFactor, line, &VisToolEndLine::SetFactor); - scene->addItem(line); - line->RefreshGeometry(); - } + AddVisualization(); } //--------------------------------------------------------------------------------------------------------------------- @@ -306,6 +313,9 @@ void DialogEndLine::SaveData() formulaAngle = ui->plainTextEditAngle->toPlainText(); formulaAngle.replace("\n", " "); + VisToolEndLine *line = qobject_cast(vis); + SCASSERT(line != nullptr); + line->setPoint1Id(GetBasePointId()); line->setLength(formulaLength); line->SetAngle(formulaAngle); @@ -324,10 +334,7 @@ void DialogEndLine::closeEvent(QCloseEvent *event) //--------------------------------------------------------------------------------------------------------------------- DialogEndLine::~DialogEndLine() { - if (qApp->getCurrentScene()->items().contains(line)) - { // In some cases scene delete object yourself. If not make check program will crash. - delete line; - } + DeleteVisualization(); delete ui; } diff --git a/src/app/dialogs/tools/dialogendline.h b/src/app/dialogs/tools/dialogendline.h index dfaf7b4c0..0164e3fb1 100644 --- a/src/app/dialogs/tools/dialogendline.h +++ b/src/app/dialogs/tools/dialogendline.h @@ -36,8 +36,6 @@ namespace Ui class DialogEndLine; } -class VisToolEndLine; - /** * @brief The DialogEndLine class dialog for ToolEndLine. Help create point and edit option. */ @@ -46,7 +44,7 @@ class DialogEndLine : public DialogTool Q_OBJECT public: DialogEndLine(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr); - ~DialogEndLine(); + virtual ~DialogEndLine(); void SetPointName(const QString &value); @@ -105,8 +103,6 @@ private: /** @brief formulaBaseHeight base height defined by dialogui */ int formulaBaseHeight; int formulaBaseHeightAngle; - - VisToolEndLine *line; }; #endif // DIALOGENDLINE_H diff --git a/src/app/dialogs/tools/dialogheight.cpp b/src/app/dialogs/tools/dialogheight.cpp index 9440e517a..d4b55f498 100644 --- a/src/app/dialogs/tools/dialogheight.cpp +++ b/src/app/dialogs/tools/dialogheight.cpp @@ -42,7 +42,7 @@ * @param parent parent widget */ DialogHeight::DialogHeight(const VContainer *data, const quint32 &toolId, QWidget *parent) - :DialogTool(data, toolId, parent), ui(new Ui::DialogHeight), line(nullptr) + :DialogTool(data, toolId, parent), ui(new Ui::DialogHeight) { ui->setupUi(this); ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel)); @@ -64,16 +64,13 @@ DialogHeight::DialogHeight(const VContainer *data, const quint32 &toolId, QWidge connect(ui->comboBoxP2Line, static_cast(&QComboBox::currentIndexChanged), this, &DialogHeight::PointNameChanged); - line = new VisToolHeight(data); + vis = new VisToolHeight(data); } //--------------------------------------------------------------------------------------------------------------------- DialogHeight::~DialogHeight() { - if (qApp->getCurrentScene()->items().contains(line)) - { // In some cases scene delete object yourself. If not make check program will crash. - delete line; - } + DeleteVisualization(); delete ui; } @@ -96,7 +93,7 @@ void DialogHeight::SetPointName(const QString &value) void DialogHeight::SetTypeLine(const QString &value) { ChangeCurrentData(ui->comboBoxLineType, value); - line->setLineStyle(VAbstractTool::LineStyleToPenStyle(value)); + vis->setLineStyle(VAbstractTool::LineStyleToPenStyle(value)); } //--------------------------------------------------------------------------------------------------------------------- @@ -107,6 +104,9 @@ void DialogHeight::SetTypeLine(const QString &value) void DialogHeight::SetBasePointId(const quint32 &value) { setCurrentPointId(ui->comboBoxBasePoint, value); + + VisToolHeight *line = qobject_cast(vis); + SCASSERT(line != nullptr); line->setPoint1Id(value); } @@ -118,6 +118,9 @@ void DialogHeight::SetBasePointId(const quint32 &value) void DialogHeight::SetP1LineId(const quint32 &value) { setCurrentPointId(ui->comboBoxP1Line, value); + + VisToolHeight *line = qobject_cast(vis); + SCASSERT(line != nullptr); line->setLineP1Id(value); } @@ -129,6 +132,9 @@ void DialogHeight::SetP1LineId(const quint32 &value) void DialogHeight::SetP2LineId(const quint32 &value) { setCurrentPointId(ui->comboBoxP2Line, value); + + VisToolHeight *line = qobject_cast(vis); + SCASSERT(line != nullptr); line->setLineP2Id(value); } @@ -156,6 +162,9 @@ void DialogHeight::ChosenObject(quint32 id, const SceneObject &type) { if (type == SceneObject::Point) { + VisToolHeight *line = qobject_cast(vis); + SCASSERT(line != nullptr); + switch (number) { case (0): @@ -208,6 +217,9 @@ void DialogHeight::SaveData() { pointName = ui->lineEditNamePoint->text(); + VisToolHeight *line = qobject_cast(vis); + SCASSERT(line != nullptr); + line->setPoint1Id(GetBasePointId()); line->setLineP1Id(GetP1LineId()); line->setLineP2Id(GetP2LineId()); @@ -252,14 +264,7 @@ void DialogHeight::PointNameChanged() //--------------------------------------------------------------------------------------------------------------------- void DialogHeight::ShowVisualization() { - if (prepare == false) - { - VMainGraphicsScene *scene = qobject_cast(qApp->getCurrentScene()); - SCASSERT(scene != nullptr) - connect(scene, &VMainGraphicsScene::NewFactor, line, &VisLine::SetFactor); - scene->addItem(line); - line->RefreshGeometry(); - } + AddVisualization(); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/dialogs/tools/dialogheight.h b/src/app/dialogs/tools/dialogheight.h index 7f96cfffb..11bf3fcbe 100644 --- a/src/app/dialogs/tools/dialogheight.h +++ b/src/app/dialogs/tools/dialogheight.h @@ -36,8 +36,6 @@ namespace Ui class DialogHeight; } -class VisToolHeight; - /** * @brief The DialogHeight class dialog for ToolHeight. Help create point and edit option. */ @@ -46,7 +44,7 @@ class DialogHeight : public DialogTool Q_OBJECT public: DialogHeight(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr); - ~DialogHeight(); + virtual ~DialogHeight(); void SetPointName(const QString &value); @@ -78,8 +76,6 @@ private: /** @brief ui keeps information about user interface */ Ui::DialogHeight *ui; - - VisToolHeight *line; }; #endif // DIALOGHEIGHT_H diff --git a/src/app/dialogs/tools/dialogline.cpp b/src/app/dialogs/tools/dialogline.cpp index 218deabb2..d474f2362 100644 --- a/src/app/dialogs/tools/dialogline.cpp +++ b/src/app/dialogs/tools/dialogline.cpp @@ -43,7 +43,7 @@ * @param parent parent widget */ DialogLine::DialogLine(const VContainer *data, const quint32 &toolId, QWidget *parent) - :DialogTool(data, toolId, parent), ui(new Ui::DialogLine), line(nullptr) + :DialogTool(data, toolId, parent), ui(new Ui::DialogLine) { ui->setupUi(this); InitOkCancelApply(ui); @@ -63,16 +63,13 @@ DialogLine::DialogLine(const VContainer *data, const quint32 &toolId, QWidget *p connect(ui->comboBoxSecondPoint, static_cast(&QComboBox::currentIndexChanged), this, &DialogLine::PointNameChanged); - line = new VisToolLine(data); + vis = new VisToolLine(data); } //--------------------------------------------------------------------------------------------------------------------- DialogLine::~DialogLine() { - if (qApp->getCurrentScene()->items().contains(line)) - { // In some cases scene delete object yourself. If not make check program will crash. - delete line; - } + DeleteVisualization(); delete ui; } @@ -84,6 +81,9 @@ DialogLine::~DialogLine() void DialogLine::SetSecondPoint(const quint32 &value) { setCurrentPointId(ui->comboBoxSecondPoint, value); + + VisToolLine *line = qobject_cast(vis); + SCASSERT(line != nullptr); line->setPoint2Id(value); } @@ -95,7 +95,7 @@ void DialogLine::SetSecondPoint(const quint32 &value) void DialogLine::SetTypeLine(const QString &value) { ChangeCurrentData(ui->comboBoxLineType, value); - line->setLineStyle(VAbstractTool::LineStyleToPenStyle(value)); + vis->setLineStyle(VAbstractTool::LineStyleToPenStyle(value)); } //--------------------------------------------------------------------------------------------------------------------- @@ -118,6 +118,9 @@ void DialogLine::SetLineColor(const QString &value) void DialogLine::SetFirstPoint(const quint32 &value) { setCurrentPointId(ui->comboBoxFirstPoint, value); + + VisToolLine *line = qobject_cast(vis); + SCASSERT(line != nullptr); line->setPoint1Id(value); } @@ -143,19 +146,15 @@ void DialogLine::PointNameChanged() //--------------------------------------------------------------------------------------------------------------------- void DialogLine::ShowVisualization() { - if (prepare == false) - { - VMainGraphicsScene *scene = qobject_cast(qApp->getCurrentScene()); - SCASSERT(scene != nullptr) - connect(scene, &VMainGraphicsScene::NewFactor, line, &VisToolLine::SetFactor); - scene->addItem(line); - line->RefreshGeometry(); - } + AddVisualization(); } //--------------------------------------------------------------------------------------------------------------------- void DialogLine::SaveData() { + VisToolLine *line = qobject_cast(vis); + SCASSERT(line != nullptr); + line->setPoint1Id(GetFirstPoint()); line->setPoint2Id(GetSecondPoint()); line->setLineStyle(VAbstractTool::LineStyleToPenStyle(GetTypeLine())); @@ -180,7 +179,7 @@ void DialogLine::ChosenObject(quint32 id, const SceneObject &type) if (SetObject(id, ui->comboBoxFirstPoint, tr("Select second point"))) { number++; - line->VisualMode(id); + vis->VisualMode(id); } break; case 1: diff --git a/src/app/dialogs/tools/dialogline.h b/src/app/dialogs/tools/dialogline.h index bb07c9b1e..cde718e56 100644 --- a/src/app/dialogs/tools/dialogline.h +++ b/src/app/dialogs/tools/dialogline.h @@ -36,8 +36,6 @@ namespace Ui class DialogLine; } -class VisToolLine; - /** * @brief The DialogLine class dialog for ToolLine. Help create line and edit option. */ @@ -46,7 +44,7 @@ class DialogLine : public DialogTool Q_OBJECT public: DialogLine(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr); - ~DialogLine(); + virtual ~DialogLine(); quint32 GetFirstPoint() const; void SetFirstPoint(const quint32 &value); @@ -73,9 +71,6 @@ private: /** @brief ui keeps information about user interface */ Ui::DialogLine *ui; - - VisToolLine *line; - }; #endif // DIALOGLINE_H diff --git a/src/app/dialogs/tools/dialoglineintersect.cpp b/src/app/dialogs/tools/dialoglineintersect.cpp index 084373e2c..8f523c833 100644 --- a/src/app/dialogs/tools/dialoglineintersect.cpp +++ b/src/app/dialogs/tools/dialoglineintersect.cpp @@ -42,7 +42,7 @@ * @param parent parent widget */ DialogLineIntersect::DialogLineIntersect(const VContainer *data, const quint32 &toolId, QWidget *parent) - :DialogTool(data, toolId, parent), ui(new Ui::DialogLineIntersect), flagPoint(true), line(nullptr) + :DialogTool(data, toolId, parent), ui(new Ui::DialogLineIntersect), flagPoint(true) { ui->setupUi(this); number = 0; @@ -65,16 +65,13 @@ DialogLineIntersect::DialogLineIntersect(const VContainer *data, const quint32 & connect(ui->comboBoxP2Line2, static_cast(&QComboBox::currentIndexChanged), this, &DialogLineIntersect::PointNameChanged); - line = new VisToolLineIntersect(data); + vis = new VisToolLineIntersect(data); } //--------------------------------------------------------------------------------------------------------------------- DialogLineIntersect::~DialogLineIntersect() { - if (qApp->getCurrentScene()->items().contains(line)) - { // In some cases scene delete object yourself. If not make check program will crash. - delete line; - } + DeleteVisualization(); delete ui; } @@ -90,6 +87,9 @@ void DialogLineIntersect::ChosenObject(quint32 id, const SceneObject &type) { if (type == SceneObject::Point) { + VisToolLineIntersect *line = qobject_cast(vis); + SCASSERT(line != nullptr); + switch (number) { case 0: @@ -165,6 +165,9 @@ void DialogLineIntersect::SaveData() { pointName = ui->lineEditNamePoint->text(); + VisToolLineIntersect *line = qobject_cast(vis); + SCASSERT(line != nullptr); + line->setPoint1Id(GetP1Line1()); line->setLine1P2Id(GetP2Line1()); line->setLine2P1Id(GetP1Line2()); @@ -227,14 +230,7 @@ void DialogLineIntersect::PointNameChanged() //--------------------------------------------------------------------------------------------------------------------- void DialogLineIntersect::ShowVisualization() { - if (prepare == false) - { - VMainGraphicsScene *scene = qobject_cast(qApp->getCurrentScene()); - SCASSERT(scene != nullptr) - connect(scene, &VMainGraphicsScene::NewFactor, line, &VisLine::SetFactor); - scene->addItem(line); - line->RefreshGeometry(); - } + AddVisualization(); } //--------------------------------------------------------------------------------------------------------------------- @@ -281,6 +277,9 @@ bool DialogLineIntersect::CheckIntersecion() void DialogLineIntersect::SetP2Line2(const quint32 &value) { setCurrentPointId(ui->comboBoxP2Line2, value); + + VisToolLineIntersect *line = qobject_cast(vis); + SCASSERT(line != nullptr); line->setLine2P2Id(value); } @@ -292,6 +291,9 @@ void DialogLineIntersect::SetP2Line2(const quint32 &value) void DialogLineIntersect::SetP1Line2(const quint32 &value) { setCurrentPointId(ui->comboBoxP1Line2, value); + + VisToolLineIntersect *line = qobject_cast(vis); + SCASSERT(line != nullptr); line->setLine2P1Id(value); } @@ -303,6 +305,9 @@ void DialogLineIntersect::SetP1Line2(const quint32 &value) void DialogLineIntersect::SetP2Line1(const quint32 &value) { setCurrentPointId(ui->comboBoxP2Line1, value); + + VisToolLineIntersect *line = qobject_cast(vis); + SCASSERT(line != nullptr); line->setLine1P2Id(value); } @@ -314,6 +319,9 @@ void DialogLineIntersect::SetP2Line1(const quint32 &value) void DialogLineIntersect::SetP1Line1(const quint32 &value) { setCurrentPointId(ui->comboBoxP1Line1, value); + + VisToolLineIntersect *line = qobject_cast(vis); + SCASSERT(line != nullptr); line->setPoint1Id(value); } diff --git a/src/app/dialogs/tools/dialoglineintersect.h b/src/app/dialogs/tools/dialoglineintersect.h index deedc9587..76bbca1a9 100644 --- a/src/app/dialogs/tools/dialoglineintersect.h +++ b/src/app/dialogs/tools/dialoglineintersect.h @@ -36,8 +36,6 @@ namespace Ui class DialogLineIntersect; } -class VisToolLineIntersect; - /** * @brief The DialogLineIntersect class dialog for ToolLineIntersect. Help create point and edit option. */ @@ -46,7 +44,7 @@ class DialogLineIntersect : public DialogTool Q_OBJECT public: DialogLineIntersect(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr); - ~DialogLineIntersect(); + virtual ~DialogLineIntersect(); quint32 GetP1Line1() const; void SetP1Line1(const quint32 &value); @@ -80,8 +78,6 @@ private: /** @brief flagPoint keep state of point */ bool flagPoint; - VisToolLineIntersect *line; - virtual void CheckState(); bool CheckIntersecion(); }; diff --git a/src/app/dialogs/tools/dialoglineintersectaxis.cpp b/src/app/dialogs/tools/dialoglineintersectaxis.cpp index d9aac1dd7..9143047c1 100644 --- a/src/app/dialogs/tools/dialoglineintersectaxis.cpp +++ b/src/app/dialogs/tools/dialoglineintersectaxis.cpp @@ -41,7 +41,7 @@ //--------------------------------------------------------------------------------------------------------------------- DialogLineIntersectAxis::DialogLineIntersectAxis(const VContainer *data, const quint32 &toolId, QWidget *parent) :DialogTool(data, toolId, parent), ui(new Ui::DialogLineIntersectAxis), formulaAngle(QString()), - formulaBaseHeightAngle(0), line(nullptr) + formulaBaseHeightAngle(0) { ui->setupUi(this); InitFormulaUI(ui); @@ -74,16 +74,13 @@ DialogLineIntersectAxis::DialogLineIntersectAxis(const VContainer *data, const q connect(ui->comboBoxAxisPoint, static_cast(&QComboBox::currentIndexChanged), this, &DialogLineIntersectAxis::PointNameChanged); - line = new VisToolLineIntersectAxis(data); + vis = new VisToolLineIntersectAxis(data); } //--------------------------------------------------------------------------------------------------------------------- DialogLineIntersectAxis::~DialogLineIntersectAxis() { - if (qApp->getCurrentScene()->items().contains(line)) - { // In some cases scene delete object yourself. If not make check program will crash. - delete line; - } + DeleteVisualization(); delete ui; } @@ -104,7 +101,7 @@ QString DialogLineIntersectAxis::GetTypeLine() const void DialogLineIntersectAxis::SetTypeLine(const QString &value) { ChangeCurrentData(ui->comboBoxLineType, value); - line->setLineStyle(VAbstractTool::LineStyleToPenStyle(value)); + vis->setLineStyle(VAbstractTool::LineStyleToPenStyle(value)); } //--------------------------------------------------------------------------------------------------------------------- @@ -124,7 +121,11 @@ void DialogLineIntersectAxis::SetAngle(const QString &value) this->DeployAngleTextEdit(); } ui->plainTextEditFormula->setPlainText(formulaAngle); + + VisToolLineIntersectAxis *line = qobject_cast(vis); + SCASSERT(line != nullptr); line->SetAngle(formulaAngle); + MoveCursorToEnd(ui->plainTextEditFormula); } @@ -138,6 +139,9 @@ quint32 DialogLineIntersectAxis::GetBasePointId() const void DialogLineIntersectAxis::SetBasePointId(const quint32 &value) { setCurrentPointId(ui->comboBoxAxisPoint, value); + + VisToolLineIntersectAxis *line = qobject_cast(vis); + SCASSERT(line != nullptr); line->setAxisPointId(value); } @@ -151,6 +155,9 @@ quint32 DialogLineIntersectAxis::GetFirstPointId() const void DialogLineIntersectAxis::SetFirstPointId(const quint32 &value) { setCurrentPointId(ui->comboBoxFirstLinePoint, value); + + VisToolLineIntersectAxis *line = qobject_cast(vis); + SCASSERT(line != nullptr); line->setPoint1Id(value); } @@ -164,6 +171,9 @@ quint32 DialogLineIntersectAxis::GetSecondPointId() const void DialogLineIntersectAxis::SetSecondPointId(const quint32 &value) { setCurrentPointId(ui->comboBoxSecondLinePoint, value); + + VisToolLineIntersectAxis *line = qobject_cast(vis); + SCASSERT(line != nullptr); line->setPoint2Id(value); } @@ -200,6 +210,10 @@ void DialogLineIntersectAxis::ShowDialog(bool click) } } this->setModal(true); + + VisToolLineIntersectAxis *line = qobject_cast(vis); + SCASSERT(line != nullptr); + this->SetAngle(line->Angle());//Show in dialog angle what user choose emit ToolTip(""); timerFormula->start(); @@ -214,6 +228,9 @@ void DialogLineIntersectAxis::ChosenObject(quint32 id, const SceneObject &type) { if (type == SceneObject::Point) { + VisToolLineIntersectAxis *line = qobject_cast(vis); + SCASSERT(line != nullptr); + switch (number) { case (0): @@ -319,15 +336,7 @@ void DialogLineIntersectAxis::FXAngle() //--------------------------------------------------------------------------------------------------------------------- void DialogLineIntersectAxis::ShowVisualization() { - if (prepare == false) - { - //TODO move to parent class! - VMainGraphicsScene *scene = qobject_cast(qApp->getCurrentScene()); - SCASSERT(scene != nullptr) - connect(scene, &VMainGraphicsScene::NewFactor, line, &VisToolLineIntersectAxis::SetFactor); - scene->addItem(line); - line->RefreshGeometry(); - } + AddVisualization(); } //--------------------------------------------------------------------------------------------------------------------- @@ -338,6 +347,9 @@ void DialogLineIntersectAxis::SaveData() formulaAngle = ui->plainTextEditFormula->toPlainText(); formulaAngle.replace("\n", " "); + VisToolLineIntersectAxis *line = qobject_cast(vis); + SCASSERT(line != nullptr); + line->setPoint1Id(GetFirstPointId()); line->setPoint2Id(GetSecondPointId()); line->setAxisPointId(GetBasePointId()); diff --git a/src/app/dialogs/tools/dialoglineintersectaxis.h b/src/app/dialogs/tools/dialoglineintersectaxis.h index f9aaa4dfb..d8975889d 100644 --- a/src/app/dialogs/tools/dialoglineintersectaxis.h +++ b/src/app/dialogs/tools/dialoglineintersectaxis.h @@ -36,15 +36,13 @@ namespace Ui class DialogLineIntersectAxis; } -class VisToolLineIntersectAxis; - class DialogLineIntersectAxis : public DialogTool { Q_OBJECT public: DialogLineIntersectAxis(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr); - ~DialogLineIntersectAxis(); + virtual ~DialogLineIntersectAxis(); void SetPointName(const QString &value); @@ -87,8 +85,6 @@ private: QString formulaAngle; int formulaBaseHeightAngle; - - VisToolLineIntersectAxis *line; }; #endif // DIALOGLINEINTERSECTAXIS_H diff --git a/src/app/dialogs/tools/dialognormal.cpp b/src/app/dialogs/tools/dialognormal.cpp index fe54d4703..edbee2001 100644 --- a/src/app/dialogs/tools/dialognormal.cpp +++ b/src/app/dialogs/tools/dialognormal.cpp @@ -40,8 +40,7 @@ * @param parent parent widget */ DialogNormal::DialogNormal(const VContainer *data, const quint32 &toolId, QWidget *parent) - :DialogTool(data, toolId, parent), ui(new Ui::DialogNormal), formula(QString()), angle(0), formulaBaseHeight(0), - line(nullptr) + :DialogTool(data, toolId, parent), ui(new Ui::DialogNormal), formula(QString()), angle(0), formulaBaseHeight(0) { ui->setupUi(this); InitFormulaUI(ui); @@ -70,7 +69,7 @@ DialogNormal::DialogNormal(const VContainer *data, const quint32 &toolId, QWidge connect(ui->comboBoxSecondPoint, static_cast(&QComboBox::currentIndexChanged), this, &DialogNormal::PointNameChanged); - line = new VisToolNormal(data); + vis = new VisToolNormal(data); } //--------------------------------------------------------------------------------------------------------------------- @@ -114,14 +113,7 @@ void DialogNormal::FXLength() //--------------------------------------------------------------------------------------------------------------------- void DialogNormal::ShowVisualization() { - if (prepare == false) - { - VMainGraphicsScene *scene = qobject_cast(qApp->getCurrentScene()); - SCASSERT(scene != nullptr) - connect(scene, &VMainGraphicsScene::NewFactor, line, &VisLine::SetFactor); - scene->addItem(line); - line->RefreshGeometry(); - } + AddVisualization(); } //--------------------------------------------------------------------------------------------------------------------- @@ -133,10 +125,7 @@ void DialogNormal::DeployFormulaTextEdit() //--------------------------------------------------------------------------------------------------------------------- DialogNormal::~DialogNormal() { - if (qApp->getCurrentScene()->items().contains(line)) - { // In some cases scene delete object yourself. If not make check program will crash. - delete line; - } + DeleteVisualization(); delete ui; } @@ -152,6 +141,9 @@ void DialogNormal::ChosenObject(quint32 id, const SceneObject &type) { if (type == SceneObject::Point) { + VisToolNormal *line = qobject_cast(vis); + SCASSERT(line != nullptr); + switch (number) { case 0: @@ -189,6 +181,9 @@ void DialogNormal::SaveData() formula.replace("\n", " "); angle = ui->doubleSpinBoxAngle->value(); + VisToolNormal *line = qobject_cast(vis); + SCASSERT(line != nullptr); + line->setPoint1Id(GetFirstPointId()); line->setPoint2Id(GetSecondPointId()); line->setLength(formula); @@ -212,6 +207,9 @@ void DialogNormal::closeEvent(QCloseEvent *event) void DialogNormal::SetSecondPointId(const quint32 &value) { setCurrentPointId(ui->comboBoxSecondPoint, value); + + VisToolNormal *line = qobject_cast(vis); + SCASSERT(line != nullptr); line->setPoint2Id(value); } @@ -235,6 +233,9 @@ void DialogNormal::SetLineColor(const QString &value) void DialogNormal::SetFirstPointId(const quint32 &value) { setCurrentPointId(ui->comboBoxFirstPoint, value); + + VisToolNormal *line = qobject_cast(vis); + SCASSERT(line != nullptr); line->setPoint1Id(value); } @@ -247,6 +248,9 @@ void DialogNormal::SetAngle(const qreal &value) { angle = value; ui->doubleSpinBoxAngle->setValue(angle); + + VisToolNormal *line = qobject_cast(vis); + SCASSERT(line != nullptr); line->SetAngle(angle); } @@ -264,7 +268,11 @@ void DialogNormal::SetFormula(const QString &value) this->DeployFormulaTextEdit(); } ui->plainTextEditFormula->setPlainText(formula); + + VisToolNormal *line = qobject_cast(vis); + SCASSERT(line != nullptr); line->setLength(formula); + MoveCursorToEnd(ui->plainTextEditFormula); } @@ -276,7 +284,7 @@ void DialogNormal::SetFormula(const QString &value) void DialogNormal::SetTypeLine(const QString &value) { ChangeCurrentData(ui->comboBoxLineType, value); - line->setLineStyle(VAbstractTool::LineStyleToPenStyle(value)); + vis->setLineStyle(VAbstractTool::LineStyleToPenStyle(value)); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/dialogs/tools/dialognormal.h b/src/app/dialogs/tools/dialognormal.h index 39c1fbb55..b07ae1b55 100644 --- a/src/app/dialogs/tools/dialognormal.h +++ b/src/app/dialogs/tools/dialognormal.h @@ -36,8 +36,6 @@ namespace Ui class DialogNormal; } -class VisToolNormal; - /** * @brief The DialogNormal class dialog for ToolNormal. Help create point and edit option. */ @@ -46,7 +44,7 @@ class DialogNormal : public DialogTool Q_OBJECT public: DialogNormal(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr); - ~DialogNormal(); + virtual ~DialogNormal(); void SetPointName(const QString &value); @@ -100,8 +98,6 @@ private: /** @brief formulaBaseHeight base height defined by dialogui */ int formulaBaseHeight; - - VisToolNormal *line; }; #endif // DIALOGNORMAL_H diff --git a/src/app/dialogs/tools/dialogpointofcontact.cpp b/src/app/dialogs/tools/dialogpointofcontact.cpp index 694ab9cdc..0dbd1de0d 100644 --- a/src/app/dialogs/tools/dialogpointofcontact.cpp +++ b/src/app/dialogs/tools/dialogpointofcontact.cpp @@ -42,8 +42,7 @@ * @param parent parent widget */ DialogPointOfContact::DialogPointOfContact(const VContainer *data, const quint32 &toolId, QWidget *parent) - :DialogTool(data, toolId, parent), ui(new Ui::DialogPointOfContact), - radius(QString()), formulaBaseHeight(0), line(nullptr) + :DialogTool(data, toolId, parent), ui(new Ui::DialogPointOfContact), radius(QString()), formulaBaseHeight(0) { ui->setupUi(this); InitFormulaUI(ui); @@ -71,16 +70,13 @@ DialogPointOfContact::DialogPointOfContact(const VContainer *data, const quint32 connect(ui->comboBoxCenter, static_cast(&QComboBox::currentIndexChanged), this, &DialogPointOfContact::PointNameChanged); - line = new VisToolPointOfContact(data); + vis = new VisToolPointOfContact(data); } //--------------------------------------------------------------------------------------------------------------------- DialogPointOfContact::~DialogPointOfContact() { - if (qApp->getCurrentScene()->items().contains(line)) - { // In some cases scene delete object yourself. If not make check program will crash. - delete line; - } + DeleteVisualization(); delete ui; } @@ -131,14 +127,7 @@ void DialogPointOfContact::FXRadius() //--------------------------------------------------------------------------------------------------------------------- void DialogPointOfContact::ShowVisualization() { - if (prepare == false) - { - VMainGraphicsScene *scene = qobject_cast(qApp->getCurrentScene()); - SCASSERT(scene != nullptr) - connect(scene, &VMainGraphicsScene::NewFactor, line, &VisLine::SetFactor); - scene->addItem(line); - line->RefreshGeometry(); - } + AddVisualization(); } //--------------------------------------------------------------------------------------------------------------------- @@ -159,6 +148,9 @@ void DialogPointOfContact::ChosenObject(quint32 id, const SceneObject &type) { if (type == SceneObject::Point) { + VisToolPointOfContact *line = qobject_cast(vis); + SCASSERT(line != nullptr); + switch (number) { case 0: @@ -213,6 +205,9 @@ void DialogPointOfContact::SaveData() radius = ui->plainTextEditFormula->toPlainText(); radius.replace("\n", " "); + VisToolPointOfContact *line = qobject_cast(vis); + SCASSERT(line != nullptr); + line->setPoint1Id(GetFirstPoint()); line->setLineP2Id(GetSecondPoint()); line->setRadiusId(getCenter()); @@ -235,6 +230,9 @@ void DialogPointOfContact::closeEvent(QCloseEvent *event) void DialogPointOfContact::SetSecondPoint(const quint32 &value) { setCurrentPointId(ui->comboBoxSecondPoint, value); + + VisToolPointOfContact *line = qobject_cast(vis); + SCASSERT(line != nullptr); line->setLineP2Id(value); } @@ -246,6 +244,9 @@ void DialogPointOfContact::SetSecondPoint(const quint32 &value) void DialogPointOfContact::SetFirstPoint(const quint32 &value) { setCurrentPointId(ui->comboBoxFirstPoint, value); + + VisToolPointOfContact *line = qobject_cast(vis); + SCASSERT(line != nullptr); line->setPoint1Id(value); } @@ -257,6 +258,9 @@ void DialogPointOfContact::SetFirstPoint(const quint32 &value) void DialogPointOfContact::setCenter(const quint32 &value) { setCurrentPointId(ui->comboBoxCenter, value); + + VisToolPointOfContact *line = qobject_cast(vis); + SCASSERT(line != nullptr); line->setRadiusId(value); } @@ -274,7 +278,11 @@ void DialogPointOfContact::setRadius(const QString &value) this->DeployFormulaTextEdit(); } ui->plainTextEditFormula->setPlainText(radius); + + VisToolPointOfContact *line = qobject_cast(vis); + SCASSERT(line != nullptr); line->setRadius(radius); + MoveCursorToEnd(ui->plainTextEditFormula); } diff --git a/src/app/dialogs/tools/dialogpointofcontact.h b/src/app/dialogs/tools/dialogpointofcontact.h index d3d59f51b..3104d9036 100644 --- a/src/app/dialogs/tools/dialogpointofcontact.h +++ b/src/app/dialogs/tools/dialogpointofcontact.h @@ -37,8 +37,6 @@ namespace Ui class DialogPointOfContact; } -class VisToolPointOfContact; - /** * @brief The DialogPointOfContact class dialog for ToolPointOfContact. Help create point and edit option. */ @@ -92,8 +90,6 @@ private: /** @brief formulaBaseHeight base height defined by dialogui */ int formulaBaseHeight; - - VisToolPointOfContact *line; }; #endif // DIALOGPOINTOFCONTACT_H diff --git a/src/app/dialogs/tools/dialogpointofintersection.cpp b/src/app/dialogs/tools/dialogpointofintersection.cpp index b122108a7..1c60117e5 100644 --- a/src/app/dialogs/tools/dialogpointofintersection.cpp +++ b/src/app/dialogs/tools/dialogpointofintersection.cpp @@ -42,7 +42,7 @@ * @param parent parent widget */ DialogPointOfIntersection::DialogPointOfIntersection(const VContainer *data, const quint32 &toolId, QWidget *parent) - :DialogTool(data, toolId, parent), ui(new Ui::DialogPointOfIntersection), line(nullptr) + :DialogTool(data, toolId, parent), ui(new Ui::DialogPointOfIntersection) { ui->setupUi(this); ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel)); @@ -60,17 +60,14 @@ DialogPointOfIntersection::DialogPointOfIntersection(const VContainer *data, con connect(ui->comboBoxSecondPoint, static_cast(&QComboBox::currentIndexChanged), this, &DialogPointOfIntersection::PointNameChanged); - line = new VisToolPointOfIntersection(data); - line->VisualMode(NULL_ID); + vis = new VisToolPointOfIntersection(data); + vis->VisualMode(NULL_ID); } //--------------------------------------------------------------------------------------------------------------------- DialogPointOfIntersection::~DialogPointOfIntersection() { - if (qApp->getCurrentScene()->items().contains(line)) - { // In some cases scene delete object yourself. If not make check program will crash. - delete line; - } + DeleteVisualization(); delete ui; } @@ -82,6 +79,9 @@ DialogPointOfIntersection::~DialogPointOfIntersection() void DialogPointOfIntersection::SetSecondPointId(const quint32 &value) { setCurrentPointId(ui->comboBoxSecondPoint, value); + + VisToolPointOfIntersection *line = qobject_cast(vis); + SCASSERT(line != nullptr); line->setPoint2Id(value); } @@ -97,6 +97,9 @@ void DialogPointOfIntersection::ChosenObject(quint32 id, const SceneObject &type { if (type == SceneObject::Point) { + VisToolPointOfIntersection *line = qobject_cast(vis); + SCASSERT(line != nullptr); + switch (number) { case 0: @@ -132,6 +135,9 @@ void DialogPointOfIntersection::SaveData() { pointName = ui->lineEditNamePoint->text(); + VisToolPointOfIntersection *line = qobject_cast(vis); + SCASSERT(line != nullptr); + line->setPoint1Id(GetFirstPointId()); line->setPoint2Id(GetSecondPointId()); line->RefreshGeometry(); @@ -162,9 +168,13 @@ void DialogPointOfIntersection::ShowVisualization() if (prepare == false) { VMainGraphicsScene *scene = qobject_cast(qApp->getCurrentScene()); - SCASSERT(scene != nullptr) - connect(scene, &VMainGraphicsScene::NewFactor, line, &VisLine::SetFactor); - line->RefreshGeometry(); + SCASSERT(scene != nullptr); + + VisToolPointOfIntersection *toolVis = qobject_cast(vis); + SCASSERT(toolVis != nullptr); + + connect(scene, &VMainGraphicsScene::NewFactor, toolVis, &Visualization::SetFactor); + toolVis->RefreshGeometry(); } } @@ -176,6 +186,9 @@ void DialogPointOfIntersection::ShowVisualization() void DialogPointOfIntersection::SetFirstPointId(const quint32 &value) { setCurrentPointId(ui->comboBoxFirstPoint, value); + + VisToolPointOfIntersection *line = qobject_cast(vis); + SCASSERT(line != nullptr); line->setPoint1Id(value); } diff --git a/src/app/dialogs/tools/dialogpointofintersection.h b/src/app/dialogs/tools/dialogpointofintersection.h index 5b76bab47..651c4c5c8 100644 --- a/src/app/dialogs/tools/dialogpointofintersection.h +++ b/src/app/dialogs/tools/dialogpointofintersection.h @@ -36,8 +36,6 @@ namespace Ui class DialogPointOfIntersection; } -class VisToolPointOfIntersection; - /** * @brief The DialogPointOfIntersection class dialog for ToolPointOfIntersection. Help create point and edit option. */ @@ -46,7 +44,7 @@ class DialogPointOfIntersection : public DialogTool Q_OBJECT public: DialogPointOfIntersection(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr); - ~DialogPointOfIntersection(); + virtual ~DialogPointOfIntersection(); void SetPointName(const QString &value); @@ -69,8 +67,6 @@ private: /** @brief ui keeps information about user interface */ Ui::DialogPointOfIntersection *ui; - - VisToolPointOfIntersection *line; }; #endif // DIALOGPOINTOFINTERSECTION_H diff --git a/src/app/dialogs/tools/dialogshoulderpoint.cpp b/src/app/dialogs/tools/dialogshoulderpoint.cpp index 33194dbce..09bae04ab 100644 --- a/src/app/dialogs/tools/dialogshoulderpoint.cpp +++ b/src/app/dialogs/tools/dialogshoulderpoint.cpp @@ -44,7 +44,7 @@ */ DialogShoulderPoint::DialogShoulderPoint(const VContainer *data, const quint32 &toolId, QWidget *parent) :DialogTool(data, toolId, parent), ui(new Ui::DialogShoulderPoint), formula(QString()), - formulaBaseHeight(0), line (nullptr) + formulaBaseHeight(0) { ui->setupUi(this); InitFormulaUI(ui); @@ -74,7 +74,7 @@ DialogShoulderPoint::DialogShoulderPoint(const VContainer *data, const quint32 & connect(ui->comboBoxP3, static_cast(&QComboBox::currentIndexChanged), this, &DialogShoulderPoint::PointNameChanged); - line = new VisToolShoulderPoint(data); + vis = new VisToolShoulderPoint(data); } //--------------------------------------------------------------------------------------------------------------------- @@ -124,14 +124,7 @@ void DialogShoulderPoint::FXLength() //--------------------------------------------------------------------------------------------------------------------- void DialogShoulderPoint::ShowVisualization() { - if (prepare == false) - { - VMainGraphicsScene *scene = qobject_cast(qApp->getCurrentScene()); - SCASSERT(scene != nullptr) - connect(scene, &VMainGraphicsScene::NewFactor, line, &VisLine::SetFactor); - scene->addItem(line); - line->RefreshGeometry(); - } + AddVisualization(); } //--------------------------------------------------------------------------------------------------------------------- @@ -143,10 +136,7 @@ void DialogShoulderPoint::DeployFormulaTextEdit() //--------------------------------------------------------------------------------------------------------------------- DialogShoulderPoint::~DialogShoulderPoint() { - if (qApp->getCurrentScene()->items().contains(line)) - { // In some cases scene delete object yourself. If not make check program will crash. - delete line; - } + DeleteVisualization(); delete ui; } @@ -162,6 +152,9 @@ void DialogShoulderPoint::ChosenObject(quint32 id, const SceneObject &type) { if (type == SceneObject::Point) { + VisToolShoulderPoint *line = qobject_cast(vis); + SCASSERT(line != nullptr); + switch (number) { case 0: @@ -216,6 +209,9 @@ void DialogShoulderPoint::SaveData() formula = ui->plainTextEditFormula->toPlainText(); formula.replace("\n", " "); + VisToolShoulderPoint *line = qobject_cast(vis); + SCASSERT(line != nullptr); + line->setPoint1Id(GetP3()); line->setLineP1Id(GetP1Line()); line->setLineP2Id(GetP2Line()); @@ -239,6 +235,9 @@ void DialogShoulderPoint::closeEvent(QCloseEvent *event) void DialogShoulderPoint::SetP3(const quint32 &value) { setCurrentPointId(ui->comboBoxP3, value); + + VisToolShoulderPoint *line = qobject_cast(vis); + SCASSERT(line != nullptr); line->setPoint1Id(value); } @@ -262,6 +261,9 @@ void DialogShoulderPoint::SetLineColor(const QString &value) void DialogShoulderPoint::SetP2Line(const quint32 &value) { setCurrentPointId(ui->comboBoxP2Line, value); + + VisToolShoulderPoint *line = qobject_cast(vis); + SCASSERT(line != nullptr); line->setLineP2Id(value); } @@ -273,6 +275,9 @@ void DialogShoulderPoint::SetP2Line(const quint32 &value) void DialogShoulderPoint::SetP1Line(const quint32 &value) { setCurrentPointId(ui->comboBoxP1Line, value); + + VisToolShoulderPoint *line = qobject_cast(vis); + SCASSERT(line != nullptr); line->setLineP1Id(value); } @@ -290,6 +295,9 @@ void DialogShoulderPoint::SetFormula(const QString &value) this->DeployFormulaTextEdit(); } ui->plainTextEditFormula->setPlainText(formula); + + VisToolShoulderPoint *line = qobject_cast(vis); + SCASSERT(line != nullptr); line->setLength(formula); MoveCursorToEnd(ui->plainTextEditFormula); } @@ -302,7 +310,7 @@ void DialogShoulderPoint::SetFormula(const QString &value) void DialogShoulderPoint::SetTypeLine(const QString &value) { ChangeCurrentData(ui->comboBoxLineType, value); - line->setLineStyle(VAbstractTool::LineStyleToPenStyle(value)); + vis->setLineStyle(VAbstractTool::LineStyleToPenStyle(value)); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/dialogs/tools/dialogshoulderpoint.h b/src/app/dialogs/tools/dialogshoulderpoint.h index 6360d75cf..f60e55d59 100644 --- a/src/app/dialogs/tools/dialogshoulderpoint.h +++ b/src/app/dialogs/tools/dialogshoulderpoint.h @@ -36,8 +36,6 @@ namespace Ui class DialogShoulderPoint; } -class VisToolShoulderPoint; - /** * @brief The DialogShoulderPoint class dialog for ToolShoulderPoint. Help create point and edit option. */ @@ -46,7 +44,7 @@ class DialogShoulderPoint : public DialogTool Q_OBJECT public: DialogShoulderPoint(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr); - ~DialogShoulderPoint(); + virtual ~DialogShoulderPoint(); void SetPointName(const QString &value); @@ -97,7 +95,6 @@ private: /** @brief formulaBaseHeight base height defined by dialogui */ int formulaBaseHeight; - VisToolShoulderPoint *line; }; #endif // DIALOGSHOULDERPOINT_H diff --git a/src/app/dialogs/tools/dialogsinglepoint.h b/src/app/dialogs/tools/dialogsinglepoint.h index c9d8098c1..79e48e980 100644 --- a/src/app/dialogs/tools/dialogsinglepoint.h +++ b/src/app/dialogs/tools/dialogsinglepoint.h @@ -44,7 +44,7 @@ class DialogSinglePoint : public DialogTool Q_OBJECT public: DialogSinglePoint(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr); - ~DialogSinglePoint(); + virtual ~DialogSinglePoint(); void SetData(const QString &name, const QPointF &point); QPointF GetPoint()const; diff --git a/src/app/dialogs/tools/dialogspline.cpp b/src/app/dialogs/tools/dialogspline.cpp index 297cd135d..924a5e759 100644 --- a/src/app/dialogs/tools/dialogspline.cpp +++ b/src/app/dialogs/tools/dialogspline.cpp @@ -42,7 +42,7 @@ */ DialogSpline::DialogSpline(const VContainer *data, const quint32 &toolId, QWidget *parent) :DialogTool(data, toolId, parent), ui(new Ui::DialogSpline), angle1(0), angle2(0), kAsm1(1), kAsm2(1), - kCurve(1), path(nullptr) + kCurve(1) { ui->setupUi(this); InitOkCancelApply(ui); @@ -56,16 +56,13 @@ DialogSpline::DialogSpline(const VContainer *data, const quint32 &toolId, QWidge connect(ui->comboBoxP4, static_cast(&QComboBox::currentIndexChanged), this, &DialogSpline::PointNameChanged); - path = new VisToolSpline(data); + vis = new VisToolSpline(data); } //--------------------------------------------------------------------------------------------------------------------- DialogSpline::~DialogSpline() { - if (qApp->getCurrentScene()->items().contains(path)) - { // In some cases scene delete object yourself. If not make check program will crash. - delete path; - } + DeleteVisualization(); delete ui; } @@ -91,6 +88,9 @@ void DialogSpline::ChosenObject(quint32 id, const SceneObject &type) { if (type == SceneObject::Point) { + VisToolSpline *path = qobject_cast(vis); + SCASSERT(path != nullptr); + switch (number) { case 0: @@ -147,6 +147,9 @@ void DialogSpline::SaveData() kAsm2 = ui->doubleSpinBoxKasm2->value(); kCurve = ui->doubleSpinBoxKcurve->value(); + VisToolSpline *path = qobject_cast(vis); + SCASSERT(path != nullptr); + path->setPoint1Id(GetP1()); path->setPoint4Id(GetP4()); path->SetAngle1(angle1); @@ -183,14 +186,7 @@ void DialogSpline::PointNameChanged() //--------------------------------------------------------------------------------------------------------------------- void DialogSpline::ShowVisualization() { - if (prepare == false) - { - VMainGraphicsScene *scene = qobject_cast(qApp->getCurrentScene()); - SCASSERT(scene != nullptr) - connect(scene, &VMainGraphicsScene::NewFactor, path, &Visualization::SetFactor); - scene->addItem(path); - path->RefreshGeometry(); - } + AddVisualization(); } //--------------------------------------------------------------------------------------------------------------------- @@ -202,6 +198,9 @@ void DialogSpline::SetKCurve(const qreal &value) { kCurve = value; ui->doubleSpinBoxKcurve->setValue(value); + + VisToolSpline *path = qobject_cast(vis); + SCASSERT(path != nullptr); path->SetKCurve(kCurve); } @@ -226,6 +225,9 @@ void DialogSpline::SetKAsm2(const qreal &value) { kAsm2 = value; ui->doubleSpinBoxKasm2->setValue(value); + + VisToolSpline *path = qobject_cast(vis); + SCASSERT(path != nullptr); path->SetKAsm2(kAsm2); } @@ -238,6 +240,9 @@ void DialogSpline::SetKAsm1(const qreal &value) { kAsm1 = value; ui->doubleSpinBoxKasm1->setValue(value); + + VisToolSpline *path = qobject_cast(vis); + SCASSERT(path != nullptr); path->SetKAsm1(kAsm1); } @@ -250,6 +255,9 @@ void DialogSpline::SetAngle2(const qreal &value) { angle2 = value; ui->spinBoxAngle2->setValue(static_cast(value)); + + VisToolSpline *path = qobject_cast(vis); + SCASSERT(path != nullptr); path->SetAngle2(angle2); } @@ -262,6 +270,9 @@ void DialogSpline::SetAngle1(const qreal &value) { angle1 = value; ui->spinBoxAngle1->setValue(static_cast(value)); + + VisToolSpline *path = qobject_cast(vis); + SCASSERT(path != nullptr); path->SetAngle1(angle1); } @@ -273,6 +284,9 @@ void DialogSpline::SetAngle1(const qreal &value) void DialogSpline::SetP4(const quint32 &value) { setCurrentPointId(ui->comboBoxP4, value); + + VisToolSpline *path = qobject_cast(vis); + SCASSERT(path != nullptr); path->setPoint4Id(value); } @@ -284,6 +298,9 @@ void DialogSpline::SetP4(const quint32 &value) void DialogSpline::SetP1(const quint32 &value) { setCurrentPointId(ui->comboBoxP1, value); + + VisToolSpline *path = qobject_cast(vis); + SCASSERT(path != nullptr); path->setPoint1Id(value); } diff --git a/src/app/dialogs/tools/dialogspline.h b/src/app/dialogs/tools/dialogspline.h index 0c65ee00e..09693f7af 100644 --- a/src/app/dialogs/tools/dialogspline.h +++ b/src/app/dialogs/tools/dialogspline.h @@ -36,8 +36,6 @@ namespace Ui class DialogSpline; } -class VisToolSpline; - /** * @brief The DialogSpline class dialog for ToolSpline. Help create spline and edit option. */ @@ -46,7 +44,7 @@ class DialogSpline : public DialogTool Q_OBJECT public: DialogSpline(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr); - ~DialogSpline(); + virtual ~DialogSpline(); quint32 GetP1() const; void SetP1(const quint32 &value); @@ -100,8 +98,6 @@ private: /** @brief kCurve coefficient curve */ qreal kCurve; - - VisToolSpline *path; }; #endif // DIALOGSPLINE_H diff --git a/src/app/dialogs/tools/dialogsplinepath.cpp b/src/app/dialogs/tools/dialogsplinepath.cpp index d36870d10..2d0f01fe6 100644 --- a/src/app/dialogs/tools/dialogsplinepath.cpp +++ b/src/app/dialogs/tools/dialogsplinepath.cpp @@ -39,7 +39,7 @@ * @param parent parent widget */ DialogSplinePath::DialogSplinePath(const VContainer *data, const quint32 &toolId, QWidget *parent) - :DialogTool(data, toolId, parent), ui(new Ui::DialogSplinePath), path(VSplinePath()), visPath(nullptr) + :DialogTool(data, toolId, parent), ui(new Ui::DialogSplinePath), path(VSplinePath()) { ui->setupUi(this); InitOkCancelApply(ui); @@ -60,16 +60,13 @@ DialogSplinePath::DialogSplinePath(const VContainer *data, const quint32 &toolId connect(ui->doubleSpinBoxKasm2, static_cast(&QDoubleSpinBox::valueChanged), this, &DialogSplinePath::KAsm2Changed); - visPath = new VisToolSplinePath(data); + vis = new VisToolSplinePath(data); } //--------------------------------------------------------------------------------------------------------------------- DialogSplinePath::~DialogSplinePath() { - if (qApp->getCurrentScene()->items().contains(visPath)) - { // In some cases scene delete object yourself. If not make check program will crash. - delete visPath; - } + DeleteVisualization(); delete ui; } @@ -90,6 +87,8 @@ void DialogSplinePath::SetPath(const VSplinePath &value) ui->listWidget->setFocus(Qt::OtherFocusReason); ui->doubleSpinBoxKcurve->setValue(path.GetKCurve()); + VisToolSplinePath *visPath = qobject_cast(vis); + SCASSERT(visPath != nullptr); visPath->setPath(path); ui->listWidget->blockSignals(false); } @@ -125,7 +124,11 @@ void DialogSplinePath::ChosenObject(quint32 id, const SceneObject &type) emit ToolTip(tr("Select point of curve path")); SavePath(); + + VisToolSplinePath *visPath = qobject_cast(vis); + SCASSERT(visPath != nullptr); visPath->setPath(path); + if (path.CountPoint() == 1) { visPath->VisualMode(NULL_ID); @@ -144,6 +147,8 @@ void DialogSplinePath::SaveData() { SavePath(); + VisToolSplinePath *visPath = qobject_cast(vis); + SCASSERT(visPath != nullptr); visPath->setPath(path); visPath->RefreshGeometry(); } @@ -268,7 +273,11 @@ void DialogSplinePath::ShowVisualization() if (prepare == false) { VMainGraphicsScene *scene = qobject_cast(qApp->getCurrentScene()); - SCASSERT(scene != nullptr) + SCASSERT(scene != nullptr); + + VisToolSplinePath *visPath = qobject_cast(vis); + SCASSERT(visPath != nullptr); + connect(scene, &VMainGraphicsScene::NewFactor, visPath, &Visualization::SetFactor); scene->addItem(visPath); visPath->setMode(Mode::Show); diff --git a/src/app/dialogs/tools/dialogsplinepath.h b/src/app/dialogs/tools/dialogsplinepath.h index eae77a031..a19f1243a 100644 --- a/src/app/dialogs/tools/dialogsplinepath.h +++ b/src/app/dialogs/tools/dialogsplinepath.h @@ -37,8 +37,6 @@ namespace Ui class DialogSplinePath; } -class VisToolSplinePath; - /** * @brief The DialogSplinePath class dialog for ToolSplinePath. Help create spline path and edit option. */ @@ -47,7 +45,7 @@ class DialogSplinePath : public DialogTool Q_OBJECT public: DialogSplinePath(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr); - ~DialogSplinePath(); + virtual ~DialogSplinePath(); VSplinePath GetPath() const; void SetPath(const VSplinePath &value); @@ -79,8 +77,6 @@ private: /** @brief path spline path */ VSplinePath path; - VisToolSplinePath *visPath; - void NewItem(quint32 id, qreal kAsm1, qreal angle1, qreal kAsm2, qreal angle2); void DataPoint(quint32 id, qreal kAsm1, qreal angle1, qreal kAsm2, qreal angle2); void EnableFields(); diff --git a/src/app/dialogs/tools/dialogtool.cpp b/src/app/dialogs/tools/dialogtool.cpp index 893e6e868..be3a446cf 100644 --- a/src/app/dialogs/tools/dialogtool.cpp +++ b/src/app/dialogs/tools/dialogtool.cpp @@ -62,7 +62,7 @@ DialogTool::DialogTool(const VContainer *data, const quint32 &toolId, QWidget *p timerFormula(nullptr), bOk(nullptr), bApply(nullptr), spinBoxAngle(nullptr), plainTextEditFormula(nullptr), labelResultCalculation(nullptr), labelEditNamePoint(nullptr), labelEditFormula(nullptr), okColor(QColor(76, 76, 76)), errorColor(Qt::red), associatedTool(nullptr), - toolId(toolId), prepare(false), pointName(QString()), number(0) + toolId(toolId), prepare(false), pointName(QString()), number(0), vis(nullptr) { SCASSERT(data != nullptr); timerFormula = new QTimer(this); diff --git a/src/app/dialogs/tools/dialogtool.h b/src/app/dialogs/tools/dialogtool.h index dd00c108a..54ce603e3 100644 --- a/src/app/dialogs/tools/dialogtool.h +++ b/src/app/dialogs/tools/dialogtool.h @@ -31,6 +31,8 @@ #include "../../core/vapplication.h" #include "../../utils/logging.h" +#include "../../widgets/vmaingraphicsscene.h" +#include "../../visualization/visualization.h" #include #include @@ -177,6 +179,8 @@ protected: /** @brief number number of handled objects */ qint32 number; + Visualization *vis; + virtual void closeEvent ( QCloseEvent * event ); virtual void showEvent( QShowEvent *event ); @@ -261,6 +265,34 @@ protected: plainTextEditFormula = ui->plainTextEditFormula; labelEditFormula = ui->labelEditFormula; } + template + void AddVisualization() + { + if (prepare == false) + { + VMainGraphicsScene *scene = qobject_cast(qApp->getCurrentScene()); + SCASSERT(scene != nullptr); + + T *toolVis = qobject_cast(vis); + SCASSERT(toolVis != nullptr); + + connect(scene, &VMainGraphicsScene::NewFactor, toolVis, &Visualization::SetFactor); + scene->addItem(toolVis); + toolVis->RefreshGeometry(); + } + } + + template + void DeleteVisualization() + { + T *toolVis = qobject_cast(vis); + SCASSERT(toolVis != nullptr); + + if (qApp->getCurrentScene()->items().contains(toolVis)) + { // In some cases scene delete object yourself. If not make check program will crash. + delete vis; + } + } void ChangeColor(QWidget *widget, const QColor &color); virtual void ShowVisualization(){} diff --git a/src/app/dialogs/tools/dialogtriangle.cpp b/src/app/dialogs/tools/dialogtriangle.cpp index e765be0c7..063910511 100644 --- a/src/app/dialogs/tools/dialogtriangle.cpp +++ b/src/app/dialogs/tools/dialogtriangle.cpp @@ -41,7 +41,7 @@ * @param parent parent widget */ DialogTriangle::DialogTriangle(const VContainer *data, const quint32 &toolId, QWidget *parent) - :DialogTool(data, toolId, parent), ui(new Ui::DialogTriangle), line (nullptr) + :DialogTool(data, toolId, parent), ui(new Ui::DialogTriangle) { ui->setupUi(this); ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel)); @@ -65,16 +65,13 @@ DialogTriangle::DialogTriangle(const VContainer *data, const quint32 &toolId, QW connect(ui->comboBoxAxisP2, static_cast(&QComboBox::currentIndexChanged), this, &DialogTriangle::PointNameChanged); - line = new VisToolTriangle(data); + vis = new VisToolTriangle(data); } //--------------------------------------------------------------------------------------------------------------------- DialogTriangle::~DialogTriangle() { - if (qApp->getCurrentScene()->items().contains(line)) - { // In some cases scene delete object yourself. If not make check program will crash. - delete line; - } + DeleteVisualization(); delete ui; } @@ -90,6 +87,9 @@ void DialogTriangle::ChosenObject(quint32 id, const SceneObject &type) { if (type == SceneObject::Point) { + VisToolTriangle *line = qobject_cast(vis); + SCASSERT(line != nullptr); + switch (number) { case (0): @@ -161,6 +161,9 @@ void DialogTriangle::SaveData() { pointName = ui->lineEditNamePoint->text(); + VisToolTriangle *line = qobject_cast(vis); + SCASSERT(line != nullptr); + line->setPoint1Id(GetAxisP1Id()); line->setPoint2Id(GetAxisP2Id()); line->setHypotenuseP1Id(GetFirstPointId()); @@ -198,14 +201,7 @@ void DialogTriangle::PointNameChanged() //--------------------------------------------------------------------------------------------------------------------- void DialogTriangle::ShowVisualization() { - if (prepare == false) - { - VMainGraphicsScene *scene = qobject_cast(qApp->getCurrentScene()); - SCASSERT(scene != nullptr) - connect(scene, &VMainGraphicsScene::NewFactor, line, &VisLine::SetFactor); - scene->addItem(line); - line->RefreshGeometry(); - } + AddVisualization(); } //--------------------------------------------------------------------------------------------------------------------- @@ -227,6 +223,9 @@ void DialogTriangle::SetPointName(const QString &value) void DialogTriangle::SetSecondPointId(const quint32 &value) { setCurrentPointId(ui->comboBoxSecondPoint, value); + + VisToolTriangle *line = qobject_cast(vis); + SCASSERT(line != nullptr); line->setHypotenuseP2Id(value); } @@ -238,6 +237,9 @@ void DialogTriangle::SetSecondPointId(const quint32 &value) void DialogTriangle::SetFirstPointId(const quint32 &value) { setCurrentPointId(ui->comboBoxFirstPoint, value); + + VisToolTriangle *line = qobject_cast(vis); + SCASSERT(line != nullptr); line->setHypotenuseP1Id(value); } @@ -249,6 +251,9 @@ void DialogTriangle::SetFirstPointId(const quint32 &value) void DialogTriangle::SetAxisP2Id(const quint32 &value) { setCurrentPointId(ui->comboBoxAxisP2, value); + + VisToolTriangle *line = qobject_cast(vis); + SCASSERT(line != nullptr); line->setPoint2Id(value); } @@ -260,6 +265,9 @@ void DialogTriangle::SetAxisP2Id(const quint32 &value) void DialogTriangle::SetAxisP1Id(const quint32 &value) { setCurrentPointId(ui->comboBoxAxisP1, value); + + VisToolTriangle *line = qobject_cast(vis); + SCASSERT(line != nullptr); line->setPoint1Id(value); } diff --git a/src/app/dialogs/tools/dialogtriangle.h b/src/app/dialogs/tools/dialogtriangle.h index 5a76914b4..d9e11357b 100644 --- a/src/app/dialogs/tools/dialogtriangle.h +++ b/src/app/dialogs/tools/dialogtriangle.h @@ -36,8 +36,6 @@ namespace Ui class DialogTriangle; } -class VisToolTriangle; - /** * @brief The DialogTriangle class dialog for ToolTriangle. Help create point and edit option. */ @@ -46,7 +44,7 @@ class DialogTriangle : public DialogTool Q_OBJECT public: DialogTriangle(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr); - ~DialogTriangle(); + virtual ~DialogTriangle(); quint32 GetAxisP1Id() const; void SetAxisP1Id(const quint32 &value); @@ -75,8 +73,6 @@ private: /** @brief ui keeps information about user interface */ Ui::DialogTriangle *ui; - - VisToolTriangle *line; }; #endif // DIALOGTRIANGLE_H diff --git a/src/app/dialogs/tools/dialoguniondetails.h b/src/app/dialogs/tools/dialoguniondetails.h index 5500a72b4..5a556ff72 100644 --- a/src/app/dialogs/tools/dialoguniondetails.h +++ b/src/app/dialogs/tools/dialoguniondetails.h @@ -44,7 +44,7 @@ class DialogUnionDetails : public DialogTool Q_OBJECT public: DialogUnionDetails(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr); - ~DialogUnionDetails(); + virtual ~DialogUnionDetails(); quint32 getD1() const; quint32 getD2() const;