From 5aff44debe0f5e78f61e90561b555c0ff181369a Mon Sep 17 00:00:00 2001 From: enricoturri1966 Date: Fri, 30 Jul 2021 09:33:51 +0200 Subject: [PATCH] ENABLE_PROJECT_DIRTY_STATE set as default --- src/libslic3r/Preset.cpp | 10 +-- src/libslic3r/Preset.hpp | 10 --- src/libslic3r/Technologies.hpp | 6 +- src/slic3r/GUI/GUI_App.cpp | 27 -------- src/slic3r/GUI/GUI_App.hpp | 4 -- src/slic3r/GUI/GUI_ObjectList.cpp | 8 --- src/slic3r/GUI/Gizmos/GLGizmoPainterBase.cpp | 24 ------- src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.cpp | 8 --- src/slic3r/GUI/MainFrame.cpp | 39 ----------- src/slic3r/GUI/MainFrame.hpp | 5 -- src/slic3r/GUI/Plater.cpp | 68 -------------------- src/slic3r/GUI/Plater.hpp | 8 --- src/slic3r/GUI/ProjectDirtyStateManager.cpp | 4 -- src/slic3r/GUI/ProjectDirtyStateManager.hpp | 4 -- src/slic3r/GUI/Tab.cpp | 9 --- src/slic3r/GUI/Tab.hpp | 28 -------- 16 files changed, 3 insertions(+), 259 deletions(-) diff --git a/src/libslic3r/Preset.cpp b/src/libslic3r/Preset.cpp index 0c1ff112f..1283d0ac1 100644 --- a/src/libslic3r/Preset.cpp +++ b/src/libslic3r/Preset.cpp @@ -625,17 +625,13 @@ const std::vector& Preset::sla_printer_options() PresetCollection::PresetCollection(Preset::Type type, const std::vector &keys, const Slic3r::StaticPrintConfig &defaults, const std::string &default_name) : m_type(type), m_edited_preset(type, "", false), -#if ENABLE_PROJECT_DIRTY_STATE m_saved_preset(type, "", false), -#endif // ENABLE_PROJECT_DIRTY_STATE m_idx_selected(0) { // Insert just the default preset. this->add_default_preset(keys, defaults, default_name); m_edited_preset.config.apply(m_presets.front().config); -#if ENABLE_PROJECT_DIRTY_STATE update_saved_preset_from_current_preset(); -#endif // ENABLE_PROJECT_DIRTY_STATE } void PresetCollection::reset(bool delete_files) @@ -816,10 +812,8 @@ std::pair PresetCollection::load_external_preset( // The source config may contain keys from many possible preset types. Just copy those that relate to this preset. this->get_edited_preset().config.apply_only(combined_config, keys, true); this->update_dirty(); -#if ENABLE_PROJECT_DIRTY_STATE update_saved_preset_from_current_preset(); -#endif // ENABLE_PROJECT_DIRTY_STATE - assert(this->get_edited_preset().is_dirty); + assert(this->get_edited_preset().is_dirty); return std::make_pair(&(*it), this->get_edited_preset().is_dirty); } if (inherits.empty()) { @@ -1229,9 +1223,7 @@ Preset& PresetCollection::select_preset(size_t idx) idx = first_visible_idx(); m_idx_selected = idx; m_edited_preset = m_presets[idx]; -#if ENABLE_PROJECT_DIRTY_STATE update_saved_preset_from_current_preset(); -#endif // ENABLE_PROJECT_DIRTY_STATE bool default_visible = ! m_default_suppressed || m_idx_selected < m_num_default_presets; for (size_t i = 0; i < m_num_default_presets; ++i) m_presets[i].is_visible = default_visible; diff --git a/src/libslic3r/Preset.hpp b/src/libslic3r/Preset.hpp index eeb1c84ee..9d5597cac 100644 --- a/src/libslic3r/Preset.hpp +++ b/src/libslic3r/Preset.hpp @@ -370,10 +370,8 @@ public: Preset& get_edited_preset() { return m_edited_preset; } const Preset& get_edited_preset() const { return m_edited_preset; } -#if ENABLE_PROJECT_DIRTY_STATE // Return the last saved preset. const Preset& get_saved_preset() const { return m_saved_preset; } -#endif // ENABLE_PROJECT_DIRTY_STATE // Return vendor of the first parent profile, for which the vendor is defined, or null if such profile does not exist. PresetWithVendorProfile get_preset_with_vendor_profile(const Preset &preset) const; @@ -394,15 +392,11 @@ public: // Return a preset by an index. If the preset is active, a temporary copy is returned. Preset& preset(size_t idx) { return (idx == m_idx_selected) ? m_edited_preset : m_presets[idx]; } const Preset& preset(size_t idx) const { return const_cast(this)->preset(idx); } -#if ENABLE_PROJECT_DIRTY_STATE void discard_current_changes() { m_presets[m_idx_selected].reset_dirty(); m_edited_preset = m_presets[m_idx_selected]; update_saved_preset_from_current_preset(); } -#else - void discard_current_changes() { m_presets[m_idx_selected].reset_dirty(); m_edited_preset = m_presets[m_idx_selected]; } -#endif // ENABLE_PROJECT_DIRTY_STATE // Return a preset by its name. If the preset is active, a temporary copy is returned. // If a preset is not found by its name, null is returned. @@ -477,7 +471,6 @@ public: std::vector current_different_from_parent_options(const bool deep_compare = false) const { return dirty_options(&this->get_edited_preset(), this->get_selected_preset_parent(), deep_compare); } -#if ENABLE_PROJECT_DIRTY_STATE // Compare the content of get_saved_preset() with get_edited_preset() configs, return true if they differ. bool saved_is_dirty() const { return !this->saved_dirty_options().empty(); } // Compare the content of get_saved_preset() with get_edited_preset() configs, return the list of keys where they differ. @@ -485,7 +478,6 @@ public: { return dirty_options(&this->get_edited_preset(), &this->get_saved_preset(), deep_compare); } // Copy edited preset into saved preset. void update_saved_preset_from_current_preset() { m_saved_preset = m_edited_preset; } -#endif // ENABLE_PROJECT_DIRTY_STATE // Return a sorted list of system preset names. // Used for validating the "inherits" flag when importing user's config bundles. @@ -574,10 +566,8 @@ private: std::map m_map_system_profile_renamed; // Initially this preset contains a copy of the selected preset. Later on, this copy may be modified by the user. Preset m_edited_preset; -#if ENABLE_PROJECT_DIRTY_STATE // Contains a copy of the last saved selected preset. Preset m_saved_preset; -#endif // ENABLE_PROJECT_DIRTY_STATE // Selected preset. size_t m_idx_selected; diff --git a/src/libslic3r/Technologies.hpp b/src/libslic3r/Technologies.hpp index 45217c959..f6366c18e 100644 --- a/src/libslic3r/Technologies.hpp +++ b/src/libslic3r/Technologies.hpp @@ -24,6 +24,8 @@ #define ENABLE_GCODE_VIEWER_STATISTICS 0 // Enable G-Code viewer comparison between toolpaths height and width detected from gcode and calculated at gcode generation #define ENABLE_GCODE_VIEWER_DATA_CHECKING 0 +// Enable project dirty state manager debug window +#define ENABLE_PROJECT_DIRTY_STATE_DEBUG_WINDOW 0 // Enable rendering of objects using environment map @@ -39,10 +41,6 @@ //==================== #define ENABLE_2_4_0_ALPHA0 1 -// Enable project dirty state manager -#define ENABLE_PROJECT_DIRTY_STATE (1 && ENABLE_2_4_0_ALPHA0) -// Enable project dirty state manager debug window -#define ENABLE_PROJECT_DIRTY_STATE_DEBUG_WINDOW (0 && ENABLE_PROJECT_DIRTY_STATE) // Enable delayed rendering of transparent volumes #define ENABLE_DELAYED_TRANSPARENT_VOLUMES_RENDERING (1 && ENABLE_2_4_0_ALPHA0) // Enable the fix of importing color print view from gcode files into GCodeViewer diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index d0d1013d2..4196dfdac 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -954,12 +954,10 @@ bool GUI_App::on_init_inner() else load_current_presets(); -#if ENABLE_PROJECT_DIRTY_STATE if (plater_ != nullptr) { plater_->reset_project_dirty_initial_presets(); plater_->update_project_dirty_from_presets(); } -#endif // ENABLE_PROJECT_DIRTY_STATE mainframe->Show(true); @@ -1852,11 +1850,7 @@ void GUI_App::add_config_menu(wxMenuBar *menu) #endif case ConfigMenuTakeSnapshot: // Take a configuration snapshot. -#if ENABLE_PROJECT_DIRTY_STATE if (check_and_save_current_preset_changes()) { -#else - if (check_unsaved_changes()) { -#endif // ENABLE_PROJECT_DIRTY_STATE wxTextEntryDialog dlg(nullptr, _L("Taking configuration snapshot"), _L("Snapshot name")); UpdateDlgDarkUI(&dlg); @@ -1872,11 +1866,7 @@ void GUI_App::add_config_menu(wxMenuBar *menu) } break; case ConfigMenuSnapshots: -#if ENABLE_PROJECT_DIRTY_STATE if (check_and_save_current_preset_changes()) { -#else - if (check_unsaved_changes()) { -#endif // ENABLE_PROJECT_DIRTY_STATE std::string on_snapshot; if (Config::SnapshotDB::singleton().is_on_snapshot(*app_config)) on_snapshot = app_config->get("on_snapshot"); @@ -2022,7 +2012,6 @@ void GUI_App::open_preferences(size_t open_on_tab) } } -#if ENABLE_PROJECT_DIRTY_STATE bool GUI_App::has_unsaved_preset_changes() const { PrinterTechnology printer_technology = preset_bundle->printers.get_edited_preset().printer_technology(); @@ -2064,28 +2053,12 @@ std::vector> GUI_App::get_selected_presets( } return ret; } -#endif // ENABLE_PROJECT_DIRTY_STATE // This is called when closing the application, when loading a config file or when starting the config wizard // to notify the user whether he is aware that some preset changes will be lost. -#if ENABLE_PROJECT_DIRTY_STATE bool GUI_App::check_and_save_current_preset_changes(const wxString& header) { if (this->plater()->model().objects.empty() && has_current_preset_changes()) { -#else -bool GUI_App::check_unsaved_changes(const wxString &header) -{ - PrinterTechnology printer_technology = preset_bundle->printers.get_edited_preset().printer_technology(); - - bool has_unsaved_changes = false; - for (Tab* tab : tabs_list) - if (tab->supports_printer_technology(printer_technology) && tab->current_preset_is_dirty()) { - has_unsaved_changes = true; - break; - } - - if (has_unsaved_changes) { -#endif // ENABLE_PROJECT_DIRTY_STATE UnsavedChangesDialog dlg(header); if (wxGetApp().app_config->get("default_action_on_close_application") == "none" && dlg.ShowModal() == wxID_CANCEL) return false; diff --git a/src/slic3r/GUI/GUI_App.hpp b/src/slic3r/GUI/GUI_App.hpp index 0ca73cde9..fc62d4c34 100644 --- a/src/slic3r/GUI/GUI_App.hpp +++ b/src/slic3r/GUI/GUI_App.hpp @@ -238,15 +238,11 @@ public: void update_mode(); void add_config_menu(wxMenuBar *menu); -#if ENABLE_PROJECT_DIRTY_STATE bool has_unsaved_preset_changes() const; bool has_current_preset_changes() const; void update_saved_preset_from_current_preset(); std::vector> get_selected_presets() const; bool check_and_save_current_preset_changes(const wxString& header = wxString()); -#else - bool check_unsaved_changes(const wxString& header = wxString()); -#endif // ENABLE_PROJECT_DIRTY_STATE bool check_print_host_queue(); bool checked_tab(Tab* tab); void load_current_presets(bool check_printer_presets = true); diff --git a/src/slic3r/GUI/GUI_ObjectList.cpp b/src/slic3r/GUI/GUI_ObjectList.cpp index df97cec5a..a2d64d72c 100644 --- a/src/slic3r/GUI/GUI_ObjectList.cpp +++ b/src/slic3r/GUI/GUI_ObjectList.cpp @@ -9,9 +9,7 @@ #include "Plater.hpp" #include "BitmapComboBox.hpp" #include "GalleryDialog.hpp" -#if ENABLE_PROJECT_DIRTY_STATE #include "MainFrame.hpp" -#endif // ENABLE_PROJECT_DIRTY_STATE #include "OptionsGroup.hpp" #include "Tab.hpp" @@ -1673,9 +1671,7 @@ void ObjectList::load_shape_object(const std::string& type_name) BoundingBoxf3 bb; TriangleMesh mesh = create_mesh(type_name, bb); load_mesh_object(mesh, _L("Shape") + "-" + _(type_name)); -#if ENABLE_PROJECT_DIRTY_STATE wxGetApp().mainframe->update_title(); -#endif // ENABLE_PROJECT_DIRTY_STATE } void ObjectList::load_shape_object_from_gallery() @@ -1706,13 +1702,9 @@ void ObjectList::load_shape_object_from_gallery(const wxArrayString& input_files snapshot_label += ", " + wxString::FromUTF8(paths[i].filename().string().c_str()); take_snapshot(snapshot_label); -#if ENABLE_PROJECT_DIRTY_STATE std::vector res = wxGetApp().plater()->load_files(paths, true, false); if (!res.empty()) wxGetApp().mainframe->update_title(); -#else - load_files(paths, true, false); -#endif // ENABLE_PROJECT_DIRTY_STATE } void ObjectList::load_mesh_object(const TriangleMesh &mesh, const wxString &name, bool center) diff --git a/src/slic3r/GUI/Gizmos/GLGizmoPainterBase.cpp b/src/slic3r/GUI/Gizmos/GLGizmoPainterBase.cpp index 84591ff59..317d7ebca 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoPainterBase.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoPainterBase.cpp @@ -31,7 +31,6 @@ GLGizmoPainterBase::GLGizmoPainterBase(GLCanvas3D& parent, const std::string& ic -#if ENABLE_PROJECT_DIRTY_STATE // port of 948bc382655993721d93d3b9fce9b0186fcfb211 void GLGizmoPainterBase::activate_internal_undo_redo_stack(bool activate) { @@ -66,29 +65,6 @@ void GLGizmoPainterBase::activate_internal_undo_redo_stack(bool activate) m_internal_stack_active = false; } } -#else -void GLGizmoPainterBase::activate_internal_undo_redo_stack(bool activate) -{ - if (activate && ! m_internal_stack_active) { - wxString str = get_painter_type() == PainterGizmoType::FDM_SUPPORTS - ? _L("Entering Paint-on supports") - : (get_painter_type() == PainterGizmoType::MMU_SEGMENTATION ? _L("Entering MMU segmentation") : _L("Entering Seam painting")); - Plater::TakeSnapshot(wxGetApp().plater(), str); - wxGetApp().plater()->enter_gizmos_stack(); - m_internal_stack_active = true; - } - if (! activate && m_internal_stack_active) { - wxString str = get_painter_type() == PainterGizmoType::SEAM - ? _L("Leaving Seam painting") - : (get_painter_type() == PainterGizmoType::MMU_SEGMENTATION ? _L("Leaving MMU segmentation") : _L("Leaving Paint-on supports")); - wxGetApp().plater()->leave_gizmos_stack(); - Plater::TakeSnapshot(wxGetApp().plater(), str); - m_internal_stack_active = false; - } -} -#endif // ENABLE_PROJECT_DIRTY_STATE - - void GLGizmoPainterBase::set_painter_gizmo_data(const Selection& selection) { diff --git a/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.cpp b/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.cpp index 39107e7be..fa61779ec 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.cpp @@ -890,11 +890,7 @@ void GLGizmoSlaSupports::on_set_state() // data are not yet available, the CallAfter will postpone taking the // snapshot until they are. No, it does not feel right. wxGetApp().CallAfter([]() { -#if ENABLE_PROJECT_DIRTY_STATE Plater::TakeSnapshot snapshot(wxGetApp().plater(), _L("Entering SLA gizmo")); -#else - Plater::TakeSnapshot snapshot(wxGetApp().plater(), _L("SLA gizmo turned on")); -#endif // ENABLE_PROJECT_DIRTY_STATE }); } @@ -922,11 +918,7 @@ void GLGizmoSlaSupports::on_set_state() else { // we are actually shutting down disable_editing_mode(); // so it is not active next time the gizmo opens -#if ENABLE_PROJECT_DIRTY_STATE Plater::TakeSnapshot snapshot(wxGetApp().plater(), _L("Leaving SLA gizmo")); -#else - Plater::TakeSnapshot snapshot(wxGetApp().plater(), _L("SLA gizmo turned off")); -#endif // ENABLE_PROJECT_DIRTY_STATE m_normal_cache.clear(); m_old_mo_id = -1; } diff --git a/src/slic3r/GUI/MainFrame.cpp b/src/slic3r/GUI/MainFrame.cpp index a95a5d0ef..5cf0d8573 100644 --- a/src/slic3r/GUI/MainFrame.cpp +++ b/src/slic3r/GUI/MainFrame.cpp @@ -213,7 +213,6 @@ DPIFrame(NULL, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_S // declare events Bind(wxEVT_CLOSE_WINDOW, [this](wxCloseEvent& event) { -#if ENABLE_PROJECT_DIRTY_STATE if (event.CanVeto() && m_plater->canvas3D()->get_gizmos_manager().is_in_editing_mode(true)) { // prevents to open the save dirty project dialog event.Veto(); @@ -226,9 +225,6 @@ DPIFrame(NULL, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_S } if (event.CanVeto() && !wxGetApp().check_and_save_current_preset_changes()) { -#else - if (event.CanVeto() && !wxGetApp().check_unsaved_changes()) { -#endif // ENABLE_PROJECT_DIRTY_STATE event.Veto(); return; } @@ -616,14 +612,9 @@ void MainFrame::update_title() // m_plater->get_project_filename() produces file name including path, but excluding extension. // Don't try to remove the extension, it would remove part of the file name after the last dot! wxString project = from_path(into_path(m_plater->get_project_filename()).filename()); -#if ENABLE_PROJECT_DIRTY_STATE wxString dirty_marker = (!m_plater->model().objects.empty() && m_plater->is_project_dirty()) ? "*" : ""; if (!dirty_marker.empty() || !project.empty()) title = dirty_marker + project + " - "; -#else - if (!project.empty()) - title += (project + " - "); -#endif // ENABLE_PROJECT_DIRTY_STATE } std::string build_id = wxGetApp().is_editor() ? SLIC3R_BUILD_ID : GCODEVIEWER_BUILD_ID; @@ -823,7 +814,6 @@ bool MainFrame::can_start_new_project() const return (m_plater != nullptr) && (!m_plater->get_project_filename(".3mf").IsEmpty() || !m_plater->model().objects.empty()); } -#if ENABLE_PROJECT_DIRTY_STATE bool MainFrame::can_save() const { return (m_plater != nullptr) && !m_plater->model().objects.empty() && @@ -850,12 +840,6 @@ void MainFrame::save_project_as(const wxString& filename) m_plater->reset_project_dirty_after_save(); } } -#else -bool MainFrame::can_save() const -{ - return (m_plater != nullptr) && !m_plater->model().objects.empty(); -} -#endif // ENABLE_PROJECT_DIRTY_STATE bool MainFrame::can_export_model() const { @@ -1175,27 +1159,16 @@ void MainFrame::init_menubar_as_editor() Bind(wxEVT_UPDATE_UI, [this](wxUpdateUIEvent& evt) { evt.Enable(m_recent_projects.GetCount() > 0); }, recent_projects_submenu->GetId()); -#if ENABLE_PROJECT_DIRTY_STATE append_menu_item(fileMenu, wxID_ANY, _L("&Save Project") + "\tCtrl+S", _L("Save current project file"), [this](wxCommandEvent&) { save_project(); }, "save", nullptr, [this](){return m_plater != nullptr && can_save(); }, this); -#else - append_menu_item(fileMenu, wxID_ANY, _L("&Save Project") + "\tCtrl+S", _L("Save current project file"), - [this](wxCommandEvent&) { if (m_plater) m_plater->export_3mf(into_path(m_plater->get_project_filename(".3mf"))); }, "save", nullptr, - [this](){return m_plater != nullptr && can_save(); }, this); -#endif // ENABLE_PROJECT_DIRTY_STATE #ifdef __APPLE__ append_menu_item(fileMenu, wxID_ANY, _L("Save Project &as") + dots + "\tCtrl+Shift+S", _L("Save current project file as"), #else append_menu_item(fileMenu, wxID_ANY, _L("Save Project &as") + dots + "\tCtrl+Alt+S", _L("Save current project file as"), #endif // __APPLE__ -#if ENABLE_PROJECT_DIRTY_STATE [this](wxCommandEvent&) { save_project_as(); }, "save", nullptr, [this](){return m_plater != nullptr && can_save_as(); }, this); -#else - [this](wxCommandEvent&) { if (m_plater) m_plater->export_3mf(); }, "save", nullptr, - [this](){return m_plater != nullptr && can_save(); }, this); -#endif // ENABLE_PROJECT_DIRTY_STATE fileMenu->AppendSeparator(); @@ -1750,11 +1723,7 @@ void MainFrame::export_config() // Load a config file containing a Print, Filament & Printer preset. void MainFrame::load_config_file() { -#if ENABLE_PROJECT_DIRTY_STATE if (!wxGetApp().check_and_save_current_preset_changes()) -#else - if (!wxGetApp().check_unsaved_changes()) -#endif // ENABLE_PROJECT_DIRTY_STATE return; wxFileDialog dlg(this, _L("Select configuration to load:"), !m_last_config.IsEmpty() ? get_dir_name(m_last_config) : wxGetApp().app_config->get_last_dir(), @@ -1789,11 +1758,7 @@ bool MainFrame::load_config_file(const std::string &path) void MainFrame::export_configbundle(bool export_physical_printers /*= false*/) { -#if ENABLE_PROJECT_DIRTY_STATE if (!wxGetApp().check_and_save_current_preset_changes()) -#else - if (!wxGetApp().check_unsaved_changes()) -#endif // ENABLE_PROJECT_DIRTY_STATE return; // validate current configuration in case it's dirty auto err = wxGetApp().preset_bundle->full_config().validate(); @@ -1825,11 +1790,7 @@ void MainFrame::export_configbundle(bool export_physical_printers /*= false*/) // but that behavior was not documented and likely buggy. void MainFrame::load_configbundle(wxString file/* = wxEmptyString, const bool reset_user_profile*/) { -#if ENABLE_PROJECT_DIRTY_STATE if (!wxGetApp().check_and_save_current_preset_changes()) -#else - if (!wxGetApp().check_unsaved_changes()) -#endif // ENABLE_PROJECT_DIRTY_STATE return; if (file.IsEmpty()) { wxFileDialog dlg(this, _L("Select configuration to load:"), diff --git a/src/slic3r/GUI/MainFrame.hpp b/src/slic3r/GUI/MainFrame.hpp index a5c6b57ca..aced5efbe 100644 --- a/src/slic3r/GUI/MainFrame.hpp +++ b/src/slic3r/GUI/MainFrame.hpp @@ -91,9 +91,6 @@ class MainFrame : public DPIFrame void on_value_changed(wxCommandEvent&); bool can_start_new_project() const; -#if !ENABLE_PROJECT_DIRTY_STATE - bool can_save() const; -#endif // !ENABLE_PROJECT_DIRTY_STATE bool can_export_model() const; bool can_export_toolpaths() const; bool can_export_supports() const; @@ -188,12 +185,10 @@ public: // Propagate changed configuration from the Tab to the Plater and save changes to the AppConfig void on_config_changed(DynamicPrintConfig* cfg) const ; -#if ENABLE_PROJECT_DIRTY_STATE bool can_save() const; bool can_save_as() const; void save_project(); void save_project_as(const wxString& filename = wxString()); -#endif // ENABLE_PROJECT_DIRTY_STATE void add_to_recent_projects(const wxString& filename); void technology_changed(); diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index e87b4b3d7..be44d32a4 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -82,9 +82,7 @@ #include "NotificationManager.hpp" #include "PresetComboBoxes.hpp" #include "MsgDialog.hpp" -#if ENABLE_PROJECT_DIRTY_STATE #include "ProjectDirtyStateManager.hpp" -#endif // ENABLE_PROJECT_DIRTY_STATE #ifdef __APPLE__ #include "Gizmos/GLGizmosManager.hpp" @@ -1460,13 +1458,9 @@ bool PlaterDropTarget::OnDropFiles(wxCoord x, wxCoord y, const wxArrayString &fi this->MSWUpdateDragImageOnLeave(); #endif // WIN32 -#if ENABLE_PROJECT_DIRTY_STATE bool res = (m_plater != nullptr) ? m_plater->load_files(filenames) : false; wxGetApp().mainframe->update_title(); return res; -#else - return (m_plater != nullptr) ? m_plater->load_files(filenames) : false; -#endif // ENABLE_PROJECT_DIRTY_STATE } // State to manage showing after export notifications and device ejecting @@ -1510,9 +1504,7 @@ struct Plater::priv Preview *preview; NotificationManager* notification_manager { nullptr }; -#if ENABLE_PROJECT_DIRTY_STATE ProjectDirtyStateManager dirty_state; -#endif // ENABLE_PROJECT_DIRTY_STATE BackgroundSlicingProcess background_process; bool suppressed_backround_processing_update { false }; @@ -1582,7 +1574,6 @@ struct Plater::priv priv(Plater *q, MainFrame *main_frame); ~priv(); -#if ENABLE_PROJECT_DIRTY_STATE bool is_project_dirty() const { return dirty_state.is_dirty(); } void update_project_dirty_from_presets() { dirty_state.update_from_presets(); } bool save_project_if_dirty() { @@ -1606,7 +1597,6 @@ struct Plater::priv #if ENABLE_PROJECT_DIRTY_STATE_DEBUG_WINDOW void render_project_state_debug_window() const { dirty_state.render_debug_window(); } #endif // ENABLE_PROJECT_DIRTY_STATE_DEBUG_WINDOW -#endif // ENABLE_PROJECT_DIRTY_STATE enum class UpdateParams { FORCE_FULL_SCREEN_REFRESH = 1, @@ -4456,9 +4446,7 @@ void Plater::priv::take_snapshot(const std::string& snapshot_name) this->undo_redo_stack().take_snapshot(snapshot_name, model, view3D->get_canvas3d()->get_selection(), view3D->get_canvas3d()->get_gizmos_manager(), snapshot_data); this->undo_redo_stack().release_least_recently_used(); -#if ENABLE_PROJECT_DIRTY_STATE dirty_state.update_from_undo_redo_stack(ProjectDirtyStateManager::UpdateType::TakeSnapshot); -#endif // ENABLE_PROJECT_DIRTY_STATE // Save the last active preset name of a particular printer technology. ((this->printer_technology == ptFFF) ? m_last_fff_printer_profile_name : m_last_sla_printer_profile_name) = wxGetApp().preset_bundle->printers.get_selected_preset_name(); @@ -4500,13 +4488,8 @@ void Plater::priv::undo_redo_to(std::vector::const_iterator if (printer_technology_changed) { // Switching the printer technology when jumping forwards / backwards in time. Switch to the last active printer profile of the other type. std::string s_pt = (it_snapshot->snapshot_data.printer_technology == ptFFF) ? "FFF" : "SLA"; -#if ENABLE_PROJECT_DIRTY_STATE if (!wxGetApp().check_and_save_current_preset_changes(format_wxstr(_L( "%1% printer was active at the time the target Undo / Redo snapshot was taken. Switching to %1% printer requires reloading of %1% presets."), s_pt))) -#else - if (! wxGetApp().check_unsaved_changes(format_wxstr(_L( - "%1% printer was active at the time the target Undo / Redo snapshot was taken. Switching to %1% printer requires reloading of %1% presets."), s_pt))) -#endif // ENABLE_PROJECT_DIRTY_STATE // Don't switch the profiles. return; } @@ -4598,9 +4581,7 @@ void Plater::priv::undo_redo_to(std::vector::const_iterator view3D->get_canvas3d()->force_main_toolbar_left_action(view3D->get_canvas3d()->get_main_toolbar_item_id("layersediting")); } -#if ENABLE_PROJECT_DIRTY_STATE dirty_state.update_from_undo_redo_stack(ProjectDirtyStateManager::UpdateType::UndoRedoTo); -#endif // ENABLE_PROJECT_DIRTY_STATE } void Plater::priv::update_after_undo_redo(const UndoRedo::Snapshot& snapshot, bool /* temp_snapshot_was_taken */) @@ -4684,7 +4665,6 @@ Plater::Plater(wxWindow *parent, MainFrame *main_frame) // Initialization performed in the private c-tor } -#if ENABLE_PROJECT_DIRTY_STATE bool Plater::is_project_dirty() const { return p->is_project_dirty(); } void Plater::update_project_dirty_from_presets() { p->update_project_dirty_from_presets(); } bool Plater::save_project_if_dirty() { return p->save_project_if_dirty(); } @@ -4693,7 +4673,6 @@ void Plater::reset_project_dirty_initial_presets() { p->reset_project_dirty_init #if ENABLE_PROJECT_DIRTY_STATE_DEBUG_WINDOW void Plater::render_project_state_debug_window() const { p->render_project_state_debug_window(); } #endif // ENABLE_PROJECT_DIRTY_STATE_DEBUG_WINDOW -#endif // ENABLE_PROJECT_DIRTY_STATE Sidebar& Plater::sidebar() { return *p->sidebar; } const Model& Plater::model() const { return p->model; } @@ -4705,29 +4684,21 @@ SLAPrint& Plater::sla_print() { return p->sla_print; } void Plater::new_project() { -#if ENABLE_PROJECT_DIRTY_STATE if (!p->save_project_if_dirty()) return; -#endif // ENABLE_PROJECT_DIRTY_STATE p->select_view_3D("3D"); -#if ENABLE_PROJECT_DIRTY_STATE take_snapshot(_L("New Project")); Plater::SuppressSnapshots suppress(this); reset(); reset_project_dirty_initial_presets(); update_project_dirty_from_presets(); -#else - wxPostEvent(p->view3D->get_wxglcanvas(), SimpleEvent(EVT_GLTOOLBAR_DELETE_ALL)); -#endif // ENABLE_PROJECT_DIRTY_STATE } void Plater::load_project() { -#if ENABLE_PROJECT_DIRTY_STATE if (!p->save_project_if_dirty()) return; -#endif // ENABLE_PROJECT_DIRTY_STATE // Ask user for a project file name. wxString input_file; @@ -4752,16 +4723,11 @@ void Plater::load_project(const wxString& filename) std::vector res = load_files(input_paths); // if res is empty no data has been loaded -#if ENABLE_PROJECT_DIRTY_STATE if (!res.empty()) { p->set_project_filename(filename); reset_project_dirty_initial_presets(); update_project_dirty_from_presets(); } -#else - if (!res.empty()) - p->set_project_filename(filename); -#endif // ENABLE_PROJECT_DIRTY_STATE } void Plater::add_model(bool imperial_units/* = false*/) @@ -4792,13 +4758,9 @@ void Plater::add_model(bool imperial_units/* = false*/) } Plater::TakeSnapshot snapshot(this, snapshot_label); -#if ENABLE_PROJECT_DIRTY_STATE std::vector res = load_files(paths, true, false, imperial_units); if (!res.empty()) wxGetApp().mainframe->update_title(); -#else - load_files(paths, true, false, imperial_units); -#endif // ENABLE_PROJECT_DIRTY_STATE } void Plater::import_sl1_archive() @@ -5556,38 +5518,22 @@ void Plater::export_amf() } } -#if ENABLE_PROJECT_DIRTY_STATE bool Plater::export_3mf(const boost::filesystem::path& output_path) -#else -void Plater::export_3mf(const boost::filesystem::path& output_path) -#endif // ENABLE_PROJECT_DIRTY_STATE { if (p->model.objects.empty()) -#if ENABLE_PROJECT_DIRTY_STATE return false; -#else - return; -#endif // ENABLE_PROJECT_DIRTY_STATE wxString path; bool export_config = true; if (output_path.empty()) { path = p->get_export_file(FT_3MF); -#if ENABLE_PROJECT_DIRTY_STATE if (path.empty()) { return false; } -#else - if (path.empty()) { return; } -#endif // ENABLE_PROJECT_DIRTY_STATE } else path = from_path(output_path); if (!path.Lower().EndsWith(".3mf")) -#if ENABLE_PROJECT_DIRTY_STATE return false; -#else - return; -#endif // ENABLE_PROJECT_DIRTY_STATE DynamicPrintConfig cfg = wxGetApp().preset_bundle->full_config_secure(); const std::string path_u8 = into_u8(path); @@ -5596,7 +5542,6 @@ void Plater::export_3mf(const boost::filesystem::path& output_path) ThumbnailData thumbnail_data; ThumbnailsParams thumbnail_params = { {}, false, true, true, true }; p->generate_thumbnail(thumbnail_data, THUMBNAIL_SIZE_3MF.first, THUMBNAIL_SIZE_3MF.second, thumbnail_params, Camera::EType::Ortho); -#if ENABLE_PROJECT_DIRTY_STATE bool ret = Slic3r::store_3mf(path_u8.c_str(), &p->model, export_config ? &cfg : nullptr, full_pathnames, &thumbnail_data); if (ret) { // Success @@ -5608,17 +5553,6 @@ void Plater::export_3mf(const boost::filesystem::path& output_path) p->statusbar()->set_status_text(format_wxstr(_L("Error exporting 3MF file %s"), path)); } return ret; -#else - if (Slic3r::store_3mf(path_u8.c_str(), &p->model, export_config ? &cfg : nullptr, full_pathnames, &thumbnail_data)) { - // Success - p->statusbar()->set_status_text(format_wxstr(_L("3MF file exported to %s"), path)); - p->set_project_filename(path); - } - else { - // Failure - p->statusbar()->set_status_text(format_wxstr(_L("Error exporting 3MF file %s"), path)); - } -#endif // ENABLE_PROJECT_DIRTY_STATE } void Plater::reload_from_disk() @@ -6514,9 +6448,7 @@ bool Plater::can_mirror() const { return p->can_mirror(); } bool Plater::can_split(bool to_objects) const { return p->can_split(to_objects); } const UndoRedo::Stack& Plater::undo_redo_stack_main() const { return p->undo_redo_stack_main(); } void Plater::clear_undo_redo_stack_main() { p->undo_redo_stack_main().clear(); } -#if ENABLE_PROJECT_DIRTY_STATE const UndoRedo::Stack& Plater::undo_redo_stack_active() const { return p->undo_redo_stack(); } -#endif // ENABLE_PROJECT_DIRTY_STATE void Plater::enter_gizmos_stack() { p->enter_gizmos_stack(); } void Plater::leave_gizmos_stack() { p->leave_gizmos_stack(); } bool Plater::inside_snapshot_capture() { return p->inside_snapshot_capture(); } diff --git a/src/slic3r/GUI/Plater.hpp b/src/slic3r/GUI/Plater.hpp index 0909a0d2b..9426cd112 100644 --- a/src/slic3r/GUI/Plater.hpp +++ b/src/slic3r/GUI/Plater.hpp @@ -138,7 +138,6 @@ public: Plater &operator=(const Plater &) = delete; ~Plater() = default; -#if ENABLE_PROJECT_DIRTY_STATE bool is_project_dirty() const; void update_project_dirty_from_presets(); bool save_project_if_dirty(); @@ -147,7 +146,6 @@ public: #if ENABLE_PROJECT_DIRTY_STATE_DEBUG_WINDOW void render_project_state_debug_window() const; #endif // ENABLE_PROJECT_DIRTY_STATE_DEBUG_WINDOW -#endif // ENABLE_PROJECT_DIRTY_STATE Sidebar& sidebar(); const Model& model() const; @@ -218,11 +216,7 @@ public: void export_gcode(bool prefer_removable); void export_stl(bool extended = false, bool selection_only = false); void export_amf(); -#if ENABLE_PROJECT_DIRTY_STATE bool export_3mf(const boost::filesystem::path& output_path = boost::filesystem::path()); -#else - void export_3mf(const boost::filesystem::path& output_path = boost::filesystem::path()); -#endif // ENABLE_PROJECT_DIRTY_STATE void reload_from_disk(); void replace_with_stl(); void reload_all_from_disk(); @@ -253,9 +247,7 @@ public: // For the memory statistics. const Slic3r::UndoRedo::Stack& undo_redo_stack_main() const; void clear_undo_redo_stack_main(); -#if ENABLE_PROJECT_DIRTY_STATE const Slic3r::UndoRedo::Stack& undo_redo_stack_active() const; -#endif // ENABLE_PROJECT_DIRTY_STATE // Enter / leave the Gizmos specific Undo / Redo stack. To be used by the SLA support point editing gizmo. void enter_gizmos_stack(); void leave_gizmos_stack(); diff --git a/src/slic3r/GUI/ProjectDirtyStateManager.cpp b/src/slic3r/GUI/ProjectDirtyStateManager.cpp index a671070fb..9efc1dd90 100644 --- a/src/slic3r/GUI/ProjectDirtyStateManager.cpp +++ b/src/slic3r/GUI/ProjectDirtyStateManager.cpp @@ -13,8 +13,6 @@ #include #include -#if ENABLE_PROJECT_DIRTY_STATE - namespace Slic3r { namespace GUI { @@ -411,5 +409,3 @@ void ProjectDirtyStateManager::update_from_undo_redo_gizmo_stack(UpdateType type } // namespace GUI } // namespace Slic3r -#endif // ENABLE_PROJECT_DIRTY_STATE - diff --git a/src/slic3r/GUI/ProjectDirtyStateManager.hpp b/src/slic3r/GUI/ProjectDirtyStateManager.hpp index f7ce81a62..2151c9717 100644 --- a/src/slic3r/GUI/ProjectDirtyStateManager.hpp +++ b/src/slic3r/GUI/ProjectDirtyStateManager.hpp @@ -3,8 +3,6 @@ #include "libslic3r/Preset.hpp" -#if ENABLE_PROJECT_DIRTY_STATE - namespace Slic3r { namespace UndoRedo { class Stack; @@ -90,7 +88,5 @@ private: } // namespace GUI } // namespace Slic3r -#endif // ENABLE_PROJECT_DIRTY_STATE - #endif // slic3r_ProjectDirtyStateManager_hpp_ diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index 989ff04c4..0d1ce1092 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -1254,9 +1254,7 @@ void Tab::on_presets_changed() // to avoid needless preset loading from update() function m_dependent_tabs.clear(); -#if ENABLE_PROJECT_DIRTY_STATE wxGetApp().plater()->update_project_dirty_from_presets(); -#endif // ENABLE_PROJECT_DIRTY_STATE } void Tab::build_preset_description_line(ConfigOptionsGroup* optgroup) @@ -2133,16 +2131,9 @@ wxSizer* Tab::description_line_widget(wxWindow* parent, ogStaticText* *StaticTex return sizer; } -#if ENABLE_PROJECT_DIRTY_STATE bool Tab::saved_preset_is_dirty() const { return m_presets->saved_is_dirty(); } void Tab::update_saved_preset_from_current_preset() { m_presets->update_saved_preset_from_current_preset(); } bool Tab::current_preset_is_dirty() const { return m_presets->current_is_dirty(); } -#else -bool Tab::current_preset_is_dirty() -{ - return m_presets->current_is_dirty(); -} -#endif // ENABLE_PROJECT_DIRTY_STATE void TabPrinter::build() { diff --git a/src/slic3r/GUI/Tab.hpp b/src/slic3r/GUI/Tab.hpp index 5f6ed10aa..74585f2aa 100644 --- a/src/slic3r/GUI/Tab.hpp +++ b/src/slic3r/GUI/Tab.hpp @@ -267,11 +267,7 @@ public: Preset::Type type() const { return m_type; } // The tab is already constructed. bool completed() const { return m_completed; } -#if ENABLE_PROJECT_DIRTY_STATE virtual bool supports_printer_technology(const PrinterTechnology tech) const = 0; -#else - virtual bool supports_printer_technology(const PrinterTechnology tech) = 0; -#endif // ENABLE_PROJECT_DIRTY_STATE void create_preset_tab(); void add_scaled_button(wxWindow* parent, ScalableButton** btn, const std::string& icon_name, @@ -334,13 +330,9 @@ public: Field* get_field(const t_config_option_key &opt_key, Page** selected_page, int opt_index = -1); void toggle_option(const std::string& opt_key, bool toggle, int opt_index = -1); wxSizer* description_line_widget(wxWindow* parent, ogStaticText** StaticText, wxString text = wxEmptyString); -#if ENABLE_PROJECT_DIRTY_STATE bool current_preset_is_dirty() const; bool saved_preset_is_dirty() const; void update_saved_preset_from_current_preset(); -#else - bool current_preset_is_dirty(); -#endif // ENABLE_PROJECT_DIRTY_STATE DynamicPrintConfig* get_config() { return m_config; } PresetCollection* get_presets() { return m_presets; } @@ -391,11 +383,7 @@ public: void toggle_options() override; void update() override; void clear_pages() override; -#if ENABLE_PROJECT_DIRTY_STATE bool supports_printer_technology(const PrinterTechnology tech) const override { return tech == ptFFF; } -#else - bool supports_printer_technology(const PrinterTechnology tech) override { return tech == ptFFF; } -#endif // ENABLE_PROJECT_DIRTY_STATE private: ogStaticText* m_recommended_thin_wall_thickness_description_line = nullptr; @@ -424,11 +412,7 @@ public: void toggle_options() override; void update() override; void clear_pages() override; -#if ENABLE_PROJECT_DIRTY_STATE bool supports_printer_technology(const PrinterTechnology tech) const override { return tech == ptFFF; } -#else - bool supports_printer_technology(const PrinterTechnology tech) override { return tech == ptFFF; } -#endif // ENABLE_PROJECT_DIRTY_STATE }; class TabPrinter : public Tab @@ -481,11 +465,7 @@ public: void on_preset_loaded() override; void init_options_list() override; void msw_rescale() override; -#if ENABLE_PROJECT_DIRTY_STATE bool supports_printer_technology(const PrinterTechnology /* tech */) const override { return true; } -#else - bool supports_printer_technology(const PrinterTechnology /* tech */) override { return true; } -#endif // ENABLE_PROJECT_DIRTY_STATE wxSizer* create_bed_shape_widget(wxWindow* parent); void cache_extruder_cnt(); @@ -504,11 +484,7 @@ public: void toggle_options() override {}; void update() override; void init_options_list() override; -#if ENABLE_PROJECT_DIRTY_STATE bool supports_printer_technology(const PrinterTechnology tech) const override { return tech == ptSLA; } -#else - bool supports_printer_technology(const PrinterTechnology tech) override { return tech == ptSLA; } -#endif // ENABLE_PROJECT_DIRTY_STATE }; class TabSLAPrint : public Tab @@ -526,11 +502,7 @@ public: void toggle_options() override; void update() override; void clear_pages() override; -#if ENABLE_PROJECT_DIRTY_STATE bool supports_printer_technology(const PrinterTechnology tech) const override { return tech == ptSLA; } -#else - bool supports_printer_technology(const PrinterTechnology tech) override { return tech == ptSLA; } -#endif // ENABLE_PROJECT_DIRTY_STATE }; } // GUI