Skip to content

Commit

Permalink
ENH: return if the bed_type of a plate is the same as global
Browse files Browse the repository at this point in the history
Signed-off-by: yifan.wu <[email protected]>
Change-Id: I15882d04fa89ebb27bc57434ff9f2c9468725d71
(cherry picked from commit b1606e07f1b9d91f1c01676ebbbe550e69a2ce53)
  • Loading branch information
YifanWuBambu authored and lanewei120 committed Dec 15, 2022
1 parent 0320872 commit acf8f7b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
19 changes: 17 additions & 2 deletions src/slic3r/GUI/PartPlate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,26 @@ BedType PartPlate::get_bed_type() const
return BedType::btPC;
}

void PartPlate::set_bed_type(BedType bed_type)
void PartPlate::set_bed_type(BedType bed_type, bool& same_as_global)
{
// should be called in GUI context
assert(m_plater != nullptr);

std::string bed_type_key = "curr_bed_type";

m_config.set_key_value("curr_bed_type", new ConfigOptionEnum<BedType>(bed_type));
if (m_plater)
if (m_plater) {
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;
return;
}
}

same_as_global = false;
}

void PartPlate::reset_bed_type()
Expand Down
2 changes: 1 addition & 1 deletion src/slic3r/GUI/PartPlate.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ class PartPlate : public ObjectBase
void clear(bool clear_sliced_result = true);

BedType get_bed_type() const;
void set_bed_type(BedType);
void set_bed_type(BedType, bool& same_as_global);
void reset_bed_type();
DynamicPrintConfig* config() { return &m_config; }

Expand Down
3 changes: 2 additions & 1 deletion src/slic3r/GUI/Plater.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10585,8 +10585,9 @@ int Plater::select_plate_by_hover_id(int hover_id, bool right_click)
SetBedTypeDialog dlg(this, wxID_ANY, _L("Select bed type"));
dlg.sync_bed_type(p->partplate_list.get_curr_plate()->get_bed_type());
dlg.Bind(EVT_SET_BED_TYPE_CONFIRM, [this, plate_index](wxCommandEvent& e) {
bool same_as_global = false;
auto type = (BedType)(e.GetInt());
p->partplate_list.get_curr_plate()->set_bed_type(type);
p->partplate_list.get_curr_plate()->set_bed_type(type, same_as_global);
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format("select bed type %1% for plate %2% at plate side")%type %plate_index;
});
dlg.ShowModal();
Expand Down

0 comments on commit acf8f7b

Please sign in to comment.