From 0d1725fc11f57dccc3b16c12ffb0a3c7e35194b5 Mon Sep 17 00:00:00 2001 From: dismine Date: Thu, 22 Jan 2015 13:39:04 +0200 Subject: [PATCH] Allow user more quick stop generation. --HG-- branch : feature --- src/libs/vlayout/vlayoutpaper.cpp | 2 +- src/libs/vlayout/vposition.cpp | 14 ++++++++++++-- src/libs/vlayout/vposition.h | 3 ++- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/libs/vlayout/vlayoutpaper.cpp b/src/libs/vlayout/vlayoutpaper.cpp index da473714e..1574ee7b6 100644 --- a/src/libs/vlayout/vlayoutpaper.cpp +++ b/src/libs/vlayout/vlayoutpaper.cpp @@ -164,7 +164,7 @@ bool VLayoutPaper::AddToSheet(const VLayoutDetail &detail, bool &stop) { for (int i=1; i<= detail.EdgesCount(); i++) { - VPosition *thread = new VPosition(d->globalContour, j, detail, i); + VPosition *thread = new VPosition(d->globalContour, j, detail, i, &stop); //Info for debug #ifdef LAYOUT_DEBUG thread->setPaperIndex(d->paperIndex); diff --git a/src/libs/vlayout/vposition.cpp b/src/libs/vlayout/vposition.cpp index 20eca8269..5d2dfda2a 100644 --- a/src/libs/vlayout/vposition.cpp +++ b/src/libs/vlayout/vposition.cpp @@ -38,9 +38,9 @@ #include //--------------------------------------------------------------------------------------------------------------------- -VPosition::VPosition(const VContour &gContour, int j, const VLayoutDetail &detail, int i) +VPosition::VPosition(const VContour &gContour, int j, const VLayoutDetail &detail, int i, bool *stop) :QRunnable(), bestResult(VBestSquare()), gContour(gContour), detail(detail), i(i), j(j), paperIndex(0), frame(0), - detailsCount(0), details(QVector()) + detailsCount(0), details(QVector()), stop(stop) {} //--------------------------------------------------------------------------------------------------------------------- @@ -48,6 +48,11 @@ void VPosition::run() { QCoreApplication::processEvents(); + if (*stop) + { + return; + } + // We should use copy of the detail. VLayoutDetail workDetail = detail; @@ -66,6 +71,11 @@ void VPosition::run() for (int angle = 0; angle <= 360; angle = angle+180) { + if (*stop) + { + return; + } + QCoreApplication::processEvents(); // We should use copy of the detail. diff --git a/src/libs/vlayout/vposition.h b/src/libs/vlayout/vposition.h index d8b2edbe4..4c18167bb 100644 --- a/src/libs/vlayout/vposition.h +++ b/src/libs/vlayout/vposition.h @@ -46,7 +46,7 @@ class QPainterPath; class VPosition : public QRunnable { public: - VPosition(const VContour &gContour, int j, const VLayoutDetail &detail, int i); + VPosition(const VContour &gContour, int j, const VLayoutDetail &detail, int i, bool *stop); virtual ~VPosition(){} virtual void run(); @@ -78,6 +78,7 @@ private: quint32 frame; quint32 detailsCount; QVector details; + bool *stop; enum class CrossingType : char {