From dd098506dd68b3821577e3d7fb147325eddc179f Mon Sep 17 00:00:00 2001 From: dismine Date: Thu, 22 Jan 2015 13:47:20 +0200 Subject: [PATCH] Move rotation to separate method. Preparetion for working with new setting. --HG-- branch : feature --- src/libs/vlayout/vposition.cpp | 56 +++++++++++++++++++--------------- src/libs/vlayout/vposition.h | 2 ++ 2 files changed, 33 insertions(+), 25 deletions(-) diff --git a/src/libs/vlayout/vposition.cpp b/src/libs/vlayout/vposition.cpp index 5d2dfda2a..cf8a2e685 100644 --- a/src/libs/vlayout/vposition.cpp +++ b/src/libs/vlayout/vposition.cpp @@ -69,31 +69,7 @@ void VPosition::run() } frame = frame + 3; - for (int angle = 0; angle <= 360; angle = angle+180) - { - if (*stop) - { - return; - } - - QCoreApplication::processEvents(); - - // We should use copy of the detail. - VLayoutDetail workDetail = detail; - - if (CheckRotationEdges(workDetail, j, i, angle)) - { - #ifdef LAYOUT_DEBUG - # ifdef SHOW_CANDIDATE_BEST - ++frame; - DrawDebug(gContour, workDetail, frame, paperIndex, detailsCount, details); - # endif - #endif - - SaveCandidate(bestResult, workDetail, j, i, BestFrom::Rotation); - } - ++frame; - } + Rotate(180); } //--------------------------------------------------------------------------------------------------------------------- @@ -607,6 +583,36 @@ QVector VPosition::CutEdge(const QLineF &edge, unsigned int shift) return points; } +//--------------------------------------------------------------------------------------------------------------------- +void VPosition::Rotate(int increase) +{ + for (int angle = 0; angle <= 360; angle = angle+increase) + { + if (*stop) + { + return; + } + + QCoreApplication::processEvents(); + + // We should use copy of the detail. + VLayoutDetail workDetail = detail; + + if (CheckRotationEdges(workDetail, j, i, angle)) + { + #ifdef LAYOUT_DEBUG + # ifdef SHOW_CANDIDATE_BEST + ++frame; + DrawDebug(gContour, workDetail, frame, paperIndex, detailsCount, details); + # endif + #endif + + SaveCandidate(bestResult, workDetail, j, i, BestFrom::Rotation); + } + ++frame; + } +} + //--------------------------------------------------------------------------------------------------------------------- bool VPosition::TrueIntersection(const QLineF &gEdge, const QLineF &dEdge, const QPointF &p) const { diff --git a/src/libs/vlayout/vposition.h b/src/libs/vlayout/vposition.h index 4c18167bb..833fdccc0 100644 --- a/src/libs/vlayout/vposition.h +++ b/src/libs/vlayout/vposition.h @@ -119,6 +119,8 @@ private: static void AppendWhole(QVector &contour, const VLayoutDetail &detail, int detJ, unsigned int shift); static QVector CutEdge(const QLineF &edge, unsigned int shift); + + void Rotate(int increase); }; #endif // VPOSITION_H