diff --git a/src/app/dialogs/tools/dialogalongline.cpp b/src/app/dialogs/tools/dialogalongline.cpp index bd34dda20..d407e44b3 100644 --- a/src/app/dialogs/tools/dialogalongline.cpp +++ b/src/app/dialogs/tools/dialogalongline.cpp @@ -42,8 +42,7 @@ */ DialogAlongLine::DialogAlongLine(const VContainer *data, const quint32 &toolId, QWidget *parent) :DialogTool(data, toolId, parent), ui(new Ui::DialogAlongLine), number(0), pointName(QString()), - typeLine(QString()), formula(QString()), firstPointId(0), secondPointId(0), formulaBaseHeight(0), line(nullptr), - prepare(false) + typeLine(QString()), formula(QString()), firstPointId(0), secondPointId(0), formulaBaseHeight(0), line(nullptr) { ui->setupUi(this); InitVariables(ui); @@ -142,12 +141,7 @@ void DialogAlongLine::ChosenObject(quint32 id, const SceneObject &type) if (ChoosedPoint(id, ui->comboBoxFirstPoint, tr("Select second point of line"))) { number++; - VMainGraphicsScene *scene = qApp->getCurrentScene(); - SCASSERT(scene != nullptr); - line->VisualMode(id, scene->getScenePos()); - scene->addItem(line); - connect(scene, &VMainGraphicsScene::NewFactor, line, &VisToolAlongLine::SetFactor); - connect(scene, &VMainGraphicsScene::mouseMove, line, &VisToolAlongLine::MousePos); + line->VisualMode(id); return; } } diff --git a/src/app/dialogs/tools/dialogalongline.h b/src/app/dialogs/tools/dialogalongline.h index a3d43a5e8..b71a313ea 100644 --- a/src/app/dialogs/tools/dialogalongline.h +++ b/src/app/dialogs/tools/dialogalongline.h @@ -106,8 +106,6 @@ private: /** @brief formulaBaseHeight base height defined by dialogui */ int formulaBaseHeight; VisToolAlongLine *line; - /** @brief prepare show if we prepare show dialog after finish working with visual part of tool*/ - bool prepare; /** * @brief SaveData Put dialog data in local variables diff --git a/src/app/dialogs/tools/dialogbisector.cpp b/src/app/dialogs/tools/dialogbisector.cpp index 995a5920a..e17b2b583 100644 --- a/src/app/dialogs/tools/dialogbisector.cpp +++ b/src/app/dialogs/tools/dialogbisector.cpp @@ -155,12 +155,7 @@ void DialogBisector::ChosenObject(quint32 id, const SceneObject &type) { // -1 for not found ui->comboBoxFirstPoint->setCurrentIndex(index); number++; - VMainGraphicsScene *scene = qApp->getCurrentScene(); - SCASSERT(scene != nullptr); - line->VisualMode(id, scene->getScenePos()); - scene->addItem(line); - connect(scene, &VMainGraphicsScene::NewFactor, line, &VisToolBisector::SetFactor); - connect(scene, &VMainGraphicsScene::mouseMove, line, &VisToolBisector::MousePos); + line->VisualMode(id); emit ToolTip(tr("Select second point of angle")); return; } diff --git a/src/app/dialogs/tools/dialogendline.cpp b/src/app/dialogs/tools/dialogendline.cpp index c6f557d6c..fc5ec8763 100644 --- a/src/app/dialogs/tools/dialogendline.cpp +++ b/src/app/dialogs/tools/dialogendline.cpp @@ -44,7 +44,7 @@ DialogEndLine::DialogEndLine(const VContainer *data, const quint32 &toolId, QWidget *parent) :DialogTool(data, toolId, parent), ui(new Ui::DialogEndLine), pointName(QString()), typeLine(QString()), formulaLength(QString()), formulaAngle(QString()), basePointId(0), formulaBaseHeight(0), - formulaBaseHeightAngle(0), line(nullptr), prepare(false) + formulaBaseHeightAngle(0), line(nullptr) { ui->setupUi(this); InitVariables(ui); @@ -144,12 +144,7 @@ void DialogEndLine::ChosenObject(quint32 id, const SceneObject &type) basePointId = id; ChangeCurrentText(ui->comboBoxBasePoint, point->name()); - VMainGraphicsScene *scene = qApp->getCurrentScene(); - SCASSERT(scene != nullptr); - scene->addItem(line); - line->VisualMode(id, scene->getScenePos()); - connect(scene, &VMainGraphicsScene::NewFactor, line, &VisToolEndLine::SetFactor); - connect(scene, &VMainGraphicsScene::mouseMove, line, &VisToolEndLine::MousePos); + line->VisualMode(id); connect(line, &VisToolEndLine::ToolTip, this, &DialogTool::ShowVisToolTip); emit ToolTip(""); diff --git a/src/app/dialogs/tools/dialogendline.h b/src/app/dialogs/tools/dialogendline.h index 5763c7b32..5d0d5ea5d 100644 --- a/src/app/dialogs/tools/dialogendline.h +++ b/src/app/dialogs/tools/dialogendline.h @@ -111,9 +111,6 @@ private: VisToolEndLine *line; - /** @brief prepare show if we prepare show dialog after finish working with visual part of tool*/ - bool prepare; - /** * @brief SaveData Put dialog data in local variables */ diff --git a/src/app/dialogs/tools/dialogline.cpp b/src/app/dialogs/tools/dialogline.cpp index c3e2eb682..23a9881e7 100644 --- a/src/app/dialogs/tools/dialogline.cpp +++ b/src/app/dialogs/tools/dialogline.cpp @@ -152,10 +152,13 @@ void DialogLine::UpdateList() //--------------------------------------------------------------------------------------------------------------------- void DialogLine::ShowVisualization() { - VMainGraphicsScene *scene = qApp->getCurrentScene(); - connect(scene, &VMainGraphicsScene::NewFactor, line, &VisToolLine::SetFactor); - scene->addItem(line); - line->RefreshGeometry(); + if (prepare == false) + { + VMainGraphicsScene *scene = qApp->getCurrentScene(); + connect(scene, &VMainGraphicsScene::NewFactor, line, &VisToolLine::SetFactor); + scene->addItem(line); + line->RefreshGeometry(); + } } //--------------------------------------------------------------------------------------------------------------------- @@ -189,13 +192,7 @@ void DialogLine::ChosenObject(quint32 id, const SceneObject &type) qint32 index = ui->comboBoxFirstPoint->findText(point->name()); if ( index != -1 ) { // -1 for not found - - VMainGraphicsScene *scene = qApp->getCurrentScene(); - line->VisualMode(id, scene->getScenePos()); - scene->addItem(line); - connect(scene, &VMainGraphicsScene::NewFactor, line, &VisToolLine::SetFactor); - connect(scene, &VMainGraphicsScene::mouseMove, line, &VisToolLine::MousePos); - + line->VisualMode(id); ui->comboBoxFirstPoint->setCurrentIndex(index); number++; emit ToolTip(tr("Select second point")); @@ -211,6 +208,7 @@ void DialogLine::ChosenObject(quint32 id, const SceneObject &type) if (flagError) { number = 0; + prepare = true; emit ToolTip(""); DialogAccepted(); } diff --git a/src/app/dialogs/tools/dialognormal.cpp b/src/app/dialogs/tools/dialognormal.cpp index f1761e37e..08ceb837f 100644 --- a/src/app/dialogs/tools/dialognormal.cpp +++ b/src/app/dialogs/tools/dialognormal.cpp @@ -40,8 +40,7 @@ */ DialogNormal::DialogNormal(const VContainer *data, const quint32 &toolId, QWidget *parent) :DialogTool(data, toolId, parent), ui(new Ui::DialogNormal), number(0), pointName(QString()), typeLine(QString()), - formula(QString()), angle(0), firstPointId(0), secondPointId(0), formulaBaseHeight(0), line(nullptr), - prepare(false) + formula(QString()), angle(0), firstPointId(0), secondPointId(0), formulaBaseHeight(0), line(nullptr) { ui->setupUi(this); InitVariables(ui); @@ -141,12 +140,7 @@ void DialogNormal::ChosenObject(quint32 id, const SceneObject &type) if (ChoosedPoint(id, ui->comboBoxFirstPoint, tr("Select second point of line"))) { number++; - VMainGraphicsScene *scene = qApp->getCurrentScene(); - SCASSERT(scene != nullptr); - line->VisualMode(id, scene->getScenePos()); - scene->addItem(line); - connect(scene, &VMainGraphicsScene::NewFactor, line, &VisToolNormal::SetFactor); - connect(scene, &VMainGraphicsScene::mouseMove, line, &VisToolNormal::MousePos); + line->VisualMode(id); return; } } diff --git a/src/app/dialogs/tools/dialognormal.h b/src/app/dialogs/tools/dialognormal.h index 60652548e..9515220e1 100644 --- a/src/app/dialogs/tools/dialognormal.h +++ b/src/app/dialogs/tools/dialognormal.h @@ -115,9 +115,6 @@ private: VisToolNormal *line; - /** @brief prepare show if we prepare show dialog after finish working with visual part of tool*/ - bool prepare; - /** * @brief SaveData Put dialog data in local variables */ diff --git a/src/app/dialogs/tools/dialogshoulderpoint.cpp b/src/app/dialogs/tools/dialogshoulderpoint.cpp index f9a96ed4a..52220b498 100644 --- a/src/app/dialogs/tools/dialogshoulderpoint.cpp +++ b/src/app/dialogs/tools/dialogshoulderpoint.cpp @@ -43,8 +43,7 @@ */ DialogShoulderPoint::DialogShoulderPoint(const VContainer *data, const quint32 &toolId, QWidget *parent) :DialogTool(data, toolId, parent), ui(new Ui::DialogShoulderPoint), number(0), pointName(QString()), - typeLine(QString()), formula(QString()), p1Line(0), p2Line(0), pShoulder(0), formulaBaseHeight(0), line (nullptr), - prepare(false) + typeLine(QString()), formula(QString()), p1Line(0), p2Line(0), pShoulder(0), formulaBaseHeight(0), line (nullptr) { ui->setupUi(this); InitVariables(ui); @@ -155,12 +154,7 @@ void DialogShoulderPoint::ChosenObject(quint32 id, const SceneObject &type) { // -1 for not found ui->comboBoxPShoulder->setCurrentIndex(index); number++; - VMainGraphicsScene *scene = qApp->getCurrentScene(); - SCASSERT(scene != nullptr); - line->VisualMode(id, scene->getScenePos()); - scene->addItem(line); - connect(scene, &VMainGraphicsScene::NewFactor, line, &VisToolShoulderPoint::SetFactor); - connect(scene, &VMainGraphicsScene::mouseMove, line, &VisToolShoulderPoint::MousePos); + line->VisualMode(id); emit ToolTip(tr("Select first point of line")); return; } diff --git a/src/app/dialogs/tools/dialogshoulderpoint.h b/src/app/dialogs/tools/dialogshoulderpoint.h index c07739c38..3c5f1f475 100644 --- a/src/app/dialogs/tools/dialogshoulderpoint.h +++ b/src/app/dialogs/tools/dialogshoulderpoint.h @@ -113,7 +113,6 @@ private: /** @brief formulaBaseHeight base height defined by dialogui */ int formulaBaseHeight; VisToolShoulderPoint *line; - bool prepare; /** * @brief SaveData Put dialog data in local variables diff --git a/src/app/dialogs/tools/dialogtool.cpp b/src/app/dialogs/tools/dialogtool.cpp index 4d806d20a..d0132d54c 100644 --- a/src/app/dialogs/tools/dialogtool.cpp +++ b/src/app/dialogs/tools/dialogtool.cpp @@ -48,7 +48,7 @@ #include #include -#define DIALOGARC_MAX_FORMULA_HEIGHT 64 +#define DIALOG_MAX_FORMULA_HEIGHT 64 //--------------------------------------------------------------------------------------------------------------------- /** @@ -63,7 +63,7 @@ DialogTool::DialogTool(const VContainer *data, const quint32 &toolId, QWidget *p labelEditFormula(nullptr), radioButtonSizeGrowth(nullptr), radioButtonStandardTable(nullptr), radioButtonIncrements(nullptr), radioButtonLengthLine(nullptr), radioButtonLengthArc(nullptr), radioButtonLengthCurve(nullptr), radioButtonAngleLine(nullptr), lineStyles(VAbstractTool::Styles()), - okColor(QColor(76, 76, 76)), errorColor(Qt::red), associatedTool(nullptr), toolId(toolId) + okColor(QColor(76, 76, 76)), errorColor(Qt::red), associatedTool(nullptr), toolId(toolId), prepare(false) { SCASSERT(data != nullptr); timerFormula = new QTimer(this); @@ -592,9 +592,9 @@ void DialogTool::DeployFormula(QPlainTextEdit *formula, QPushButton *buttonGrowL { SCASSERT(formula != nullptr); SCASSERT(buttonGrowLength != nullptr) - if (formula->height() < DIALOGARC_MAX_FORMULA_HEIGHT) + if (formula->height() < DIALOG_MAX_FORMULA_HEIGHT) { - formula->setFixedHeight(DIALOGARC_MAX_FORMULA_HEIGHT); + formula->setFixedHeight(DIALOG_MAX_FORMULA_HEIGHT); //Set icon from theme (internal for Windows system) buttonGrowLength->setIcon(QIcon::fromTheme("go-next", QIcon(":/icons/win.icon.theme/16x16/actions/go-next.png"))); diff --git a/src/app/dialogs/tools/dialogtool.h b/src/app/dialogs/tools/dialogtool.h index 6b74c9eb8..03d1c1668 100644 --- a/src/app/dialogs/tools/dialogtool.h +++ b/src/app/dialogs/tools/dialogtool.h @@ -197,6 +197,9 @@ protected: VAbstractTool *associatedTool; quint32 toolId; + /** @brief prepare show if we prepare. Show dialog after finish working with visual part of tool*/ + bool prepare; + virtual void closeEvent ( QCloseEvent * event ); virtual void showEvent( QShowEvent *event ); void FillComboBoxPoints(QComboBox *box)const; diff --git a/src/app/visualization/visline.cpp b/src/app/visualization/visline.cpp index 0c74b1c5a..a3aff1ad5 100644 --- a/src/app/visualization/visline.cpp +++ b/src/app/visualization/visline.cpp @@ -270,11 +270,18 @@ void VisLine::setScenePos(const QPointF &value) } //--------------------------------------------------------------------------------------------------------------------- -void VisLine::VisualMode(const quint32 &pointId, const QPointF &scenePos) +void VisLine::VisualMode(const quint32 &pointId) { + VMainGraphicsScene *scene = qApp->getCurrentScene(); + SCASSERT(scene != nullptr); + this->point1Id = pointId; - this->scenePos = scenePos; + this->scenePos = scene->getScenePos(); RefreshGeometry(); + + scene->addItem(this); + connect(scene, &VMainGraphicsScene::NewFactor, this, &VisLine::SetFactor); + connect(scene, &VMainGraphicsScene::mouseMove, this, &VisLine::MousePos); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/visualization/visline.h b/src/app/visualization/visline.h index 4bec68a2b..e9ff543ae 100644 --- a/src/app/visualization/visline.h +++ b/src/app/visualization/visline.h @@ -46,7 +46,7 @@ public: void setLineStyle(const Qt::PenStyle &value); virtual void RefreshGeometry()=0; void setScenePos(const QPointF &value); - void VisualMode(const quint32 &pointId, const QPointF &scenePos); + void VisualMode(const quint32 &pointId); void setMainColor(const QColor &value); signals: void ToolTip(const QString &toolTip);