DialogLineIntersect - check if names of points don't equal.

--HG--
branch : develop
This commit is contained in:
dismine 2014-07-14 18:01:14 +03:00
parent c090325875
commit efd6760e30
4 changed files with 74 additions and 16 deletions

View File

@ -31,6 +31,7 @@
#include "../../geometry/vpointf.h" #include "../../geometry/vpointf.h"
#include "../../container/vcontainer.h" #include "../../container/vcontainer.h"
#include "../../tools/vabstracttool.h"
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
@ -180,11 +181,20 @@ void DialogHeight::DialogAccepted()
void DialogHeight::PointNameChanged() void DialogHeight::PointNameChanged()
{ {
QSet<quint32> set; QSet<quint32> set;
set.insert(getCurrentObjectId(ui->comboBoxBasePoint)); const quint32 basePointId = getCurrentObjectId(ui->comboBoxBasePoint);
set.insert(getCurrentObjectId(ui->comboBoxP1Line)); const quint32 p1LineId = getCurrentObjectId(ui->comboBoxP1Line);
set.insert(getCurrentObjectId(ui->comboBoxP2Line)); const quint32 p2LineId = getCurrentObjectId(ui->comboBoxP2Line);
if (set.size() != 3) set.insert(basePointId);
set.insert(p1LineId);
set.insert(p2LineId);
const VPointF *basePoint = data->GeometricObject<const VPointF *>(basePointId);
const VPointF *p1Line = data->GeometricObject<const VPointF *>(p1LineId);
const VPointF *p2Line = data->GeometricObject<const VPointF *>(p2LineId);
if (set.size() != 3 || VAbstractTool::ClosestPoint(QLineF(p1Line->toQPointF(), p2Line->toQPointF()),
basePoint->toQPointF()) == QPointF())
{ {
flagError = false; flagError = false;
ChangeColor(ui->labelBasePoint, Qt::red); ChangeColor(ui->labelBasePoint, Qt::red);

View File

@ -54,6 +54,14 @@ DialogLineIntersect::DialogLineIntersect(const VContainer *data, QWidget *parent
FillComboBoxPoints(ui->comboBoxP2Line2); FillComboBoxPoints(ui->comboBoxP2Line2);
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogLineIntersect::NamePointChanged); connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogLineIntersect::NamePointChanged);
connect(ui->comboBoxP1Line1, static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged),
this, &DialogLineIntersect::PointNameChanged);
connect(ui->comboBoxP2Line1, static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged),
this, &DialogLineIntersect::PointNameChanged);
connect(ui->comboBoxP1Line2, static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged),
this, &DialogLineIntersect::PointNameChanged);
connect(ui->comboBoxP2Line2, static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged),
this, &DialogLineIntersect::PointNameChanged);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -204,6 +212,49 @@ void DialogLineIntersect::P2Line2Changed(int index)
CheckState(); CheckState();
} }
//---------------------------------------------------------------------------------------------------------------------
void DialogLineIntersect::PointNameChanged()
{
QSet<quint32> 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<const VPointF *>(p1Line1Id);
const VPointF *p2Line1 = data->GeometricObject<const VPointF *>(p2Line1Id);
const VPointF *p1Line2 = data->GeometricObject<const VPointF *>(p1Line2Id);
const VPointF *p2Line2 = data->GeometricObject<const VPointF *>(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. * @brief CheckState check state of dialog. Enable or disable button ok.
@ -247,8 +298,7 @@ bool DialogLineIntersect::CheckIntersecion()
*/ */
void DialogLineIntersect::setP2Line2(const quint32 &value) void DialogLineIntersect::setP2Line2(const quint32 &value)
{ {
p2Line2 = value; setPointId(ui->comboBoxP2Line2, p2Line2, value, 0);
ChangeCurrentData(ui->comboBoxP2Line2, value);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -258,8 +308,7 @@ void DialogLineIntersect::setP2Line2(const quint32 &value)
*/ */
void DialogLineIntersect::setP1Line2(const quint32 &value) void DialogLineIntersect::setP1Line2(const quint32 &value)
{ {
p1Line2 = value; setPointId(ui->comboBoxP1Line2, p1Line2, value, 0);
ChangeCurrentData(ui->comboBoxP1Line2, value);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -269,8 +318,7 @@ void DialogLineIntersect::setP1Line2(const quint32 &value)
*/ */
void DialogLineIntersect::setP2Line1(const quint32 &value) void DialogLineIntersect::setP2Line1(const quint32 &value)
{ {
p2Line1 = value; setPointId(ui->comboBoxP2Line1, p2Line1, value, 0);
ChangeCurrentData(ui->comboBoxP2Line1, value);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -280,8 +328,7 @@ void DialogLineIntersect::setP2Line1(const quint32 &value)
*/ */
void DialogLineIntersect::setP1Line1(const quint32 &value) void DialogLineIntersect::setP1Line1(const quint32 &value)
{ {
p1Line1 = value; setPointId(ui->comboBoxP1Line1, p1Line1, value, 0);
ChangeCurrentData(ui->comboBoxP1Line1, value);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -71,6 +71,7 @@ public slots:
void P2Line1Changed( int index); void P2Line1Changed( int index);
void P1Line2Changed( int index); void P1Line2Changed( int index);
void P2Line2Changed( int index); void P2Line2Changed( int index);
virtual void PointNameChanged();
private: private:
Q_DISABLE_COPY(DialogLineIntersect) Q_DISABLE_COPY(DialogLineIntersect)

View File

@ -88,7 +88,7 @@
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_3"> <layout class="QHBoxLayout" name="horizontalLayout_3">
<item> <item>
<widget class="QLabel" name="label_3"> <widget class="QLabel" name="labelP1Line1">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed"> <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -104,7 +104,7 @@
<widget class="QComboBox" name="comboBoxP1Line1"/> <widget class="QComboBox" name="comboBoxP1Line1"/>
</item> </item>
<item> <item>
<widget class="QLabel" name="label_5"> <widget class="QLabel" name="labelP2Line1">
<property name="text"> <property name="text">
<string>Second point</string> <string>Second point</string>
</property> </property>
@ -125,7 +125,7 @@
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_5"> <layout class="QHBoxLayout" name="horizontalLayout_5">
<item> <item>
<widget class="QLabel" name="label_6"> <widget class="QLabel" name="labelP1Line2">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed"> <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -141,7 +141,7 @@
<widget class="QComboBox" name="comboBoxP1Line2"/> <widget class="QComboBox" name="comboBoxP1Line2"/>
</item> </item>
<item> <item>
<widget class="QLabel" name="label_7"> <widget class="QLabel" name="labelP2Line2">
<property name="text"> <property name="text">
<string>Second point</string> <string>Second point</string>
</property> </property>