From d7a0dfd8e4e6dfc1230b02495ea6398722fc257f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Hejl?= Date: Mon, 11 Nov 2024 10:12:54 +0100 Subject: [PATCH] SPE-2501: Improve the notification about the bed temperature difference. --- src/libslic3r/Config.hpp | 1 + src/libslic3r/Print.cpp | 19 ++++++---- src/libslic3r/Print.hpp | 2 +- src/libslic3r/PrintApply.cpp | 21 ++++++++++- src/libslic3r/PrintBase.hpp | 2 +- src/libslic3r/SLAPrint.cpp | 2 +- src/libslic3r/SLAPrint.hpp | 2 +- src/slic3r/GUI/BackgroundSlicingProcess.cpp | 4 +- src/slic3r/GUI/BackgroundSlicingProcess.hpp | 2 +- src/slic3r/GUI/Plater.cpp | 41 ++++++++++++--------- 10 files changed, 64 insertions(+), 32 deletions(-) diff --git a/src/libslic3r/Config.hpp b/src/libslic3r/Config.hpp index cc7eabe336..93b90ead57 100644 --- a/src/libslic3r/Config.hpp +++ b/src/libslic3r/Config.hpp @@ -974,6 +974,7 @@ public: // A scalar is nil, or all values of a vector are nil. bool is_nil() const override { for (auto v : this->values) if (v != nil_value()) return false; return true; } bool is_nil(size_t idx) const override { return values[idx < this->values.size() ? idx : 0] == nil_value(); } + std::vector getInts() const override { return this->values; } std::string serialize() const override { diff --git a/src/libslic3r/Print.cpp b/src/libslic3r/Print.cpp index 529fd604a8..ba6dbef7b6 100644 --- a/src/libslic3r/Print.cpp +++ b/src/libslic3r/Print.cpp @@ -443,14 +443,19 @@ std::string Print::validate(std::vector* warnings) const std::vector extruders = this->extruders(); if (warnings) { - for (size_t a=0; a 15 - || std::abs(m_config.first_layer_bed_temperature.get_at(extruders[a]) - m_config.first_layer_bed_temperature.get_at(extruders[b])) > 15) { - warnings->emplace_back("_BED_TEMPS_DIFFER"); - goto DONE; + if (m_config.bed_temperature_extruder == 0) { + for (size_t a = 0; a < extruders.size(); ++a) { + for (size_t b = a + 1; b < extruders.size(); ++b) { + if (std::abs(m_config.bed_temperature.get_at(extruders[a]) - m_config.bed_temperature.get_at(extruders[b])) > 15 + || std::abs(m_config.first_layer_bed_temperature.get_at(extruders[a]) - m_config.first_layer_bed_temperature.get_at(extruders[b])) > 15) { + warnings->emplace_back("_BED_TEMPS_DIFFER"); + goto DONE; + } } - DONE:; + } + + DONE:; + } if (!this->has_same_shrinkage_compensations()) warnings->emplace_back("_FILAMENT_SHRINKAGE_DIFFER"); diff --git a/src/libslic3r/Print.hpp b/src/libslic3r/Print.hpp index e6728cf69e..1ea05498a1 100644 --- a/src/libslic3r/Print.hpp +++ b/src/libslic3r/Print.hpp @@ -608,7 +608,7 @@ public: // List of existing PrintObject IDs, to remove notifications for non-existent IDs. std::vector print_object_ids() const override; - ApplyStatus apply(const Model &model, DynamicPrintConfig config) override; + ApplyStatus apply(const Model &model, DynamicPrintConfig config, std::vector *warnings = nullptr) override; void set_task(const TaskParams ¶ms) override { PrintBaseWithState::set_task_impl(params, m_objects); } void process() override; void finalize() override { PrintBaseWithState::finalize_impl(m_objects); } diff --git a/src/libslic3r/PrintApply.cpp b/src/libslic3r/PrintApply.cpp index eac7d8df5d..74c1056def 100644 --- a/src/libslic3r/PrintApply.cpp +++ b/src/libslic3r/PrintApply.cpp @@ -1050,7 +1050,23 @@ static PrintObjectRegions* generate_print_object_regions( return out.release(); } -Print::ApplyStatus Print::apply(const Model &model, DynamicPrintConfig new_full_config) +static void validate_print_config_change(const PrintConfig &old_config, const DynamicPrintConfig &new_config, std::vector *warnings) +{ + if (warnings == nullptr) { + return; + } + + if (old_config.bed_temperature_extruder > 0 && old_config.bed_temperature_extruder == new_config.option("bed_temperature_extruder")->getInt()) { + // Bed temperature extruder is set, and it didn't change with the new config. + if (old_config.bed_temperature.values != new_config.option("bed_temperature")->getInts() + || old_config.first_layer_bed_temperature.values != new_config.option("first_layer_bed_temperature")->getInts()) { + // When any bed temperature changes, we warn the user that the bed temperature extruder may need to be changed. + warnings->emplace_back("_BED_TEMPS_CHANGED"); + } + } +} + +Print::ApplyStatus Print::apply(const Model &model, DynamicPrintConfig new_full_config, std::vector *warnings) { #ifdef _DEBUG check_model_ids_validity(model); @@ -1076,6 +1092,9 @@ Print::ApplyStatus Print::apply(const Model &model, DynamicPrintConfig new_full_ t_config_option_keys object_diff = m_default_object_config.diff(new_full_config); t_config_option_keys region_diff = m_default_region_config.diff(new_full_config); + // Check if the print config change will produce any warnings. + validate_print_config_change(m_config, new_full_config, warnings); + // Do not use the ApplyStatus as we will use the max function when updating apply_status. unsigned int apply_status = APPLY_STATUS_UNCHANGED; auto update_apply_status = [&apply_status](bool invalidated) diff --git a/src/libslic3r/PrintBase.hpp b/src/libslic3r/PrintBase.hpp index 2c113f1ee2..e8832c00e4 100644 --- a/src/libslic3r/PrintBase.hpp +++ b/src/libslic3r/PrintBase.hpp @@ -433,7 +433,7 @@ public: // Some data was changed, which in turn invalidated already calculated steps. APPLY_STATUS_INVALIDATED, }; - virtual ApplyStatus apply(const Model &model, DynamicPrintConfig config) = 0; + virtual ApplyStatus apply(const Model &model, DynamicPrintConfig config, std::vector *warnings = nullptr) = 0; const Model& model() const { return m_model; } struct TaskParams { diff --git a/src/libslic3r/SLAPrint.cpp b/src/libslic3r/SLAPrint.cpp index 9182cb7932..954aed7a2a 100644 --- a/src/libslic3r/SLAPrint.cpp +++ b/src/libslic3r/SLAPrint.cpp @@ -260,7 +260,7 @@ static t_config_option_keys print_config_diffs(const StaticPrintConfig &curr } -SLAPrint::ApplyStatus SLAPrint::apply(const Model &model, DynamicPrintConfig config) +SLAPrint::ApplyStatus SLAPrint::apply(const Model &model, DynamicPrintConfig config, std::vector *warnings) { #ifdef _DEBUG check_model_ids_validity(model); diff --git a/src/libslic3r/SLAPrint.hpp b/src/libslic3r/SLAPrint.hpp index d02b4af725..abb76b6b7c 100644 --- a/src/libslic3r/SLAPrint.hpp +++ b/src/libslic3r/SLAPrint.hpp @@ -490,7 +490,7 @@ public: bool empty() const override { return m_objects.empty(); } // List of existing PrintObject IDs, to remove notifications for non-existent IDs. std::vector print_object_ids() const override; - ApplyStatus apply(const Model &model, DynamicPrintConfig config) override; + ApplyStatus apply(const Model &model, DynamicPrintConfig config, std::vector *warnings = nullptr) override; void set_task(const TaskParams ¶ms) override { PrintBaseWithState::set_task_impl(params, m_objects); } void process() override; void finalize() override { PrintBaseWithState::finalize_impl(m_objects); } diff --git a/src/slic3r/GUI/BackgroundSlicingProcess.cpp b/src/slic3r/GUI/BackgroundSlicingProcess.cpp index 0388ea2e99..cf39de01a8 100644 --- a/src/slic3r/GUI/BackgroundSlicingProcess.cpp +++ b/src/slic3r/GUI/BackgroundSlicingProcess.cpp @@ -590,11 +590,11 @@ std::string BackgroundSlicingProcess::validate(std::vector* warning // Apply config over the print. Returns false, if the new config values caused any of the already // processed steps to be invalidated, therefore the task will need to be restarted. -Print::ApplyStatus BackgroundSlicingProcess::apply(const Model &model, const DynamicPrintConfig &config) +Print::ApplyStatus BackgroundSlicingProcess::apply(const Model &model, const DynamicPrintConfig &config, std::vector *warnings) { assert(m_print != nullptr); assert(config.opt_enum("printer_technology") == m_print->technology()); - Print::ApplyStatus invalidated = m_print->apply(model, config); + Print::ApplyStatus invalidated = m_print->apply(model, config, warnings); if ((invalidated & PrintBase::APPLY_STATUS_INVALIDATED) != 0 && m_print->technology() == ptFFF && !m_fff_print->is_step_done(psGCodeExport)) { // Some FFF status was invalidated, and the G-code was not exported yet. diff --git a/src/slic3r/GUI/BackgroundSlicingProcess.hpp b/src/slic3r/GUI/BackgroundSlicingProcess.hpp index d11d1d1c33..22779611a1 100644 --- a/src/slic3r/GUI/BackgroundSlicingProcess.hpp +++ b/src/slic3r/GUI/BackgroundSlicingProcess.hpp @@ -133,7 +133,7 @@ public: // Apply config over the print. Returns false, if the new config values caused any of the already // processed steps to be invalidated, therefore the task will need to be restarted. - PrintBase::ApplyStatus apply(const Model &model, const DynamicPrintConfig &config); + PrintBase::ApplyStatus apply(const Model &model, const DynamicPrintConfig &config, std::vector *warnings = nullptr); // After calling the apply() function, set_task() may be called to limit the task to be processed by process(). // This is useful for calculating SLA supports for a single object only. void set_task(const PrintBase::TaskParams ¶ms); diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 5bf75209bc..b40b8dd47c 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -968,7 +968,7 @@ void Plater::priv::init() this->notification_manager->close_notification_of_type(NotificationType::UserAccountID); // show connect tab this->notification_manager->push_notification(NotificationType::UserAccountID, NotificationManager::NotificationLevel::ImportantNotificationLevel, text); - + this->main_frame->on_account_login(user_account->get_access_token()); } else { // refresh do different operations than on_account_login @@ -1060,11 +1060,11 @@ void Plater::priv::init() this->q->Bind(EVT_UA_REFRESH_TIME, [this](UserAccountTimeEvent& evt) { this->user_account->set_refresh_time(evt.data); - }); + }); this->q->Bind(EVT_UA_ENQUEUED_REFRESH, [this](SimpleEvent& evt) { this->main_frame->on_account_will_refresh(); - }); - + }); + this->q->Bind(EVT_PRINTABLES_CONNECT_PRINT, [this](wxCommandEvent& evt) { if (!this->user_account->is_logged()) { // show login dialog instead of print dialog @@ -1287,7 +1287,7 @@ std::vector Plater::priv::load_files(const std::vector& input_ #ifdef __linux__ // On Linux Constructor of the ProgressDialog calls DisableOtherWindows() function which causes a disabling of all children of the find_toplevel_parent(q) // And a destructor of the ProgressDialog calls ReenableOtherWindows() function which revert previously disabled children. - // But if printer technology will be changes during project loading, + // But if printer technology will be changes during project loading, // then related SLA Print and Materials Settings or FFF Print and Filaments Settings will be unparent from the wxNoteBook // and that is why they will never be enabled after destruction of the ProgressDialog. // So, distroy progress_gialog if we are loading project file @@ -1365,8 +1365,8 @@ std::vector Plater::priv::load_files(const std::vector& input_ // For exporting from the 3mf we shouldn't check printer_presets for the containing information about "Print Host upload" wxGetApp().load_current_presets(false); - // Update filament colors for the MM-printer profile in the full config - // to avoid black (default) colors for Extruders in the ObjectList, + // Update filament colors for the MM-printer profile in the full config + // to avoid black (default) colors for Extruders in the ObjectList, // when for extruder colors are used filament colors q->update_filament_colors_in_full_config(); is_project_file = true; @@ -2131,9 +2131,16 @@ void Plater::priv::process_validation_warning(const std::vector& wa print_tab->on_value_change("support_material_auto", config.opt_bool("support_material_auto")); return true; }; - } else if (text == "_BED_TEMPS_DIFFER") { - text = _u8L("Bed temperatures for the used filaments differ significantly."); + } else if (text == "_BED_TEMPS_DIFFER" || text == "_BED_TEMPS_CHANGED") { + text = _u8L("Bed temperatures for the used filaments differ significantly.\n" + "For multi-material prints it is recommended to set the "); + hypertext = _u8L("'Bed temperature by extruder' and 'Wipe tower extruder'"); + multiline = true; notification_type = NotificationType::BedTemperaturesDiffer; + action_fn = [](wxEvtHandler*) { + GUI::wxGetApp().jump_to_option("bed_temperature_extruder", Preset::Type::TYPE_PRINT, boost::nowide::widen("Multiple Extruders")); + return true; + }; } else if (text == "_FILAMENT_SHRINKAGE_DIFFER") { text = _u8L("Filament shrinkage will not be used because filament shrinkage " "for the used filaments differs significantly."); @@ -2290,15 +2297,16 @@ unsigned int Plater::priv::update_background_process(bool force_validation, bool std::vector(1) }; - // Apply new config to the possibly running background task. + std::vector warnings; + // Apply new config to the possibly running background task and give the user feedback on warnings. if (printer_technology == ptFFF) { with_single_bed_model_fff(q->model(), s_multiple_beds.get_active_bed(), [&](){ - invalidated = background_process.apply(q->model(), full_config); + invalidated = background_process.apply(q->model(), full_config, &warnings); apply_statuses[s_multiple_beds.get_active_bed()] = invalidated; }); } else if (printer_technology == ptSLA) { with_single_bed_model_sla(q->model(), s_multiple_beds.get_active_bed(), [&](){ - invalidated = background_process.apply(q->model(), full_config); + invalidated = background_process.apply(q->model(), full_config, &warnings); apply_statuses[0] = invalidated; }); } else { @@ -2378,7 +2386,6 @@ unsigned int Plater::priv::update_background_process(bool force_validation, bool // The delayed error message is no more valid. delayed_error_message.clear(); // The state of the Print changed, and it is non-zero. Let's validate it and give the user feedback on errors. - std::vector warnings; std::string err = background_process.validate(&warnings); if (err.empty()) { notification_manager->set_all_slicing_errors_gray(true); @@ -3170,16 +3177,16 @@ void Plater::priv::on_slicing_update(SlicingStatusEvent &evt) std::vector object_ids = { evt.status.warning_object_id }; std::vector warning_steps = { evt.status.warning_step }; std::vector flagss = { int(evt.status.flags) }; - + if (warning_steps.front() == -1) { flagss = { PrintBase::SlicingStatus::UPDATE_PRINT_STEP_WARNINGS, PrintBase::SlicingStatus::UPDATE_PRINT_OBJECT_STEP_WARNINGS }; notification_manager->close_slicing_errors_and_warnings(); } - + for (int flags : flagss ) { if (warning_steps.front() == -1) { warning_steps.clear(); - if (flags == PrintBase::SlicingStatus::UPDATE_PRINT_STEP_WARNINGS) { + if (flags == PrintBase::SlicingStatus::UPDATE_PRINT_STEP_WARNINGS) { int i = 0; while (i < int(printer_technology == ptFFF ? psCount : slapsCount)) { warning_steps.push_back(i); ++i; } } else { @@ -5242,7 +5249,7 @@ bool Plater::load_files(const wxArrayString& filenames, bool delete_after_load/* return true; } else if (boost::algorithm::iends_with(filename, ".zip")) { if (!load_just_one_file) { - WarningDialog dlg(static_cast(this), + WarningDialog dlg(static_cast(this), format_wxstr(_L("You have several files for loading and \"%1%\" is one of them.\n" "Please note that only one .zip file can be loaded at a time.\n" "In this case we can load just \"%1%\".\n\n"