diff --git a/resources/printers/filaments_blacklist.json b/resources/printers/filaments_blacklist.json index 636c628fca..f30cfce505 100644 --- a/resources/printers/filaments_blacklist.json +++ b/resources/printers/filaments_blacklist.json @@ -5,22 +5,26 @@ { "type": "TPU", "action": "prohibition", - "description": "TPU: not supported" + "slot": "ams", + "description": "TPU is not supported by AMS." }, { "type": "PVA", "action": "warning", - "description": "PVA: flexible" + "slot": "ams", + "description": "Damp PVA will become flexible and get stuck inside AMS, please take care to dry it before use." }, { "type_suffix": "CF", "action": "warning", - "description": "CF/GF: hard and brittle" + "slot": "ams", + "description": "CF/GF filaments are hard and brittle, it's easy to break or get stuck in AMS, please use with caution." }, { "type_suffix": "GF", "action": "warning", - "description": "CF/GF: hard and brittle" + "slot": "ams", + "description": "CF/GF filaments are hard and brittle, it's easy to break or get stuck in AMS, please use with caution." }, { "vendor": "Bambu Lab", @@ -28,7 +32,8 @@ "name": "PLA Glow", "model_id":["N1","N2S"], "action": "warning", - "description": "PLA-Glow" + "slot": "ams", + "description": "The rough surface of PLA Glow can accelerate wear on the AMS system, particularly on the internal components of the AMS Lite." } ] } diff --git a/resources/printers/version.txt b/resources/printers/version.txt index 3dbc8d48e8..7f023810f7 100644 --- a/resources/printers/version.txt +++ b/resources/printers/version.txt @@ -1 +1 @@ -02.00.00.24 \ No newline at end of file +02.00.00.25 \ No newline at end of file diff --git a/src/slic3r/GUI/DeviceManager.cpp b/src/slic3r/GUI/DeviceManager.cpp index b25594dd9f..37deff9cfc 100644 --- a/src/slic3r/GUI/DeviceManager.cpp +++ b/src/slic3r/GUI/DeviceManager.cpp @@ -7859,31 +7859,23 @@ void DeviceManager::OnSelectedMachineLost() { GUI::wxGetApp().sidebar().load_ams_list(string(), nullptr); } -// moved from tao.wang and zhimin.zeng -void check_filaments_for_ams_slot(std::string model_id, - std::string tag_vendor, - std::string tag_type, - int ams_id, - int slot_id, - std::string tag_name, - bool& in_blacklist, - std::string& ac, - wxString& info) + +void check_filaments(std::string model_id, + std::string tag_vendor, + std::string tag_type, + int ams_id, + int slot_id, + std::string tag_name, + bool& in_blacklist, + std::string& ac, + wxString& info, + wxString& wiki_url) { if (tag_name.empty()) { tag_name = DeviceManager::get_filament_name_from_ams(ams_id, slot_id); } - std::unordered_map blacklist_prompt = - { - {"TPU: not supported", _L("TPU is not supported by AMS.")}, - {"Bambu CF: not supported", _L("Bambu PET-CF/PA6-CF/PPA-CF/PPS-CF is not supported by AMS.")}, - {"PVA: flexible", _L("Damp PVA will become flexible and get stuck inside AMS, please take care to dry it before use.")}, - {"CF/GF: hard and brittle", _L("CF/GF filaments are hard and brittle, it's easy to break or get stuck in AMS, please use with caution.")}, - {"PLA-Glow", _L("The rough surface of PLA Glow can accelerate wear on the AMS system, particularly on the internal components of the AMS Lite.")} - }; - in_blacklist = false; std::transform(tag_vendor.begin(), tag_vendor.end(), tag_vendor.begin(), ::tolower); @@ -7896,6 +7888,7 @@ void check_filaments_for_ams_slot(std::string model_id, std::string type = filament_item.contains("type") ? filament_item["type"].get() : ""; std::string type_suffix = filament_item.contains("type_suffix") ? filament_item["type_suffix"].get() : ""; std::string name = filament_item.contains("name") ? filament_item["name"].get() : ""; + std::string slot = filament_item.contains("slot") ? filament_item["slot"].get() : ""; std::vector model_ids = filament_item.contains("model_id") ? filament_item["model_id"].get>() : std::vector(); std::string action = filament_item.contains("action") ? filament_item["action"].get() : ""; std::string description = filament_item.contains("description") ? filament_item["description"].get() : ""; @@ -7929,14 +7922,35 @@ void check_filaments_for_ams_slot(std::string model_id, std::transform(name.begin(), name.end(), name.begin(), ::tolower); if (!name.empty() && (name != tag_name)) { continue;} + // check loc + if (!slot.empty()) { + bool is_virtual_slot = DeviceManager::is_virtual_slot(ams_id); + bool check_virtual_slot = (slot == "ext"); + bool check_ams_slot = (slot == "ams"); + if (is_virtual_slot && !check_virtual_slot) { + continue; + } else if (!is_virtual_slot && !check_ams_slot) { + continue; + } + } + if (GUI::wxGetApp().app_config->get("skip_ams_blacklist_check") == "true") { action = "warning"; } in_blacklist = true; ac = action; - info = blacklist_prompt[description]; + info = _L(description); + wiki_url = filament_item.contains("wiki") ? filament_item["wiki"].get() : ""; return; + + // Using in description + L("TPU is not supported by AMS."); + L("Damp PVA will become flexible and get stuck inside AMS, please take care to dry it before use."); + L("The rough surface of PLA Glow can accelerate wear on the AMS system, particularly on the internal components of the AMS Lite."); + L("CF/GF filaments are hard and brittle, it's easy to break or get stuck in AMS, please use with caution."); + L("PPS-CF is brittle and could break in bended PTFE tube above Toolhead."); + L("PPA-CF is brittle and could break in bended PTFE tube above Toolhead."); } } } @@ -7954,17 +7968,23 @@ void DeviceManager::check_filaments_in_blacklist(std::string model_id, std::string &ac, wxString &info) { - if (ams_id < 0 || slot_id < 0) { + wxString wiki_url; + check_filaments_in_blacklist_url(model_id, tag_vendor, tag_type, filament_id, ams_id, slot_id, tag_name, in_blacklist, ac, info, wiki_url); +} + +void DeviceManager::check_filaments_in_blacklist_url(std::string model_id, std::string tag_vendor, std::string tag_type, const std::string& filament_id, int ams_id, int slot_id, std::string tag_name, bool& in_blacklist, std::string& ac, wxString& info, wxString& wiki_url) +{ + if (ams_id < 0 || slot_id < 0) + { return; } - if (!check_filaments_printable(tag_vendor, tag_type, filament_id, ams_id, in_blacklist, ac, info)) { + if (!check_filaments_printable(tag_vendor, tag_type, filament_id, ams_id, in_blacklist, ac, info)) + { return; } - if (!DeviceManager::is_virtual_slot(ams_id)) { - check_filaments_for_ams_slot(model_id, tag_vendor, tag_type, ams_id, slot_id, tag_name, in_blacklist, ac, info); - } + check_filaments(model_id, tag_vendor, tag_type, ams_id, slot_id, tag_name, in_blacklist, ac, info, wiki_url); } std::string DeviceManager::load_gcode(std::string type_str, std::string gcode_file) diff --git a/src/slic3r/GUI/DeviceManager.hpp b/src/slic3r/GUI/DeviceManager.hpp index 655969626e..4e3967743c 100644 --- a/src/slic3r/GUI/DeviceManager.hpp +++ b/src/slic3r/GUI/DeviceManager.hpp @@ -1510,6 +1510,7 @@ public: static std::vector get_compatible_machine(std::string type_str); static std::vector get_unsupport_auto_cali_filaments(std::string type_str); static void check_filaments_in_blacklist(std::string model_id, std::string tag_vendor, std::string tag_type, const std::string& filament_id, int ams_id, int slot_id, std::string tag_name, bool &in_blacklist, std::string &ac, wxString &info); + static void check_filaments_in_blacklist_url(std::string model_id, std::string tag_vendor, std::string tag_type, const std::string& filament_id, int ams_id, int slot_id, std::string tag_name, bool& in_blacklist, std::string& ac, wxString& info, wxString& wiki_url); static boost::bimaps::bimap get_all_model_id_with_name(); static std::string load_gcode(std::string type_str, std::string gcode_file); static bool is_virtual_slot(int ams_id); diff --git a/src/slic3r/GUI/PrePrintChecker.cpp b/src/slic3r/GUI/PrePrintChecker.cpp index b4dbfa65bc..b31f580221 100644 --- a/src/slic3r/GUI/PrePrintChecker.cpp +++ b/src/slic3r/GUI/PrePrintChecker.cpp @@ -94,7 +94,7 @@ void PrePrintChecker::clear() filamentList.clear(); } -void PrePrintChecker::add(PrintDialogStatus state, wxString msg, wxString tip) +void PrePrintChecker::add(PrintDialogStatus state, wxString msg, wxString tip, const wxString& wiki_url) { prePrintInfo info; @@ -124,12 +124,18 @@ void PrePrintChecker::add(PrintDialogStatus state, wxString msg, wxString tip) info.tips = wxEmptyString; } + info.wiki_url = wiki_url; + switch (info.type) { case prePrintInfoType::Filament: - filamentList.push_back(info); + if (std::find(filamentList.begin(), filamentList.end(), info) == filamentList.end()) { + filamentList.push_back(info); + } break; case prePrintInfoType::Printer: - printerList.push_back(info); + if (std::find(printerList.begin(), printerList.end(), info) == printerList.end()) { + printerList.push_back(info); + } break; default: break; } @@ -171,67 +177,61 @@ PrinterMsgPanel::PrinterMsgPanel(wxWindow *parent) this->SetSizer(m_sizer); } -void PrinterMsgPanel::SetLabelList(const std::vector &texts, const wxColour &colour) +static wxColour _GetLabelColour(const prePrintInfo& info) { - if (texts == m_last_texts) - return; - - m_last_texts = texts; - m_labels.clear(); - m_sizer->Clear(true); - std::set unique_texts; - - for (const wxString &text : texts) { - if (text.empty()) { - continue; - } - if (!unique_texts.insert(text).second) { - continue; - } - Label *label = new Label(this); - label->SetFont(::Label::Body_13); - label->SetForegroundColour(colour); - label->SetLabel(text); - label->Wrap(this->GetMinSize().GetWidth()); - label->Show(); - m_sizer->Add(label, 0, wxBOTTOM, FromDIP(4)); - m_labels.push_back(label); + if (info.level == Error) + { + return wxColour("#D01B1B"); } + else if (info.level == Warning) + { + return wxColour("#FF6F00"); + } + + return *wxBLACK; // Default colour for normal messages +} + +void PrinterMsgPanel::UpdateInfos(const std::vector& infos) +{ + if (m_infos == infos) + { + return; + } + m_infos = infos; + + m_sizer->Clear(true); + for (const prePrintInfo& info : infos) + { + if (!info.msg.empty()) + { + Label* label = new Label(this); + label->SetFont(::Label::Body_13); + label->SetForegroundColour(_GetLabelColour(info)); + + + if (info.wiki_url.empty()) + { + label->SetLabel(info.msg); + } + else + { + label->SetLabel(info.msg + " " + _L("Please refer to Wiki before use->")); + label->Bind(wxEVT_ENTER_WINDOW, [this](auto& e) { SetCursor(wxCURSOR_HAND); }); + label->Bind(wxEVT_LEAVE_WINDOW, [this](auto& e) { SetCursor(wxCURSOR_ARROW); }); + label->Bind(wxEVT_LEFT_DOWN, [info](wxMouseEvent& event) { wxLaunchDefaultBrowser(info.wiki_url); }); + } + + label->Wrap(this->GetMinSize().GetWidth()); + label->Show(); + m_sizer->Add(label, 0, wxBOTTOM, FromDIP(4)); + } + } + this->Show(); this->Layout(); Fit(); } -//void PrinterMsgPanel::SetLabelSingle(const wxString &texts, const wxColour &colour) -//{ -// Label *label = new Label(this); -// label->SetMinSize(wxSize(FromDIP(420), -1)); -// label->SetMaxSize(wxSize(FromDIP(420), -1)); -// label->SetFont(::Label::Body_13); -// label->SetForegroundColour(colour); -// label->SetLabel(texts); -// label->Wrap(FromDIP(-1)); -// label->Show(); -// m_sizer->Add(label, 0, wxBOTTOM, FromDIP(4)); -// m_labels.push_back(label); -// this->Layout(); -// Fit(); -//} - -wxString PrinterMsgPanel::GetLabel() { - if (!m_labels.empty() && m_labels[0] != nullptr) - return m_labels[0]->GetLabel(); - return wxEmptyString; -} - - -std::vector PrinterMsgPanel::GetLabelList() { - if (m_last_texts.empty()) - wxLogDebug(_L("No labels are currently stored.")); - return m_last_texts; -} - - } }; diff --git a/src/slic3r/GUI/PrePrintChecker.hpp b/src/slic3r/GUI/PrePrintChecker.hpp index aa50348de0..01ff37ac6f 100644 --- a/src/slic3r/GUI/PrePrintChecker.hpp +++ b/src/slic3r/GUI/PrePrintChecker.hpp @@ -22,7 +22,15 @@ struct prePrintInfo prePrintInfoType type; wxString msg; wxString tips; + wxString wiki_url; int index; + +public: + bool operator==(const prePrintInfo& other) const { + return level == other.level && type == other.type && + msg == other.msg && tips == other.tips && + wiki_url == other.wiki_url && index == other.index; + } }; enum PrintDialogStatus : unsigned int { @@ -119,7 +127,7 @@ public: public: void clear(); /*auto merge*/ - void add(PrintDialogStatus state, wxString msg, wxString tip); + void add(PrintDialogStatus state, wxString msg, wxString tip, const wxString& wiki_url); static ::std::string get_print_status_info(PrintDialogStatus status); wxString get_pre_state_msg(PrintDialogStatus status); @@ -164,17 +172,13 @@ class PrinterMsgPanel : public wxPanel public: PrinterMsgPanel(wxWindow *parent); - void SetLabelList(const std::vector &texts, const wxColour &colour); - - // void SetLabelSingle(const wxString &texts,const wxColour& colour); - - wxString GetLabel(); - std::vector GetLabelList(); +public: + void UpdateInfos(const std::vector& infos); private: - wxBoxSizer * m_sizer = nullptr; - std::vector