ENH: refine global bed type config logic

Add default type to plate bed types.

Signed-off-by: yifan.wu <yifan.wu@bambulab.com>
Change-Id: I26f3a64dba4a19b0d882b828f1ee54c84df1879c
(cherry picked from commit 1ebed465d2b3bcd482dd4ba7a5930b721c79fc13)
This commit is contained in:
yifan.wu 2022-11-22 17:39:35 +08:00 committed by Lane.Wei
parent 3b3ad1b390
commit d152b4d235
11 changed files with 109 additions and 100 deletions

View file

@ -2037,17 +2037,11 @@ void GCode::print_machine_envelope(GCodeOutputStream &file, Print &print)
} }
// BBS // BBS
void GCode::get_bed_temperature(const int extruder_id, const bool is_first_layer, std::vector<int>& temps_per_bed, int& default_temp) const int GCode::get_bed_temperature(const int extruder_id, const bool is_first_layer, const BedType bed_type) const
{ {
temps_per_bed.resize((int)BedType::btCount, 0); std::string bed_temp_key = is_first_layer ? get_bed_temp_1st_layer_key(bed_type) : get_bed_temp_key(bed_type);
for (int bed_type = 0; bed_type < BedType::btCount; bed_type++) {
std::string bed_temp_key = is_first_layer ? get_bed_temp_1st_layer_key((BedType)bed_type) : get_bed_temp_key((BedType)bed_type);
const ConfigOptionInts* bed_temp_opt = m_config.option<ConfigOptionInts>(bed_temp_key); const ConfigOptionInts* bed_temp_opt = m_config.option<ConfigOptionInts>(bed_temp_key);
return bed_temp_opt->get_at(extruder_id);
temps_per_bed[bed_type] = bed_temp_opt->get_at(extruder_id);
if (bed_type == m_config.curr_bed_type)
default_temp = temps_per_bed[bed_type];
}
} }
// Write 1st layer bed temperatures into the G-code. // Write 1st layer bed temperatures into the G-code.
@ -2059,8 +2053,7 @@ void GCode::_print_first_layer_bed_temperature(GCodeOutputStream &file, Print &p
// Initial bed temperature based on the first extruder. // Initial bed temperature based on the first extruder.
// BBS // BBS
std::vector<int> temps_per_bed; std::vector<int> temps_per_bed;
int default_temp = 0; int bed_temp = get_bed_temperature(first_printing_extruder_id, true, print.config().curr_bed_type);
get_bed_temperature(first_printing_extruder_id, true, temps_per_bed, default_temp);
// Is the bed temperature set by the provided custom G-code? // Is the bed temperature set by the provided custom G-code?
int temp_by_gcode = -1; int temp_by_gcode = -1;
@ -2073,7 +2066,7 @@ void GCode::_print_first_layer_bed_temperature(GCodeOutputStream &file, Print &p
// Always call m_writer.set_bed_temperature() so it will set the internal "current" state of the bed temp as if // Always call m_writer.set_bed_temperature() so it will set the internal "current" state of the bed temp as if
// the custom start G-code emited these. // the custom start G-code emited these.
std::string set_temp_gcode = m_writer.set_bed_temperature(temps_per_bed, default_temp, wait); std::string set_temp_gcode = m_writer.set_bed_temperature(bed_temp, wait);
if (! temp_set_by_gcode) if (! temp_set_by_gcode)
file.write(set_temp_gcode); file.write(set_temp_gcode);
} }
@ -2528,10 +2521,8 @@ GCode::LayerResult GCode::process_layer(
} }
// BBS // BBS
std::vector<int> temps_per_bed; int bed_temp = get_bed_temperature(first_extruder_id, false, print.config().curr_bed_type);
int default_temp = 0; gcode += m_writer.set_bed_temperature(bed_temp);
get_bed_temperature(first_extruder_id, false, temps_per_bed, default_temp);
gcode += m_writer.set_bed_temperature(temps_per_bed, default_temp);
// Mark the temperature transition from 1st to 2nd layer to be finished. // Mark the temperature transition from 1st to 2nd layer to be finished.
m_second_layer_things_done = true; m_second_layer_things_done = true;
} }

