Refactoring.

--HG--
branch : feature
This commit is contained in:
dismine 2015-01-21 16:33:06 +02:00
parent dac95d00fe
commit 8655460d6e
2 changed files with 1 additions and 77 deletions

View File

@ -232,15 +232,8 @@ bool VLayoutPaper::ArrangeDetail(const VLayoutDetail &detail, bool &stop)
d->frame = 0;
if (Count() == 0)
{
return AddToBlankSheet(detail, stop);
}
else
{
return AddToSheet(detail, stop);
}
}
//---------------------------------------------------------------------------------------------------------------------
int VLayoutPaper::Count() const
@ -248,74 +241,6 @@ int VLayoutPaper::Count() const
return d->details.count();
}
//---------------------------------------------------------------------------------------------------------------------
bool VLayoutPaper::AddToBlankSheet(const VLayoutDetail &detail, bool &stop)
{
BestResult bestResult;
for (int j=1; j <= EdgesCount(); ++j)
{
for (int i=1; i<= detail.EdgesCount(); i++)
{
QCoreApplication::processEvents();
if (stop)
{
return false;
}
// We should use copy of the detail.
VLayoutDetail workDetail = detail;
int dEdge = i;// For mirrored detail edge will be different
if (CheckCombineEdges(workDetail, j, dEdge))
{
#ifdef LAYOUT_DEBUG
# ifdef SHOW_CANDIDATE_BEST
DrawDebug(workDetail, d->frame+2);
# endif
#endif
const QRectF rec = workDetail.BoundingRect();
bestResult.NewResult(static_cast<qint64>(rec.width()*rec.height()), j, dEdge,
workDetail.GetMatrix(), workDetail.IsMirror(), BestFrom::Combine);
}
d->frame = d->frame + 3;
for (int angle = 0; angle <= 360; angle = angle+20)
{
QCoreApplication::processEvents();
if (stop)
{
return false;
}
// We should use copy of the detail.
VLayoutDetail workDetail = detail;
if (CheckRotationEdges(workDetail, j, i, angle))
{
#ifdef LAYOUT_DEBUG
# ifdef SHOW_CANDIDATE_BEST
++d->frame;
DrawDebug(workDetail, d->frame);
# endif
#endif
const QRectF rec = workDetail.BoundingRect();
bestResult.NewResult(static_cast<qint64>(rec.width()*rec.height()), j, i,
workDetail.GetMatrix(), workDetail.IsMirror(), BestFrom::Rotation);
}
++d->frame;
}
}
}
return SaveResult(bestResult, detail);
}
//---------------------------------------------------------------------------------------------------------------------
bool VLayoutPaper::AddToSheet(const VLayoutDetail &detail, bool &stop)
{

View File

@ -85,7 +85,6 @@ private:
EdgeError = 2
};
bool AddToBlankSheet(const VLayoutDetail &detail, bool &stop);
bool AddToSheet(const VLayoutDetail &detail, bool &stop);
bool CheckCombineEdges(VLayoutDetail &detail, int j, int &dEdge) const;