diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index c0fcb63fc2..bd74e3e77e 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -3990,7 +3990,7 @@ void PrintConfigDef::init_sla_params() "Otherwise 'Above area fill parameters are used."); def->sidetext = L("%"); def->min = 0; - def->mode = comExpert; + def->mode = comAdvanced; def->set_default_value(new ConfigOptionFloat(35.)); def = this->add("relative_correction", coFloats); @@ -4515,7 +4515,7 @@ void PrintConfigDef::init_sla_tilt_params() def->sidetext = L("s"); def->min = 0; def->max = 30; - def->mode = comExpert; + def->mode = comAdvanced; def->set_default_value(new ConfigOptionFloats({ 3., 3.})); def = this->add("delay_after_exposure", coFloats); @@ -4524,7 +4524,7 @@ void PrintConfigDef::init_sla_tilt_params() def->sidetext = L("s"); def->min = 0; def->max = 30; - def->mode = comExpert; + def->mode = comAdvanced; def->set_default_value(new ConfigOptionFloats({ 0., 0.})); def = this->add("tower_hop_height", coInts); diff --git a/src/libslic3r/SLAPrint.hpp b/src/libslic3r/SLAPrint.hpp index 93d94b016c..aebfe7b8aa 100644 --- a/src/libslic3r/SLAPrint.hpp +++ b/src/libslic3r/SLAPrint.hpp @@ -406,6 +406,7 @@ struct SLAPrintStatistics { SLAPrintStatistics() { clear(); } double estimated_print_time; + double estimated_print_time_tolerance; double objects_used_material; double support_used_material; size_t slow_layers_count; @@ -424,6 +425,7 @@ struct SLAPrintStatistics void clear() { estimated_print_time = 0.; + estimated_print_time_tolerance = 0.; objects_used_material = 0.; support_used_material = 0.; slow_layers_count = 0; diff --git a/src/libslic3r/SLAPrintSteps.cpp b/src/libslic3r/SLAPrintSteps.cpp index dd6141faf8..420887bb28 100644 --- a/src/libslic3r/SLAPrintSteps.cpp +++ b/src/libslic3r/SLAPrintSteps.cpp @@ -1130,20 +1130,10 @@ void SLAPrint::Steps::merge_slices_and_eval_stats() { double supports_volume(0.0); double models_volume(0.0); - double estim_time(0.0); - std::vector> layers_times; // level and time - std::vector> layers_areas; // level and area - layers_times.reserve(printer_input.size()); - layers_areas.reserve(printer_input.size()); - - size_t slow_layers = 0; - size_t fast_layers = 0; + std::vector> layers_info; // time, area, is_fast, models_volume, supports_volume + layers_info.resize(printer_input.size()); const double delta_fade_time = (init_exp_time - exp_time) / (fade_layers_cnt + 1); - double fade_layer_time = init_exp_time; - - execution::SpinningMutex mutex; - using Lock = std::lock_guard; // Going to parallel: auto printlayerfn = [this, @@ -1151,8 +1141,7 @@ void SLAPrint::Steps::merge_slices_and_eval_stats() { area_fill, display_area, exp_time, init_exp_time, fast_tilt, slow_tilt, hv_tilt, material_config, delta_fade_time, is_prusa_print, first_slow_layers, below, above, // write vars - &mutex, &models_volume, &supports_volume, &estim_time, &slow_layers, - &fast_layers, &fade_layer_time, &layers_times, &layers_areas](size_t sliced_layer_cnt) + &layers_info](size_t sliced_layer_cnt) { PrintLayer &layer = m_print->m_printer_input[sliced_layer_cnt]; @@ -1202,9 +1191,7 @@ void SLAPrint::Steps::merge_slices_and_eval_stats() { for (const ExPolygon& polygon : model_polygons) layer_model_area += area(polygon); - if (layer_model_area < 0 || layer_model_area > 0) { - Lock lck(mutex); models_volume += layer_model_area * l_height; - } + const double models_volume = (layer_model_area < 0 || layer_model_area > 0) ? layer_model_area * l_height : 0.; if(!supports_polygons.empty()) { if(model_polygons.empty()) supports_polygons = union_ex(supports_polygons); @@ -1216,11 +1203,8 @@ void SLAPrint::Steps::merge_slices_and_eval_stats() { for (const ExPolygon& polygon : supports_polygons) layer_support_area += area(polygon); - if (layer_support_area < 0 || layer_support_area > 0) { - Lock lck(mutex); supports_volume += layer_support_area * l_height; - } - - double layer_area = layer_model_area + layer_support_area; + const double supports_volume = (layer_support_area < 0 || layer_support_area > 0) ? layer_support_area * l_height : 0.; + const double layer_area = layer_model_area + layer_support_area; // Here we can save the expensively calculated polygons for printing ExPolygons trslices; @@ -1233,86 +1217,52 @@ void SLAPrint::Steps::merge_slices_and_eval_stats() { // Calculation of the printing time // + Calculation of the slow and fast layers to the future controlling those values on FW double layer_times = 0.0; + bool is_fast_layer = false; if (is_prusa_print) { - const bool is_fast_layer = sliced_layer_cnt < first_slow_layers || layer_area <= display_area * area_fill; + is_fast_layer = sliced_layer_cnt < first_slow_layers || layer_area <= display_area * area_fill; + const int l_height_nm = 1000000 * l_height; - { Lock lck(mutex); - - const int l_height_nm = 1000000 * l_height; - - if (is_fast_layer) { - fast_layers++; - layer_times = layer_peel_move_time(l_height_nm, below) + - below.delay_before_exposure_ms + - below.delay_after_exposure_ms + - refresh_delay_ms * 5 + // ~ 5x frame display wait - 124; // Magical constant to compensate remaining computation delay in exposure thread - } - else { - slow_layers++; - layer_times = layer_peel_move_time(l_height_nm, above) + - above.delay_before_exposure_ms + - above.delay_after_exposure_ms + - refresh_delay_ms * 5 + // ~ 5x frame display wait - 124; // Magical constant to compensate remaining computation delay in exposure thread - } - - // All before calculations are made in ms, but we need it in s - layer_times *= 0.001; - - layers_times.emplace_back(layer.level(), layer_times); - estim_time += layer_times; - layers_areas.emplace_back(layer.level(), layer_area * SCALING_FACTOR * SCALING_FACTOR); - } + layer_times = layer_peel_move_time(l_height_nm, is_fast_layer ? below : above) + + (is_fast_layer ? below : above).delay_before_exposure_ms + + (is_fast_layer ? below : above).delay_after_exposure_ms + + refresh_delay_ms * 5 + // ~ 5x frame display wait + 124; // Magical constant to compensate remaining computation delay in exposure thread + layer_times *= 0.001; // All before calculations are made in ms, but we need it in s } else { - const bool is_fast_layer = layer_area <= display_area*area_fill; + is_fast_layer = layer_area <= display_area*area_fill; const double tilt_time = material_config.material_print_speed == slamsSlow ? slow_tilt : material_config.material_print_speed == slamsHighViscosity ? hv_tilt : is_fast_layer ? fast_tilt : slow_tilt; - { Lock lck(mutex); - if (is_fast_layer) - fast_layers++; - else - slow_layers++; - if (sliced_layer_cnt < 3) - layer_times += init_exp_time; - else if (fade_layer_time > exp_time) { - fade_layer_time -= delta_fade_time; - layer_times += fade_layer_time; - } - else - layer_times += exp_time; - layer_times += tilt_time; + layer_times += tilt_time; - //// Per layer times (magical constants cuclulated from FW) + //// Per layer times (magical constants cuclulated from FW) + static double exposure_safe_delay_before{ 3.0 }; + static double exposure_high_viscosity_delay_before{ 3.5 }; + static double exposure_slow_move_delay_before{ 1.0 }; - static double exposure_safe_delay_before{ 3.0 }; - static double exposure_high_viscosity_delay_before{ 3.5 }; - static double exposure_slow_move_delay_before{ 1.0 }; - - if (material_config.material_print_speed == slamsSlow) - layer_times += exposure_safe_delay_before; - else if (material_config.material_print_speed == slamsHighViscosity) - layer_times += exposure_high_viscosity_delay_before; - else if (!is_fast_layer) - layer_times += exposure_slow_move_delay_before; - - // Increase layer time for "magic constants" from FW - layer_times += ( - l_height * 5 // tower move - + 120 / 1000 // Magical constant to compensate remaining computation delay in exposure thread - ); - - layers_times.emplace_back(layer.level(), layer_times); - estim_time += layer_times; - layers_areas.emplace_back(layer.level(), layer_area * SCALING_FACTOR * SCALING_FACTOR); - } + if (material_config.material_print_speed == slamsSlow) + layer_times += exposure_safe_delay_before; + else if (material_config.material_print_speed == slamsHighViscosity) + layer_times += exposure_high_viscosity_delay_before; + else if (!is_fast_layer) + layer_times += exposure_slow_move_delay_before; + // Increase layer time for "magic constants" from FW + layer_times += ( + l_height * 5 // tower move + + 120 / 1000 // Magical constant to compensate remaining computation delay in exposure thread + ); } + + // We are done with tilt time, but we haven't added the exposure time yet. + layer_times += std::max(exp_time, init_exp_time - sliced_layer_cnt * delta_fade_time); + + // Collect values for this layer. + layers_info[sliced_layer_cnt] = std::make_tuple(layer_times, layer_area * SCALING_FACTOR * SCALING_FACTOR, is_fast_layer, models_volume, supports_volume); }; // sequential version for debugging: @@ -1320,32 +1270,27 @@ void SLAPrint::Steps::merge_slices_and_eval_stats() { execution::for_each(ex_tbb, size_t(0), printer_input.size(), printlayerfn, execution::max_concurrency(ex_tbb)); - auto SCALING2 = SCALING_FACTOR * SCALING_FACTOR; - print_statistics.support_used_material = supports_volume * SCALING2; - print_statistics.objects_used_material = models_volume * SCALING2; + print_statistics.clear(); - // Estimated printing time - // A layers count o the highest object if (printer_input.size() == 0) print_statistics.estimated_print_time = NaNd; else { - print_statistics.estimated_print_time = estim_time; - - // Times and areas vectors were filled in parallel, they need to be sorted first. - // The print statistics will contain only the values (in the correct order). - std::sort(layers_times.begin(), layers_times.end(), [](const auto& a, const auto& b) { return a.first < b.first; }); - std::sort(layers_areas.begin(), layers_areas.end(), [](const auto& a, const auto& b) { return a.first < b.first; }); - print_statistics.layers_times_running_total.clear(); - for (size_t i=0; iSetTextAndShow(siCost, str_total_cost, "Cost"); - wxString t_est = std::isnan(ps.estimated_print_time) ? "N/A" : from_u8(short_time_ui(get_time_dhms(float(ps.estimated_print_time)))); - // For Prusa SLA printer we add +/- 3% ration for estimated time - if (std::string printer_model = wxGetApp().preset_bundle->printers.get_edited_preset().config.opt_string("printer_model"); - t_est != "N/A" && (printer_model == "SL1" || printer_model == "SL1S" || printer_model == "M1")) { - const double ratio = 0.03 * ps.estimated_print_time; - const wxString ratio_str = from_u8(short_time_ui(get_time_dhms(float(ratio)))); - t_est += " +/- " + ratio_str; + wxString t_est = "N/A"; + if (! std::isnan(ps.estimated_print_time)) { + t_est = from_u8(short_time_ui(get_time_dhms(float(ps.estimated_print_time)))); + if (ps.estimated_print_time_tolerance > 0.) + t_est += from_u8(" \u00B1 ") + from_u8(short_time_ui(get_time_dhms(float(ps.estimated_print_time_tolerance)))); } m_sliced_info->SetTextAndShow(siEstimatedTime, t_est, _L("Estimated printing time") + ":"); diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index ebaceccefd..1b9e2c13c0 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -5413,12 +5413,12 @@ void TabSLAMaterial::build_tilt_group(Slic3r::GUI::PageShp page) { // Legend std::vector> legend_columns = { - {L("Below"), L("Values in this column are for ???")}, - {L("Above"), L("Values in this column are for ???")}, + {L("Below"), L("Values in this column are applied when layer area is smaller than area_fill.")}, + {L("Above"), L("Values in this column are applied when layer area is larger than area_fill.")}, }; create_legend(page, legend_columns, comExpert/*, true*/); - auto optgroup = page->new_optgroup(L("Tilt profiles")); + auto optgroup = page->new_optgroup(L("Profile settings")); optgroup->on_change = [this, optgroup](const t_config_option_key& key, boost::any value) { if (key.find_first_of("use_tilt") == 0) @@ -5482,7 +5482,7 @@ void TabSLAMaterial::toggle_tilt_options(bool is_above) if (m_active_page && m_active_page->title() == "Material printing profile") { int column_id = is_above ? 0 : 1; - auto optgroup = m_active_page->get_optgroup("Tilt profiles"); + auto optgroup = m_active_page->get_optgroup("Profile settings"); bool use_tilt = boost::any_cast(optgroup->get_config_value(*m_config, "use_tilt", column_id)); for (const std::string& opt_key : disable_tilt_options) { @@ -5540,11 +5540,11 @@ void TabSLAMaterial::sys_color_changed() void TabSLAMaterial::update_sla_prusa_specific_visibility() { if (m_active_page && m_active_page->title() == "Material printing profile") { - for (auto& title : { "", "Tilt profiles" }) { + for (auto& title : { "", "Profile settings" }) { auto og_it = std::find_if(m_active_page->m_optgroups.begin(), m_active_page->m_optgroups.end(), [title](const ConfigOptionsGroupShp og) { return og->title == title; }); if (og_it != m_active_page->m_optgroups.end()) - og_it->get()->Show(m_mode == comExpert && is_prusa_printer()); + og_it->get()->Show(m_mode >= comAdvanced && is_prusa_printer()); } auto og_it = std::find_if(m_active_page->m_optgroups.begin(), m_active_page->m_optgroups.end(),