View file

@ -492,7 +492,7 @@ private:
static bool gcode_label_objects; static bool gcode_label_objects;
// BBS // BBS
void get_bed_temperature(const int extruder_id, const bool is_first_layer, std::vector<int>& temps_per_bed, int& default_temp) const; int get_bed_temperature(const int extruder_id, const bool is_first_layer, const BedType bed_type) const;
std::string _extrude(const ExtrusionPath &path, std::string description = "", double speed = -1); std::string _extrude(const ExtrusionPath &path, std::string description = "", double speed = -1);
void print_machine_envelope(GCodeOutputStream &file, Print &print); void print_machine_envelope(GCodeOutputStream &file, Print &print);

View file

@ -120,13 +120,12 @@ std::string GCodeWriter::set_temperature(unsigned int temperature, bool wait, in
} }
// BBS // BBS
std::string GCodeWriter::set_bed_temperature(std::vector<int> temps_per_bed, int default_temp, bool wait) std::string GCodeWriter::set_bed_temperature(int temperature, bool wait)
{ {
if (temps_per_bed == m_last_bed_temperature && (! wait || m_last_bed_temperature_reached)) if (temperature == m_last_bed_temperature && (! wait || m_last_bed_temperature_reached))
return std::string(); return std::string();
bool target_temp_changed = (temps_per_bed != m_last_bed_temperature); m_last_bed_temperature = temperature;
m_last_bed_temperature = temps_per_bed;
m_last_bed_temperature_reached = wait; m_last_bed_temperature_reached = wait;
std::string code, comment; std::string code, comment;
@ -141,7 +140,7 @@ std::string GCodeWriter::set_bed_temperature(std::vector<int> temps_per_bed, int
comment = "set bed temperature"; comment = "set bed temperature";
} }
gcode << code << " S" << default_temp << " ; " << comment << "\n"; gcode << code << " S" << temperature << " ; " << comment << "\n";
return gcode.str(); return gcode.str();
} }

View file

@ -48,8 +48,7 @@ public:
std::string preamble(); std::string preamble();
std::string postamble() const; std::string postamble() const;
std::string set_temperature(unsigned int temperature, bool wait = false, int tool = -1) const; std::string set_temperature(unsigned int temperature, bool wait = false, int tool = -1) const;
// BBS std::string set_bed_temperature(int temperature, bool wait = false);
std::string set_bed_temperature(std::vector<int> temps_per_bed, int default_temp, bool wait = false);
std::string set_acceleration(unsigned int acceleration); std::string set_acceleration(unsigned int acceleration);
std::string reset_e(bool force = false); std::string reset_e(bool force = false);
std::string update_progress(unsigned int num, unsigned int tot, bool allow_100 = false) const; std::string update_progress(unsigned int num, unsigned int tot, bool allow_100 = false) const;
@ -106,8 +105,7 @@ private:
unsigned int m_max_acceleration; unsigned int m_max_acceleration;
//BBS //BBS
unsigned int m_last_additional_fan_speed; unsigned int m_last_additional_fan_speed;
// BBS int m_last_bed_temperature;
std::vector<int> m_last_bed_temperature;
bool m_last_bed_temperature_reached; bool m_last_bed_temperature_reached;
double m_lifted; double m_lifted;

View file

