From e80c6f8935dd8f0e043531be41538ef12ad32d70 Mon Sep 17 00:00:00 2001 From: "zhimin.zeng" Date: Wed, 3 Aug 2022 17:21:59 +0800 Subject: [PATCH] FIX: STUDIO-395 update the filament preset parameter dirty logic Change-Id: Iaca29d397f7395f71a5f17007ab2341f8d4ceeeb --- src/slic3r/GUI/Plater.cpp | 1 + src/slic3r/GUI/ProjectDirtyStateManager.cpp | 19 +++++++++++++++---- src/slic3r/GUI/ProjectDirtyStateManager.hpp | 3 +++ 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index d8e5a4022..ac00d550d 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -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(); diff --git a/src/slic3r/GUI/ProjectDirtyStateManager.cpp b/src/slic3r/GUI/ProjectDirtyStateManager.cpp index c79ac0c39..1f228f446 100644 --- a/src/slic3r/GUI/ProjectDirtyStateManager.cpp +++ b/src/slic3r/GUI/ProjectDirtyStateManager.cpp @@ -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; } diff --git a/src/slic3r/GUI/ProjectDirtyStateManager.hpp b/src/slic3r/GUI/ProjectDirtyStateManager.hpp index 6841c89c6..203c87076 100644 --- a/src/slic3r/GUI/ProjectDirtyStateManager.hpp +++ b/src/slic3r/GUI/ProjectDirtyStateManager.hpp @@ -31,6 +31,9 @@ private: // Keeps track of preset names selected at the time of last project save. std::array m_initial_presets; DynamicPrintConfig m_initial_project_config; + + // filament preset independent of the m_initial_presets + std::vector m_initial_filament_presets; }; } // namespace GUI