diff --git a/resources/profiles/BBL/machine/Bambu Lab H2D.json b/resources/profiles/BBL/machine/Bambu Lab H2D.json index 7c72cf848..63d543b8f 100644 --- a/resources/profiles/BBL/machine/Bambu Lab H2D.json +++ b/resources/profiles/BBL/machine/Bambu Lab H2D.json @@ -6,6 +6,7 @@ "bed_model": "bbl-3dp-H2D.stl", "bed_texture": "bbl-3dp-logo.svg", "default_bed_type": "Textured PEI Plate", + "not_support_bed_type":"Cool Plate;Engineering Plate;Bambu Cool Plate SuperTack", "family": "BBL-3DP", "machine_tech": "FFF", "model_id": "O1D", diff --git a/src/libslic3r/Preset.hpp b/src/libslic3r/Preset.hpp index e43adf6cd..16b5ac801 100644 --- a/src/libslic3r/Preset.hpp +++ b/src/libslic3r/Preset.hpp @@ -62,6 +62,7 @@ #define BBL_JSON_KEY_DEFAULT_BED_TYPE "default_bed_type" #define BBL_JSON_KEY_HOTEND_MODEL "hotend_model" #define BBL_JSON_KEY_DEFAULT_MATERIALS "default_materials" +#define BBL_JSON_KEY_NOT_SUPPORT_BED_TYPE "not_support_bed_type" #define BBL_JSON_KEY_MODEL_ID "model_id" //BBL: json path @@ -112,6 +113,7 @@ public: std::string family; std::vector variants; std::vector default_materials; + std::vector not_support_bed_types; // Vendor & Printer Model specific print bed model & texture. std::string bed_model; std::string bed_texture; diff --git a/src/libslic3r/PresetBundle.cpp b/src/libslic3r/PresetBundle.cpp index b02c465ee..a3cca48e4 100644 --- a/src/libslic3r/PresetBundle.cpp +++ b/src/libslic3r/PresetBundle.cpp @@ -3743,6 +3743,18 @@ std::pair PresetBundle::load_vendor_configs_ } else { BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << boost::format(": invalid default_materials %1% for Vendor %1%") % default_materials_field % vendor_name; } + } else if (boost::iequals(it.key(), BBL_JSON_KEY_NOT_SUPPORT_BED_TYPE)) { + // get machine list + std::string not_support_bed_type_field = it.value(); + if (Slic3r::unescape_strings_cstyle(not_support_bed_type_field, model.not_support_bed_types)) { + Slic3r::sort_remove_duplicates(model.not_support_bed_types); + if (!model.not_support_bed_types.empty() && model.not_support_bed_types.front().empty()) + // An empty material was inserted into the list of default materials. Remove it. + model.not_support_bed_types.erase(model.not_support_bed_types.begin()); + } else { + BOOST_LOG_TRIVIAL(error) << __FUNCTION__ + << boost::format(": invalid not_support_bed_types %1% for Vendor %1%") % not_support_bed_type_field % vendor_name; + } } } } diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 4b3b57d6e..19001c109 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -1568,18 +1568,13 @@ Sidebar::Sidebar(Plater *parent) p->combo_printer_bed = new ComboBox(p->panel_printer_bed, wxID_ANY, wxString(""), wxDefaultPosition, wxDefaultSize, 0, nullptr, wxCB_READONLY | wxALIGN_CENTER_HORIZONTAL); p->combo_printer_bed->SetBorderWidth(0); p->combo_printer_bed->GetDropDown().SetUseContentWidth(true); - const ConfigOptionDef *bed_type_def = print_config_def.get("curr_bed_type"); - if (bed_type_def && bed_type_def->enum_keys_map) { - for (auto item : bed_type_def->enum_labels) { - p->combo_printer_bed->AppendString(_L(item)); - } - } + reset_bed_type_combox_choices(); p->combo_printer_bed->Bind(wxEVT_COMBOBOX, [this](auto &e) { - int selection = p->combo_printer_bed->GetSelection(); - bool isDual = static_cast(p->panel_printer_preset->GetSizer())->GetOrientation() == wxVERTICAL; - p->image_printer_bed->SetBitmap(create_scaled_bitmap(bed_type_thumbnails[BedType(selection + 1)], this, isDual ? 48 : 32)); - e.Skip();//fix bug:Event spreads to sidebar + auto select_bed_type = get_cur_select_bed_type(); + bool isDual = static_cast(p->panel_printer_preset->GetSizer())->GetOrientation() == wxVERTICAL; + p->image_printer_bed->SetBitmap(create_scaled_bitmap(bed_type_thumbnails[select_bed_type], this, isDual ? 48 : 32)); + e.Skip(); // fix bug:Event spreads to sidebar }); { @@ -2062,6 +2057,7 @@ void Sidebar::update_all_preset_comboboxes() AppConfig* config = wxGetApp().app_config; if (config) { m_update_3d_state = true; + reset_bed_type_combox_choices(); if (m_soft_first_start && !wxGetApp().get_app_conf_exists()) { use_default_bed_type(); } else { @@ -2246,6 +2242,7 @@ void Sidebar::update_presets(Preset::Type preset_type) extruder.combo_diameter->SetSelection(select); extruder.diameter = diameter; }; + auto select_bed_type = get_cur_select_bed_type(); if (is_dual_extruder) { AMSCountPopupWindow::UpdateAMSCount(0, p->left_extruder); AMSCountPopupWindow::UpdateAMSCount(1, p->right_extruder); @@ -2255,13 +2252,14 @@ void Sidebar::update_presets(Preset::Type preset_type) update_extruder_diameter(*p->left_extruder); update_extruder_diameter(*p->right_extruder); //} - p->image_printer_bed->SetBitmap(create_scaled_bitmap(bed_type_thumbnails[BedType(p->combo_printer_bed->GetSelection() + 1)], this, 48)); + + p->image_printer_bed->SetBitmap(create_scaled_bitmap(bed_type_thumbnails[select_bed_type], this, 48)); } else { AMSCountPopupWindow::UpdateAMSCount(0, p->single_extruder); update_extruder_variant(*p->single_extruder, 0); //if (!p->is_switching_diameter) update_extruder_diameter(*p->single_extruder); - p->image_printer_bed->SetBitmap(create_scaled_bitmap(bed_type_thumbnails[BedType(p->combo_printer_bed->GetSelection() + 1)], this, 32)); + p->image_printer_bed->SetBitmap(create_scaled_bitmap(bed_type_thumbnails[select_bed_type], this, 32)); } if (GUI::wxGetApp().plater()) @@ -2342,6 +2340,47 @@ void Sidebar::save_bed_type_to_config(const std::string &bed_type_name) } } +BedType Sidebar::get_cur_select_bed_type() { + int selection = p->combo_printer_bed->GetSelection(); + if (selection < 0 && selection >= m_cur_combox_bed_types.size()) { + p->combo_printer_bed->SetSelection(0); + selection = 0; + } + auto select_bed_type = m_cur_combox_bed_types[selection]; + return select_bed_type; +} + +void Sidebar::reset_bed_type_combox_choices() { + if (!p->combo_printer_bed) { return; } + auto bundle = wxGetApp().preset_bundle; + const Preset * curr = &bundle->printers.get_selected_preset(); + const VendorProfile::PrinterModel *pm = PresetUtils::system_printer_model(*curr); + + const ConfigOptionDef *bed_type_def = print_config_def.get("curr_bed_type"); + p->combo_printer_bed->Clear(); + m_cur_combox_bed_types.clear(); + if (pm &&bed_type_def && bed_type_def->enum_keys_map) { + int index = 0; + for (auto item : bed_type_def->enum_labels) { + index++; + bool find = std::find(pm->not_support_bed_types.begin(), pm->not_support_bed_types.end(), item) != pm->not_support_bed_types.end(); + if (find) { + continue; + } + m_cur_combox_bed_types.emplace_back(BedType(index));//BedType //btPC =1 + p->combo_printer_bed->AppendString(_L(item)); + } + } + else { + int index = 0; + for (auto item : bed_type_def->enum_labels) { + index++; + m_cur_combox_bed_types.emplace_back(BedType(index)); // BedType //btPC =1 + p->combo_printer_bed->AppendString(_L(item)); + } + } +} + bool Sidebar::use_default_bed_type(bool is_bbl_preset) { auto bundle = wxGetApp().preset_bundle; @@ -2350,8 +2389,8 @@ bool Sidebar::use_default_bed_type(bool is_bbl_preset) if (is_bbl_preset && pm && pm->default_bed_type.size() > 0) { return set_bed_type(pm->default_bed_type); } - int selection = p->combo_printer_bed->GetSelection(); - std::string bed_type_name = print_config_def.get("curr_bed_type")->enum_values[selection]; + auto select_bed_type = get_cur_select_bed_type(); + std::string bed_type_name = print_config_def.get("curr_bed_type")->enum_values[int(select_bed_type) - 1]; save_bed_type_to_config(bed_type_name); return false; } @@ -2378,7 +2417,8 @@ void Sidebar::msw_rescale() p->btn_edit_printer->msw_rescale(); p->image_printer->SetSize(PRINTER_THUMBNAIL_SIZE); bool isDual = static_cast(p->panel_printer_preset->GetSizer())->GetOrientation() == wxVERTICAL; - p->image_printer_bed->SetBitmap(create_scaled_bitmap(bed_type_thumbnails[BedType(p->combo_printer_bed->GetSelection() + 1)], this, 48)); + auto select_bed_type = get_cur_select_bed_type(); + p->image_printer_bed->SetBitmap(create_scaled_bitmap(bed_type_thumbnails[select_bed_type], this, 48)); p->m_filament_icon->msw_rescale(); p->m_bpButton_add_filament->msw_rescale(); p->m_bpButton_del_filament->msw_rescale(); @@ -3446,6 +3486,7 @@ struct Plater::priv { // PIMPL back pointer ("Q-Pointer") Plater *q; + Sidebar * sidebar; MainFrame *main_frame; MenuFactory menus; @@ -3467,7 +3508,7 @@ struct Plater::priv wxSizer* panel_sizer{ nullptr }; wxPanel* current_panel{ nullptr }; std::vector panels; - Sidebar *sidebar; + Bed3D bed; Camera camera; //BBS: partplate related structure @@ -7800,8 +7841,8 @@ void Plater::priv::on_combobox_select(wxCommandEvent &evt) void Plater::priv::on_select_bed_type(wxCommandEvent &evt) { ComboBox* combo = static_cast(evt.GetEventObject()); - int selection = combo->GetSelection(); - std::string bed_type_name = print_config_def.get("curr_bed_type")->enum_values[selection]; + auto select_bed_type = sidebar->get_cur_select_bed_type(); + std::string bed_type_name = print_config_def.get("curr_bed_type")->enum_values[(int)select_bed_type - 1]; PresetBundle& preset_bundle = *wxGetApp().preset_bundle; DynamicPrintConfig& proj_config = wxGetApp().preset_bundle->project_config; diff --git a/src/slic3r/GUI/Plater.hpp b/src/slic3r/GUI/Plater.hpp index f3e6d4680..78d06f990 100644 --- a/src/slic3r/GUI/Plater.hpp +++ b/src/slic3r/GUI/Plater.hpp @@ -121,6 +121,8 @@ class Sidebar : public wxPanel ScalableButton * ams_btn{nullptr}; std::shared_ptr m_sna_dialog{nullptr}; std::shared_ptr m_fna_dialog{nullptr}; + std::vector m_cur_combox_bed_types; + public: Sidebar(Plater *parent); Sidebar(Sidebar &&) = delete; @@ -140,6 +142,8 @@ public: void update_presets_from_to(Slic3r::Preset::Type preset_type, std::string from, std::string to); bool set_bed_type(const std::string& bed_type_name); void save_bed_type_to_config(const std::string &bed_type_name); + BedType get_cur_select_bed_type(); + void reset_bed_type_combox_choices(); bool use_default_bed_type(bool is_bbl_preset = true); void change_top_border_for_mode_sizer(bool increase_border); void msw_rescale(); diff --git a/src/slic3r/GUI/Widgets/ComboBox.cpp b/src/slic3r/GUI/Widgets/ComboBox.cpp index a1cc85522..f9d6d3911 100644 --- a/src/slic3r/GUI/Widgets/ComboBox.cpp +++ b/src/slic3r/GUI/Widgets/ComboBox.cpp @@ -76,7 +76,9 @@ ComboBox::ComboBox(wxWindow *parent, for (int i = 0; i < n; ++i) Append(choices[i]); } -int ComboBox::GetSelection() const { return drop.GetSelection(); } +int ComboBox::GetSelection() const { + return drop.GetSelection(); +} void ComboBox::SetSelection(int n) {