Code that converts VPiece to VLayoutDetail moved to static function.

--HG--
branch : feature
This commit is contained in:
Roman Telezhynskyi 2017-01-22 10:32:01 +02:00
parent 26c76bbc71
commit 8fb6c9c508
3 changed files with 38 additions and 31 deletions

View file

@ -475,37 +475,7 @@ void MainWindowsNoGUI::PrepareDetailsForLayout(const QHash<quint32, VPiece> *det
QHash<quint32, VPiece>::const_iterator i = details->constBegin();
while (i != details->constEnd())
{
VLayoutDetail det = VLayoutDetail();
const VPiece d = i.value();
det.SetCountourPoints(d.MainPathPoints(pattern));
det.SetSeamAllowencePoints(d.SeamAllowancePoints(pattern), d.IsSeamAllowance(), false);
det.setName(d.GetName());
const VPatternPieceData& data = d.GetPatternPieceData();
if (data.IsVisible() == true)
{
det.SetDetail(d.GetName(), data, qApp->font());
}
const VPatternInfoGeometry& geom = d.GetPatternInfo();
if (geom.IsVisible() == true)
{
VAbstractPattern* pDoc = qApp->getCurrentDocument();
QDate date;
if (pDoc->IsDateVisible() == true)
{
date = QDate::currentDate();
}
det.SetPatternInfo(pDoc, geom, qApp->font(), pattern->size(), pattern->height());
}
const VGrainlineGeometry& grainlineGeom = d.GetGrainlineGeometry();
if (grainlineGeom.IsVisible() == true)
{
det.SetGrainline(grainlineGeom, *pattern);
}
det.setWidth(qApp->toPixel(d.GetSAWidth()));
det.CreateTextItems();
det.setForbidFlipping(d.IsForbidFlipping());
listDetails.append(det);
listDetails.append(VLayoutDetail::Create(i.value(), pattern));
++i;
}
}

View file

@ -83,6 +83,41 @@ VLayoutDetail &VLayoutDetail::operator=(const VLayoutDetail &detail)
VLayoutDetail::~VLayoutDetail()
{}
//---------------------------------------------------------------------------------------------------------------------
VLayoutDetail VLayoutDetail::Create(const VPiece &piece, const VContainer *pattern)
{
VLayoutDetail det = VLayoutDetail();
det.SetCountourPoints(piece.MainPathPoints(pattern));
det.SetSeamAllowencePoints(piece.SeamAllowancePoints(pattern), piece.IsSeamAllowance(), false);
det.setName(piece.GetName());
const VPatternPieceData& data = piece.GetPatternPieceData();
if (data.IsVisible() == true)
{
det.SetDetail(piece.GetName(), data, qApp->font());
}
const VPatternInfoGeometry& geom = piece.GetPatternInfo();
if (geom.IsVisible() == true)
{
VAbstractPattern* pDoc = qApp->getCurrentDocument();
QDate date;
if (pDoc->IsDateVisible() == true)
{
date = QDate::currentDate();
}
det.SetPatternInfo(pDoc, geom, qApp->font(), pattern->size(), pattern->height());
}
const VGrainlineGeometry& grainlineGeom = piece.GetGrainlineGeometry();
if (grainlineGeom.IsVisible() == true)
{
det.SetGrainline(grainlineGeom, *pattern);
}
det.setWidth(qApp->toPixel(piece.GetSAWidth()));
det.CreateTextItems();
det.setForbidFlipping(piece.IsForbidFlipping());
return det;
}
//---------------------------------------------------------------------------------------------------------------------
// cppcheck-suppress unusedFunction
QVector<QPointF> VLayoutDetail::GetContourPoints() const

View file

@ -68,6 +68,8 @@ public:
VLayoutDetail &operator=(const VLayoutDetail &detail);
virtual ~VLayoutDetail() Q_DECL_OVERRIDE;
static VLayoutDetail Create(const VPiece &piece, const VContainer *pattern);
QVector<QPointF> GetContourPoints() const;
void SetCountourPoints(const QVector<QPointF> &points);