mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-12-26 09:38:37 -07:00
ENH:add "not support bed type" function
jira: STUDIO-9028 Change-Id: Id1c6cc9005fc5073d885274e360d31282063a9a3 (cherry picked from commit e74c9e710b4bed97e637c8197052b5bd864bfc95)
This commit is contained in:
parent
80f6ce9e3d
commit
30731cfd54
6 changed files with 79 additions and 18 deletions
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -62,6 +62,7 @@
|
|||
#define BBL_JSON_KEY_BED_TEXTURE "bed_texture"
|
||||
#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"
|
||||
|
||||
// Orca extension
|
||||
|
|
@ -113,6 +114,7 @@ public:
|
|||
std::string family;
|
||||
std::vector<PrinterVariant> variants;
|
||||
std::vector<std::string> default_materials;
|
||||
std::vector<std::string> not_support_bed_types;
|
||||
// Vendor & Printer Model specific print bed model & texture.
|
||||
std::string bed_model;
|
||||
std::string bed_texture;
|
||||
|
|
|
|||
|
|
@ -3252,6 +3252,18 @@ std::pair<PresetsConfigSubstitutions, size_t> PresetBundle::load_vendor_configs_
|
|||
++m_errors;
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1527,18 +1527,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<wxBoxSizer *>(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<wxBoxSizer *>(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
|
||||
});
|
||||
|
||||
{
|
||||
|
|
@ -2043,6 +2038,7 @@ void Sidebar::update_all_preset_comboboxes()
|
|||
p->combo_printer_bed->Enable();
|
||||
// Orca: don't update bed type if loading project
|
||||
if (!p->plater->is_loading_project()) {
|
||||
reset_bed_type_combox_choices();
|
||||
auto str_bed_type = wxGetApp().app_config->get_printer_setting(wxGetApp().preset_bundle->printers.get_selected_preset_name(),
|
||||
"curr_bed_type");
|
||||
if (!str_bed_type.empty()) {
|
||||
|
|
@ -2167,13 +2163,15 @@ void Sidebar::update_presets(Preset::Type preset_type)
|
|||
|
||||
bool is_dual_extruder = nozzle_diameter->size() == 2;
|
||||
p->layout_printer(isBBL, is_dual_extruder);
|
||||
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);
|
||||
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);
|
||||
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())
|
||||
|
|
@ -2224,6 +2222,47 @@ void Sidebar::update_presets_from_to(Slic3r::Preset::Type preset_type, std::stri
|
|||
BOOST_LOG_TRIVIAL(debug) << __FUNCTION__ << boost::format(": exit!");
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Sidebar::change_top_border_for_mode_sizer(bool increase_border)
|
||||
{
|
||||
// BBS
|
||||
|
|
@ -2246,7 +2285,8 @@ void Sidebar::msw_rescale()
|
|||
p->btn_edit_printer->msw_rescale();
|
||||
p->image_printer->SetSize(PRINTER_THUMBNAIL_SIZE);
|
||||
bool isDual = static_cast<wxBoxSizer *>(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();
|
||||
|
|
@ -3344,6 +3384,7 @@ struct Plater::priv
|
|||
{
|
||||
// PIMPL back pointer ("Q-Pointer")
|
||||
Plater *q;
|
||||
Sidebar * sidebar;
|
||||
MainFrame *main_frame;
|
||||
|
||||
MenuFactory menus;
|
||||
|
|
@ -3366,7 +3407,7 @@ struct Plater::priv
|
|||
wxString m_default_window_layout;
|
||||
wxPanel* current_panel{ nullptr };
|
||||
std::vector<wxPanel*> panels;
|
||||
Sidebar *sidebar;
|
||||
|
||||
struct SidebarLayout
|
||||
{
|
||||
bool is_enabled{false};
|
||||
|
|
@ -7772,8 +7813,8 @@ void Plater::priv::on_combobox_select(wxCommandEvent &evt)
|
|||
void Plater::priv::on_select_bed_type(wxCommandEvent &evt)
|
||||
{
|
||||
ComboBox* combo = static_cast<ComboBox*>(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;
|
||||
|
|
|
|||
|
|
@ -129,6 +129,8 @@ class Sidebar : public wxPanel
|
|||
ScalableButton * ams_btn{nullptr};
|
||||
std::shared_ptr<SyncNozzleAndAmsDialog> m_sna_dialog{nullptr};
|
||||
std::shared_ptr<FinishSyncAmsDialog> m_fna_dialog{nullptr};
|
||||
std::vector<BedType> m_cur_combox_bed_types;
|
||||
|
||||
public:
|
||||
enum DockingState
|
||||
{
|
||||
|
|
@ -150,7 +152,8 @@ public:
|
|||
void update_presets(Slic3r::Preset::Type preset_type);
|
||||
//BBS
|
||||
void update_presets_from_to(Slic3r::Preset::Type preset_type, std::string from, std::string to);
|
||||
|
||||
BedType get_cur_select_bed_type();
|
||||
void reset_bed_type_combox_choices();
|
||||
void change_top_border_for_mode_sizer(bool increase_border);
|
||||
void msw_rescale();
|
||||
void sys_color_changed();
|
||||
|
|
|
|||
|
|
@ -77,7 +77,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)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue