From cea723cbffbddc8dcfa7a5f8ec1c785fdb434a92 Mon Sep 17 00:00:00 2001 From: Simon Giraudot Date: Tue, 13 Mar 2018 12:57:39 +0100 Subject: [PATCH] Add sequential qprogressdialog --- .../include/run_with_qprogressdialog.h | 51 +++++++++++++------ 1 file changed, 35 insertions(+), 16 deletions(-) diff --git a/Polyhedron/demo/Polyhedron/include/run_with_qprogressdialog.h b/Polyhedron/demo/Polyhedron/include/run_with_qprogressdialog.h index 801f52fc3f1..9c43f6db14c 100644 --- a/Polyhedron/demo/Polyhedron/include/run_with_qprogressdialog.h +++ b/Polyhedron/demo/Polyhedron/include/run_with_qprogressdialog.h @@ -2,16 +2,22 @@ #define RUN_WITH_QPROGRESSDIALOG_H #include +#include + +#include #include "Callback_signaler.h" #ifdef CGAL_LINKED_WITH_TBB -#ifndef TBB_IMPLEMENT_CPP0X -#define TBB_IMPLEMENT_CPP0X 1 -#endif -#include + typedef CGAL::Parallel_tag Concurrency_tag; +# undef TBB_IMPLEMENT_CPP0X +# define TBB_IMPLEMENT_CPP0X 1 +# include +#else + typedef CGAL::Sequential_tag Concurrency_tag; #endif + class Signal_callback { public: @@ -89,6 +95,14 @@ public: template +void run_with_qprogressdialog (Functor& functor, + const char* title, + QWidget* mainWindow) +{ + return run_with_qprogressdialog (functor, title, mainWindow); +} + +template void run_with_qprogressdialog (Functor& functor, const char* title, QWidget* mainWindow) @@ -108,20 +122,25 @@ void run_with_qprogressdialog (Functor& functor, signal_callback->signaler.get(), SLOT(cancel())); #ifdef CGAL_LINKED_WITH_TBB - std::thread thread (functor); - - while (*signal_callback->latest_adv != 1. && - *signal_callback->state) + if (boost::is_convertible::value) { - QThread::msleep(10); - QApplication::processEvents (); - } + std::thread thread (functor); + + while (*signal_callback->latest_adv != 1. && + *signal_callback->state) + { + QThread::msleep(10); + QApplication::processEvents (); + } - thread.join(); -#else // Sequential version - progress.setWindowModality(Qt::WindowModal); - functor(); -#endif + thread.join(); + } + else +#endif // Sequential version + { + progress.setWindowModality(Qt::WindowModal); + functor(); + } mainWindow->setEnabled(true); }