1
0
mirror of https://github.com/FULU-Foundation/OrcaSlicer-bambulab.git synced 2026-07-13 08:24:27 +00:00

Abort semantics added.

Signed-off-by: tamasmeszaros <meszaros.q@gmail.com>
This commit is contained in:
tamasmeszaros
2018-09-11 12:36:24 +02:00
parent 6e2ed48e5a
commit 6106ce9ff0
9 changed files with 74 additions and 35 deletions
+17 -6
View File
@@ -438,6 +438,11 @@ void AppController::arrange_model()
{
using Coord = libnest2d::TCoord<libnest2d::PointImpl>;
if(arranging_.load()) return;
// to prevent UI reentrancies
arranging_.store(true);
unsigned count = 0;
for(auto obj : model_->objects) count += obj->instances.size();
@@ -451,8 +456,8 @@ void AppController::arrange_model()
// Set the range of the progress to the object count
pind->max(count);
pind->on_cancel([](){
std::cout << "Cannot be cancelled!" << std::endl;
pind->on_cancel([this](){
arranging_.store(false);
});
}
@@ -478,10 +483,12 @@ void AppController::arrange_model()
bed,
hint,
false, // create many piles not just one pile
[pind, count](unsigned rem) {
[this, pind, count](unsigned rem) {
if(pind)
pind->update(count - rem, _(L("Arranging objects...")));
});
pind->update(count - rem, L("Arranging objects..."));
process_events();
}, [this] () { return !arranging_.load(); });
} catch(std::exception& e) {
std::cerr << e.what() << std::endl;
report_issue(IssueType::ERR,
@@ -493,9 +500,13 @@ void AppController::arrange_model()
// Restore previous max value
if(pind) {
pind->max(pmax);
pind->update(0, _(L("Arranging done.")));
pind->update(0, arranging_.load() ? L("Arranging done.") :
L("Arranging canceled."));
pind->on_cancel(/*remove cancel function*/);
}
arranging_.store(false);
}
}