From 2b711c5f8f0615a370d4ff37a1fcc922e440eb0b Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Sat, 14 Mar 2015 14:38:44 +0200 Subject: [PATCH] Bad API in class LayoutDetail. Fixed checking seam allowence points. --HG-- branch : release --- src/app/geometry/vdetail.cpp | 36 +++++++++++++----------------- src/app/mainwindow.cpp | 3 +-- src/libs/vlayout/vlayoutdetail.cpp | 27 ++++++++++++++++------ src/libs/vlayout/vlayoutdetail.h | 2 +- 4 files changed, 38 insertions(+), 30 deletions(-) diff --git a/src/app/geometry/vdetail.cpp b/src/app/geometry/vdetail.cpp index 7f58c3c9d..bfe8374c6 100644 --- a/src/app/geometry/vdetail.cpp +++ b/src/app/geometry/vdetail.cpp @@ -395,6 +395,11 @@ QVector VDetail::ContourPoints(const VContainer *data) const QVector VDetail::SeamAllowancePoints(const VContainer *data) const { QVector pointsEkv; + if (getSeamAllowance() == false) + { + return pointsEkv; + } + for (int i = 0; i< CountNode(); ++i) { switch (at(i).getTypeTool()) @@ -402,13 +407,10 @@ QVector VDetail::SeamAllowancePoints(const VContainer *data) const case (Tool::NodePoint): { const QSharedPointer point = data->GeometricObject(at(i).getId()); - if (getSeamAllowance() == true) - { - QPointF pEkv = point->toQPointF(); - pEkv.setX(pEkv.x()+at(i).getMx()); - pEkv.setY(pEkv.y()+at(i).getMy()); - pointsEkv.append(pEkv); - } + QPointF pEkv = point->toQPointF(); + pEkv.setX(pEkv.x()+at(i).getMx()); + pEkv.setY(pEkv.y()+at(i).getMy()); + pointsEkv.append(pEkv); } break; case (Tool::NodeArc): @@ -421,10 +423,7 @@ QVector VDetail::SeamAllowancePoints(const VContainer *data) const const QPointF end = EndSegment(data, i); QVector nodePoints = curve->GetSegmentPoints(begin, end, at(i).getReverse()); - if (getSeamAllowance() == true) - { - pointsEkv << biasPoints(nodePoints, at(i).getMx(), at(i).getMy()); - } + pointsEkv << biasPoints(nodePoints, at(i).getMx(), at(i).getMy()); } break; default: @@ -433,16 +432,13 @@ QVector VDetail::SeamAllowancePoints(const VContainer *data) const } } - if (getSeamAllowance() == true) + if (getClosed() == true) { - if (getClosed() == true) - { - pointsEkv = Equidistant(pointsEkv, EquidistantType::CloseEquidistant, qApp->toPixel(getWidth())); - } - else - { - pointsEkv = Equidistant(pointsEkv, EquidistantType::OpenEquidistant, qApp->toPixel(getWidth())); - } + pointsEkv = Equidistant(pointsEkv, EquidistantType::CloseEquidistant, qApp->toPixel(getWidth())); + } + else + { + pointsEkv = Equidistant(pointsEkv, EquidistantType::OpenEquidistant, qApp->toPixel(getWidth())); } return pointsEkv; } diff --git a/src/app/mainwindow.cpp b/src/app/mainwindow.cpp index ee837e22e..ad820ff58 100644 --- a/src/app/mainwindow.cpp +++ b/src/app/mainwindow.cpp @@ -1906,8 +1906,7 @@ void MainWindow::ActionLayout(bool checked) idetail.next(); VLayoutDetail det = VLayoutDetail(); det.SetCountourPoints(idetail.value().ContourPoints(pattern)); - det.SetSeamAllowencePoints(idetail.value().SeamAllowancePoints(pattern)); - det.setSeamAllowance(idetail.value().getSeamAllowance()); + det.SetSeamAllowencePoints(idetail.value().SeamAllowancePoints(pattern), idetail.value().getSeamAllowance()); det.setName(idetail.value().getName()); det.setWidth(qApp->toPixel(idetail.value().getWidth())); diff --git a/src/libs/vlayout/vlayoutdetail.cpp b/src/libs/vlayout/vlayoutdetail.cpp index b0d249425..a94d48d5f 100644 --- a/src/libs/vlayout/vlayoutdetail.cpp +++ b/src/libs/vlayout/vlayoutdetail.cpp @@ -32,6 +32,7 @@ #include #include #include +#include //--------------------------------------------------------------------------------------------------------------------- VLayoutDetail::VLayoutDetail() @@ -85,16 +86,28 @@ QVector VLayoutDetail::GetSeamAllowencePoints() const } //--------------------------------------------------------------------------------------------------------------------- -void VLayoutDetail::SetSeamAllowencePoints(const QVector &points) +void VLayoutDetail::SetSeamAllowencePoints(const QVector &points, bool seamAllowence) { - d->seamAllowence = points; - // Seam allowence can't be closed - if (d->seamAllowence.first() == d->seamAllowence.last()) + if (seamAllowence) { - d->seamAllowence.removeLast(); - } + setSeamAllowance(seamAllowence); + d->seamAllowence = points; + if (not d->seamAllowence.isEmpty()) + { + // Seam allowence can't be closed + if (d->seamAllowence.first() == d->seamAllowence.last()) + { + d->seamAllowence.removeLast(); + } - d->seamAllowence = RemoveDublicates(RoundPoints(d->seamAllowence)); + d->seamAllowence = RemoveDublicates(RoundPoints(d->seamAllowence)); + } + else + { + qWarning()<<"Seam allowence is empty."; + setSeamAllowance(false); + } + } } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vlayout/vlayoutdetail.h b/src/libs/vlayout/vlayoutdetail.h index 591cf12cd..b53522bbf 100644 --- a/src/libs/vlayout/vlayoutdetail.h +++ b/src/libs/vlayout/vlayoutdetail.h @@ -49,7 +49,7 @@ public: void SetCountourPoints(const QVector &points); QVector GetSeamAllowencePoints() const; - void SetSeamAllowencePoints(const QVector &points); + void SetSeamAllowencePoints(const QVector &points, bool seamAllowence = true); QVector GetLayoutAllowencePoints() const; void SetLayoutAllowencePoints();