@ -269,6 +269,7 @@ CONFIG_OPTION_ENUM_DEFINE_STATIC_MAPS(OverhangFanThreshold)
// BBS // BBS
static const t_config_enum_values s_keys_map_BedType = { static const t_config_enum_values s_keys_map_BedType = {
{ "Default Plate", btDefault },
{ "Cool Plate", btPC }, { "Cool Plate", btPC },
{ "Engineering Plate", btEP }, { "Engineering Plate", btEP },
{ "High Temp Plate", btPEI }, { "High Temp Plate", btPEI },

View file

@ -166,7 +166,8 @@ enum OverhangFanThreshold {
// BBS // BBS
enum BedType { enum BedType {
btPC = 0, btDefault = 0,
btPC,
btEP, btEP,
btPEI, btPEI,
btPTE, btPTE,

View file

@ -133,12 +133,20 @@ void PartPlate::init()
m_print = nullptr; m_print = nullptr;
} }
BedType PartPlate::get_bed_type() const BedType PartPlate::get_bed_type(bool check_global/*= true*/) const
{ {
std::string bed_type_key = "curr_bed_type"; std::string bed_type_key = "curr_bed_type";
if (m_config.has(bed_type_key)) // should be called in GUI context
return m_config.opt_enum<BedType>(bed_type_key); assert(m_plater != nullptr);
if (m_config.has(bed_type_key)) {
BedType bed_type = m_config.opt_enum<BedType>(bed_type_key);
if (bed_type != btDefault)
return bed_type;
}
if (!check_global)
return btDefault;
if (m_plater) { if (m_plater) {
// In GUI mode // In GUI mode
@ -150,30 +158,20 @@ BedType PartPlate::get_bed_type() const
return BedType::btPC; return BedType::btPC;
} }
void PartPlate::set_bed_type(BedType bed_type, bool& same_as_global) void PartPlate::set_bed_type(BedType bed_type)
{ {
is_same_bedtype_with_global = true; std::string bed_type_key = "curr_bed_type";
// should be called in GUI context // should be called in GUI context
assert(m_plater != nullptr); assert(m_plater != nullptr);
std::string bed_type_key = "curr_bed_type"; if (bed_type == BedType::btDefault)
m_config.erase(bed_type_key);
else
m_config.set_key_value("curr_bed_type", new ConfigOptionEnum<BedType>(bed_type)); m_config.set_key_value("curr_bed_type", new ConfigOptionEnum<BedType>(bed_type));
if (m_plater) {
m_plater->update_project_dirty_from_presets();
//m_plater->schedule_background_process();
DynamicConfig& proj_cfg = wxGetApp().preset_bundle->project_config;
if (proj_cfg.has(bed_type_key)) {
//std::string bed_type_key = "curr_bed_type";
BedType global_bed_type = proj_cfg.opt_enum<BedType>(bed_type_key);
same_as_global = bed_type == global_bed_type;
is_same_bedtype_with_global = same_as_global;
return;
}
}
same_as_global = false; if (m_plater)
is_same_bedtype_with_global = same_as_global; m_plater->update_project_dirty_from_presets();
} }
void PartPlate::reset_bed_type() void PartPlate::reset_bed_type()
@ -551,7 +549,8 @@ void PartPlate::render_logo(bool bottom) const
PartPlateList::load_bedtype_textures(); PartPlateList::load_bedtype_textures();
int bed_type_idx = (int)get_bed_type(); // btDefault should be skipped
int bed_type_idx = (int)get_bed_type() - 1;
render_logo_texture(PartPlateList::bed_textures[bed_type_idx], bottom); render_logo_texture(PartPlateList::bed_textures[bed_type_idx], bottom);
} }
@ -717,13 +716,13 @@ void PartPlate::render_icons(bool bottom, int hover_id) const
if (m_partplate_list->render_bedtype_setting) { if (m_partplate_list->render_bedtype_setting) {
if (hover_id == 5) { if (hover_id == 5) {
if (is_same_bedtype_with_global) if (get_bed_type(false) == BedType::btDefault)
render_icon_texture(position_id, tex_coords_id, m_bedtype_icon, m_partplate_list->m_bedtype_hovered_texture, m_bedtype_vbo_id); render_icon_texture(position_id, tex_coords_id, m_bedtype_icon, m_partplate_list->m_bedtype_hovered_texture, m_bedtype_vbo_id);
else else
render_icon_texture(position_id, tex_coords_id, m_bedtype_icon, m_partplate_list->m_bedtype_changed_hovered_texture, m_bedtype_vbo_id); render_icon_texture(position_id, tex_coords_id, m_bedtype_icon, m_partplate_list->m_bedtype_changed_hovered_texture, m_bedtype_vbo_id);
} }
else { else {
if (is_same_bedtype_with_global) if (get_bed_type(false) == BedType::btDefault)
render_icon_texture(position_id, tex_coords_id, m_bedtype_icon, m_partplate_list->m_bedtype_texture, m_bedtype_vbo_id); render_icon_texture(position_id, tex_coords_id, m_bedtype_icon, m_partplate_list->m_bedtype_texture, m_bedtype_vbo_id);
else else
render_icon_texture(position_id, tex_coords_id, m_bedtype_icon, m_partplate_list->m_bedtype_changed_texture, m_bedtype_vbo_id); render_icon_texture(position_id, tex_coords_id, m_bedtype_icon, m_partplate_list->m_bedtype_changed_texture, m_bedtype_vbo_id);

View file

@ -213,8 +213,8 @@ public:
//clear alll the instances in plate //clear alll the instances in plate
void clear(bool clear_sliced_result = true); void clear(bool clear_sliced_result = true);
BedType get_bed_type() const; BedType get_bed_type(bool check_global = true) const;
void set_bed_type(BedType, bool& same_as_global); void set_bed_type(BedType bed_type);
void reset_bed_type(); void reset_bed_type();
DynamicPrintConfig* config() { return &m_config; } DynamicPrintConfig* config() { return &m_config; }

View file

@ -542,9 +542,13 @@ Sidebar::Sidebar(Plater *parent)
m_bed_type_list = new ComboBox(p->m_panel_printer_content, wxID_ANY, wxString(""), wxDefaultPosition, {-1, FromDIP(24)}, 0, nullptr, wxCB_READONLY); m_bed_type_list = new ComboBox(p->m_panel_printer_content, wxID_ANY, wxString(""), wxDefaultPosition, {-1, FromDIP(24)}, 0, nullptr, wxCB_READONLY);
const ConfigOptionDef* bed_type_def = print_config_def.get("curr_bed_type"); const ConfigOptionDef* bed_type_def = print_config_def.get("curr_bed_type");
if (bed_type_def && bed_type_def->enum_keys_map) { if (bed_type_def && bed_type_def->enum_keys_map) {
for (auto item : *bed_type_def->enum_keys_map) for (auto item : *bed_type_def->enum_keys_map) {
if (item.first == "Default Plate")
continue;
m_bed_type_list->AppendString(_L(item.first)); m_bed_type_list->AppendString(_L(item.first));
} }
}
bed_type_title->Bind(wxEVT_ENTER_WINDOW, [bed_type_title, this](wxMouseEvent &e) { bed_type_title->Bind(wxEVT_ENTER_WINDOW, [bed_type_title, this](wxMouseEvent &e) {
e.Skip(); e.Skip();
@ -1253,8 +1257,10 @@ void Sidebar::on_filaments_change(size_t num_filaments)
void Sidebar::on_bed_type_change(BedType bed_type) void Sidebar::on_bed_type_change(BedType bed_type)
{ {
// btDefault option is not included in global bed type setting
int sel_idx = (int)bed_type - 1;
if (m_bed_type_list != nullptr) if (m_bed_type_list != nullptr)
m_bed_type_list->SetSelection(bed_type); m_bed_type_list->SetSelection(sel_idx);
} }
void Sidebar::load_ams_list(std::map<std::string, Ams *> const &list) void Sidebar::load_ams_list(std::map<std::string, Ams *> const &list)
@ -5231,38 +5237,32 @@ void Plater::priv::on_select_bed_type(wxCommandEvent &evt)
int selection = combo->GetSelection(); int selection = combo->GetSelection();
wxString bed_type_name = combo->GetString(selection); wxString bed_type_name = combo->GetString(selection);
DynamicPrintConfig& config = wxGetApp().preset_bundle->project_config; DynamicPrintConfig& proj_config = wxGetApp().preset_bundle->project_config;
const t_config_enum_values* keys_map = print_config_def.get("curr_bed_type")->enum_keys_map; const t_config_enum_values* keys_map = print_config_def.get("curr_bed_type")->enum_keys_map;
if (keys_map) { if (keys_map) {
BedType bed_type = btCount; BedType new_bed_type = btCount;
for (auto item : *keys_map) { for (auto item : *keys_map) {
if (_L(item.first) == bed_type_name) if (_L(item.first) == bed_type_name) {
bed_type = (BedType)item.second; new_bed_type = (BedType)item.second;
break;
}
} }
if (bed_type != btCount) { if (new_bed_type != btCount) {
config.set_key_value("curr_bed_type", new ConfigOptionEnum<BedType>(bed_type)); BedType old_bed_type = proj_config.opt_enum<BedType>("curr_bed_type");
proj_config.set_key_value("curr_bed_type", new ConfigOptionEnum<BedType>(new_bed_type));
wxGetApp().plater()->update_project_dirty_from_presets(); wxGetApp().plater()->update_project_dirty_from_presets();
// clear all plates' bed type config
for (int i = 0; i < partplate_list.get_plate_count(); i++)
partplate_list.get_plate(i)->reset_bed_type();
// update plater with new config // update plater with new config
q->on_config_change(wxGetApp().preset_bundle->full_config()); q->on_config_change(wxGetApp().preset_bundle->full_config());
// update app_config // update app_config
AppConfig *app_config = wxGetApp().app_config; AppConfig *app_config = wxGetApp().app_config;
app_config->set("curr_bed_type", std::to_string(int(bed_type))); app_config->set("curr_bed_type", std::to_string(int(new_bed_type)));
// update render // update render
auto plate_list = partplate_list.get_plate_list();
for (auto plate : plate_list) {
bool same_as_global = false;
auto type = plate->get_bed_type();
plate->set_bed_type(type, same_as_global);
}
view3D->get_canvas3d()->render(); view3D->get_canvas3d()->render();
preview->msw_rescale(); preview->msw_rescale();
} }
@ -10645,11 +10645,11 @@ int Plater::select_plate_by_hover_id(int hover_id, bool right_click)
ret = select_plate(plate_index); ret = select_plate(plate_index);
if (!ret) { if (!ret) {
SetBedTypeDialog dlg(this, wxID_ANY, _L("Select Bed Type")); SetBedTypeDialog dlg(this, wxID_ANY, _L("Select Bed Type"));
dlg.sync_bed_type(p->partplate_list.get_curr_plate()->get_bed_type()); PartPlate* curr_plate = p->partplate_list.get_curr_plate();
dlg.sync_bed_type(curr_plate->get_bed_type(false));
dlg.Bind(EVT_SET_BED_TYPE_CONFIRM, [this, plate_index](wxCommandEvent& e) { dlg.Bind(EVT_SET_BED_TYPE_CONFIRM, [this, plate_index](wxCommandEvent& e) {
bool same_as_global = false;
auto type = (BedType)(e.GetInt()); auto type = (BedType)(e.GetInt());
p->partplate_list.get_curr_plate()->set_bed_type(type, same_as_global); p->partplate_list.get_curr_plate()->set_bed_type(type);
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format("select bed type %1% for plate %2% at plate side")%type %plate_index; BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format("select bed type %1% for plate %2% at plate side")%type %plate_index;
}); });
dlg.ShowModal(); dlg.ShowModal();

View file

@ -19,14 +19,17 @@ SetBedTypeDialog::SetBedTypeDialog(wxWindow* parent, wxWindowID id, const wxStri
m_sizer_main->Add(0, 0, 0, wxTOP, FromDIP(5)); m_sizer_main->Add(0, 0, 0, wxTOP, FromDIP(5));
wxBoxSizer* m_sizer_radiobutton = new wxBoxSizer(wxVERTICAL); wxBoxSizer* m_sizer_radiobutton = new wxBoxSizer(wxVERTICAL);
m_cool_btn = create_item_radiobox(_L("Cool Plate"), this, wxEmptyString, FromDIP(5), 0, "btPC");
m_sizer_radiobutton->Add( m_cool_btn, 1, wxALL, FromDIP(5) ); m_rb_default_plate = create_item_radiobox(_L("Default"), this, wxEmptyString, FromDIP(5), btDefault);
m_engineering_btn = create_item_radiobox(_L("Engineering Plate"), this, wxEmptyString, FromDIP(5), 1, "btEP"); m_sizer_radiobutton->Add(m_rb_default_plate->GetParent(), 1, wxALL, FromDIP(5));
m_sizer_radiobutton->Add( m_engineering_btn, 1, wxALL, FromDIP(5) ); m_rb_cool_plate = create_item_radiobox(_L("Cool Plate"), this, wxEmptyString, FromDIP(5), btPC);
m_high_temp_btn = create_item_radiobox(_L("High Temp Plate"), this, wxEmptyString, FromDIP(5), 2, "btPEI"); m_sizer_radiobutton->Add(m_rb_cool_plate->GetParent(), 1, wxALL, FromDIP(5));
m_sizer_radiobutton->Add( m_high_temp_btn, 1, wxALL, FromDIP(5) ); m_rb_eng_plate = create_item_radiobox(_L("Engineering Plate"), this, wxEmptyString, FromDIP(5), btEP);
m_texture_pei_btn = create_item_radiobox(_L("Textured PEI Plate"), this, wxEmptyString, FromDIP(5), 3, "btPTE"); m_sizer_radiobutton->Add(m_rb_eng_plate->GetParent(), 1, wxALL, FromDIP(5) );
m_sizer_radiobutton->Add( m_texture_pei_btn, 1, wxALL, FromDIP(5) ); m_rb_high_temp_plate = create_item_radiobox(_L("High Temp Plate"), this, wxEmptyString, FromDIP(5), btPEI);
m_sizer_radiobutton->Add(m_rb_high_temp_plate->GetParent(), 1, wxALL, FromDIP(5));
m_rb_texture_pei_plate = create_item_radiobox(_L("Textured PEI Plate"), this, wxEmptyString, FromDIP(5), btPTE);
m_sizer_radiobutton->Add(m_rb_texture_pei_plate->GetParent(), 1, wxALL, FromDIP(5));
m_sizer_main->Add(m_sizer_radiobutton, 0, wxEXPAND | wxALL, FromDIP(10)); m_sizer_main->Add(m_sizer_radiobutton, 0, wxEXPAND | wxALL, FromDIP(10));
@ -50,7 +53,7 @@ SetBedTypeDialog::SetBedTypeDialog(wxWindow* parent, wxWindowID id, const wxStri
for (int i = 0; i < len; ++i) { for (int i = 0; i < len; ++i) {
if (radio_buttons[i]->GetValue()) { if (radio_buttons[i]->GetValue()) {
wxCommandEvent evt(EVT_SET_BED_TYPE_CONFIRM, GetId()); wxCommandEvent evt(EVT_SET_BED_TYPE_CONFIRM, GetId());
evt.SetInt(i); evt.SetInt(radio_buttons[i]->GetBedType());
e.SetEventObject(this); e.SetEventObject(this);
GetEventHandler()->ProcessEvent(evt); GetEventHandler()->ProcessEvent(evt);
break; break;
@ -94,12 +97,12 @@ SetBedTypeDialog::~SetBedTypeDialog()
} }
wxWindow* SetBedTypeDialog::create_item_radiobox(wxString title, wxWindow* parent, wxString tooltip, int padding_left, int groupid, std::string param) BedTypeRadioBox* SetBedTypeDialog::create_item_radiobox(wxString title, wxWindow* parent, wxString tooltip, int padding_left, BedType bed_type)
{ {
wxWindow *item = new wxWindow(parent, wxID_ANY, wxDefaultPosition, wxSize(-1, FromDIP(28))); wxWindow *item = new wxWindow(parent, wxID_ANY, wxDefaultPosition, wxSize(-1, FromDIP(28)));
item->SetBackgroundColour(*wxWHITE); item->SetBackgroundColour(*wxWHITE);
RadioBox *radiobox = new RadioBox(item); BedTypeRadioBox* radiobox = new BedTypeRadioBox(item, bed_type);
radiobox->SetPosition(wxPoint(padding_left, (item->GetSize().GetHeight() - radiobox->GetSize().GetHeight()) / 2)); radiobox->SetPosition(wxPoint(padding_left, (item->GetSize().GetHeight() - radiobox->GetSize().GetHeight()) / 2));
radio_buttons.push_back(radiobox); radio_buttons.push_back(radiobox);
int btn_idx = radio_buttons.size() - 1; int btn_idx = radio_buttons.size() - 1;
@ -117,7 +120,7 @@ wxWindow* SetBedTypeDialog::create_item_radiobox(wxString title, wxWindow* paren
radiobox->SetToolTip(tooltip); radiobox->SetToolTip(tooltip);
text->SetToolTip(tooltip); text->SetToolTip(tooltip);
return item; return radiobox;
} }
void SetBedTypeDialog::select_curr_radiobox(int btn_idx) void SetBedTypeDialog::select_curr_radiobox(int btn_idx)
@ -133,8 +136,12 @@ void SetBedTypeDialog::select_curr_radiobox(int btn_idx)
void SetBedTypeDialog::sync_bed_type(BedType type) void SetBedTypeDialog::sync_bed_type(BedType type)
{ {
int select_type = (int)(type); for (auto radio_box : radio_buttons) {
select_curr_radiobox(select_type); if (radio_box->GetBedType() == type)
radio_box->SetValue(true);
else
radio_box->SetValue(false);
}
} }
void SetBedTypeDialog::on_dpi_changed(const wxRect& suggested_rect) void SetBedTypeDialog::on_dpi_changed(const wxRect& suggested_rect)

View file

@ -10,6 +10,18 @@ namespace Slic3r { namespace GUI {
wxDECLARE_EVENT(EVT_SET_BED_TYPE_CONFIRM, wxCommandEvent); wxDECLARE_EVENT(EVT_SET_BED_TYPE_CONFIRM, wxCommandEvent);
class BedTypeRadioBox : public RadioBox
{
public:
BedTypeRadioBox(wxWindow* parent, BedType bed_type) : RadioBox(parent), m_bed_type(bed_type) {}
void SetBedType(BedType bed_type) { m_bed_type = bed_type; }
BedType GetBedType() { return m_bed_type; }
private:
BedType m_bed_type{ BedType::btCount };
};
class SetBedTypeDialog : public DPIDialog class SetBedTypeDialog : public DPIDialog
{ {
public: public:
@ -32,15 +44,16 @@ public:
void on_dpi_changed(const wxRect& suggested_rect) override; void on_dpi_changed(const wxRect& suggested_rect) override;
protected: protected:
wxWindow* m_cool_btn; BedTypeRadioBox* m_rb_default_plate{ nullptr };
wxWindow* m_engineering_btn; BedTypeRadioBox* m_rb_cool_plate{ nullptr };
wxWindow* m_high_temp_btn; BedTypeRadioBox* m_rb_eng_plate{ nullptr };
wxWindow* m_texture_pei_btn; BedTypeRadioBox* m_rb_high_temp_plate{ nullptr };
BedTypeRadioBox* m_rb_texture_pei_plate{ nullptr };
Button* m_button_ok; Button* m_button_ok;
Button* m_button_cancel; Button* m_button_cancel;
std::vector<RadioBox*> radio_buttons; std::vector<BedTypeRadioBox*> radio_buttons;
wxWindow * create_item_radiobox(wxString title, wxWindow *parent, wxString tooltip, int padding_left, int groupid, std::string param); BedTypeRadioBox* create_item_radiobox(wxString title, wxWindow* parent, wxString tooltip, int padding_left, BedType bed_type);
void select_curr_radiobox(int btn_idx); void select_curr_radiobox(int btn_idx);
}; };