Don't allow selection details with less than 2 points and less than three

objects.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2015-03-30 17:27:45 +03:00
parent a38448623c
commit d9a9df14f6
4 changed files with 40 additions and 12 deletions

View File

@ -87,14 +87,32 @@ void DialogUnionDetails::UpdateList()
*/
bool DialogUnionDetails::CheckObject(const quint32 &id, const quint32 &idDetail) const
{
if (idDetail == 0)
if (idDetail == NULL_ID)
{
return false;
}
VDetail det = data->GetDetail(idDetail);
const VDetail det = data->GetDetail(idDetail);
return det.Containes(id);
}
//---------------------------------------------------------------------------------------------------------------------
bool DialogUnionDetails::CheckDetail(const quint32 &idDetail) const
{
if (idDetail == NULL_ID)
{
return false;
}
const VDetail det = data->GetDetail(idDetail);
if (det.CountNode() >= 3 && det.listNodePoint().size() >= 2)
{
return true;
}
else
{
return false;
}
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief ChoosedDetail help save information about detail and points on detail
@ -106,14 +124,22 @@ bool DialogUnionDetails::CheckObject(const quint32 &id, const quint32 &idDetail)
void DialogUnionDetails::ChoosedDetail(const quint32 &id, const SceneObject &type, quint32 &idDetail,
int &index)
{
if (idDetail == 0)
if (idDetail == NULL_ID)
{
if (type == SceneObject::Detail)
{
if (CheckDetail(id))
{
idDetail = id;
emit ToolTip(tr("Select first point"));
emit ToolTip(tr("Select a first point"));
return;
}
else
{
emit ToolTip(tr("Workpiece should have at least two points and three objects"));
return;
}
}
}
if (CheckObject(id, idDetail) == false)
{
@ -125,14 +151,14 @@ void DialogUnionDetails::ChoosedDetail(const quint32 &id, const SceneObject &typ
{
p1 = id;
++numberP;
emit ToolTip(tr("Select second point"));
emit ToolTip(tr("Select a second point"));
return;
}
if (numberP == 1)
{
if (id == p1)
{
emit ToolTip(tr("Select another second point"));
emit ToolTip(tr("Select a unique point"));
return;
}
VDetail d = data->GetDetail(idDetail);
@ -154,13 +180,13 @@ void DialogUnionDetails::ChoosedDetail(const quint32 &id, const SceneObject &typ
numberP = 0;
p1 = 0;
p2 = 0;
emit ToolTip(tr("Select detail"));
emit ToolTip(tr("Select a detail"));
return;
}
}
else
{
emit ToolTip(tr("Select another second point"));
emit ToolTip(tr("Select a point on edge"));
return;
}
}

View File

@ -84,6 +84,8 @@ private:
quint32 p2;
bool CheckObject(const quint32 &id, const quint32 &idDetail) const;
bool CheckDetail(const quint32 &idDetail) const;
void ChoosedDetail(const quint32 &id, const SceneObject &type, quint32 &idDetail,
int &index);
};

View File

@ -186,7 +186,7 @@ void VDetail::setId(const quint32 &id)
bool VDetail::OnEdge(const quint32 &p1, const quint32 &p2) const
{
QVector<VNodeDetail> list = listNodePoint();
if (list.size() < 3)
if (list.size() < 2)
{
qDebug()<<"Not enough points.";
return false;

View File

@ -82,10 +82,10 @@ public:
QVector<QPointF> SeamAllowancePoints(const VContainer *data) const;
QPainterPath ContourPath(const VContainer *data) const;
QVector<VNodeDetail> listNodePoint()const;
private:
QSharedDataPointer<VDetailData> d;
QVector<VNodeDetail> listNodePoint()const;
static int indexOfNode(const QVector<VNodeDetail> &list, const quint32 &id);
QPointF StartSegment(const VContainer *data, const int &i) const;