From 3733f33953fa89b490be0d2f36e225fa62dcbc00 Mon Sep 17 00:00:00 2001 From: "xun.zhang" Date: Fri, 14 Feb 2025 17:19:30 +0800 Subject: [PATCH] FIX: add some missing translate keys 1. Add missing translation keys 2. Fix filament map dialog can't display in auto mode JIRA:STUDIO-10216 Signed-off-by: xun.zhang Change-Id: I0c3927877dd91befc2463a300324bc6823615673 --- src/libslic3r/GCode/ToolOrdering.cpp | 24 +++++++++++++++--------- src/libslic3r/Print.cpp | 10 ++++------ src/slic3r/GUI/FilamentGroupPopup.cpp | 4 ++-- src/slic3r/GUI/FilamentMapDialog.cpp | 5 ++--- src/slic3r/GUI/FilamentMapDialog.hpp | 2 +- src/slic3r/GUI/FilamentMapPanel.cpp | 4 ++-- src/slic3r/GUI/NotificationManager.cpp | 2 +- 7 files changed, 27 insertions(+), 24 deletions(-) diff --git a/src/libslic3r/GCode/ToolOrdering.cpp b/src/libslic3r/GCode/ToolOrdering.cpp index 4332f536b..8f36bfef1 100644 --- a/src/libslic3r/GCode/ToolOrdering.cpp +++ b/src/libslic3r/GCode/ToolOrdering.cpp @@ -5,6 +5,8 @@ #include "ParameterUtils.hpp" #include "GCode/ToolOrderUtils.hpp" #include "FilamentGroupUtils.hpp" +#include "I18N.hpp" + // #define SLIC3R_DEBUG // Make assert active if SLIC3R_DEBUG @@ -23,6 +25,13 @@ namespace Slic3r { + //! macro used to mark string used at localization, + //! return same string + +#ifndef _L +#define _L(s) Slic3r::I18N::translate(s) +#endif + const static bool g_wipe_into_objects = false; constexpr double similar_color_threshold_de2000 = 20.0; @@ -63,9 +72,8 @@ bool check_filament_printable_after_group(const std::vector &used_ std::vector limit_types = split_string(print_config->unprintable_filament_types.get_at(idx), ','); auto iter = std::find(limit_types.begin(), limit_types.end(), filament_type); if (iter != limit_types.end()) { - std::string error_msg; - std::string extruder_name = idx == 0 ? "left" : "right"; - error_msg = "Grouping error: " + filament_type + " can not be placed in the " + extruder_name + " extruder"; + std::string extruder_name = idx == 0 ? _L("left") : _L("right"); + std::string error_msg = _L("Grouping error: ") + filament_type + _L(" can not be placed in the ") + extruder_name + _L(" nozzle"); throw Slic3r::RuntimeError(error_msg); } } @@ -1141,12 +1149,10 @@ void ToolOrdering::reorder_extruders_for_minimum_flush_volume(bool reorder_first check_filament_printable_after_group(used_filaments, filament_maps, print_config); if (nozzle_nums > 1 && !check_tpu_group(used_filaments, filament_maps, print_config)) { - if (map_mode == FilamentMapMode::fmmManual) { - throw Slic3r::RuntimeError(std::string("Manual grouping error: TPU can only be placed in a nozzle alone.")); - } - else { - throw Slic3r::RuntimeError(std::string("Auto grouping error: TPU can only be placed in a nozzle alone.")); - } + int master_extruder_id = print_config->master_extruder_id.value - 1; // to 0 based + std::string nozzle_name = master_extruder_id == 0 ? "left" : "right"; + std::string exception_str = _L(std::string("TPU is incompatible with AMS and must be printed seperately in the ") + nozzle_name + " nozzle.\nPlease adjust the filament group accordingly."); + throw Slic3r::RuntimeError(exception_str); } } else { diff --git a/src/libslic3r/Print.cpp b/src/libslic3r/Print.cpp index 729cd8c4d..a4ed41cf2 100644 --- a/src/libslic3r/Print.cpp +++ b/src/libslic3r/Print.cpp @@ -1923,12 +1923,10 @@ void Print::process(std::unordered_map* slice_time, bool // check map valid both in auto and mannual mode std::transform(filament_maps.begin(), filament_maps.end(), filament_maps.begin(), [](int value) {return value - 1; }); if (!ToolOrdering::check_tpu_group(used_filaments, filament_maps, &m_config)) { - if (map_mode == FilamentMapMode::fmmManual) { - throw Slic3r::RuntimeError(std::string("Manual grouping error: TPU can only be placed in a nozzle alone.")); - } - else { - throw Slic3r::RuntimeError(std::string("Auto grouping error: TPU can only be placed in a nozzle alone.")); - } + int master_extruder_id = m_config.master_extruder_id.value - 1; // to 0 based + std::string nozzle_name = master_extruder_id == 0 ? "left" : "right"; + std::string exception_str = L(std::string("TPU is incompatible with AMS and must be printed seperately in the ") + nozzle_name + " nozzle.\nPlease adjust the filament group accordingly."); + throw Slic3r::RuntimeError(exception_str); } // print_object_instances_ordering = sort_object_instances_by_max_z(print); diff --git a/src/slic3r/GUI/FilamentGroupPopup.cpp b/src/slic3r/GUI/FilamentGroupPopup.cpp index 9d3c271d5..ba08ed048 100644 --- a/src/slic3r/GUI/FilamentGroupPopup.cpp +++ b/src/slic3r/GUI/FilamentGroupPopup.cpp @@ -53,8 +53,8 @@ FilamentGroupPopup::FilamentGroupPopup(wxWindow *parent) : PopupWindow(parent, w const wxString AutoForMatchLabel = _L("Convenience Mode"); const wxString ManualLabel = _L("Custom Mode"); - const wxString AutoForFlushDetail = _L("Recommends filament grouping for the left and right nozzles based on the most filament-saving principles to minimize waste"); - const wxString AutoForMatchDetail = _L("Recommends filament grouping for the left and right nozzles based on the printer's actual filament status, reducing the need for manual filament adjustment"); + const wxString AutoForFlushDetail = _L("Generates filament grouping for the left and right nozzles based on the most filament-saving principles to minimize waste"); + const wxString AutoForMatchDetail = _L("Generates filament grouping for the left and right nozzles based on the printer's actual filament status, reducing the need for manual filament adjustment"); const wxString ManualDetail = _L("Manually assign filament to the left or right nozzle"); const wxString AutoForFlushDesp = ""; //_L("(Post-slicing arrangement)"); diff --git a/src/slic3r/GUI/FilamentMapDialog.cpp b/src/slic3r/GUI/FilamentMapDialog.cpp index 0c4ba6e9b..94fab96c5 100644 --- a/src/slic3r/GUI/FilamentMapDialog.cpp +++ b/src/slic3r/GUI/FilamentMapDialog.cpp @@ -37,14 +37,13 @@ extern std::string& get_left_extruder_unprintable_text(); extern std::string& get_right_extruder_unprintable_text(); -bool try_pop_up_before_slice(bool is_slice_all, Plater* plater_ref, PartPlate* partplate_ref) +bool try_pop_up_before_slice(bool is_slice_all, Plater* plater_ref, PartPlate* partplate_ref, bool force_pop_up) { auto full_config = wxGetApp().preset_bundle->full_config(); const auto nozzle_diameters = full_config.option("nozzle_diameter"); if (nozzle_diameters->size() <= 1) return true; - bool force_pop_up = get_pop_up_remind_flag(); bool sync_plate = true; std::vector filament_colors = full_config.option("filament_colour")->values; @@ -52,7 +51,7 @@ bool try_pop_up_before_slice(bool is_slice_all, Plater* plater_ref, PartPlate* p std::vector applied_maps = get_applied_map(full_config, plater_ref, partplate_ref, sync_plate); applied_maps.resize(filament_colors.size(), 1); - if (applied_mode != fmmManual) + if (!force_pop_up && applied_mode != fmmManual) return true; std::vector filament_lists; diff --git a/src/slic3r/GUI/FilamentMapDialog.hpp b/src/slic3r/GUI/FilamentMapDialog.hpp index 99fd50aca..da9b89e99 100644 --- a/src/slic3r/GUI/FilamentMapDialog.hpp +++ b/src/slic3r/GUI/FilamentMapDialog.hpp @@ -27,7 +27,7 @@ class PartPlate; * @param partplate_ref Partplate to get/set plate filament map mode * @return whether continue slicing */ -bool try_pop_up_before_slice(bool is_slice_all, Plater* plater_ref, PartPlate* partplate_ref); +bool try_pop_up_before_slice(bool is_slice_all, Plater* plater_ref, PartPlate* partplate_ref, bool force_pop_up = false); class FilamentMapDialog : public wxDialog diff --git a/src/slic3r/GUI/FilamentMapPanel.cpp b/src/slic3r/GUI/FilamentMapPanel.cpp index 130946269..cf68ee8c3 100644 --- a/src/slic3r/GUI/FilamentMapPanel.cpp +++ b/src/slic3r/GUI/FilamentMapPanel.cpp @@ -282,9 +282,9 @@ void GUI::FilamentMapBtnPanel::Show() FilamentMapAutoPanel::FilamentMapAutoPanel(wxWindow *parent, FilamentMapMode mode, bool machine_synced) : wxPanel(parent) { - const wxString AutoForFlushDetail = _L("Recommends filament grouping for the left and right nozzles based on the most filament-saving principles to minimize waste"); + const wxString AutoForFlushDetail = _L("Generates filament grouping for the left and right nozzles based on the most filament-saving principles to minimize waste"); - const wxString AutoForMatchDetail = _L("Recommends filament grouping for the left and right nozzles based on the printer's actual filament status, reducing the need for manual filament adjustment"); + const wxString AutoForMatchDetail = _L("Generates filament grouping for the left and right nozzles based on the printer's actual filament status, reducing the need for manual filament adjustment"); auto sizer = new wxBoxSizer(wxHORIZONTAL); m_flush_panel = new FilamentMapBtnPanel(this, _L("Filament-Saving Mode"), AutoForFlushDetail, "flush_mode_panel_icon"); diff --git a/src/slic3r/GUI/NotificationManager.cpp b/src/slic3r/GUI/NotificationManager.cpp index 6549a5934..b7c704e1d 100644 --- a/src/slic3r/GUI/NotificationManager.cpp +++ b/src/slic3r/GUI/NotificationManager.cpp @@ -2806,7 +2806,7 @@ void NotificationManager::bbl_show_filament_map_invalid_notification_before_slic auto callback = [](wxEvtHandler*) { auto plater = wxGetApp().plater(); auto partplate = plater->get_partplate_list().get_curr_plate(); - try_pop_up_before_slice(false, plater, partplate); // ignore the return value + try_pop_up_before_slice(false, plater, partplate, true); // ignore the return value return false; };