diff --git a/src/slic3r/GUI/AMSMaterialsSetting.cpp b/src/slic3r/GUI/AMSMaterialsSetting.cpp index a4763d8f8b..47c105162e 100644 --- a/src/slic3r/GUI/AMSMaterialsSetting.cpp +++ b/src/slic3r/GUI/AMSMaterialsSetting.cpp @@ -13,31 +13,6 @@ namespace Slic3r { namespace GUI { wxDEFINE_EVENT(EVT_SELECTED_COLOR, wxCommandEvent); -static void get_default_k_n_value(const std::string &filament_id, float &k, float &n) -{ - if (filament_id.compare("GFG00") == 0) { - // PETG - k = 0.04; - n = 1.0; - } else if (filament_id.compare("GFB00") == 0 || filament_id.compare("GFB50") == 0) { - // ABS - k = 0.04; - n = 1.0; - } else if (filament_id.compare("GFU01") == 0) { - // TPU - k = 0.2; - n = 1.0; - } else if (filament_id.compare("GFB01") == 0) { - // ASA - k = 0.04; - n = 1.0; - } else { - // PLA , other - k = 0.02; - n = 1.0; - } -} - static std::string float_to_string_with_precision(float value, int precision = 3) { std::stringstream stream; diff --git a/src/slic3r/GUI/Widgets/AMSItem.cpp b/src/slic3r/GUI/Widgets/AMSItem.cpp index 5560676ebb..bd0cdccbf2 100644 --- a/src/slic3r/GUI/Widgets/AMSItem.cpp +++ b/src/slic3r/GUI/Widgets/AMSItem.cpp @@ -66,6 +66,8 @@ bool AMSinfo::parse_ams_info(MachineObject *obj, Ams *ams, bool remain_flag, boo info.can_id = it->second->id; info.ctype = it->second->ctype; info.material_name = it->second->get_display_filament_type(); + info.cali_idx = it->second->cali_idx; + info.filament_id = it->second->filament_setting_id; if (!it->second->color.empty()) { info.material_colour = AmsTray::decode_color(it->second->color); } else { @@ -97,6 +99,8 @@ bool AMSinfo::parse_ams_info(MachineObject *obj, Ams *ams, bool remain_flag, boo } else { info.can_id = it->second->id; info.material_name = ""; + info.cali_idx = -1; + info.filament_id = ""; info.ctype = 0; info.material_colour = AMS_TRAY_DEFAULT_COL; info.material_state = AMSCanType::AMS_CAN_TYPE_THIRDBRAND; @@ -136,6 +140,8 @@ void AMSinfo::parse_ext_info(MachineObject* obj, AmsTray tray) { if (tray.is_tray_info_ready()) { info.ctype = tray.ctype; info.material_name = tray.get_display_filament_type(); + info.cali_idx = tray.cali_idx; + info.filament_id = tray.filament_setting_id; if (!tray.color.empty()) { info.material_colour = AmsTray::decode_color(tray.color); } @@ -151,6 +157,8 @@ void AMSinfo::parse_ext_info(MachineObject* obj, AmsTray tray) { } else { info.material_name = ""; + info.cali_idx = -1; + info.filament_id = ""; info.ctype = 0; info.material_colour = AMS_TRAY_DEFAULT_COL; wxColour(255, 255, 255); @@ -907,9 +915,12 @@ void AMSLib::render_lite_text(wxDC& dc) void AMSLib::render_generic_text(wxDC &dc) { bool show_k_value = true; - if (m_obj && (m_obj->cali_version >= 0) && (abs(m_info.k - 0) < 1e-3)) { + if (m_info.material_name.empty()) { show_k_value = false; } + else if (m_info.cali_idx == -1) { + get_default_k_n_value(m_info.filament_id, m_info.k, m_info.n); + } auto tmp_lib_colour = m_info.material_colour; change_the_opacity(tmp_lib_colour); diff --git a/src/slic3r/GUI/Widgets/AMSItem.hpp b/src/slic3r/GUI/Widgets/AMSItem.hpp index 8556c54d89..ac926b0aa1 100644 --- a/src/slic3r/GUI/Widgets/AMSItem.hpp +++ b/src/slic3r/GUI/Widgets/AMSItem.hpp @@ -147,6 +147,8 @@ struct Caninfo AMSCanType material_state; int ctype=0; int material_remain = 100; + int cali_idx = -1; + std::string filament_id; float k = 0.0f; float n = 0.0f; std::vector material_cols; diff --git a/src/slic3r/Utils/CalibUtils.cpp b/src/slic3r/Utils/CalibUtils.cpp index 841f655238..525c892eba 100644 --- a/src/slic3r/Utils/CalibUtils.cpp +++ b/src/slic3r/Utils/CalibUtils.cpp @@ -34,6 +34,30 @@ static std::string MachineBedTypeString[7] = { "pct", }; +void get_default_k_n_value(const std::string &filament_id, float &k, float &n) +{ + if (filament_id.compare("GFG00") == 0) { + // PETG + k = 0.04; + n = 1.0; + } else if (filament_id.compare("GFB00") == 0 || filament_id.compare("GFB50") == 0) { + // ABS + k = 0.04; + n = 1.0; + } else if (filament_id.compare("GFU01") == 0) { + // TPU + k = 0.2; + n = 1.0; + } else if (filament_id.compare("GFB01") == 0) { + // ASA + k = 0.04; + n = 1.0; + } else { + // PLA , other + k = 0.02; + n = 1.0; + } +} wxString get_nozzle_volume_type_name(NozzleVolumeType type) { diff --git a/src/slic3r/Utils/CalibUtils.hpp b/src/slic3r/Utils/CalibUtils.hpp index 6b6a7017c0..c6042a5955 100644 --- a/src/slic3r/Utils/CalibUtils.hpp +++ b/src/slic3r/Utils/CalibUtils.hpp @@ -77,6 +77,8 @@ private: static void send_to_print(const CalibInfo &calib_info, wxString& error_message, int flow_ratio_mode = 0); // 0: none 1: coarse 2: fine }; +extern void get_default_k_n_value(const std::string &filament_id, float &k, float &n); + extern wxString get_nozzle_volume_type_name(NozzleVolumeType type); } } \ No newline at end of file