diff --git a/src/app/dialogs/tools/dialogheight.cpp b/src/app/dialogs/tools/dialogheight.cpp index 4fc9815a1..62a3c187d 100644 --- a/src/app/dialogs/tools/dialogheight.cpp +++ b/src/app/dialogs/tools/dialogheight.cpp @@ -31,6 +31,7 @@ #include "../../geometry/vpointf.h" #include "../../container/vcontainer.h" +#include "../../tools/vabstracttool.h" //--------------------------------------------------------------------------------------------------------------------- /** @@ -180,11 +181,20 @@ void DialogHeight::DialogAccepted() void DialogHeight::PointNameChanged() { QSet set; - set.insert(getCurrentObjectId(ui->comboBoxBasePoint)); - set.insert(getCurrentObjectId(ui->comboBoxP1Line)); - set.insert(getCurrentObjectId(ui->comboBoxP2Line)); + const quint32 basePointId = getCurrentObjectId(ui->comboBoxBasePoint); + const quint32 p1LineId = getCurrentObjectId(ui->comboBoxP1Line); + const quint32 p2LineId = getCurrentObjectId(ui->comboBoxP2Line); - if (set.size() != 3) + set.insert(basePointId); + set.insert(p1LineId); + set.insert(p2LineId); + + const VPointF *basePoint = data->GeometricObject(basePointId); + const VPointF *p1Line = data->GeometricObject(p1LineId); + const VPointF *p2Line = data->GeometricObject(p2LineId); + + if (set.size() != 3 || VAbstractTool::ClosestPoint(QLineF(p1Line->toQPointF(), p2Line->toQPointF()), + basePoint->toQPointF()) == QPointF()) { flagError = false; ChangeColor(ui->labelBasePoint, Qt::red); diff --git a/src/app/dialogs/tools/dialoglineintersect.cpp b/src/app/dialogs/tools/dialoglineintersect.cpp index 82fe6f5b9..619d090bb 100644 --- a/src/app/dialogs/tools/dialoglineintersect.cpp +++ b/src/app/dialogs/tools/dialoglineintersect.cpp @@ -54,6 +54,14 @@ DialogLineIntersect::DialogLineIntersect(const VContainer *data, QWidget *parent FillComboBoxPoints(ui->comboBoxP2Line2); connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogLineIntersect::NamePointChanged); + connect(ui->comboBoxP1Line1, static_cast(&QComboBox::currentIndexChanged), + this, &DialogLineIntersect::PointNameChanged); + connect(ui->comboBoxP2Line1, static_cast(&QComboBox::currentIndexChanged), + this, &DialogLineIntersect::PointNameChanged); + connect(ui->comboBoxP1Line2, static_cast(&QComboBox::currentIndexChanged), + this, &DialogLineIntersect::PointNameChanged); + connect(ui->comboBoxP2Line2, static_cast(&QComboBox::currentIndexChanged), + this, &DialogLineIntersect::PointNameChanged); } //--------------------------------------------------------------------------------------------------------------------- @@ -204,6 +212,49 @@ void DialogLineIntersect::P2Line2Changed(int index) CheckState(); } +//--------------------------------------------------------------------------------------------------------------------- +void DialogLineIntersect::PointNameChanged() +{ + QSet set; + const quint32 p1Line1Id = getCurrentObjectId(ui->comboBoxP1Line1); + const quint32 p2Line1Id = getCurrentObjectId(ui->comboBoxP2Line1); + const quint32 p1Line2Id = getCurrentObjectId(ui->comboBoxP1Line2); + const quint32 p2Line2Id = getCurrentObjectId(ui->comboBoxP2Line2); + + set.insert(p1Line1Id); + set.insert(p2Line1Id); + set.insert(p1Line2Id); + set.insert(p2Line2Id); + + const VPointF *p1Line1 = data->GeometricObject(p1Line1Id); + const VPointF *p2Line1 = data->GeometricObject(p2Line1Id); + const VPointF *p1Line2 = data->GeometricObject(p1Line2Id); + const VPointF *p2Line2 = data->GeometricObject(p2Line2Id); + + QLineF line1(p1Line1->toQPointF(), p2Line1->toQPointF()); + QLineF line2(p1Line2->toQPointF(), p2Line2->toQPointF()); + QPointF fPoint; + QLineF::IntersectType intersect = line1.intersect(line2, &fPoint); + + if (set.size() < 3 || intersect == QLineF::NoIntersection) + { + flagError = false; + ChangeColor(ui->labelP1Line1, Qt::red); + ChangeColor(ui->labelP2Line1, Qt::red); + ChangeColor(ui->labelP1Line2, Qt::red); + ChangeColor(ui->labelP2Line2, Qt::red); + } + else + { + flagError = true; + ChangeColor(ui->labelP1Line1, QColor(76, 76, 76)); + ChangeColor(ui->labelP2Line1, QColor(76, 76, 76)); + ChangeColor(ui->labelP1Line2, QColor(76, 76, 76)); + ChangeColor(ui->labelP2Line2, QColor(76, 76, 76)); + } + CheckState(); +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief CheckState check state of dialog. Enable or disable button ok. @@ -247,8 +298,7 @@ bool DialogLineIntersect::CheckIntersecion() */ void DialogLineIntersect::setP2Line2(const quint32 &value) { - p2Line2 = value; - ChangeCurrentData(ui->comboBoxP2Line2, value); + setPointId(ui->comboBoxP2Line2, p2Line2, value, 0); } //--------------------------------------------------------------------------------------------------------------------- @@ -258,8 +308,7 @@ void DialogLineIntersect::setP2Line2(const quint32 &value) */ void DialogLineIntersect::setP1Line2(const quint32 &value) { - p1Line2 = value; - ChangeCurrentData(ui->comboBoxP1Line2, value); + setPointId(ui->comboBoxP1Line2, p1Line2, value, 0); } //--------------------------------------------------------------------------------------------------------------------- @@ -269,8 +318,7 @@ void DialogLineIntersect::setP1Line2(const quint32 &value) */ void DialogLineIntersect::setP2Line1(const quint32 &value) { - p2Line1 = value; - ChangeCurrentData(ui->comboBoxP2Line1, value); + setPointId(ui->comboBoxP2Line1, p2Line1, value, 0); } //--------------------------------------------------------------------------------------------------------------------- @@ -280,8 +328,7 @@ void DialogLineIntersect::setP2Line1(const quint32 &value) */ void DialogLineIntersect::setP1Line1(const quint32 &value) { - p1Line1 = value; - ChangeCurrentData(ui->comboBoxP1Line1, value); + setPointId(ui->comboBoxP1Line1, p1Line1, value, 0); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/dialogs/tools/dialoglineintersect.h b/src/app/dialogs/tools/dialoglineintersect.h index 8c02428bf..518d9cca2 100644 --- a/src/app/dialogs/tools/dialoglineintersect.h +++ b/src/app/dialogs/tools/dialoglineintersect.h @@ -71,6 +71,7 @@ public slots: void P2Line1Changed( int index); void P1Line2Changed( int index); void P2Line2Changed( int index); + virtual void PointNameChanged(); private: Q_DISABLE_COPY(DialogLineIntersect) diff --git a/src/app/dialogs/tools/dialoglineintersect.ui b/src/app/dialogs/tools/dialoglineintersect.ui index bb2e1b3bd..d9e5f6653 100644 --- a/src/app/dialogs/tools/dialoglineintersect.ui +++ b/src/app/dialogs/tools/dialoglineintersect.ui @@ -88,7 +88,7 @@ - + 0 @@ -104,7 +104,7 @@ - + Second point @@ -125,7 +125,7 @@ - + 0 @@ -141,7 +141,7 @@ - + Second point