diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index 35b072198c..c574d053e5 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -1905,6 +1905,9 @@ void GCode::_do_export(Print& print_mod, GCodeOutputStream &file, ThumbnailsGene this->m_throw_if_canceled(); // Collect custom seam data from all objects. + print.set_status(0, L("Computing seam visibility areas: object %s / %s"), + {"1", std::to_string(print.objects().size())}, + PrintBase::SlicingStatus::FORCE_SHOW | PrintBase::SlicingStatus::SECONDARY_STATE); m_seam_placer.init(print, this->m_throw_if_canceled); //activate first extruder is multi-extruder and not in start-gcode @@ -3073,6 +3076,22 @@ LayerResult GCode::process_layer( // Nothing to extrude. return result; + if (object_layer) { + if (single_object_instance_idx != size_t(-1)) { + size_t nb_layers = object_layer->object()->layer_count(); + m_object_sequentially_printed.insert(object_layer->object()); + print.set_status(int((layer.id() * 100) / nb_layers), + std::string(L("Generating G-code layer %s / %s for object %s / %s")), + std::vector{std::to_string(layer.id()), std::to_string(nb_layers), m_object_sequentially_printed.size(), print.num_object_instances()}, + PrintBase::SlicingStatus::DEFAULT | PrintBase::SlicingStatus::SECONDARY_STATE); + } else { + print.set_status(int((layer.id() * 100) / layer_count()), + std::string(L("Generating G-code layer %s / %s")), + std::vector{std::to_string(layer.id()), std::to_string(layer_count())}, + PrintBase::SlicingStatus::DEFAULT | PrintBase::SlicingStatus::SECONDARY_STATE); + } + } + // Extract 1st object_layer and support_layer of this set of layers with an equal print_z. coordf_t print_z = layer.print_z; bool first_layer = layer_id == 0; @@ -3764,9 +3783,6 @@ LayerResult GCode::process_layer( BOOST_LOG_TRIVIAL(trace) << "Exported layer " << layer.id() << " print_z " << print_z << log_memory_info(); - if(object_layer) - print.set_status(int((layer.id() * 100) / layer_count()), std::string(L("Generating G-code layer %s / %s")), std::vector{ std::to_string(layer.id()), std::to_string(layer_count()) }, PrintBase::SlicingStatus::DEFAULT | PrintBase::SlicingStatus::SECONDARY_STATE); - result.gcode = std::move(gcode); result.cooling_buffer_flush = object_layer || raft_layer || last_layer; return result; diff --git a/src/libslic3r/GCode.hpp b/src/libslic3r/GCode.hpp index 89f7052015..2ff9d345c5 100644 --- a/src/libslic3r/GCode.hpp +++ b/src/libslic3r/GCode.hpp @@ -436,6 +436,8 @@ class GCode : ExtrusionVisitorConst { std::string m_delayed_layer_change; // Keeps track of the last extrusion role passed to the processor ExtrusionRole m_last_processor_extrusion_role; + // For Progress bar indicator, in sequential mode (complete objects) + std::set m_object_sequentially_printed; // How many times will change_layer() be called? // change_layer() will update the progress bar. uint32_t m_layer_count; diff --git a/src/libslic3r/GCode/SeamPlacer.cpp b/src/libslic3r/GCode/SeamPlacer.cpp index 5ec022a55e..98d97418c0 100644 --- a/src/libslic3r/GCode/SeamPlacer.cpp +++ b/src/libslic3r/GCode/SeamPlacer.cpp @@ -1653,7 +1653,12 @@ void SeamPlacer::init(const Print &print, std::function throw_if_can m_seam_per_object.clear(); this->external_perimeters_first = print.default_region_config().external_perimeters_first; - for (const PrintObject *po : print.objects()) { + for (size_t obj_idx = 0; obj_idx < print.objects().size(); ++ obj_idx) { + const PrintObject *po = print.objects()[obj_idx]; + print.set_status(int((obj_idx * 100) / print.objects().size()), + ("Computing seam visibility areas: object %s / %s"), + {std::to_string(obj_idx + 1), std::to_string(print.objects().size())}, + PrintBase::SlicingStatus::SECONDARY_STATE); throw_if_canceled_func(); SeamPosition configured_seam_preference = po->config().seam_position.value; SeamComparator comparator { configured_seam_preference, *po }; diff --git a/src/libslic3r/PrintBase.hpp b/src/libslic3r/PrintBase.hpp index 255cb0bf30..532865262c 100644 --- a/src/libslic3r/PrintBase.hpp +++ b/src/libslic3r/PrintBase.hpp @@ -420,7 +420,8 @@ class PrintBase : public ObjectBase SLICING_ENDED = 1 << 6, GCODE_ENDED = 1 << 7, MAIN_STATE = 1 << 8, - SECONDARY_STATE = 1 << 9 + SECONDARY_STATE = 1 << 9, + FORCE_SHOW = 1 << 10 }; // Bitmap of FlagBits unsigned int flags; @@ -443,7 +444,7 @@ class PrintBase : public ObjectBase } void set_status(int percent, const std::string& message, const std::vector& args, unsigned int flags = SlicingStatus::DEFAULT) const { //check if it need an update. Avoid doing a gui update each ms. - if ((flags & SlicingStatus::SECONDARY_STATE) != 0 && message != m_last_status_message) { + if ((flags & SlicingStatus::FORCE_SHOW) == 0 && (flags & SlicingStatus::SECONDARY_STATE) != 0 && message != m_last_status_message) { std::chrono::time_point current_time = std::chrono::system_clock::now(); if ((static_cast>(current_time - PrintBase::m_last_status_update)).count() > 0.002 && PrintBase::m_last_status_percent != percent) { PrintBase::m_last_status_update = current_time; diff --git a/src/libslic3r/PrintObject.cpp b/src/libslic3r/PrintObject.cpp index d981f8c9c9..aa2a7be1fd 100644 --- a/src/libslic3r/PrintObject.cpp +++ b/src/libslic3r/PrintObject.cpp @@ -155,7 +155,6 @@ namespace Slic3r { if (!region.config().extra_perimeters || region.config().perimeters == 0 || region.config().fill_density == 0 || this->layer_count() < 2) continue; // use an antomic idx instead of the range, to avoid a thread being very late because it's on the difficult layers. - //TODO: sort the layers by difficulty (difficult first) (number of points, region, surfaces, .. ?) std::atomic_size_t next_layer_idx(0); BOOST_LOG_TRIVIAL(debug) << "Generating extra perimeters for region " << region_id << " in parallel - start"; tbb::parallel_for( @@ -218,6 +217,8 @@ namespace Slic3r { } BOOST_LOG_TRIVIAL(debug) << "Generating perimeters in parallel - start"; + // use an antomic idx instead of the range, to avoid a thread being very late because it's on the difficult layers. + //TODO: sort the layers by difficulty (difficult first) (number of points, region, surfaces, .. ?) (and use parallel_for_each( list.begin(), list.end(), ApplyFoo() );) std::atomic_size_t next_layer_idx(0); tbb::parallel_for( tbb::blocked_range(0, m_layers.size()), @@ -281,6 +282,7 @@ namespace Slic3r { // Then the classifcation of $layerm->slices is transfered onto // the $layerm->fill_surfaces by clipping $layerm->fill_surfaces // by the cummulative area of the previous $layerm->fill_surfaces. + m_print->set_status( 0, L("Detect surfaces types"), {}, PrintBase::SlicingStatus::SECONDARY_STATE); this->detect_surfaces_type(); m_print->throw_if_canceled(); @@ -288,11 +290,17 @@ namespace Slic3r { // Here the stTop / stBottomBridge / stBottom infill is turned to just stInternal if zero top / bottom infill layers are configured. // Also tiny stInternal surfaces are turned to stInternalSolid. BOOST_LOG_TRIVIAL(info) << "Preparing fill surfaces..." << log_memory_info(); - for (auto* layer : m_layers) - for (auto* region : layer->m_regions) { + for (size_t layer_idx = 0; layer_idx < m_layers.size(); ++layer_idx) { + Layer *layer = m_layers[layer_idx]; + m_print->set_status(int(100 * layer_idx / m_layers.size()), + L("Prepare fill surfaces: layer %s / %s"), + {std::to_string(layer_idx), std::to_string(m_layers.size())}, + PrintBase::SlicingStatus::SECONDARY_STATE); + for (auto *region : layer->m_regions) { region->prepare_fill_surfaces(); m_print->throw_if_canceled(); } + } // solid_infill_below_area has just beeing applied at the end of prepare_fill_surfaces() apply_solid_infill_below_layer_area(); @@ -306,10 +314,12 @@ namespace Slic3r { // 3) Clip the internal surfaces by the grown top/bottom surfaces. // 4) Merge surfaces with the same style. This will mostly get rid of the overlaps. //FIXME This does not likely merge surfaces, which are supported by a material with different colors, but same properties. + m_print->set_status( 20, L("Process external surfaces"), {}, PrintBase::SlicingStatus::SECONDARY_STATE); this->process_external_surfaces(); m_print->throw_if_canceled(); // Add solid fills to ensure the shell vertical thickness. + m_print->set_status( 40, L("Discover shells"), {}, PrintBase::SlicingStatus::SECONDARY_STATE); this->discover_vertical_shells(); m_print->throw_if_canceled(); @@ -335,6 +345,7 @@ namespace Slic3r { m_print->throw_if_canceled(); //as there is some too thin solid surface, please deleted them and merge all of the surfacesthat are contigous. + m_print->set_status( 55, L("Clean surfaces"), {}, PrintBase::SlicingStatus::SECONDARY_STATE); this->clean_surfaces(); #ifdef SLIC3R_DEBUG_SLICE_PROCESSING @@ -353,6 +364,7 @@ namespace Slic3r { //FIXME The surfaces are supported by a sparse infill, but the sparse infill is only as large as the area to support. // Likely the sparse infill will not be anchored correctly, so it will not work as intended. // Also one wishes the perimeters to be supported by a full infill. + m_print->set_status( 70, L("Clip surfaces"), {}, PrintBase::SlicingStatus::SECONDARY_STATE); this->clip_fill_surfaces(); m_print->throw_if_canceled(); @@ -388,6 +400,7 @@ namespace Slic3r { m_print->throw_if_canceled(); // combine fill surfaces to honor the "infill every N layers" option + m_print->set_status( 85, L("Combine infill"), {}, PrintBase::SlicingStatus::SECONDARY_STATE); this->combine_infill(); m_print->throw_if_canceled(); @@ -462,6 +475,7 @@ namespace Slic3r { const int nb_layers_update = std::max(1, (int)m_layers.size() / 20); BOOST_LOG_TRIVIAL(debug) << "Filling layers in parallel - start"; + // use an antomic idx instead of the range, to avoid a thread being very late because it's on the difficult layers. std::atomic_size_t next_layer_idx(0); tbb::parallel_for( tbb::blocked_range(0, m_layers.size()),