From d9a9df14f628bfdc4d1f151e751160d1452e8d15 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Mon, 30 Mar 2015 17:27:45 +0300 Subject: [PATCH] Don't allow selection details with less than 2 points and less than three objects. --HG-- branch : develop --- src/app/dialogs/tools/dialoguniondetails.cpp | 46 +++++++++++++++----- src/app/dialogs/tools/dialoguniondetails.h | 2 + src/app/geometry/vdetail.cpp | 2 +- src/app/geometry/vdetail.h | 2 +- 4 files changed, 40 insertions(+), 12 deletions(-) diff --git a/src/app/dialogs/tools/dialoguniondetails.cpp b/src/app/dialogs/tools/dialoguniondetails.cpp index 612be7d0a..b9ad8c05e 100644 --- a/src/app/dialogs/tools/dialoguniondetails.cpp +++ b/src/app/dialogs/tools/dialoguniondetails.cpp @@ -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,13 +124,21 @@ 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) { - idDetail = id; - emit ToolTip(tr("Select first point")); - return; + if (CheckDetail(id)) + { + idDetail = id; + 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; } } diff --git a/src/app/dialogs/tools/dialoguniondetails.h b/src/app/dialogs/tools/dialoguniondetails.h index e7842a249..9ad563022 100644 --- a/src/app/dialogs/tools/dialoguniondetails.h +++ b/src/app/dialogs/tools/dialoguniondetails.h @@ -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); }; diff --git a/src/app/geometry/vdetail.cpp b/src/app/geometry/vdetail.cpp index 48303e819..217d437e6 100644 --- a/src/app/geometry/vdetail.cpp +++ b/src/app/geometry/vdetail.cpp @@ -186,7 +186,7 @@ void VDetail::setId(const quint32 &id) bool VDetail::OnEdge(const quint32 &p1, const quint32 &p2) const { QVector list = listNodePoint(); - if (list.size() < 3) + if (list.size() < 2) { qDebug()<<"Not enough points."; return false; diff --git a/src/app/geometry/vdetail.h b/src/app/geometry/vdetail.h index d273e8da1..e3fa253eb 100644 --- a/src/app/geometry/vdetail.h +++ b/src/app/geometry/vdetail.h @@ -82,10 +82,10 @@ public: QVector SeamAllowancePoints(const VContainer *data) const; QPainterPath ContourPath(const VContainer *data) const; + QVector listNodePoint()const; private: QSharedDataPointer d; - QVector listNodePoint()const; static int indexOfNode(const QVector &list, const quint32 &id); QPointF StartSegment(const VContainer *data, const int &i) const;