Bad API in class LayoutDetail. Fixed checking seam allowence points.

--HG--
branch : release
This commit is contained in:
Roman Telezhynskyi 2015-03-14 14:38:44 +02:00
parent d287e63790
commit 2b711c5f8f
4 changed files with 38 additions and 30 deletions

View File

@ -395,6 +395,11 @@ QVector<QPointF> VDetail::ContourPoints(const VContainer *data) const
QVector<QPointF> VDetail::SeamAllowancePoints(const VContainer *data) const QVector<QPointF> VDetail::SeamAllowancePoints(const VContainer *data) const
{ {
QVector<QPointF> pointsEkv; QVector<QPointF> pointsEkv;
if (getSeamAllowance() == false)
{
return pointsEkv;
}
for (int i = 0; i< CountNode(); ++i) for (int i = 0; i< CountNode(); ++i)
{ {
switch (at(i).getTypeTool()) switch (at(i).getTypeTool())
@ -402,14 +407,11 @@ QVector<QPointF> VDetail::SeamAllowancePoints(const VContainer *data) const
case (Tool::NodePoint): case (Tool::NodePoint):
{ {
const QSharedPointer<VPointF> point = data->GeometricObject<VPointF>(at(i).getId()); const QSharedPointer<VPointF> point = data->GeometricObject<VPointF>(at(i).getId());
if (getSeamAllowance() == true)
{
QPointF pEkv = point->toQPointF(); QPointF pEkv = point->toQPointF();
pEkv.setX(pEkv.x()+at(i).getMx()); pEkv.setX(pEkv.x()+at(i).getMx());
pEkv.setY(pEkv.y()+at(i).getMy()); pEkv.setY(pEkv.y()+at(i).getMy());
pointsEkv.append(pEkv); pointsEkv.append(pEkv);
} }
}
break; break;
case (Tool::NodeArc): case (Tool::NodeArc):
case (Tool::NodeSpline): case (Tool::NodeSpline):
@ -421,11 +423,8 @@ QVector<QPointF> VDetail::SeamAllowancePoints(const VContainer *data) const
const QPointF end = EndSegment(data, i); const QPointF end = EndSegment(data, i);
QVector<QPointF> nodePoints = curve->GetSegmentPoints(begin, end, at(i).getReverse()); QVector<QPointF> 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; break;
default: default:
qDebug()<<"Get wrong tool type. Ignore."<< static_cast<char>(at(i).getTypeTool()); qDebug()<<"Get wrong tool type. Ignore."<< static_cast<char>(at(i).getTypeTool());
@ -433,8 +432,6 @@ QVector<QPointF> VDetail::SeamAllowancePoints(const VContainer *data) const
} }
} }
if (getSeamAllowance() == true)
{
if (getClosed() == true) if (getClosed() == true)
{ {
pointsEkv = Equidistant(pointsEkv, EquidistantType::CloseEquidistant, qApp->toPixel(getWidth())); pointsEkv = Equidistant(pointsEkv, EquidistantType::CloseEquidistant, qApp->toPixel(getWidth()));
@ -443,7 +440,6 @@ QVector<QPointF> VDetail::SeamAllowancePoints(const VContainer *data) const
{ {
pointsEkv = Equidistant(pointsEkv, EquidistantType::OpenEquidistant, qApp->toPixel(getWidth())); pointsEkv = Equidistant(pointsEkv, EquidistantType::OpenEquidistant, qApp->toPixel(getWidth()));
} }
}
return pointsEkv; return pointsEkv;
} }

View File

@ -1906,8 +1906,7 @@ void MainWindow::ActionLayout(bool checked)
idetail.next(); idetail.next();
VLayoutDetail det = VLayoutDetail(); VLayoutDetail det = VLayoutDetail();
det.SetCountourPoints(idetail.value().ContourPoints(pattern)); det.SetCountourPoints(idetail.value().ContourPoints(pattern));
det.SetSeamAllowencePoints(idetail.value().SeamAllowancePoints(pattern)); det.SetSeamAllowencePoints(idetail.value().SeamAllowancePoints(pattern), idetail.value().getSeamAllowance());
det.setSeamAllowance(idetail.value().getSeamAllowance());
det.setName(idetail.value().getName()); det.setName(idetail.value().getName());
det.setWidth(qApp->toPixel(idetail.value().getWidth())); det.setWidth(qApp->toPixel(idetail.value().getWidth()));

View File

@ -32,6 +32,7 @@
#include <QGraphicsItem> #include <QGraphicsItem>
#include <QPainterPath> #include <QPainterPath>
#include <QtMath> #include <QtMath>
#include <QDebug>
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VLayoutDetail::VLayoutDetail() VLayoutDetail::VLayoutDetail()
@ -85,9 +86,14 @@ QVector<QPointF> VLayoutDetail::GetSeamAllowencePoints() const
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VLayoutDetail::SetSeamAllowencePoints(const QVector<QPointF> &points) void VLayoutDetail::SetSeamAllowencePoints(const QVector<QPointF> &points, bool seamAllowence)
{ {
if (seamAllowence)
{
setSeamAllowance(seamAllowence);
d->seamAllowence = points; d->seamAllowence = points;
if (not d->seamAllowence.isEmpty())
{
// Seam allowence can't be closed // Seam allowence can't be closed
if (d->seamAllowence.first() == d->seamAllowence.last()) if (d->seamAllowence.first() == d->seamAllowence.last())
{ {
@ -95,6 +101,13 @@ void VLayoutDetail::SetSeamAllowencePoints(const QVector<QPointF> &points)
} }
d->seamAllowence = RemoveDublicates(RoundPoints(d->seamAllowence)); d->seamAllowence = RemoveDublicates(RoundPoints(d->seamAllowence));
}
else
{
qWarning()<<"Seam allowence is empty.";
setSeamAllowance(false);
}
}
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -49,7 +49,7 @@ public:
void SetCountourPoints(const QVector<QPointF> &points); void SetCountourPoints(const QVector<QPointF> &points);
QVector<QPointF> GetSeamAllowencePoints() const; QVector<QPointF> GetSeamAllowencePoints() const;
void SetSeamAllowencePoints(const QVector<QPointF> &points); void SetSeamAllowencePoints(const QVector<QPointF> &points, bool seamAllowence = true);
QVector<QPointF> GetLayoutAllowencePoints() const; QVector<QPointF> GetLayoutAllowencePoints() const;
void SetLayoutAllowencePoints(); void SetLayoutAllowencePoints();