diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index 7b19aa269b..edf875bcbd 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -363,7 +363,8 @@ void PrintConfigDef::init_common_params() def = this->add("printable_area", coPoints); def->label = L("Printable area"); //BBS - def->mode = comDevelop; + def->mode = comAdvanced; + def->gui_type = ConfigOptionDef::GUIType::one_string; def->set_default_value(new ConfigOptionPoints{ Vec2d(0, 0), Vec2d(200, 0), Vec2d(200, 200), Vec2d(0, 200) }); //BBS: add "bed_exclude_area" @@ -378,11 +379,13 @@ void PrintConfigDef::init_common_params() def = this->add("bed_custom_texture", coString); def->label = L("Bed custom texture"); def->mode = comAdvanced; + def->gui_type = ConfigOptionDef::GUIType::one_string; def->set_default_value(new ConfigOptionString("")); def = this->add("bed_custom_model", coString); def->label = L("Bed custom model"); def->mode = comAdvanced; + def->gui_type = ConfigOptionDef::GUIType::one_string; def->set_default_value(new ConfigOptionString("")); def = this->add("elefant_foot_compensation", coFloat); @@ -2341,7 +2344,7 @@ void PrintConfigDef::init_fff_params() def->label = L("Nozzle volume"); def->tooltip = L("Volume of nozzle between the cutter and the end of nozzle"); def->sidetext = L("mm³"); - def->mode = comDevelop; + def->mode = comAdvanced; def->readonly = true; def->set_default_value(new ConfigOptionFloat { 0.0 }); diff --git a/src/libslic3r/PrintConfig.hpp b/src/libslic3r/PrintConfig.hpp index db54819379..51d47db076 100644 --- a/src/libslic3r/PrintConfig.hpp +++ b/src/libslic3r/PrintConfig.hpp @@ -920,6 +920,8 @@ PRINT_CONFIG_CLASS_DERIVED_DEFINE( //BBS: add bed_exclude_area ((ConfigOptionPoints, bed_exclude_area)) // BBS + ((ConfigOptionString, bed_custom_texture)) + ((ConfigOptionString, bed_custom_model)) ((ConfigOptionEnum, curr_bed_type)) ((ConfigOptionInts, cool_plate_temp)) ((ConfigOptionInts, eng_plate_temp)) diff --git a/src/slic3r/GUI/2DBed.cpp b/src/slic3r/GUI/2DBed.cpp index e7c2cbe542..9760c36be1 100644 --- a/src/slic3r/GUI/2DBed.cpp +++ b/src/slic3r/GUI/2DBed.cpp @@ -34,11 +34,12 @@ void Bed_2D::repaint(const std::vector& shape) // On MacOS the background is erased, on Windows the background is not erased // and on Linux / GTK the background is erased to gray color. // Fill DC with the background on Windows & Linux / GTK. -#ifdef _WIN32 - auto color = wxGetApp().get_highlight_default_clr(); -#else - auto color = wxSystemSettings::GetColour(wxSYS_COLOUR_3DLIGHT); //GetSystemColour -#endif + wxColour color; + if (wxGetApp().dark_mode()) {// SetBackgroundColour + color = wxColour(45, 45, 49); + } else { + color = *wxWHITE; + } dc.SetPen(*new wxPen(color, 1, wxPENSTYLE_SOLID)); dc.SetBrush(*new wxBrush(color, wxBRUSHSTYLE_SOLID)); auto rect = GetUpdateRegion().GetBox(); diff --git a/src/slic3r/GUI/BedShapeDialog.cpp b/src/slic3r/GUI/BedShapeDialog.cpp index d692d45370..be083cd9b4 100644 --- a/src/slic3r/GUI/BedShapeDialog.cpp +++ b/src/slic3r/GUI/BedShapeDialog.cpp @@ -35,7 +35,7 @@ static std::string get_option_label(BedShape::Parameter param) } } -void BedShape::append_option_line(ConfigOptionsGroupShp optgroup, Parameter param) +void BedShape::append_option_line(ConfigOptionsGroupShp optgroup, Parameter param, bool can_edit) { ConfigOptionDef def; t_config_option_key key; @@ -47,6 +47,7 @@ void BedShape::append_option_line(ConfigOptionsGroupShp optgroup, Parameter para def.max = 1200; def.label = get_option_label(param); def.tooltip = L("Size in X and Y of the rectangular plate."); + def.readonly = !can_edit; key = "rect_size"; break; case Parameter::RectOrigin: @@ -56,6 +57,7 @@ void BedShape::append_option_line(ConfigOptionsGroupShp optgroup, Parameter para def.max = 600; def.label = get_option_label(param); def.tooltip = L("Distance of the 0,0 G-code coordinate from the front left corner of the rectangle."); + def.readonly = !can_edit; key = "rect_origin"; break; case Parameter::Diameter: @@ -64,6 +66,7 @@ void BedShape::append_option_line(ConfigOptionsGroupShp optgroup, Parameter para def.sidetext = L("mm"); def.label = get_option_label(param); def.tooltip = L("Diameter of the print bed. It is assumed that origin (0,0) is located in the center."); + def.readonly = !can_edit; key = "diameter"; break; default: @@ -128,22 +131,23 @@ void BedShape::apply_optgroup_values(ConfigOptionsGroupShp optgroup) } } -void BedShapeDialog::build_dialog(const ConfigOptionPoints& default_pt, const ConfigOptionString& custom_texture, const ConfigOptionString& custom_model) +void BedShapeDialog::build_dialog(const ConfigOptionPoints &default_pt, const ConfigOptionString &custom_texture, const ConfigOptionString &custom_model, bool can_edit) { SetFont(wxGetApp().normal_font()); - - m_panel = new BedShapePanel(this); + this->SetBackgroundColour(*wxWHITE); + m_panel = new BedShapePanel(this); + m_panel->set_edit_state(can_edit); m_panel->build_panel(default_pt, custom_texture, custom_model); - auto main_sizer = new wxBoxSizer(wxVERTICAL); - main_sizer->Add(m_panel, 1, wxEXPAND); - main_sizer->Add(CreateButtonSizer(wxOK | wxCANCEL), 0, wxALIGN_CENTER_HORIZONTAL | wxBOTTOM, 10); + auto main_sizer = new wxBoxSizer(wxVERTICAL); + main_sizer->Add(m_panel, 1, wxEXPAND); + main_sizer->Add(CreateButtonSizer(wxOK | wxCANCEL), 0, wxALIGN_CENTER_HORIZONTAL | wxBOTTOM, 10); wxGetApp().UpdateDlgDarkUI(this); - SetSizer(main_sizer); - SetMinSize(GetSize()); - main_sizer->SetSizeHints(this); + SetSizer(main_sizer); + SetMinSize(GetSize()); + main_sizer->SetSizeHints(this); this->Bind(wxEVT_CLOSE_WINDOW, ([this](wxCloseEvent& evt) { EndModal(wxID_CANCEL); @@ -178,6 +182,7 @@ void BedShapePanel::build_panel(const ConfigOptionPoints& default_pt, const Conf auto sbsizer = new wxStaticBoxSizer(wxVERTICAL, this, _L("Shape")); sbsizer->GetStaticBox()->SetFont(wxGetApp().bold_font()); + sbsizer->GetStaticBox()->Enable(m_can_edit); wxGetApp().UpdateDarkUI(sbsizer->GetStaticBox()); // shape options @@ -187,13 +192,12 @@ void BedShapePanel::build_panel(const ConfigOptionPoints& default_pt, const Conf sbsizer->Add(m_shape_options_book); auto optgroup = init_shape_options_page(BedShape::get_name(BedShape::PageType::Rectangle)); - BedShape::append_option_line(optgroup, BedShape::Parameter::RectSize); + BedShape::append_option_line(optgroup, BedShape::Parameter::RectSize,m_can_edit); // BBS hide - //BedShape::append_option_line(optgroup, BedShape::Parameter::RectOrigin); + BedShape::append_option_line(optgroup, BedShape::Parameter::RectOrigin, m_can_edit); activate_options_page(optgroup); - // BBS hide -/* optgroup = init_shape_options_page(BedShape::get_name(BedShape::PageType::Circle)); + /* optgroup = init_shape_options_page(BedShape::get_name(BedShape::PageType::Circle)); BedShape::append_option_line(optgroup, BedShape::Parameter::Diameter); activate_options_page(optgroup); @@ -219,9 +223,6 @@ void BedShapePanel::build_panel(const ConfigOptionPoints& default_pt, const Conf wxPanel* texture_panel = init_texture_panel(); wxPanel* model_panel = init_model_panel(); - // BBS hide - texture_panel->Hide(); - model_panel->Hide(); Bind(wxEVT_CHOICEBOOK_PAGE_CHANGED, ([this](wxCommandEvent& e) { update_shape(); })); @@ -251,6 +252,7 @@ void BedShapePanel::build_panel(const ConfigOptionPoints& default_pt, const Conf ConfigOptionsGroupShp BedShapePanel::init_shape_options_page(const wxString& title) { wxPanel* panel = new wxPanel(m_shape_options_book); + panel->SetBackgroundColour(*wxWHITE); ConfigOptionsGroupShp optgroup = std::make_shared(panel, _L("Settings")); optgroup->label_width = 10; @@ -271,83 +273,64 @@ void BedShapePanel::activate_options_page(ConfigOptionsGroupShp options_group) options_group->parent()->SetSizerAndFit(options_group->sizer); } -wxPanel* BedShapePanel::init_texture_panel() +wxPanel *BedShapePanel::init_texture_panel() { - wxPanel* panel = new wxPanel(this); - panel->SetBackgroundColour(*wxWHITE); + wxPanel *panel = new wxPanel(this); + wxGetApp().UpdateDarkUI(panel, true); ConfigOptionsGroupShp optgroup = std::make_shared(panel, _L("Texture")); optgroup->label_width = 10; - optgroup->m_on_change = [this](t_config_option_key opt_key, boost::any value) { - update_shape(); - }; + optgroup->m_on_change = [this](t_config_option_key opt_key, boost::any value) { update_shape(); }; - Line line{ "", "" }; + Line line{"", ""}; line.full_width = 1; - line.widget = [this](wxWindow* parent) { - - StateColor btn_bg_white(std::pair(wxColour(206, 206, 206), StateColor::Disabled), std::pair(wxColour(206, 206, 206), StateColor::Pressed), - std::pair(wxColour(206, 206, 206), StateColor::Hovered), - std::pair(*wxWHITE, StateColor::Normal)); - - StateColor btn_bd_white(std::pair(*wxWHITE, StateColor::Disabled), std::pair(wxColour(38, 46, 48), StateColor::Enabled)); - - Button* load_btn = new Button(parent, _L("Load...")); - load_btn->SetBackgroundColor(btn_bg_white); - load_btn->SetBorderColor(btn_bd_white); - load_btn->SetBackgroundColour(*wxWHITE); - wxSizer* load_sizer = new wxBoxSizer(wxHORIZONTAL); + line.widget = [this](wxWindow *parent) { + wxButton *load_btn = new wxButton(parent, wxID_ANY, _L("Load...")); + load_btn->Enable(m_can_edit); + wxSizer * load_sizer = new wxBoxSizer(wxHORIZONTAL); load_sizer->Add(load_btn, 1, wxEXPAND); - wxStaticText* filename_lbl = new wxStaticText(parent, wxID_ANY, _(NONE)); + wxStaticText *filename_lbl = new wxStaticText(parent, wxID_ANY, _(NONE)); - wxSizer* filename_sizer = new wxBoxSizer(wxHORIZONTAL); + wxSizer *filename_sizer = new wxBoxSizer(wxHORIZONTAL); filename_sizer->Add(filename_lbl, 1, wxEXPAND); - Button* remove_btn = new Button(parent, _L("Remove")); - remove_btn->SetBackgroundColor(btn_bg_white); - remove_btn->SetBorderColor(btn_bd_white); - remove_btn->SetBackgroundColour(*wxWHITE); - wxSizer* remove_sizer = new wxBoxSizer(wxHORIZONTAL); + wxButton *remove_btn = new wxButton(parent, wxID_ANY, _L("Remove")); + wxSizer * remove_sizer = new wxBoxSizer(wxHORIZONTAL); remove_sizer->Add(remove_btn, 1, wxEXPAND); - wxGetApp().UpdateDarkUI(load_btn); - wxGetApp().UpdateDarkUI(remove_btn); - - wxSizer* sizer = new wxBoxSizer(wxVERTICAL); + wxSizer *sizer = new wxBoxSizer(wxVERTICAL); sizer->Add(filename_sizer, 1, wxEXPAND); sizer->Add(load_sizer, 1, wxEXPAND); sizer->Add(remove_sizer, 1, wxEXPAND | wxTOP, 2); - load_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent& e) { load_texture(); })); - remove_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent& e) { - m_custom_texture = NONE; - update_shape(); - })); + load_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent &e) { load_texture(); })); + remove_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent &e) { + m_custom_texture = NONE; + update_shape(); + })); - filename_lbl->Bind(wxEVT_UPDATE_UI, ([this](wxUpdateUIEvent& e) { - e.SetText(_(boost::filesystem::path(m_custom_texture).filename().string())); - wxStaticText* lbl = dynamic_cast(e.GetEventObject()); - if (lbl != nullptr) { - bool exists = (m_custom_texture == NONE) || boost::filesystem::exists(m_custom_texture); - lbl->SetForegroundColour(exists ? /*wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT)*/wxGetApp().get_label_clr_default() : wxColor(*wxRED)); + filename_lbl->Bind(wxEVT_UPDATE_UI, ([this](wxUpdateUIEvent &e) { + e.SetText(_(boost::filesystem::path(m_custom_texture).filename().string())); + wxStaticText *lbl = dynamic_cast(e.GetEventObject()); + if (lbl != nullptr) { + bool exists = (m_custom_texture == NONE) || boost::filesystem::exists(m_custom_texture); + lbl->SetForegroundColour(exists ? wxGetApp().get_label_clr_default() : wxColor(*wxRED)); - wxString tooltip_text = ""; - if (m_custom_texture != NONE) { - if (!exists) - tooltip_text += _L("Not found:") + " "; + wxString tooltip_text = ""; + if (m_custom_texture != NONE) { + if (!exists) tooltip_text += _L("Not found:") + " "; - tooltip_text += _(m_custom_texture); - } + tooltip_text += _(m_custom_texture); + } - wxToolTip* tooltip = lbl->GetToolTip(); - if ((tooltip == nullptr) || (tooltip->GetTip() != tooltip_text)) - lbl->SetToolTip(tooltip_text); - } - })); - - remove_btn->Bind(wxEVT_UPDATE_UI, ([this](wxUpdateUIEvent& e) { e.Enable(m_custom_texture != NONE); })); + wxToolTip *tooltip = lbl->GetToolTip(); + if ((tooltip == nullptr) || (tooltip->GetTip() != tooltip_text)) lbl->SetToolTip(tooltip_text); + } + })); + remove_btn->Bind(wxEVT_UPDATE_UI, ([this](wxUpdateUIEvent &e) { e.Enable(m_custom_texture != NONE); })); + parent->SetBackgroundColour(*wxWHITE); return sizer; }; optgroup->append_line(line); @@ -358,84 +341,64 @@ wxPanel* BedShapePanel::init_texture_panel() return panel; } -wxPanel* BedShapePanel::init_model_panel() +wxPanel *BedShapePanel::init_model_panel() { - wxPanel* panel = new wxPanel(this); - panel->SetBackgroundColour(*wxWHITE); + wxPanel *panel = new wxPanel(this); + wxGetApp().UpdateDarkUI(panel, true); ConfigOptionsGroupShp optgroup = std::make_shared(panel, _L("Model")); optgroup->label_width = 10; - optgroup->m_on_change = [this](t_config_option_key opt_key, boost::any value) { - update_shape(); - }; + optgroup->m_on_change = [this](t_config_option_key opt_key, boost::any value) { update_shape(); }; - - Line line{ "", "" }; + Line line{"", ""}; line.full_width = 1; - line.widget = [this](wxWindow* parent) { - StateColor btn_bg_white(std::pair(wxColour(206, 206, 206), StateColor::Disabled), std::pair(wxColour(206, 206, 206), StateColor::Pressed), - std::pair(wxColour(206, 206, 206), StateColor::Hovered), - std::pair(*wxWHITE, StateColor::Normal)); - - StateColor btn_bd_white(std::pair(*wxWHITE, StateColor::Disabled), std::pair(wxColour(38, 46, 48), StateColor::Enabled)); - - - Button* load_btn = new Button(parent, _L("Load...")); - load_btn->SetBackgroundColor(btn_bg_white); - load_btn->SetBorderColor(btn_bd_white); - load_btn->SetBackgroundColour(*wxWHITE); - wxSizer* load_sizer = new wxBoxSizer(wxHORIZONTAL); + line.widget = [this](wxWindow *parent) { + wxButton *load_btn = new wxButton(parent, wxID_ANY, _L("Load...")); + load_btn->Enable(m_can_edit); + wxSizer * load_sizer = new wxBoxSizer(wxHORIZONTAL); load_sizer->Add(load_btn, 1, wxEXPAND); - wxStaticText* filename_lbl = new wxStaticText(parent, wxID_ANY, _(NONE)); - wxSizer* filename_sizer = new wxBoxSizer(wxHORIZONTAL); + wxStaticText *filename_lbl = new wxStaticText(parent, wxID_ANY, _(NONE)); + wxSizer * filename_sizer = new wxBoxSizer(wxHORIZONTAL); filename_sizer->Add(filename_lbl, 1, wxEXPAND); - Button* remove_btn = new Button(parent, _L("Remove")); - remove_btn->SetBackgroundColor(btn_bg_white); - remove_btn->SetBorderColor(btn_bd_white); - remove_btn->SetBackgroundColour(*wxWHITE); - wxSizer* remove_sizer = new wxBoxSizer(wxHORIZONTAL); + wxButton *remove_btn = new wxButton(parent, wxID_ANY, _L("Remove")); + wxSizer * remove_sizer = new wxBoxSizer(wxHORIZONTAL); remove_sizer->Add(remove_btn, 1, wxEXPAND); - wxGetApp().UpdateDarkUI(load_btn); - wxGetApp().UpdateDarkUI(remove_btn); - - wxSizer* sizer = new wxBoxSizer(wxVERTICAL); + wxSizer *sizer = new wxBoxSizer(wxVERTICAL); sizer->Add(filename_sizer, 1, wxEXPAND); sizer->Add(load_sizer, 1, wxEXPAND); sizer->Add(remove_sizer, 1, wxEXPAND | wxTOP, 2); - load_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent& e) { load_model(); })); + load_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent &e) { load_model(); })); - remove_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent& e) { - m_custom_model = NONE; - update_shape(); - })); + remove_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent &e) { + m_custom_model = NONE; + update_shape(); + })); - filename_lbl->Bind(wxEVT_UPDATE_UI, ([this](wxUpdateUIEvent& e) { - e.SetText(_(boost::filesystem::path(m_custom_model).filename().string())); - wxStaticText* lbl = dynamic_cast(e.GetEventObject()); - if (lbl != nullptr) { - bool exists = (m_custom_model == NONE) || boost::filesystem::exists(m_custom_model); - lbl->SetForegroundColour(exists ? /*wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT)*/wxGetApp().get_label_clr_default() : wxColor(*wxRED)); + filename_lbl->Bind(wxEVT_UPDATE_UI, ([this](wxUpdateUIEvent &e) { + e.SetText(_(boost::filesystem::path(m_custom_model).filename().string())); + wxStaticText *lbl = dynamic_cast(e.GetEventObject()); + if (lbl != nullptr) { + bool exists = (m_custom_model == NONE) || boost::filesystem::exists(m_custom_model); + lbl->SetForegroundColour(exists ? wxGetApp().get_label_clr_default() : wxColor(*wxRED)); - wxString tooltip_text = ""; - if (m_custom_model != NONE) { - if (!exists) - tooltip_text += _L("Not found:") + " "; + wxString tooltip_text = ""; + if (m_custom_model != NONE) { + if (!exists) tooltip_text += _L("Not found:") + " "; - tooltip_text += _(m_custom_model); - } + tooltip_text += _(m_custom_model); + } - wxToolTip* tooltip = lbl->GetToolTip(); - if ((tooltip == nullptr) || (tooltip->GetTip() != tooltip_text)) - lbl->SetToolTip(tooltip_text); - } - })); - - remove_btn->Bind(wxEVT_UPDATE_UI, ([this](wxUpdateUIEvent& e) { e.Enable(m_custom_model != NONE); })); + wxToolTip *tooltip = lbl->GetToolTip(); + if ((tooltip == nullptr) || (tooltip->GetTip() != tooltip_text)) lbl->SetToolTip(tooltip_text); + } + })); + remove_btn->Bind(wxEVT_UPDATE_UI, ([this](wxUpdateUIEvent &e) { e.Enable(m_custom_model != NONE); })); + parent->SetBackgroundColour(*wxWHITE); return sizer; }; optgroup->append_line(line); @@ -480,34 +443,46 @@ void BedShapePanel::update_shape() auto opt_group = m_optgroups[page_idx]; switch (static_cast(page_idx)) { - case BedShape::PageType::Rectangle: - { + case BedShape::PageType::Rectangle: { + m_is_valid = true; Vec2d rect_size(Vec2d::Zero()); - Vec2d rect_origin(Vec2d::Zero()); + Vec2d rect_origin(Vec2d::Zero()); - try { rect_size = boost::any_cast(opt_group->get_value("rect_size")); } - catch (const std::exception& /* e */) { return; } + try { + rect_size = boost::any_cast(opt_group->get_value("rect_size")); + } catch (const std::exception & /* e */) { + return; + } // BBS - //try { rect_origin = boost::any_cast(opt_group->get_value("rect_origin")); } - //catch (const std::exception & /* e */) { return; } - - auto x = rect_size(0); - auto y = rect_size(1); - // empty strings or '-' or other things - if (x == 0 || y == 0) return; - double x0 = 0.0; - double y0 = 0.0; - double x1 = x; - double y1 = y; + try { + rect_origin = boost::any_cast(opt_group->get_value("rect_origin")); + } catch (const std::exception & /* e */) { + return; + } - auto dx = rect_origin(0); - auto dy = rect_origin(1); + auto x = rect_size(0); + auto y = rect_size(1); + // empty strings or '-' or other things + if (x == 0 || y == 0) { + m_is_valid = false; + return; + } + double x0 = 0.0; + double y0 = 0.0; + double x1 = x; + double y1 = y; - x0 -= dx; - x1 -= dx; - y0 -= dy; - y1 -= dy; + auto dx = rect_origin(0); + auto dy = rect_origin(1); + if (dx >= x || dy >= y) { + m_is_valid = false; + return; + } + x0 -= dx; + x1 -= dx; + y0 -= dy; + y1 -= dy; m_shape = { Vec2d(x0, y0), Vec2d(x1, y0), Vec2d(x1, y1), diff --git a/src/slic3r/GUI/BedShapeDialog.hpp b/src/slic3r/GUI/BedShapeDialog.hpp index 032aa28800..5b4989655f 100644 --- a/src/slic3r/GUI/BedShapeDialog.hpp +++ b/src/slic3r/GUI/BedShapeDialog.hpp @@ -37,7 +37,7 @@ struct BedShape bool is_custom() { return m_build_volume.type() == BuildVolume::Type::Convex || m_build_volume.type() == BuildVolume::Type::Custom; } - static void append_option_line(ConfigOptionsGroupShp optgroup, Parameter param); + static void append_option_line(ConfigOptionsGroupShp optgroup, Parameter param,bool can_edit); static wxString get_name(PageType type); PageType get_page_type(); @@ -59,6 +59,8 @@ class BedShapePanel : public wxPanel std::vector m_loaded_shape; std::string m_custom_texture; std::string m_custom_model; + bool m_is_valid{true}; + bool m_can_edit{true}; public: BedShapePanel(wxWindow* parent) : wxPanel(parent, wxID_ANY), m_custom_texture(NONE), m_custom_model(NONE) {} @@ -69,6 +71,8 @@ public: const std::vector& get_shape() const { return m_shape; } const std::string& get_custom_texture() const { return (m_custom_texture != NONE) ? m_custom_texture : EMPTY_STRING; } const std::string& get_custom_model() const { return (m_custom_model != NONE) ? m_custom_model : EMPTY_STRING; } + bool get_valid() { return m_is_valid; } + void set_edit_state(bool flag) { m_can_edit = flag; } private: ConfigOptionsGroupShp init_shape_options_page(const wxString& title); @@ -91,16 +95,18 @@ private: class BedShapeDialog : public DPIDialog { BedShapePanel* m_panel; + + public: BedShapeDialog(wxWindow* parent) : DPIDialog(parent, wxID_ANY, _(L("Bed Shape")), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) {} - void build_dialog(const ConfigOptionPoints& default_pt, const ConfigOptionString& custom_texture, const ConfigOptionString& custom_model); + void build_dialog(const ConfigOptionPoints& default_pt, const ConfigOptionString& custom_texture, const ConfigOptionString& custom_model,bool can_edit); const std::vector& get_shape() const { return m_panel->get_shape(); } const std::string& get_custom_texture() const { return m_panel->get_custom_texture(); } const std::string& get_custom_model() const { return m_panel->get_custom_model(); } - + bool get_valid() { return m_panel->get_valid(); } protected: void on_dpi_changed(const wxRect &suggested_rect) override; }; diff --git a/src/slic3r/GUI/CreatePresetsDialog.cpp b/src/slic3r/GUI/CreatePresetsDialog.cpp index cff40017ed..86757c0203 100644 --- a/src/slic3r/GUI/CreatePresetsDialog.cpp +++ b/src/slic3r/GUI/CreatePresetsDialog.cpp @@ -1,5 +1,5 @@ #include "CreatePresetsDialog.hpp" - +#include #include #include #include @@ -1237,7 +1237,7 @@ wxBoxSizer *CreatePrinterPresetDialog::create_bed_size_item(wxWindow *parent) length_sizer->Add(static_length_text, 0, wxEXPAND | wxALL, 0); horizontal_sizer->Add(length_sizer, 0, wxEXPAND | wxLEFT | wxTOP | wxALIGN_CENTER_VERTICAL, FromDIP(10)); wxBoxSizer *length_input_sizer = new wxBoxSizer(wxVERTICAL); - m_bed_size_x_input = new TextInput(parent, wxEmptyString, "mm", wxEmptyString, wxDefaultPosition, PRINTER_SPACE_SIZE, wxTE_CENTRE | wxTE_PROCESS_ENTER); + m_bed_size_x_input = new TextInput(parent, "200", "mm", wxEmptyString, wxDefaultPosition, PRINTER_SPACE_SIZE, wxTE_CENTRE | wxTE_PROCESS_ENTER); wxTextValidator validator(wxFILTER_DIGITS); m_bed_size_x_input->GetTextCtrl()->SetValidator(validator); length_input_sizer->Add(m_bed_size_x_input, 0, wxEXPAND | wxALL, 0); @@ -1250,7 +1250,7 @@ wxBoxSizer *CreatePrinterPresetDialog::create_bed_size_item(wxWindow *parent) width_sizer->Add(static_width_text, 0, wxEXPAND | wxALL, 0); horizontal_sizer->Add(width_sizer, 0, wxEXPAND | wxLEFT | wxTOP | wxALIGN_CENTER_VERTICAL, FromDIP(10)); wxBoxSizer *width_input_sizer = new wxBoxSizer(wxVERTICAL); - m_bed_size_y_input = new TextInput(parent, wxEmptyString, "mm", wxEmptyString, wxDefaultPosition, PRINTER_SPACE_SIZE, wxTE_CENTRE | wxTE_PROCESS_ENTER); + m_bed_size_y_input = new TextInput(parent, "200", "mm", wxEmptyString, wxDefaultPosition, PRINTER_SPACE_SIZE, wxTE_CENTRE | wxTE_PROCESS_ENTER); m_bed_size_y_input->GetTextCtrl()->SetValidator(validator); width_input_sizer->Add(m_bed_size_y_input, 0, wxEXPAND | wxALL, 0); horizontal_sizer->Add(width_input_sizer, 0, wxEXPAND | wxALL | wxALIGN_CENTER_VERTICAL, FromDIP(5)); @@ -1276,7 +1276,7 @@ wxBoxSizer *CreatePrinterPresetDialog::create_origin_item(wxWindow *parent) length_sizer->Add(static_origin_x_text, 0, wxEXPAND | wxALL, 0); horizontal_sizer->Add(length_sizer, 0, wxEXPAND | wxLEFT | wxTOP | wxALIGN_CENTER_VERTICAL, FromDIP(10)); wxBoxSizer *length_input_sizer = new wxBoxSizer(wxVERTICAL); - m_bed_origin_x_input = new TextInput(parent, wxEmptyString, "mm", wxEmptyString, wxDefaultPosition, PRINTER_SPACE_SIZE, wxTE_CENTRE | wxTE_PROCESS_ENTER); + m_bed_origin_x_input = new TextInput(parent, "0", "mm", wxEmptyString, wxDefaultPosition, PRINTER_SPACE_SIZE, wxTE_CENTRE | wxTE_PROCESS_ENTER); wxTextValidator validator(wxFILTER_DIGITS); m_bed_origin_x_input->GetTextCtrl()->SetValidator(validator); length_input_sizer->Add(m_bed_origin_x_input, 0, wxEXPAND | wxALL, 0); @@ -1289,7 +1289,7 @@ wxBoxSizer *CreatePrinterPresetDialog::create_origin_item(wxWindow *parent) width_sizer->Add(static_origin_y_text, 0, wxEXPAND | wxALL, 0); horizontal_sizer->Add(width_sizer, 0, wxEXPAND | wxLEFT | wxTOP | wxALIGN_CENTER_VERTICAL, FromDIP(10)); wxBoxSizer *width_input_sizer = new wxBoxSizer(wxVERTICAL); - m_bed_origin_y_input = new TextInput(parent, wxEmptyString, "mm", wxEmptyString, wxDefaultPosition, PRINTER_SPACE_SIZE, wxTE_CENTRE | wxTE_PROCESS_ENTER); + m_bed_origin_y_input = new TextInput(parent, "0", "mm", wxEmptyString, wxDefaultPosition, PRINTER_SPACE_SIZE, wxTE_CENTRE | wxTE_PROCESS_ENTER); m_bed_origin_y_input->GetTextCtrl()->SetValidator(validator); width_input_sizer->Add(m_bed_origin_y_input, 0, wxEXPAND | wxALL, 0); horizontal_sizer->Add(width_input_sizer, 0, wxEXPAND | wxALL | wxALIGN_CENTER_VERTICAL, FromDIP(5)); @@ -1316,6 +1316,7 @@ wxBoxSizer *CreatePrinterPresetDialog::create_hot_bed_stl_item(wxWindow *parent) std::pair(wxColour(172, 172, 172), StateColor::Normal)); m_button_bed_stl = new Button(parent, _L("Upload")); + m_button_bed_stl->Bind(wxEVT_BUTTON, ([this](wxCommandEvent &e) { load_model_stl(); })); m_button_bed_stl->SetFont(Label::Body_10); m_button_bed_stl->SetPaddingSize(wxSize(FromDIP(30), FromDIP(8))); @@ -1349,6 +1350,7 @@ wxBoxSizer *CreatePrinterPresetDialog::create_hot_bed_svg_item(wxWindow *parent) std::pair(wxColour(172, 172, 172), StateColor::Normal)); m_button_bed_svg = new Button(parent, _L("Upload")); + m_button_bed_svg->Bind(wxEVT_BUTTON, ([this](wxCommandEvent &e) { load_texture(); })); m_button_bed_svg->SetFont(Label::Body_10); m_button_bed_svg->SetPaddingSize(wxSize(FromDIP(30), FromDIP(8))); @@ -1374,7 +1376,7 @@ wxBoxSizer *CreatePrinterPresetDialog::create_max_print_height_item(wxWindow *pa horizontal_sizer->Add(optionSizer, 0, wxEXPAND | wxALL | wxALIGN_CENTER_VERTICAL, FromDIP(10)); wxBoxSizer *hight_input_sizer = new wxBoxSizer(wxVERTICAL); - m_print_height_input = new TextInput(parent, wxEmptyString, "mm", wxEmptyString, wxDefaultPosition, PRINTER_SPACE_SIZE, wxTE_CENTRE | wxTE_PROCESS_ENTER); + m_print_height_input = new TextInput(parent, "200", "mm", wxEmptyString, wxDefaultPosition, PRINTER_SPACE_SIZE, wxTE_CENTRE | wxTE_PROCESS_ENTER); wxTextValidator validator(wxFILTER_DIGITS); m_print_height_input->GetTextCtrl()->SetValidator(validator); hight_input_sizer->Add(m_print_height_input, 0, wxEXPAND | wxLEFT, FromDIP(5)); @@ -1401,7 +1403,8 @@ wxBoxSizer *CreatePrinterPresetDialog::create_page1_btns_item(wxWindow *parent) m_button_OK->SetCornerRadius(FromDIP(12)); bSizer_button->Add(m_button_OK, 0, wxRIGHT, FromDIP(10)); - m_button_OK->Bind(wxEVT_LEFT_DOWN, [this](wxMouseEvent &e) { + m_button_OK->Bind(wxEVT_LEFT_DOWN, [this](wxMouseEvent &e) { + if (!validate_input_valid()) return; data_init(); show_page2(); }); @@ -1422,6 +1425,39 @@ wxBoxSizer *CreatePrinterPresetDialog::create_page1_btns_item(wxWindow *parent) return bSizer_button; } +static std::string last_directory = ""; +void CreatePrinterPresetDialog::load_texture() { + wxFileDialog dialog(this, _L("Choose a file to import bed texture from (PNG/SVG):"), last_directory, "", file_wildcards(FT_TEX), wxFD_OPEN | wxFD_FILE_MUST_EXIST); + + if (dialog.ShowModal() != wxID_OK) + return; + + m_custom_texture = ""; + last_directory = dialog.GetDirectory().ToUTF8().data(); + std::string file_name = dialog.GetPath().ToUTF8().data(); + if (!boost::algorithm::iends_with(file_name, ".png") && !boost::algorithm::iends_with(file_name, ".svg")) { + show_error(this, _L("Invalid file format.")); + return; + } + m_custom_texture = file_name; +} + +void CreatePrinterPresetDialog::load_model_stl() +{ + wxFileDialog dialog(this, _L("Choose an STL file to import bed model from:"), last_directory, "", file_wildcards(FT_STL), wxFD_OPEN | wxFD_FILE_MUST_EXIST); + + if (dialog.ShowModal() != wxID_OK) + return; + + m_custom_model = ""; + last_directory = dialog.GetDirectory().ToUTF8().data(); + std::string file_name = dialog.GetPath().ToUTF8().data(); + if (!boost::algorithm::iends_with(file_name, ".stl")) { + show_error(this, _L("Invalid file format.")); + return; + } + m_custom_model = file_name; +} wxBoxSizer *CreatePrinterPresetDialog::create_radio_item(wxString title, wxWindow *parent, wxString tooltip, std::vector> &radiobox_list) { @@ -1431,12 +1467,12 @@ wxBoxSizer *CreatePrinterPresetDialog::create_radio_item(wxString title, wxWindo horizontal_sizer->Add(0, 0, 0, wxEXPAND | wxLEFT, FromDIP(5)); radiobox_list.push_back(std::make_pair(radiobox,title)); int btn_idx = radiobox_list.size() - 1; - radiobox->Bind(wxEVT_LEFT_DOWN, [this, &radiobox_list, btn_idx](wxMouseEvent &e) { + radiobox->Bind(wxEVT_LEFT_DOWN, [this, &radiobox_list, btn_idx](wxMouseEvent &e) { select_curr_radiobox(radiobox_list, btn_idx); }); wxStaticText *text = new wxStaticText(parent, wxID_ANY, title, wxDefaultPosition, wxDefaultSize); - text->Bind(wxEVT_LEFT_DOWN, [this, &radiobox_list, btn_idx](wxMouseEvent &e) { + text->Bind(wxEVT_LEFT_DOWN, [this, &radiobox_list, btn_idx](wxMouseEvent &e) { select_curr_radiobox(radiobox_list, btn_idx); }); horizontal_sizer->Add(text, 0, wxEXPAND | wxLEFT, 0); @@ -1675,8 +1711,8 @@ wxBoxSizer *CreatePrinterPresetDialog::create_page2_btns_item(wxWindow *parent) m_button_create->SetCornerRadius(FromDIP(12)); bSizer_button->Add(m_button_create, 0, wxRIGHT, FromDIP(10)); - m_button_create->Bind(wxEVT_LEFT_DOWN, [this](wxMouseEvent &e) { - if (!validate_input_valid()) return; + m_button_create->Bind(wxEVT_LEFT_DOWN, [this](wxMouseEvent &e) { + PresetBundle *preset_bundle = wxGetApp().preset_bundle; wxString curr_selected_printer_type = curr_create_printer_type(); wxString curr_selected_preset_type = curr_create_preset_type(); @@ -1689,7 +1725,7 @@ wxBoxSizer *CreatePrinterPresetDialog::create_page2_btns_item(wxWindow *parent) std::string nozzle_diameter = into_u8(m_nozzle_diameter->GetStringSelection()); if (m_can_not_find_vendor_combox->GetValue()) { std::string vendor_model = into_u8(m_custom_vendor_model->GetLabel()); - if (vendor_model.empty()) { + if (vendor_model.empty()) { MessageDialog dlg(this, _L("The custom printer and model are not inputed, place return page 1 to input."), wxString(SLIC3R_APP_FULL_NAME) + " - " + _L("Info"), wxYES | wxYES_DEFAULT | wxCENTRE); dlg.ShowModal(); @@ -1700,16 +1736,8 @@ wxBoxSizer *CreatePrinterPresetDialog::create_page2_btns_item(wxWindow *parent) } else { std::string vender_name = into_u8(m_select_vendor->GetStringSelection()); std::string model_name = into_u8(m_select_model->GetStringSelection()); - if (vender_name.empty() || model_name.empty()) { - MessageDialog dlg(this, _L("The printer and model are not selected, place return page 1 to select."), - wxString(SLIC3R_APP_FULL_NAME) + " - " + _L("Info"), wxYES | wxYES_DEFAULT | wxCENTRE); - dlg.ShowModal(); - show_page1(); - return; - } printer_preset_name = vender_name + " " + model_name + " " + nozzle_diameter; } - //Confirm if the printer preset exists if (!m_printer_preset) { MessageDialog dlg(this, _L("You have not yet chosen which printer preset to create based on. Please choose the vendor and model of the printer"), wxString(SLIC3R_APP_FULL_NAME) + " - " + _L("Info"), @@ -1797,7 +1825,6 @@ wxBoxSizer *CreatePrinterPresetDialog::create_page2_btns_item(wxWindow *parent) dlg.ShowModal(); } } - save_preset_config(m_printer_preset); preset_bundle->printers.save_current_preset(printer_preset_name, true, false, m_printer_preset); preset_bundle->update_compatible(PresetSelectCompatibleType::Always); } @@ -2071,40 +2098,91 @@ void CreatePrinterPresetDialog::clear_preset_combobox() m_process_preset_template_sizer->Clear(true); } -void CreatePrinterPresetDialog::save_preset_config(Preset* preset) +bool CreatePrinterPresetDialog::save_printable_area_config(Preset *preset) { DynamicPrintConfig &config = preset->config; - double prnite_area_x = 0; - m_bed_size_x_input->GetTextCtrl()->GetValue().ToDouble(&prnite_area_x); - double prnite_area_y = 0; - m_bed_size_y_input->GetTextCtrl()->GetValue().ToDouble(&prnite_area_y); - std::vector points = {{0, 0}, {prnite_area_x, 0}, {prnite_area_x, prnite_area_y}, {0, prnite_area_y}}; + double x = 0; + m_bed_size_x_input->GetTextCtrl()->GetValue().ToDouble(&x); + double y = 0; + m_bed_size_y_input->GetTextCtrl()->GetValue().ToDouble(&y); + double dx = 0; + m_bed_origin_x_input->GetTextCtrl()->GetValue().ToDouble(&dx); + double dy = 0; + m_bed_origin_y_input->GetTextCtrl()->GetValue().ToDouble(&dy); + //range check begin + if (x == 0 || y == 0) { + return false; + } + double x0 = 0.0; + double y0 = 0.0; + double x1 = x; + double y1 = y; + if (dx >= x || dy >= y) { + return false; + } + x0 -= dx; + x1 -= dx; + y0 -= dy; + y1 -= dy; + // range check end + std::vector points = {Vec2d(x0, y0), + Vec2d(x1, y0), + Vec2d(x1, y1), + Vec2d(x0, y1)}; config.set_key_value("printable_area", new ConfigOptionPoints(points)); double max_print_height = 0; m_print_height_input->GetTextCtrl()->GetValue().ToDouble(&max_print_height); config.set("printable_height", max_print_height); + std::regex regex("\\\\"); + m_custom_model = std::regex_replace(m_custom_model, regex, "/"); + m_custom_texture = std::regex_replace(m_custom_texture, regex, "/"); + config.set("bed_custom_model", m_custom_model); + config.set("bed_custom_texture", m_custom_texture); + return true; } bool CreatePrinterPresetDialog::validate_input_valid() { if (m_bed_size_x_input->GetTextCtrl()->GetValue().empty() || m_bed_size_y_input->GetTextCtrl()->GetValue().empty()) { - MessageDialog dlg(this, _L("You did not entered in the printable area of the printer. Please return to page 1 to input."), wxString(SLIC3R_APP_FULL_NAME) + " - " + _L("Info"), + MessageDialog dlg(this, _L("You did not entered in the printable area of the printer."), wxString(SLIC3R_APP_FULL_NAME) + " - " + _L("Info"), wxYES | wxYES_DEFAULT | wxCENTRE); dlg.ShowModal(); - show_page1(); return false; } if (m_print_height_input->GetTextCtrl()->GetValue().empty()) { - MessageDialog dlg(this, _L("You have not entered the maximum printing height of the printer. Please return to page 1 for input."), + MessageDialog dlg(this, _L("You have not entered the maximum printing height of the printer."), wxString(SLIC3R_APP_FULL_NAME) + " - " + _L("Info"), wxYES | wxYES_DEFAULT | wxCENTRE); dlg.ShowModal(); - show_page1(); return false; } - + std::string vender_name = into_u8(m_select_vendor->GetStringSelection()); + std::string model_name = into_u8(m_select_model->GetStringSelection()); + if (vender_name.empty() || model_name.empty()) { + MessageDialog dlg(this, _L("You have not selected the printer and model."), wxString(SLIC3R_APP_FULL_NAME) + " - " + _L("Info"), + wxYES | wxYES_DEFAULT | wxCENTRE); + dlg.ShowModal(); + return false; + } + if (m_custom_texture.empty()) { + MessageDialog dlg(this, _L("You have not upload bed texture."), + wxString(SLIC3R_APP_FULL_NAME) + " - " + _L("Info"), wxYES | wxYES_DEFAULT | wxCENTRE); + dlg.ShowModal(); + return false; + } + if (m_custom_model.empty()) { + MessageDialog dlg(this, _L("You have not upload bed model."), + wxString(SLIC3R_APP_FULL_NAME) + " - " + _L("Info"), wxYES | wxYES_DEFAULT | wxCENTRE); + dlg.ShowModal(); + return false; + } + if (save_printable_area_config(m_printer_preset) == false) { + MessageDialog dlg(this, _L("Please check bed shape input."), wxString(SLIC3R_APP_FULL_NAME) + " - " + _L("Info"), wxYES | wxYES_DEFAULT | wxCENTRE); + dlg.ShowModal(); + return false; + } return true; } diff --git a/src/slic3r/GUI/CreatePresetsDialog.hpp b/src/slic3r/GUI/CreatePresetsDialog.hpp index 6ed2dac164..46903b31d8 100644 --- a/src/slic3r/GUI/CreatePresetsDialog.hpp +++ b/src/slic3r/GUI/CreatePresetsDialog.hpp @@ -100,8 +100,8 @@ protected: wxBoxSizer *create_hot_bed_svg_item(wxWindow *parent); wxBoxSizer *create_max_print_height_item(wxWindow *parent); wxBoxSizer *create_page1_btns_item(wxWindow *parent); - - + void load_texture(); + void load_model_stl(); //Improt Presets Page2 void create_printer_page2(wxWindow *parent); wxBoxSizer *create_printer_preset_item(wxWindow *parent); @@ -120,12 +120,12 @@ protected: void update_presets_list(); void on_preset_model_value_change(wxCommandEvent &e); void clear_preset_combobox(); - void save_preset_config(Preset *preset); + bool save_printable_area_config(Preset *preset); bool validate_input_valid(); wxArrayString printer_preset_sort_with_nozzle_diameter(const VendorProfile &vendor_profile, float nozzle_diameter); wxBoxSizer *create_radio_item(wxString title, wxWindow *parent, wxString tooltip, std::vector> &radiobox_list); - + wxString curr_create_preset_type(); wxString curr_create_printer_type(); @@ -170,7 +170,8 @@ private: wxPanel * m_filament_preset_panel = nullptr; wxPanel * m_process_preset_panel = nullptr; wxPanel * m_preset_template_panel = nullptr; - + std::string m_custom_texture; + std::string m_custom_model; }; enum SuccessType { diff --git a/src/slic3r/GUI/Field.cpp b/src/slic3r/GUI/Field.cpp index 1f9179b82d..53dd56fb9a 100644 --- a/src/slic3r/GUI/Field.cpp +++ b/src/slic3r/GUI/Field.cpp @@ -131,7 +131,9 @@ void Field::PostInitialize() // For the mode, when settings are in non-modal dialog, neither dialog nor tabpanel doesn't receive wxEVT_KEY_UP event, when some field is selected. // So, like a workaround check wxEVT_KEY_UP event for the Filed and switch between tabs if Ctrl+(1-4) was pressed if (getWindow()) { - if (m_opt.readonly) getWindow()->Disable(); + if (m_opt.readonly) { + this->disable(); + } getWindow()->Bind(wxEVT_KEY_UP, [](wxKeyEvent& evt) { if ((evt.GetModifiers() & wxMOD_CONTROL) != 0) { int tab_id = -1; @@ -424,6 +426,12 @@ void Field::get_value_by_opt_type(wxString& str, const bool check_value/* = true continue; } } + else if (m_opt_id == "printable_area") { + if (0 <= x && x <= 1000 && 0 <= y && y <= 1000) { + out_values.push_back(Vec2d(x, y)); + continue; + } + } else { if (0 < x && x < 1000 && 0 < y && y < 1000) { out_values.push_back(Vec2d(x, y)); diff --git a/src/slic3r/GUI/OptionsGroup.cpp b/src/slic3r/GUI/OptionsGroup.cpp index 4c301a8e42..37254293c1 100644 --- a/src/slic3r/GUI/OptionsGroup.cpp +++ b/src/slic3r/GUI/OptionsGroup.cpp @@ -233,26 +233,26 @@ void OptionsGroup::activate_line(Line& line) m_use_custom_ctrl_as_parent = false; - if (line.full_width && ( - line.widget != nullptr || - !line.get_extra_widgets().empty()) - ) { - // BBS: new layout - const auto h_sizer = new wxBoxSizer(wxHORIZONTAL); - sizer->Add(h_sizer, 1, wxEXPAND | wxALL, wxOSX ? 0 : 15); + if (line.full_width && ( + line.widget != nullptr || + !line.get_extra_widgets().empty()) + ) { + // BBS: new layout + const auto h_sizer = new wxBoxSizer(wxHORIZONTAL); + sizer->Add(h_sizer, 1, wxEXPAND | wxALL, wxOSX ? 0 : 15); if (line.widget != nullptr) { - // description lines - h_sizer->Add(line.widget(this->ctrl_parent()), 0, wxEXPAND | wxLEFT, titleWidth * wxGetApp().em_unit()); + // description lines + sizer->Add(line.widget(this->ctrl_parent()), 0, wxEXPAND | wxALL, wxOSX ? 0 : 15); return; } - if (!line.get_extra_widgets().empty()) { + if (!line.get_extra_widgets().empty()) { bool is_first_item = true; - for (auto extra_widget : line.get_extra_widgets()) { - h_sizer->Add(extra_widget(this->ctrl_parent()), is_first_item ? 1 : 0, wxLEFT, titleWidth * wxGetApp().em_unit()); - is_first_item = false; - } - return; - } + for (auto extra_widget : line.get_extra_widgets()) { + h_sizer->Add(extra_widget(this->ctrl_parent()), is_first_item ? 1 : 0, wxLEFT, titleWidth * wxGetApp().em_unit()); + is_first_item = false; + } + return; + } } auto option_set = line.get_options(); @@ -1038,7 +1038,7 @@ boost::any ConfigOptionsGroup::get_config_value(const DynamicPrintConfig& config break; case coPoints: if (opt_key == "printable_area") - ret = config.option(opt_key)->values; + ret = get_thumbnails_string(config.option(opt_key)->values); else if (opt_key == "bed_exclude_area") ret = get_thumbnails_string(config.option(opt_key)->values); else if (opt_key == "thumbnail_size") @@ -1153,7 +1153,7 @@ boost::any ConfigOptionsGroup::get_config_value2(const DynamicPrintConfig& confi break; case coPoints: if (opt_key == "printable_area") - ret = config.option(opt_key)->values; + ret = get_thumbnails_string(config.option(opt_key)->values); else if (opt_key == "bed_exclude_area") ret = get_thumbnails_string(config.option(opt_key)->values); else if (opt_key == "thumbnail_size") diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 5f443875a7..4534380576 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -588,11 +588,16 @@ Sidebar::Sidebar(Plater *parent) if (wxID_OK == res) { wxGetApp().mainframe->update_side_preset_ui(); update_all_preset_comboboxes(); + Tab *printer_tab = wxGetApp().get_tab(Preset::TYPE_PRINTER); + if (printer_tab) { + printer_tab->load_current_preset(); + printer_tab->update(); + } CreatePresetSuccessfulDialog success_dlg(p->m_panel_filament_title, SuccessType::PRINTER); int res = success_dlg.ShowModal(); - if (res == wxID_OK) { + if (res == wxID_OK) { p->editing_filament = -1; - if (p->combo_printer->switch_to_tab()) + if (p->combo_printer->switch_to_tab()) p->editing_filament = 0; } } diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index e259db62fb..adb961a966 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -3692,7 +3692,7 @@ void TabPrinter::toggle_options() // toggle_option("change_filament_gcode", have_multiple_extruders); //} if (m_active_page->title() == "Basic information") { - toggle_line("printable_area", !is_BBL_printer); + //toggle_line("printable_area", !is_configed_by_BBL);//all printer can entry and view data toggle_option("single_extruder_multi_material", have_multiple_extruders); //BBS: gcode_flavore of BBL printer can't be edited and changed toggle_option("gcode_flavor", !is_BBL_printer); @@ -4945,16 +4945,26 @@ wxSizer* TabPrinter::create_bed_shape_widget(wxWindow* parent) auto sizer = new wxBoxSizer(wxHORIZONTAL); sizer->Add(btn, 0, wxALIGN_CENTER_VERTICAL); - btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent e) - { + btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent e) { + bool is_configed_by_BBL = PresetUtils::system_printer_bed_model(m_preset_bundle->printers.get_edited_preset()).size() > 0; BedShapeDialog dlg(this); - dlg.build_dialog(*m_config->option("printable_area"), {}, {}); - if (dlg.ShowModal() == wxID_OK) { - const std::vector& shape = dlg.get_shape(); - if (!shape.empty()) - { - load_key_value("printable_area", shape); - update_changed_ui(); + dlg.build_dialog(*m_config->option("printable_area"), + *m_config->option("bed_custom_texture"), + *m_config->option("bed_custom_model") , !is_configed_by_BBL); + if (dlg.ShowModal() == wxID_OK && !is_configed_by_BBL) { + if (dlg.get_valid()) { + const std::vector &shape = dlg.get_shape(); + const std::string & custom_texture = dlg.get_custom_texture(); + const std::string & custom_model = dlg.get_custom_model(); + if (!shape.empty()) { + load_key_value("printable_area", shape); + load_key_value("bed_custom_texture", custom_texture); + load_key_value("bed_custom_model", custom_model); + update_changed_ui(); + } + + } else { + show_error(m_parent, _L("Invalid input.")); } } })); @@ -4962,6 +4972,8 @@ wxSizer* TabPrinter::create_bed_shape_widget(wxWindow* parent) { Search::OptionsSearcher& searcher = wxGetApp().sidebar().get_searcher(); const Search::GroupAndCategory& gc = searcher.get_group_and_category("printable_area"); + searcher.add_key("bed_custom_texture", m_type, gc.group, gc.category); + searcher.add_key("bed_custom_model", m_type, gc.group, gc.category); } return sizer;