diff --git a/src/libslic3r/CustomGCode.hpp b/src/libslic3r/CustomGCode.hpp index 334b40431..c4a47b9a3 100644 --- a/src/libslic3r/CustomGCode.hpp +++ b/src/libslic3r/CustomGCode.hpp @@ -66,6 +66,8 @@ struct Info bool operator==(const Info& rhs) const { + if (rhs.gcodes.empty() && this->gcodes.empty()) + return true; // don't respect to the comparison of the mode, when g_codes are empty return (rhs.mode == this->mode ) && (rhs.gcodes == this->gcodes ); } diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 36f2f3861..14562a20d 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -3317,6 +3317,7 @@ unsigned int Plater::priv::update_background_process(bool force_validation, bool sidebar->set_btn_label(ActionButtonType::abExport, _(label_btn_export)); sidebar->set_btn_label(ActionButtonType::abSendGCode, _(label_btn_send)); + dirty_state.update_from_preview(); const wxString slice_string = background_process.running() && wxGetApp().get_mode() == comSimple ? _L("Slicing") + dots : _L("Slice now"); diff --git a/src/slic3r/GUI/ProjectDirtyStateManager.cpp b/src/slic3r/GUI/ProjectDirtyStateManager.cpp index 89c13b640..d30e5d510 100644 --- a/src/slic3r/GUI/ProjectDirtyStateManager.cpp +++ b/src/slic3r/GUI/ProjectDirtyStateManager.cpp @@ -7,6 +7,8 @@ #include "I18N.hpp" #include "Plater.hpp" +#include "libslic3r/Model.hpp" + #include #include @@ -38,12 +40,18 @@ void ProjectDirtyStateManager::update_from_presets() app.mainframe->update_title(); } +void ProjectDirtyStateManager::update_from_preview() +{ + m_custom_gcode_per_print_z_dirty = m_initial_custom_gcode_per_print_z != wxGetApp().model().custom_gcode_per_print_z; +} + void ProjectDirtyStateManager::reset_after_save() { this->reset_initial_presets(); m_plater_dirty = false; m_presets_dirty = false; m_project_config_dirty = false; + m_custom_gcode_per_print_z_dirty = false; wxGetApp().mainframe->update_title(); } @@ -54,6 +62,7 @@ void ProjectDirtyStateManager::reset_initial_presets() for (const PresetCollection *preset_collection : app.get_active_preset_collections()) m_initial_presets[preset_collection->type()] = preset_collection->get_selected_preset_name(); m_initial_project_config = app.preset_bundle->project_config; + m_initial_custom_gcode_per_print_z = app.model().custom_gcode_per_print_z; } #if ENABLE_PROJECT_DIRTY_STATE_DEBUG_WINDOW diff --git a/src/slic3r/GUI/ProjectDirtyStateManager.hpp b/src/slic3r/GUI/ProjectDirtyStateManager.hpp index 6841c89c6..e4e2668fd 100644 --- a/src/slic3r/GUI/ProjectDirtyStateManager.hpp +++ b/src/slic3r/GUI/ProjectDirtyStateManager.hpp @@ -2,6 +2,7 @@ #define slic3r_ProjectDirtyStateManager_hpp_ #include "libslic3r/Preset.hpp" +#include "libslic3r/CustomGCode.hpp" namespace Slic3r { namespace GUI { @@ -11,10 +12,11 @@ class ProjectDirtyStateManager public: void update_from_undo_redo_stack(bool dirty); void update_from_presets(); + void update_from_preview(); void reset_after_save(); void reset_initial_presets(); - bool is_dirty() const { return m_plater_dirty || m_project_config_dirty || m_presets_dirty; } + bool is_dirty() const { return m_plater_dirty || m_project_config_dirty || m_presets_dirty || m_custom_gcode_per_print_z_dirty; } bool is_presets_dirty() const { return m_presets_dirty; } #if ENABLE_PROJECT_DIRTY_STATE_DEBUG_WINDOW @@ -28,9 +30,12 @@ private: bool m_presets_dirty { false }; // Is the project config dirty? bool m_project_config_dirty { false }; + // Is the custom_gcode_per_print_z dirty? + bool m_custom_gcode_per_print_z_dirty { false }; // Keeps track of preset names selected at the time of last project save. std::array m_initial_presets; DynamicPrintConfig m_initial_project_config; + CustomGCode::Info m_initial_custom_gcode_per_print_z; }; } // namespace GUI