FIX: STUDIO-395

update the filament preset parameter dirty logic

Change-Id: Iaca29d397f7395f71a5f17007ab2341f8d4ceeeb
This commit is contained in:
zhimin.zeng 2022-08-03 17:21:59 +08:00 committed by Lane.Wei
parent 10c152c40d
commit e80c6f8935
3 changed files with 19 additions and 4 deletions

View File

@ -4750,6 +4750,7 @@ void Plater::priv::on_select_preset(wxCommandEvent &evt)
if (preset_type == Preset::TYPE_FILAMENT) {
wxGetApp().preset_bundle->set_filament_preset(idx, preset_name);
wxGetApp().get_tab(preset_type)->select_preset(preset_name);
}
bool select_preset = !combo->selection_is_changed_according_to_physical_printers();

View File

@ -28,8 +28,14 @@ void ProjectDirtyStateManager::update_from_presets()
// check switching of the presets only for exist/loaded project, but not for new
GUI_App &app = wxGetApp();
if (!app.plater()->get_project_filename().IsEmpty()) {
for (const auto& [type, name] : app.get_selected_presets())
m_presets_dirty |= !m_initial_presets[type].empty() && m_initial_presets[type] != name;
for (const auto &[type, name] : app.get_selected_presets()) {
if (type == Preset::Type::TYPE_FILAMENT) {
m_presets_dirty |= m_initial_filament_presets != wxGetApp().preset_bundle->filament_presets;
} else {
m_presets_dirty |= !m_initial_presets[type].empty() && m_initial_presets[type] != name;
}
}
}
m_presets_dirty |= app.has_unsaved_preset_changes();
m_project_config_dirty = m_initial_project_config != app.preset_bundle->project_config;
@ -49,8 +55,13 @@ void ProjectDirtyStateManager::reset_initial_presets()
{
m_initial_presets.fill(std::string{});
GUI_App &app = wxGetApp();
for (const auto& [type, name] : app.get_selected_presets())
m_initial_presets[type] = name;
for (const auto &[type, name] : app.get_selected_presets()) {
if (type == Preset::Type::TYPE_FILAMENT) {
m_initial_filament_presets = wxGetApp().preset_bundle->filament_presets;
} else {
m_initial_presets[type] = name;
}
}
m_initial_project_config = app.preset_bundle->project_config;
}

View File

@ -31,6 +31,9 @@ private:
// Keeps track of preset names selected at the time of last project save.
std::array<std::string, Preset::TYPE_COUNT> m_initial_presets;
DynamicPrintConfig m_initial_project_config;
// filament preset independent of the m_initial_presets
std::vector<std::string> m_initial_filament_presets;
};
} // namespace GUI