FIX: can not save project when modify bed type in the scene

Change-Id: Iaea1bef142edcf0c68a64cfa1f3b1d309b96f251
This commit is contained in:
zhimin.zeng 2023-01-03 13:04:32 +08:00 committed by Lane.Wei
parent 8183b7d333
commit e70253cf25
4 changed files with 12 additions and 2 deletions

View file

@ -1775,6 +1775,7 @@ struct Plater::priv
bool need_update() const { return m_need_update; }
void set_need_update(bool need_update) { m_need_update = need_update; }
void set_plater_dirty(bool is_dirty) { dirty_state.set_plater_dirty(is_dirty); }
bool is_project_dirty() const { return dirty_state.is_dirty(); }
bool is_presets_dirty() const { return dirty_state.is_presets_dirty(); }
void update_project_dirty_from_presets()
@ -7387,6 +7388,7 @@ bool Plater::Show(bool show)
bool Plater::is_project_dirty() const { return p->is_project_dirty(); }
bool Plater::is_presets_dirty() const { return p->is_presets_dirty(); }
void Plater::set_plater_dirty(bool is_dirty) { p->set_plater_dirty(is_dirty); }
void Plater::update_project_dirty_from_presets() { p->update_project_dirty_from_presets(); }
int Plater::save_project_if_dirty(const wxString& reason) { return p->save_project_if_dirty(reason); }
void Plater::reset_project_dirty_after_save() { p->reset_project_dirty_after_save(); }
@ -10964,8 +10966,13 @@ int Plater::select_plate_by_hover_id(int hover_id, bool right_click)
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) {
PartPlate *curr_plate = p->partplate_list.get_curr_plate();
BedType old_bed_type = curr_plate->get_bed_type(false);
auto type = (BedType)(e.GetInt());
p->partplate_list.get_curr_plate()->set_bed_type(type);
if (old_bed_type != type) {
curr_plate->set_bed_type(type);
set_plater_dirty(true);
}
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format("select bed type %1% for plate %2% at plate side")%type %plate_index;
});
dlg.ShowModal();

View file

@ -187,6 +187,7 @@ public:
bool is_project_dirty() const;
bool is_presets_dirty() const;
void set_plater_dirty(bool is_dirty);
void update_project_dirty_from_presets();
int save_project_if_dirty(const wxString& reason);
void reset_project_dirty_after_save();

View file

@ -17,7 +17,8 @@ namespace GUI {
void ProjectDirtyStateManager::update_from_undo_redo_stack(bool dirty)
{
m_plater_dirty = dirty;
if (!m_plater_dirty)
m_plater_dirty = dirty;
if (const Plater *plater = wxGetApp().plater(); plater && wxGetApp().initialized())
wxGetApp().mainframe->update_title();
}

View file

@ -14,6 +14,7 @@ public:
void reset_after_save();
void reset_initial_presets();
void set_plater_dirty(bool is_dirty) { m_plater_dirty = is_dirty; }
bool is_dirty() const { return m_plater_dirty || m_project_config_dirty || m_presets_dirty; }
bool is_presets_dirty() const { return m_presets_dirty; }