Allow user more quick stop generation.

--HG--
branch : feature
This commit is contained in:
dismine 2015-01-22 13:39:04 +02:00
parent d538f2af73
commit 0d1725fc11
3 changed files with 15 additions and 4 deletions

View File

@ -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);

View File

@ -38,9 +38,9 @@
#include <QCoreApplication>
//---------------------------------------------------------------------------------------------------------------------
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<VLayoutDetail>())
detailsCount(0), details(QVector<VLayoutDetail>()), 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.

View File

@ -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<VLayoutDetail> details;
bool *stop;
enum class CrossingType : char
{