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> pointsEkv;
if (getSeamAllowance() == false)
{
return pointsEkv;
}
for (int i = 0; i< CountNode(); ++i)
{
switch (at(i).getTypeTool())
@ -402,13 +407,10 @@ QVector<QPointF> VDetail::SeamAllowancePoints(const VContainer *data) const
case (Tool::NodePoint):
{
const QSharedPointer<VPointF> point = data->GeometricObject<VPointF>(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<QPointF> VDetail::SeamAllowancePoints(const VContainer *data) const
const QPointF end = EndSegment(data, i);
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;
default:
@ -433,16 +432,13 @@ 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()));
}
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;
}

View File

@ -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()));

View File

@ -32,6 +32,7 @@
#include <QGraphicsItem>
#include <QPainterPath>
#include <QtMath>
#include <QDebug>
//---------------------------------------------------------------------------------------------------------------------
VLayoutDetail::VLayoutDetail()
@ -85,16 +86,28 @@ QVector<QPointF> VLayoutDetail::GetSeamAllowencePoints() const
}
//---------------------------------------------------------------------------------------------------------------------
void VLayoutDetail::SetSeamAllowencePoints(const QVector<QPointF> &points)
void VLayoutDetail::SetSeamAllowencePoints(const QVector<QPointF> &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);
}
}
}
//---------------------------------------------------------------------------------------------------------------------

View File

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