diff --git a/src/slic3r/GUI/Jobs/ArrangeJob.cpp b/src/slic3r/GUI/Jobs/ArrangeJob.cpp index b076b1657..3a5a86d88 100644 --- a/src/slic3r/GUI/Jobs/ArrangeJob.cpp +++ b/src/slic3r/GUI/Jobs/ArrangeJob.cpp @@ -614,121 +614,124 @@ static std::string concat_strings(const std::set &strings, void ArrangeJob::finalize() { // Ignore the arrange result if aborted. - if (was_canceled()) return; + if (!was_canceled()) { - // Unprintable items go to the last virtual bed - int beds = 0; + // Unprintable items go to the last virtual bed + int beds = 0; - //BBS: partplate - PartPlateList& plate_list = m_plater->get_partplate_list(); - //clear all the relations before apply the arrangement results - if (only_on_partplate) { - plate_list.clear(false, false, true, current_plate_index); - } - else - plate_list.clear(false, false, true, -1); - //BBS: adjust the bed_index, create new plates, get the max bed_index - for (ArrangePolygon& ap : m_selected) { - //if (ap.bed_idx < 0) continue; // bed_idx<0 means unarrangable - //BBS: partplate postprocess - if (only_on_partplate) - plate_list.postprocess_bed_index_for_current_plate(ap); + //BBS: partplate + PartPlateList& plate_list = m_plater->get_partplate_list(); + //clear all the relations before apply the arrangement results + if (only_on_partplate) { + plate_list.clear(false, false, true, current_plate_index); + } else - plate_list.postprocess_bed_index_for_selected(ap); + plate_list.clear(false, false, true, -1); + //BBS: adjust the bed_index, create new plates, get the max bed_index + for (ArrangePolygon& ap : m_selected) { + //if (ap.bed_idx < 0) continue; // bed_idx<0 means unarrangable + //BBS: partplate postprocess + if (only_on_partplate) + plate_list.postprocess_bed_index_for_current_plate(ap); + else + plate_list.postprocess_bed_index_for_selected(ap); - beds = std::max(ap.bed_idx, beds); + beds = std::max(ap.bed_idx, beds); - BOOST_LOG_TRIVIAL(debug) << __FUNCTION__ << boost::format(": arrange selected %4%: bed_id %1%, trans {%2%,%3%}") % ap.bed_idx % unscale(ap.translation(X)) % unscale(ap.translation(Y)) % ap.name; - } + BOOST_LOG_TRIVIAL(debug) << __FUNCTION__ << boost::format(": arrange selected %4%: bed_id %1%, trans {%2%,%3%}") % ap.bed_idx % unscale(ap.translation(X)) % unscale(ap.translation(Y)) % ap.name; + } - //BBS: adjust the bed_index, create new plates, get the max bed_index - for (ArrangePolygon& ap : m_unselected) - { - if (ap.is_virt_object) - continue; + //BBS: adjust the bed_index, create new plates, get the max bed_index + for (ArrangePolygon& ap : m_unselected) { + if (ap.is_virt_object) + continue; - //BBS: partplate postprocess - if (!only_on_partplate) - plate_list.postprocess_bed_index_for_unselected(ap); + //BBS: partplate postprocess + if (!only_on_partplate) + plate_list.postprocess_bed_index_for_unselected(ap); - beds = std::max(ap.bed_idx, beds); - BOOST_LOG_TRIVIAL(debug) << __FUNCTION__ << boost::format(":arrange unselected %4%: bed_id %1%, trans {%2%,%3%}") % ap.bed_idx % unscale(ap.translation(X)) % unscale(ap.translation(Y)) % ap.name; - } + beds = std::max(ap.bed_idx, beds); + BOOST_LOG_TRIVIAL(debug) << __FUNCTION__ << boost::format(":arrange unselected %4%: bed_id %1%, trans {%2%,%3%}") % ap.bed_idx % unscale(ap.translation(X)) % unscale(ap.translation(Y)) % ap.name; + } - for (ArrangePolygon& ap : m_locked) { - beds = std::max(ap.bed_idx, beds); + for (ArrangePolygon& ap : m_locked) { + beds = std::max(ap.bed_idx, beds); - plate_list.postprocess_arrange_polygon(ap, false); + plate_list.postprocess_arrange_polygon(ap, false); - ap.apply(); - } + ap.apply(); + } - // Apply the arrange result to all selected objects - for (ArrangePolygon& ap : m_selected) { - //BBS: partplate postprocess - plate_list.postprocess_arrange_polygon(ap, true); + // Apply the arrange result to all selected objects + for (ArrangePolygon& ap : m_selected) { + //BBS: partplate postprocess + plate_list.postprocess_arrange_polygon(ap, true); - ap.apply(); - } + ap.apply(); + } - // Apply the arrange result to unselected objects(due to the sukodu-style column changes, the position of unselected may also be modified) - for (ArrangePolygon& ap : m_unselected) - { - if (ap.is_virt_object) - continue; + // Apply the arrange result to unselected objects(due to the sukodu-style column changes, the position of unselected may also be modified) + for (ArrangePolygon& ap : m_unselected) { + if (ap.is_virt_object) + continue; - //BBS: partplate postprocess - plate_list.postprocess_arrange_polygon(ap, false); + //BBS: partplate postprocess + plate_list.postprocess_arrange_polygon(ap, false); - ap.apply(); - } + ap.apply(); + } - // Move the unprintable items to the last virtual bed. - // Note ap.apply() moves relatively according to bed_idx, so we need to subtract the orignal bed_idx - for (ArrangePolygon& ap : m_unprintable) { - ap.bed_idx = beds + 1; - plate_list.postprocess_arrange_polygon(ap, true); + // Move the unprintable items to the last virtual bed. + // Note ap.apply() moves relatively according to bed_idx, so we need to subtract the orignal bed_idx + for (ArrangePolygon& ap : m_unprintable) { + ap.bed_idx = beds + 1; + plate_list.postprocess_arrange_polygon(ap, true); - ap.apply(); - BOOST_LOG_TRIVIAL(debug) << __FUNCTION__ << boost::format(":arrange m_unprintable: name: %4%, bed_id %1%, trans {%2%,%3%}") % ap.bed_idx % unscale(ap.translation(X)) % unscale(ap.translation(Y)) % ap.name; - } + ap.apply(); + BOOST_LOG_TRIVIAL(debug) << __FUNCTION__ << boost::format(":arrange m_unprintable: name: %4%, bed_id %1%, trans {%2%,%3%}") % ap.bed_idx % unscale(ap.translation(X)) % unscale(ap.translation(Y)) % ap.name; + } - m_plater->update(); - // BBS - //wxGetApp().obj_manipul()->set_dirty(); + m_plater->update(); + // BBS + //wxGetApp().obj_manipul()->set_dirty(); - if (!m_unarranged.empty()) { - std::set names; - for (ModelInstance *mi : m_unarranged) - names.insert(mi->get_object()->name); + if (!m_unarranged.empty()) { + std::set names; + for (ModelInstance* mi : m_unarranged) + names.insert(mi->get_object()->name); - m_plater->get_notification_manager()->push_notification(GUI::format( - _L("Arrangement ignored the following objects which can't fit into a single bed:\n%s"), - concat_strings(names, "\n"))); - } - m_plater->get_notification_manager()->close_notification_of_type(NotificationType::ArrangeOngoing); + m_plater->get_notification_manager()->push_notification(GUI::format( + _L("Arrangement ignored the following objects which can't fit into a single bed:\n%s"), + concat_strings(names, "\n"))); + } - // unlock the plates we just locked - for (int i : m_uncompatible_plates) { - PartPlate* plate = plate_list.get_plate(i); - if (plate) plate->lock(false); - } + // unlock the plates we just locked + for (int i : m_uncompatible_plates) { + PartPlate* plate = plate_list.get_plate(i); + if (plate) plate->lock(false); + } - //BBS: reload all objects due to arrange - if (only_on_partplate) { - plate_list.rebuild_plates_after_arrangement(!only_on_partplate, true, current_plate_index); + //BBS: reload all objects due to arrange + if (only_on_partplate) { + plate_list.rebuild_plates_after_arrangement(!only_on_partplate, true, current_plate_index); + } + else { + plate_list.rebuild_plates_after_arrangement(!only_on_partplate, true); + } + + // BBS: update slice context and gcode result. + m_plater->update_slicing_context_to_current_partplate(); + + wxGetApp().obj_list()->reload_all_plates(); + + m_plater->update(); + m_plater->get_notification_manager()->push_notification(NotificationType::ArrangeOngoing, + NotificationManager::NotificationLevel::RegularNotificationLevel, _u8L("Arranging done.")); } else { - plate_list.rebuild_plates_after_arrangement(!only_on_partplate, true); + m_plater->get_notification_manager()->push_notification(NotificationType::ArrangeOngoing, + NotificationManager::NotificationLevel::RegularNotificationLevel, _u8L("Arranging canceled.")); } - - // BBS: update slice context and gcode result. - m_plater->update_slicing_context_to_current_partplate(); - - wxGetApp().obj_list()->reload_all_plates(); - - m_plater->update(); - Job::finalize(); m_plater->m_arrange_running.store(false); } diff --git a/src/slic3r/GUI/Jobs/OrientJob.cpp b/src/slic3r/GUI/Jobs/OrientJob.cpp index c750a509a..98a1891d4 100644 --- a/src/slic3r/GUI/Jobs/OrientJob.cpp +++ b/src/slic3r/GUI/Jobs/OrientJob.cpp @@ -202,19 +202,15 @@ void OrientJob::process() void OrientJob::finalize() { // Ignore the arrange result if aborted. - if (was_canceled()) return; + if (!was_canceled()) { + for (OrientMesh& mesh : m_selected) { + mesh.apply(); + } + m_plater->update(); - for (OrientMesh& mesh : m_selected) - { - mesh.apply(); + // BBS + //wxGetApp().obj_manipul()->set_dirty(); } - - - m_plater->update(); - - // BBS - //wxGetApp().obj_manipul()->set_dirty(); - Job::finalize(); }