From 7563446cf99e09e92746e89f58edd3f5d419a66d Mon Sep 17 00:00:00 2001 From: dismine Date: Sun, 9 Nov 2014 12:57:49 +0200 Subject: [PATCH] Only unique points allowed. --HG-- branch : develop --- src/app/dialogs/tools/dialogalongline.cpp | 20 ++++-- src/app/dialogs/tools/dialogbisector.cpp | 33 +++++++--- src/app/dialogs/tools/dialogheight.cpp | 33 +++++++--- src/app/dialogs/tools/dialoglineintersect.cpp | 66 +++++++++++-------- src/app/dialogs/tools/dialognormal.cpp | 15 +++-- .../dialogs/tools/dialogpointofcontact.cpp | 33 +++++++--- .../tools/dialogpointofintersection.cpp | 15 +++-- src/app/dialogs/tools/dialogshoulderpoint.cpp | 33 +++++++--- src/app/dialogs/tools/dialogspline.cpp | 47 ++++++------- src/app/dialogs/tools/dialogtriangle.cpp | 52 +++++++++++---- 10 files changed, 227 insertions(+), 120 deletions(-) diff --git a/src/app/dialogs/tools/dialogalongline.cpp b/src/app/dialogs/tools/dialogalongline.cpp index 9d37faa3b..66a45239f 100644 --- a/src/app/dialogs/tools/dialogalongline.cpp +++ b/src/app/dialogs/tools/dialogalongline.cpp @@ -139,10 +139,11 @@ void DialogAlongLine::ChosenObject(quint32 id, const SceneObject &type) { if (type == SceneObject::Point) { + const QString toolTip = tr("Select second point of line"); switch (number) { case 0: - if (SetObject(id, ui->comboBoxFirstPoint, tr("Select second point of line"))) + if (SetObject(id, ui->comboBoxFirstPoint, toolTip)) { number++; line->VisualMode(id); @@ -151,11 +152,18 @@ void DialogAlongLine::ChosenObject(quint32 id, const SceneObject &type) case 1: if (SetObject(id, ui->comboBoxSecondPoint, "")) { - line->setPoint2Id(id); - line->RefreshGeometry(); - prepare = true; - this->setModal(true); - this->show(); + if (flagError) + { + line->setPoint2Id(id); + line->RefreshGeometry(); + prepare = true; + this->setModal(true); + this->show(); + } + else + { + emit ToolTip(toolTip); + } } break; default: diff --git a/src/app/dialogs/tools/dialogbisector.cpp b/src/app/dialogs/tools/dialogbisector.cpp index 7abbc3f2e..b2a9a8535 100644 --- a/src/app/dialogs/tools/dialogbisector.cpp +++ b/src/app/dialogs/tools/dialogbisector.cpp @@ -158,22 +158,35 @@ void DialogBisector::ChosenObject(quint32 id, const SceneObject &type) } break; case 1: - if (SetObject(id, ui->comboBoxSecondPoint, tr("Select third point of angle"))) + if (getCurrentObjectId(ui->comboBoxFirstPoint) != id) { - number++; - line->setPoint2Id(id); - line->RefreshGeometry(); + 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, "")) + { + QSet set; + set.insert(getCurrentObjectId(ui->comboBoxFirstPoint)); + set.insert(getCurrentObjectId(ui->comboBoxSecondPoint)); + set.insert(id); + + if (set.size() == 3) { - line->setPoint3Id(id); - line->RefreshGeometry(); - prepare = true; - this->setModal(true); - this->show(); + 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/dialogheight.cpp b/src/app/dialogs/tools/dialogheight.cpp index 01c17f079..510096af3 100644 --- a/src/app/dialogs/tools/dialogheight.cpp +++ b/src/app/dialogs/tools/dialogheight.cpp @@ -151,22 +151,35 @@ void DialogHeight::ChosenObject(quint32 id, const SceneObject &type) } break; case (1): - if (SetObject(id, ui->comboBoxP1Line, tr("Select second point of line"))) + if (getCurrentObjectId(ui->comboBoxBasePoint) != id) { - number++; - line->setLineP1Id(id); - line->RefreshGeometry(); + 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, "")) + { + QSet set; + set.insert(getCurrentObjectId(ui->comboBoxBasePoint)); + set.insert(getCurrentObjectId(ui->comboBoxP1Line)); + set.insert(id); + + if (set.size() == 3) { - line->setLineP2Id(id); - line->RefreshGeometry(); - prepare = true; - this->setModal(true); - this->show(); + 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/dialoglineintersect.cpp b/src/app/dialogs/tools/dialoglineintersect.cpp index 4de620302..030d66b38 100644 --- a/src/app/dialogs/tools/dialoglineintersect.cpp +++ b/src/app/dialogs/tools/dialoglineintersect.cpp @@ -99,12 +99,15 @@ void DialogLineIntersect::ChosenObject(quint32 id, const SceneObject &type) } break; case 1: - if (SetObject(id, ui->comboBoxP2Line1, tr("Select first point of second line"))) + if (getCurrentObjectId(ui->comboBoxP1Line1) != id) { - number++; - p2Line1 = id; - line->setLine1P2Id(id); - line->RefreshGeometry(); + if (SetObject(id, ui->comboBoxP2Line1, tr("Select first point of second line"))) + { + number++; + p2Line1 = id; + line->setLine1P2Id(id); + line->RefreshGeometry(); + } } break; case 2: @@ -117,29 +120,40 @@ void DialogLineIntersect::ChosenObject(quint32 id, const SceneObject &type) } break; case 3: - if (SetObject(id, ui->comboBoxP2Line2, "")) + { + QSet set; + set.insert(getCurrentObjectId(ui->comboBoxP1Line1)); + set.insert(getCurrentObjectId(ui->comboBoxP2Line1)); + set.insert(getCurrentObjectId(ui->comboBoxP1Line2)); + set.insert(id); + + if (set.size() >= 3) { - 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); + 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 77bf2cc3c..f6b508aad 100644 --- a/src/app/dialogs/tools/dialognormal.cpp +++ b/src/app/dialogs/tools/dialognormal.cpp @@ -146,13 +146,16 @@ void DialogNormal::ChosenObject(quint32 id, const SceneObject &type) } break; case 1: - if (SetObject(id, ui->comboBoxSecondPoint, "")) + if (getCurrentObjectId(ui->comboBoxFirstPoint) != id) { - line->setPoint2Id(id); - line->RefreshGeometry(); - prepare = true; - this->setModal(true); - this->show(); + if (SetObject(id, ui->comboBoxSecondPoint, "")) + { + line->setPoint2Id(id); + line->RefreshGeometry(); + prepare = true; + this->setModal(true); + this->show(); + } } break; default: diff --git a/src/app/dialogs/tools/dialogpointofcontact.cpp b/src/app/dialogs/tools/dialogpointofcontact.cpp index f07f18458..4af6aa7cc 100644 --- a/src/app/dialogs/tools/dialogpointofcontact.cpp +++ b/src/app/dialogs/tools/dialogpointofcontact.cpp @@ -171,22 +171,35 @@ void DialogPointOfContact::ChosenObject(quint32 id, const SceneObject &type) } break; case 1: - if (SetObject(id, ui->comboBoxSecondPoint, tr("Select point of center of arc"))) + if (getCurrentObjectId(ui->comboBoxFirstPoint) != id) { - number++; - line->setLineP2Id(id); - line->RefreshGeometry(); + 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, "")) + { + QSet set; + set.insert(getCurrentObjectId(ui->comboBoxFirstPoint)); + set.insert(getCurrentObjectId(ui->comboBoxSecondPoint)); + set.insert(id); + + if (set.size() == 3) { - line->setRadiusId(id); - line->RefreshGeometry(); - prepare = true; - this->setModal(true); - this->show(); + 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 0788a791c..37661b4e3 100644 --- a/src/app/dialogs/tools/dialogpointofintersection.cpp +++ b/src/app/dialogs/tools/dialogpointofintersection.cpp @@ -104,13 +104,16 @@ void DialogPointOfIntersection::ChosenObject(quint32 id, const SceneObject &type } break; case 1: - if (SetObject(id, ui->comboBoxSecondPoint, "")) + if (getCurrentObjectId(ui->comboBoxFirstPoint) != id) { - line->setPoint2Id(id); - line->RefreshGeometry(); - prepare = true; - this->setModal(true); - this->show(); + if (SetObject(id, ui->comboBoxSecondPoint, "")) + { + line->setPoint2Id(id); + line->RefreshGeometry(); + prepare = true; + this->setModal(true); + this->show(); + } } break; default: diff --git a/src/app/dialogs/tools/dialogshoulderpoint.cpp b/src/app/dialogs/tools/dialogshoulderpoint.cpp index 7048321af..55c062a67 100644 --- a/src/app/dialogs/tools/dialogshoulderpoint.cpp +++ b/src/app/dialogs/tools/dialogshoulderpoint.cpp @@ -157,22 +157,35 @@ void DialogShoulderPoint::ChosenObject(quint32 id, const SceneObject &type) } break; case 1: - if (SetObject(id, ui->comboBoxP1Line, tr("Select second point of line"))) + if (getCurrentObjectId(ui->comboBoxP3) != id) { - number++; - line->setLineP1Id(id); - line->RefreshGeometry(); + 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, "")) + { + QSet set; + set.insert(getCurrentObjectId(ui->comboBoxP3)); + set.insert(getCurrentObjectId(ui->comboBoxP1Line)); + set.insert(id); + + if (set.size() == 3) { - line->setLineP2Id(id); - line->RefreshGeometry(); - prepare = true; - this->setModal(true); - this->show(); + 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 cd9f9ab29..5f8ea4f10 100644 --- a/src/app/dialogs/tools/dialogspline.cpp +++ b/src/app/dialogs/tools/dialogspline.cpp @@ -97,29 +97,32 @@ void DialogSpline::ChosenObject(quint32 id, const SceneObject &type) break; case 1: { - const QSharedPointer 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())); - - path->setPoint4Id(id); - path->RefreshGeometry(); - prepare = true; - DialogAccepted(); - } - else + if (getCurrentObjectId(ui->comboBoxP1) != id) { - qWarning()<<"Can't find object by name"<name(); + const QSharedPointer 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())); + + path->setPoint4Id(id); + path->RefreshGeometry(); + prepare = true; + DialogAccepted(); + } + else + { + qWarning()<<"Can't find object by name"<name(); + } } break; } diff --git a/src/app/dialogs/tools/dialogtriangle.cpp b/src/app/dialogs/tools/dialogtriangle.cpp index 065b03093..9948f90f0 100644 --- a/src/app/dialogs/tools/dialogtriangle.cpp +++ b/src/app/dialogs/tools/dialogtriangle.cpp @@ -98,30 +98,54 @@ void DialogTriangle::ChosenObject(quint32 id, const SceneObject &type) } break; case (1): - if (SetObject(id, ui->comboBoxAxisP2, tr("Select first point"))) + if (getCurrentObjectId(ui->comboBoxAxisP1) != id) { - number++; - line->setPoint2Id(id); - line->RefreshGeometry(); + 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"))) + { + QSet set; + set.insert(getCurrentObjectId(ui->comboBoxAxisP1)); + set.insert(getCurrentObjectId(ui->comboBoxAxisP2)); + set.insert(id); + + if (set.size() == 3) { - number++; - line->setHypotenuseP1Id(id); - line->RefreshGeometry(); + if (SetObject(id, ui->comboBoxFirstPoint, tr("Select second point"))) + { + number++; + line->setHypotenuseP1Id(id); + line->RefreshGeometry(); + } } + } break; case (3): - if (SetObject(id, ui->comboBoxSecondPoint, "")) + { + QSet set; + set.insert(getCurrentObjectId(ui->comboBoxAxisP1)); + set.insert(getCurrentObjectId(ui->comboBoxAxisP2)); + set.insert(getCurrentObjectId(ui->comboBoxFirstPoint)); + set.insert(id); + + if (set.size() == 4) { - line->setHypotenuseP2Id(id); - line->RefreshGeometry(); - prepare = true; - this->setModal(true); - this->show(); + if (SetObject(id, ui->comboBoxSecondPoint, "")) + { + line->setHypotenuseP2Id(id); + line->RefreshGeometry(); + prepare = true; + this->setModal(true); + this->show(); + } } + } break; default: break;