From 8655460d6e2663e51e978fea3fec610efa8c5571 Mon Sep 17 00:00:00 2001 From: dismine Date: Wed, 21 Jan 2015 16:33:06 +0200 Subject: [PATCH] Refactoring. --HG-- branch : feature --- src/libs/vlayout/vlayoutpaper.cpp | 77 +------------------------------ src/libs/vlayout/vlayoutpaper.h | 1 - 2 files changed, 1 insertion(+), 77 deletions(-) diff --git a/src/libs/vlayout/vlayoutpaper.cpp b/src/libs/vlayout/vlayoutpaper.cpp index ac34a161c..987e001d4 100644 --- a/src/libs/vlayout/vlayoutpaper.cpp +++ b/src/libs/vlayout/vlayoutpaper.cpp @@ -232,14 +232,7 @@ bool VLayoutPaper::ArrangeDetail(const VLayoutDetail &detail, bool &stop) d->frame = 0; - if (Count() == 0) - { - return AddToBlankSheet(detail, stop); - } - else - { - return AddToSheet(detail, stop); - } + return AddToSheet(detail, stop); } //--------------------------------------------------------------------------------------------------------------------- @@ -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(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(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) { diff --git a/src/libs/vlayout/vlayoutpaper.h b/src/libs/vlayout/vlayoutpaper.h index 8401515a5..734363b64 100644 --- a/src/libs/vlayout/vlayoutpaper.h +++ b/src/libs/vlayout/vlayoutpaper.h @@ -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;