From fcffc03649505132f659108148a095642ae1c783 Mon Sep 17 00:00:00 2001 From: dismine Date: Sun, 17 Aug 2014 21:49:29 +0300 Subject: [PATCH] Refactoring. --HG-- branch : develop --- src/app/dialogs/tools/dialogalongline.cpp | 29 ++-- src/app/dialogs/tools/dialogarc.cpp | 20 +-- src/app/dialogs/tools/dialogbisector.cpp | 70 ++++------ src/app/dialogs/tools/dialogcutarc.cpp | 19 +-- src/app/dialogs/tools/dialogcutspline.cpp | 15 +- src/app/dialogs/tools/dialogcutsplinepath.cpp | 15 +- src/app/dialogs/tools/dialogendline.cpp | 16 +-- src/app/dialogs/tools/dialogheight.cpp | 63 ++++----- src/app/dialogs/tools/dialogline.cpp | 50 ++++--- src/app/dialogs/tools/dialoglineintersect.cpp | 130 ++++++++---------- src/app/dialogs/tools/dialognormal.cpp | 34 +++-- .../dialogs/tools/dialogpointofcontact.cpp | 71 ++++------ .../tools/dialogpointofintersection.cpp | 50 +++---- src/app/dialogs/tools/dialogshoulderpoint.cpp | 71 ++++------ src/app/dialogs/tools/dialogspline.cpp | 64 ++++----- src/app/dialogs/tools/dialogtool.cpp | 31 ++--- src/app/dialogs/tools/dialogtool.h | 3 +- src/app/dialogs/tools/dialogtriangle.cpp | 78 ++++++----- 18 files changed, 379 insertions(+), 450 deletions(-) diff --git a/src/app/dialogs/tools/dialogalongline.cpp b/src/app/dialogs/tools/dialogalongline.cpp index 54c597106..c2b67d9bb 100644 --- a/src/app/dialogs/tools/dialogalongline.cpp +++ b/src/app/dialogs/tools/dialogalongline.cpp @@ -137,30 +137,27 @@ void DialogAlongLine::ChosenObject(quint32 id, const SceneObject &type) { if (type == SceneObject::Point) { - if (number == 0) + switch (number) { - if (ChoosedPoint(id, ui->comboBoxFirstPoint, tr("Select second point of line"))) - { - number++; - line->VisualMode(id); - return; - } - } - if (number == 1) - { - if (ChoosedPoint(id, ui->comboBoxSecondPoint, "")) - { - number = 0; - if (isInitialized == false) + case 0: + if (SetObject(id, ui->comboBoxFirstPoint, tr("Select second point of line"))) + { + number++; + line->VisualMode(id); + } + break; + case 1: + if (SetObject(id, ui->comboBoxSecondPoint, "")) { line->setPoint2Id(id); line->RefreshGeometry(); - prepare = true; this->setModal(true); this->show(); } - } + break; + default: + break; } } } diff --git a/src/app/dialogs/tools/dialogarc.cpp b/src/app/dialogs/tools/dialogarc.cpp index cd87bdcd9..e14418a86 100644 --- a/src/app/dialogs/tools/dialogarc.cpp +++ b/src/app/dialogs/tools/dialogarc.cpp @@ -187,16 +187,18 @@ void DialogArc::SetRadius(const QString &value) */ void DialogArc::ChosenObject(quint32 id, const SceneObject &type) { - if (type == SceneObject::Point) + if (prepare == false)// After first choose we ignore all objects { - const VPointF *point = data->GeometricObject(id); - - ChangeCurrentText(ui->comboBoxBasePoint, point->name()); - path->VisualMode(id); - prepare = true; - emit ToolTip(""); - this->setModal(true); - this->show(); + if (type == SceneObject::Point) + { + if (SetObject(id, ui->comboBoxBasePoint, "")) + { + path->VisualMode(id); + prepare = true; + this->setModal(true); + this->show(); + } + } } } diff --git a/src/app/dialogs/tools/dialogbisector.cpp b/src/app/dialogs/tools/dialogbisector.cpp index 341d6b330..2526aa7d4 100644 --- a/src/app/dialogs/tools/dialogbisector.cpp +++ b/src/app/dialogs/tools/dialogbisector.cpp @@ -147,49 +147,35 @@ void DialogBisector::ChosenObject(quint32 id, const SceneObject &type) { if (type == SceneObject::Point) { - const VPointF *point = data->GeometricObject(id); - if (number == 0) + switch (number) { - qint32 index = ui->comboBoxFirstPoint->findText(point->name()); - if ( index != -1 ) - { // -1 for not found - ui->comboBoxFirstPoint->setCurrentIndex(index); - number++; - line->VisualMode(id); - emit ToolTip(tr("Select second point of angle")); - return; - } - } - if (number == 1) - { - qint32 index = ui->comboBoxSecondPoint->findText(point->name()); - if ( index != -1 ) - { // -1 for not found - ui->comboBoxSecondPoint->setCurrentIndex(index); - number++; - line->setPoint2Id(id); - line->RefreshGeometry(); - emit ToolTip(tr("Select third point of angle")); - return; - } - } - if (number == 2) - { - qint32 index = ui->comboBoxThirdPoint->findText(point->name()); - if ( index != -1 ) - { // -1 for not found - ui->comboBoxThirdPoint->setCurrentIndex(index); - number = 0; - line->setPoint3Id(id); - line->RefreshGeometry(); - prepare = true; - emit ToolTip(""); - } - if (isInitialized == false) - { - this->setModal(true); - this->show(); - } + case 0: + if (SetObject(id, ui->comboBoxFirstPoint, tr("Select second point of angle"))) + { + number++; + line->VisualMode(id); + } + break; + case 1: + if (SetObject(id, ui->comboBoxSecondPoint, tr("Select third point of angle"))) + { + number++; + line->setPoint2Id(id); + line->RefreshGeometry(); + } + break; + case 2: + if (SetObject(id, ui->comboBoxThirdPoint, "")) + { + line->setPoint3Id(id); + line->RefreshGeometry(); + prepare = true; + this->setModal(true); + this->show(); + } + break; + default: + break; } } } diff --git a/src/app/dialogs/tools/dialogcutarc.cpp b/src/app/dialogs/tools/dialogcutarc.cpp index b5e9620d5..599960f14 100644 --- a/src/app/dialogs/tools/dialogcutarc.cpp +++ b/src/app/dialogs/tools/dialogcutarc.cpp @@ -107,15 +107,18 @@ DialogCutArc::~DialogCutArc() */ void DialogCutArc::ChosenObject(quint32 id, const SceneObject &type) { - if (type == SceneObject::Arc) + if (prepare == false)// After first choose we ignore all objects { - const VArc *arc = data->GeometricObject(id); - ChangeCurrentText(ui->comboBoxArc, arc->name()); - path->VisualMode(id); - prepare = true; - emit ToolTip(""); - this->setModal(true); - this->show(); + if (type == SceneObject::Arc) + { + if (SetObject(id, ui->comboBoxArc, "")) + { + path->VisualMode(id); + prepare = true; + this->setModal(true); + this->show(); + } + } } } diff --git a/src/app/dialogs/tools/dialogcutspline.cpp b/src/app/dialogs/tools/dialogcutspline.cpp index 3d8365483..985c1d512 100644 --- a/src/app/dialogs/tools/dialogcutspline.cpp +++ b/src/app/dialogs/tools/dialogcutspline.cpp @@ -115,13 +115,16 @@ void DialogCutSpline::setSplineId(const quint32 &value) */ void DialogCutSpline::ChosenObject(quint32 id, const SceneObject &type) { - if (type == SceneObject::Spline) + if (prepare == false)// After first choose we ignore all objects { - const VSpline *spl = data->GeometricObject(id); - ChangeCurrentText(ui->comboBoxSpline, spl->name()); - emit ToolTip(""); - this->setModal(true); - this->show(); + if (type == SceneObject::Spline) + { + if (SetObject(id, ui->comboBoxSpline, "")) + { + this->setModal(true); + this->show(); + } + } } } diff --git a/src/app/dialogs/tools/dialogcutsplinepath.cpp b/src/app/dialogs/tools/dialogcutsplinepath.cpp index 237c96e0f..7448318a9 100644 --- a/src/app/dialogs/tools/dialogcutsplinepath.cpp +++ b/src/app/dialogs/tools/dialogcutsplinepath.cpp @@ -115,13 +115,16 @@ void DialogCutSplinePath::setSplinePathId(const quint32 &value) */ void DialogCutSplinePath::ChosenObject(quint32 id, const SceneObject &type) { - if (type == SceneObject::SplinePath) + if (prepare == false)// After first choose we ignore all objects { - const VSplinePath *splPath = data->GeometricObject(id); - ChangeCurrentText(ui->comboBoxSplinePath, splPath->name()); - emit ToolTip(""); - this->setModal(true); - this->show(); + if (type == SceneObject::SplinePath) + { + if (SetObject(id, ui->comboBoxSplinePath, "")) + { + this->setModal(true); + this->show(); + } + } } } diff --git a/src/app/dialogs/tools/dialogendline.cpp b/src/app/dialogs/tools/dialogendline.cpp index 98c2e895f..fd4bb2cec 100644 --- a/src/app/dialogs/tools/dialogendline.cpp +++ b/src/app/dialogs/tools/dialogendline.cpp @@ -140,15 +140,13 @@ void DialogEndLine::ChosenObject(quint32 id, const SceneObject &type) { if (type == SceneObject::Point) { - const VPointF *point = data->GeometricObject(id); - basePointId = id; - ChangeCurrentText(ui->comboBoxBasePoint, point->name()); - - line->VisualMode(id); - connect(line, &VisToolEndLine::ToolTip, this, &DialogTool::ShowVisToolTip); - - emit ToolTip(""); - prepare = true; + if (SetObject(id, ui->comboBoxBasePoint, "")) + { + basePointId = id; + line->VisualMode(id); + connect(line, &VisToolEndLine::ToolTip, this, &DialogTool::ShowVisToolTip); + prepare = true; + } } } } diff --git a/src/app/dialogs/tools/dialogheight.cpp b/src/app/dialogs/tools/dialogheight.cpp index d60a2bab7..8eddb8f03 100644 --- a/src/app/dialogs/tools/dialogheight.cpp +++ b/src/app/dialogs/tools/dialogheight.cpp @@ -137,39 +137,40 @@ void DialogHeight::setP2LineId(const quint32 &value) */ void DialogHeight::ChosenObject(quint32 id, const SceneObject &type) { - if (type == SceneObject::Point) + if (prepare == false)// After first choose we ignore all objects { - const VPointF *point = data->GeometricObject(id); - switch (number) + if (type == SceneObject::Point) { - case (0): - ChangeCurrentText(ui->comboBoxBasePoint, point->name()); - number++; - line->VisualMode(id); - emit ToolTip(tr("Select first point of line")); - break; - case (1): - ChangeCurrentText(ui->comboBoxP1Line, point->name()); - number++; - line->setLineP1Id(id); - line->RefreshGeometry(); - emit ToolTip(tr("Select second point of line")); - break; - case (2): - ChangeCurrentText(ui->comboBoxP2Line, point->name()); - number = 0; - emit ToolTip(""); - line->setLineP2Id(id); - line->RefreshGeometry(); - prepare = true; - if (isInitialized == false) - { - this->setModal(true); - this->show(); - } - break; - default: - break; + switch (number) + { + case (0): + if (SetObject(id, ui->comboBoxBasePoint, tr("Select first point of line"))) + { + number++; + line->VisualMode(id); + } + break; + case (1): + if (SetObject(id, ui->comboBoxP1Line, tr("Select second point of line"))) + { + number++; + line->setLineP1Id(id); + line->RefreshGeometry(); + } + break; + case (2): + if (SetObject(id, ui->comboBoxP2Line, "")) + { + line->setLineP2Id(id); + line->RefreshGeometry(); + prepare = true; + this->setModal(true); + this->show(); + } + break; + default: + break; + } } } } diff --git a/src/app/dialogs/tools/dialogline.cpp b/src/app/dialogs/tools/dialogline.cpp index 081cbbe65..56c606437 100644 --- a/src/app/dialogs/tools/dialogline.cpp +++ b/src/app/dialogs/tools/dialogline.cpp @@ -167,34 +167,32 @@ void DialogLine::SaveData() */ void DialogLine::ChosenObject(quint32 id, const SceneObject &type) { - if (type == SceneObject::Point) + if (prepare == false)// After first choose we ignore all objects { - const VPointF *point = data->GeometricObject(id); - if (number == 0) + if (type == SceneObject::Point) { - qint32 index = ui->comboBoxFirstPoint->findText(point->name()); - if ( index != -1 ) - { // -1 for not found - line->VisualMode(id); - ui->comboBoxFirstPoint->setCurrentIndex(index); - number++; - emit ToolTip(tr("Select second point")); - return; - } - } - if (number == 1) - { - qint32 index = ui->comboBoxSecondPoint->findText(point->name()); - if ( index != -1 ) - { // -1 for not found - ui->comboBoxSecondPoint->setCurrentIndex(index); - if (flagError) - { - number = 0; - prepare = true; - emit ToolTip(""); - DialogAccepted(); - } + switch (number) + { + case 0: + if (SetObject(id, ui->comboBoxFirstPoint, tr("Select second point"))) + { + number++; + line->VisualMode(id); + } + break; + case 1: + if (SetObject(id, ui->comboBoxSecondPoint, "")) + { + if (flagError) + { + number = 0; + prepare = true; + DialogAccepted(); + } + } + break; + default: + break; } } } diff --git a/src/app/dialogs/tools/dialoglineintersect.cpp b/src/app/dialogs/tools/dialoglineintersect.cpp index fcf6eb8cf..2b9466508 100644 --- a/src/app/dialogs/tools/dialoglineintersect.cpp +++ b/src/app/dialogs/tools/dialoglineintersect.cpp @@ -1,4 +1,4 @@ -/************************************************************************ +/************************************************************************ ** ** @file dialoglineintersect.cpp ** @author Roman Telezhynskyi @@ -83,81 +83,65 @@ DialogLineIntersect::~DialogLineIntersect() */ void DialogLineIntersect::ChosenObject(quint32 id, const SceneObject &type) { - if (type == SceneObject::Point) + if (prepare == false)// After first choose we ignore all objects { - const VPointF *point = data->GeometricObject(id); - if (number == 0) + if (type == SceneObject::Point) { - qint32 index = ui->comboBoxP1Line1->findText(point->name()); - if ( index != -1 ) - { // -1 for not found - ui->comboBoxP1Line1->setCurrentIndex(index); - p1Line1 = id; - number++; - line->VisualMode(id); - emit ToolTip(tr("Select second point of first line")); - return; - } - } - if (number == 1) - { - qint32 index = ui->comboBoxP2Line1->findText(point->name()); - if ( index != -1 ) - { // -1 for not found - ui->comboBoxP2Line1->setCurrentIndex(index); - p2Line1 = id; - number++; - line->setLine1P2Id(p2Line1); - line->RefreshGeometry(); - emit ToolTip(tr("Select first point of second line")); - return; - } - } - if (number == 2) - { - qint32 index = ui->comboBoxP1Line2->findText(point->name()); - if ( index != -1 ) - { // -1 for not found - ui->comboBoxP1Line2->setCurrentIndex(index); - p1Line2 = id; - number++; - line->setLine2P1Id(p1Line2); - line->RefreshGeometry(); - emit ToolTip(tr("Select second point of second line")); - return; - } - } - if (number == 3) - { - qint32 index = ui->comboBoxP2Line2->findText(point->name()); - if ( index != -1 ) - { // -1 for not found - ui->comboBoxP2Line2->setCurrentIndex(index); - p2Line2 = id; - number = 0; - line->setLine2P2Id(p2Line2); - line->RefreshGeometry(); - prepare = true; - emit ToolTip(""); - } - if (isInitialized == false) + switch (number) { - flagPoint = CheckIntersecion(); - CheckState(); - this->setModal(true); - this->show(); - connect(ui->comboBoxP1Line1, - static_cast(&QComboBox::currentIndexChanged), this, - &DialogLineIntersect::P1Line1Changed); - connect(ui->comboBoxP2Line1, - static_cast(&QComboBox::currentIndexChanged), this, - &DialogLineIntersect::P2Line1Changed); - connect(ui->comboBoxP1Line2, - static_cast(&QComboBox::currentIndexChanged), this, - &DialogLineIntersect::P1Line2Changed); - connect(ui->comboBoxP2Line2, - static_cast(&QComboBox::currentIndexChanged), this, - &DialogLineIntersect::P2Line2Changed); + case 0: + if (SetObject(id, ui->comboBoxP1Line1, tr("Select second point of first line"))) + { + number++; + p1Line1 = id; + line->VisualMode(id); + } + break; + case 1: + if (SetObject(id, ui->comboBoxP2Line1, tr("Select first point of second line"))) + { + number++; + p2Line1 = id; + line->setLine1P2Id(id); + line->RefreshGeometry(); + } + break; + case 2: + if (SetObject(id, ui->comboBoxP1Line2, tr("Select second point of second line"))) + { + number++; + p1Line2 = id; + line->setLine2P1Id(id); + line->RefreshGeometry(); + } + break; + case 3: + if (SetObject(id, ui->comboBoxP2Line2, "")) + { + p2Line2 = id; + line->setLine2P2Id(id); + line->RefreshGeometry(); + prepare = true; + flagPoint = CheckIntersecion(); + CheckState(); + this->setModal(true); + this->show(); + connect(ui->comboBoxP1Line1, + static_cast(&QComboBox::currentIndexChanged), this, + &DialogLineIntersect::P1Line1Changed); + connect(ui->comboBoxP2Line1, + static_cast(&QComboBox::currentIndexChanged), this, + &DialogLineIntersect::P2Line1Changed); + connect(ui->comboBoxP1Line2, + static_cast(&QComboBox::currentIndexChanged), this, + &DialogLineIntersect::P1Line2Changed); + connect(ui->comboBoxP2Line2, + static_cast(&QComboBox::currentIndexChanged), this, + &DialogLineIntersect::P2Line2Changed); + } + break; + default: + break; } } } diff --git a/src/app/dialogs/tools/dialognormal.cpp b/src/app/dialogs/tools/dialognormal.cpp index 47b023fd2..72122f60f 100644 --- a/src/app/dialogs/tools/dialognormal.cpp +++ b/src/app/dialogs/tools/dialognormal.cpp @@ -135,29 +135,27 @@ void DialogNormal::ChosenObject(quint32 id, const SceneObject &type) { if (type == SceneObject::Point) { - if (number == 0) + switch (number) { - if (ChoosedPoint(id, ui->comboBoxFirstPoint, tr("Select second point of line"))) - { - number++; - line->VisualMode(id); - return; - } - } - if (number == 1) - { - if (ChoosedPoint(id, ui->comboBoxSecondPoint, "")) - { - number = 0; - line->setPoint2Id(id); - line->RefreshGeometry(); - prepare = true; - if (isInitialized == false) + case 0: + if (SetObject(id, ui->comboBoxFirstPoint, tr("Select second point of line"))) { + number++; + line->VisualMode(id); + } + break; + case 1: + if (SetObject(id, ui->comboBoxSecondPoint, "")) + { + line->setPoint2Id(id); + line->RefreshGeometry(); + prepare = true; this->setModal(true); this->show(); } - } + break; + default: + break; } } } diff --git a/src/app/dialogs/tools/dialogpointofcontact.cpp b/src/app/dialogs/tools/dialogpointofcontact.cpp index ca5bb45b8..207306b3c 100644 --- a/src/app/dialogs/tools/dialogpointofcontact.cpp +++ b/src/app/dialogs/tools/dialogpointofcontact.cpp @@ -155,50 +155,39 @@ void DialogPointOfContact::DeployFormulaTextEdit() */ void DialogPointOfContact::ChosenObject(quint32 id, const SceneObject &type) { - if (type == SceneObject::Point) + if (prepare == false)// After first choose we ignore all objects { - const VPointF *point = data->GeometricObject(id); - if (number == 0) + if (type == SceneObject::Point) { - qint32 index = ui->comboBoxFirstPoint->findText(point->name()); - if ( index != -1 ) - { // -1 for not found - ui->comboBoxFirstPoint->setCurrentIndex(index); - number++; - line->VisualMode(id); - emit ToolTip(tr("Select second point of line")); - return; - } - } - if (number == 1) - { - qint32 index = ui->comboBoxSecondPoint->findText(point->name()); - if ( index != -1 ) - { // -1 for not found - ui->comboBoxSecondPoint->setCurrentIndex(index); - number++; - line->setLineP2Id(id); - line->RefreshGeometry(); - emit ToolTip(tr("Select point of center of arc")); - return; - } - } - if (number == 2) - { - qint32 index = ui->comboBoxCenter->findText(point->name()); - if ( index != -1 ) - { // -1 for not found - ui->comboBoxCenter->setCurrentIndex(index); - number = 0; - line->setRadiusId(id); - line->RefreshGeometry(); - prepare = true; - emit ToolTip(""); - } - if (isInitialized == false) + switch (number) { - this->setModal(true); - this->show(); + case 0: + if (SetObject(id, ui->comboBoxFirstPoint, tr("Select second point of line"))) + { + number++; + line->VisualMode(id); + } + break; + case 1: + if (SetObject(id, ui->comboBoxSecondPoint, tr("Select point of center of arc"))) + { + number++; + line->setLineP2Id(id); + line->RefreshGeometry(); + } + break; + case 2: + if (SetObject(id, ui->comboBoxCenter, "")) + { + line->setRadiusId(id); + line->RefreshGeometry(); + prepare = true; + this->setModal(true); + this->show(); + } + break; + default: + break; } } } diff --git a/src/app/dialogs/tools/dialogpointofintersection.cpp b/src/app/dialogs/tools/dialogpointofintersection.cpp index de739593e..4dd2c5bd9 100644 --- a/src/app/dialogs/tools/dialogpointofintersection.cpp +++ b/src/app/dialogs/tools/dialogpointofintersection.cpp @@ -89,37 +89,31 @@ void DialogPointOfIntersection::setSecondPointId(const quint32 &value) */ void DialogPointOfIntersection::ChosenObject(quint32 id, const SceneObject &type) { - if (type == SceneObject::Point) + if (prepare == false)// After first choose we ignore all objects { - const VPointF *point = data->GeometricObject(id); - if (number == 0) + if (type == SceneObject::Point) { - qint32 index = ui->comboBoxFirstPoint->findText(point->name()); - if ( index != -1 ) - { // -1 for not found - ui->comboBoxFirstPoint->setCurrentIndex(index); - number++; - line->VisualMode(id); - emit ToolTip(tr("Select point horizontally")); - return; - } - } - if (number == 1) - { - qint32 index = ui->comboBoxSecondPoint->findText(point->name()); - if ( index != -1 ) - { // -1 for not found - ui->comboBoxSecondPoint->setCurrentIndex(index); - number = 0; - line->setPoint2Id(id); - line->RefreshGeometry(); - prepare = true; - emit ToolTip(""); - } - if (isInitialized == false) + switch (number) { - this->setModal(true); - this->show(); + case 0: + if (SetObject(id, ui->comboBoxFirstPoint, tr("Select point horizontally"))) + { + number++; + line->VisualMode(id); + } + break; + case 1: + if (SetObject(id, ui->comboBoxSecondPoint, "")) + { + line->setPoint2Id(id); + line->RefreshGeometry(); + prepare = true; + this->setModal(true); + this->show(); + } + break; + default: + break; } } } diff --git a/src/app/dialogs/tools/dialogshoulderpoint.cpp b/src/app/dialogs/tools/dialogshoulderpoint.cpp index 551029c7c..2fbaf4b69 100644 --- a/src/app/dialogs/tools/dialogshoulderpoint.cpp +++ b/src/app/dialogs/tools/dialogshoulderpoint.cpp @@ -146,50 +146,35 @@ void DialogShoulderPoint::ChosenObject(quint32 id, const SceneObject &type) { if (type == SceneObject::Point) { - const VPointF *point = data->GeometricObject(id); - if (number == 0) + switch (number) { - qint32 index = ui->comboBoxPShoulder->findText(point->name()); - if ( index != -1 ) - { // -1 for not found - ui->comboBoxPShoulder->setCurrentIndex(index); - number++; - line->VisualMode(id); - emit ToolTip(tr("Select first point of line")); - return; - } - } - if (number == 1) - { - qint32 index = ui->comboBoxP1Line->findText(point->name()); - if ( index != -1 ) - { // -1 for not found - ui->comboBoxP1Line->setCurrentIndex(index); - number++; - line->setLineP1Id(id); - line->RefreshGeometry(); - emit ToolTip(tr("Select second point of line")); - return; - } - } - if (number == 2) - { - qint32 index = ui->comboBoxP2Line->findText(point->name()); - - if ( index != -1 ) - { // -1 for not found - ui->comboBoxP2Line->setCurrentIndex(index); - number = 0; - line->setLineP2Id(id); - line->RefreshGeometry(); - prepare = true; - emit ToolTip(""); - } - if (isInitialized == false) - { - this->setModal(true); - this->show(); - } + case 0: + if (SetObject(id, ui->comboBoxPShoulder, tr("Select first point of line"))) + { + number++; + line->VisualMode(id); + } + break; + case 1: + if (SetObject(id, ui->comboBoxP1Line, tr("Select second point of line"))) + { + number++; + line->setLineP1Id(id); + line->RefreshGeometry(); + } + break; + case 2: + if (SetObject(id, ui->comboBoxP2Line, "")) + { + line->setLineP2Id(id); + line->RefreshGeometry(); + prepare = true; + this->setModal(true); + this->show(); + } + break; + default: + break; } } } diff --git a/src/app/dialogs/tools/dialogspline.cpp b/src/app/dialogs/tools/dialogspline.cpp index 7b1f5474e..07351826c 100644 --- a/src/app/dialogs/tools/dialogspline.cpp +++ b/src/app/dialogs/tools/dialogspline.cpp @@ -79,40 +79,42 @@ void DialogSpline::ChosenObject(quint32 id, const SceneObject &type) { if (type == SceneObject::Point) { - const VPointF *point = data->GeometricObject(id); - if (number == 0) + switch (number) { - qint32 index = ui->comboBoxP1->findText(point->name()); - if ( index != -1 ) - { // -1 for not found - ui->comboBoxP1->setCurrentIndex(index); - number++; - emit ToolTip(tr("Select last point of curve")); - return; - } - } - if (number == 1) - { - qint32 index = ui->comboBoxP4->findText(point->name()); - if ( index != -1 ) - { // -1 for not found - ui->comboBoxP4->setCurrentIndex(index); - number = 0; - emit ToolTip(""); - index = ui->comboBoxP1->currentIndex(); - quint32 p1Id = qvariant_cast(ui->comboBoxP1->itemData(index)); - - QPointF p1 = data->GeometricObject(p1Id)->toQPointF(); - QPointF p4 = data->GeometricObject(id)->toQPointF(); - - ui->spinBoxAngle1->setValue(static_cast(QLineF(p1, p4).angle())); - ui->spinBoxAngle2->setValue(static_cast(QLineF(p4, p1).angle())); - } - if (isInitialized == false) + case 0: + if (SetObject(id, ui->comboBoxP1, tr("Select last point of curve"))) + { + number++; + } + break; + case 1: { - this->setModal(true); - this->show(); + const VPointF *point = data->GeometricObject(id); + qint32 index = ui->comboBoxP4->findText(point->name()); + if ( index != -1 ) + { // -1 for not found + ui->comboBoxP4->setCurrentIndex(index); + emit ToolTip(""); + index = ui->comboBoxP1->currentIndex(); + quint32 p1Id = qvariant_cast(ui->comboBoxP1->itemData(index)); + + QPointF p1 = data->GeometricObject(p1Id)->toQPointF(); + QPointF p4 = data->GeometricObject(id)->toQPointF(); + + ui->spinBoxAngle1->setValue(static_cast(QLineF(p1, p4).angle())); + ui->spinBoxAngle2->setValue(static_cast(QLineF(p4, p1).angle())); + + this->setModal(true); + this->show(); + } + else + { + qWarning()<<"Can't find object by name"<name(); + } + break; } + default: + break; } } } diff --git a/src/app/dialogs/tools/dialogtool.cpp b/src/app/dialogs/tools/dialogtool.cpp index 8f88813d2..ce695c101 100644 --- a/src/app/dialogs/tools/dialogtool.cpp +++ b/src/app/dialogs/tools/dialogtool.cpp @@ -322,25 +322,6 @@ void DialogTool::SetupTypeLine(QComboBox *box, const QString &value) } } -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief ChangeCurrentText select item in combobox by name - * @param box combobox - * @param value name of item - */ -void DialogTool::ChangeCurrentText(QComboBox *box, const QString &value) -{ - qint32 index = box->findText(value); - if (index != -1) - { - box->setCurrentIndex(index); - } - else - { - qDebug()<<"Can't find object by name"<GeometricObject(id); - SCASSERT(point != nullptr); - const qint32 index = box->findText(point->name()); + const VGObject *obj = data->GetGObject(id); + SCASSERT(obj != nullptr); + const qint32 index = box->findText(obj->name()); if ( index != -1 ) { // -1 for not found box->setCurrentIndex(index); emit ToolTip(toolTip); return true; } + else + { + qWarning()<<"Can't find object by name"<name(); + } return false; } diff --git a/src/app/dialogs/tools/dialogtool.h b/src/app/dialogs/tools/dialogtool.h index 5bea4a5fa..5d2ab7950 100644 --- a/src/app/dialogs/tools/dialogtool.h +++ b/src/app/dialogs/tools/dialogtool.h @@ -213,7 +213,6 @@ protected: template void ShowVariable(const QMap var); void SetupTypeLine(QComboBox *box, const QString &value); - void ChangeCurrentText(QComboBox *box, const QString &value); void ChangeCurrentData(QComboBox *box, const quint32 &value) const; void PutValHere(QLineEdit *lineEdit, QListWidget *listWidget); void PutValHere(QPlainTextEdit *plainTextEdit, QListWidget *listWidget); @@ -229,7 +228,7 @@ protected: void setCurrentSplinePathId(QComboBox *box, quint32 &splinePathId, const quint32 &value, ComboBoxCutSpline cut = ComboBoxCutSpline::NoCutSpline) const; quint32 getCurrentObjectId(QComboBox *box) const; - bool ChoosedPoint(const quint32 &id, QComboBox *box, const QString &toolTip); + bool SetObject(const quint32 &id, QComboBox *box, const QString &toolTip); void DeployFormula(QPlainTextEdit *formula, QPushButton *buttonGrowLength, int formulaBaseHeight); template void InitArrow(T *ui) diff --git a/src/app/dialogs/tools/dialogtriangle.cpp b/src/app/dialogs/tools/dialogtriangle.cpp index 794e71312..a4e4f0112 100644 --- a/src/app/dialogs/tools/dialogtriangle.cpp +++ b/src/app/dialogs/tools/dialogtriangle.cpp @@ -83,46 +83,48 @@ DialogTriangle::~DialogTriangle() */ void DialogTriangle::ChosenObject(quint32 id, const SceneObject &type) { - if (type == SceneObject::Point) + if (prepare == false)// After first choose we ignore all objects { - const VPointF *point = data->GeometricObject(id); - switch (number) + if (type == SceneObject::Point) { - case (0): - ChangeCurrentText(ui->comboBoxAxisP1, point->name()); - number++; - line->VisualMode(id); - emit ToolTip(tr("Select second point of axis")); - break; - case (1): - ChangeCurrentText(ui->comboBoxAxisP2, point->name()); - number++; - line->setPoint2Id(id); - line->RefreshGeometry(); - emit ToolTip(tr("Select first point")); - break; - case (2): - ChangeCurrentText(ui->comboBoxFirstPoint, point->name()); - number++; - line->setHypotenuseP1Id(id); - line->RefreshGeometry(); - emit ToolTip(tr("Select second point")); - break; - case (3): - ChangeCurrentText(ui->comboBoxSecondPoint, point->name()); - number = 0; - line->setHypotenuseP2Id(id); - line->RefreshGeometry(); - prepare = true; - emit ToolTip(tr("")); - if (isInitialized == false) - { - this->setModal(true); - this->show(); - } - break; - default: - break; + switch (number) + { + case (0): + if (SetObject(id, ui->comboBoxAxisP1, tr("Select second point of axis"))) + { + number++; + line->VisualMode(id); + } + break; + case (1): + if (SetObject(id, ui->comboBoxAxisP2, tr("Select first point"))) + { + number++; + line->setPoint2Id(id); + line->RefreshGeometry(); + } + break; + case (2): + if (SetObject(id, ui->comboBoxFirstPoint, tr("Select second point"))) + { + number++; + line->setHypotenuseP1Id(id); + line->RefreshGeometry(); + } + break; + case (3): + if (SetObject(id, ui->comboBoxSecondPoint, "")) + { + line->setHypotenuseP2Id(id); + line->RefreshGeometry(); + prepare = true; + this->setModal(true); + this->show(); + } + break; + default: + break; + } } } }