From 242c1a04154bdcc261a2bfcecb73126d3cf6cef1 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Wed, 12 Feb 2025 12:49:07 +0100 Subject: [PATCH] DoubleSliderForLayers: Added cog menu item "Sequential slider applied only to top layer" --- src/slic3r/GUI/DoubleSliderForLayers.cpp | 5 +++++ src/slic3r/GUI/DoubleSliderForLayers.hpp | 2 ++ src/slic3r/GUI/GUI_Preview.cpp | 6 +++++- src/slic3r/GUI/Preferences.cpp | 1 + 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/slic3r/GUI/DoubleSliderForLayers.cpp b/src/slic3r/GUI/DoubleSliderForLayers.cpp index 1d6275e441..bead6e4a4e 100644 --- a/src/slic3r/GUI/DoubleSliderForLayers.cpp +++ b/src/slic3r/GUI/DoubleSliderForLayers.cpp @@ -773,6 +773,11 @@ void DSForLayers::render_cog_menu() if (m_cb_change_app_config) m_cb_change_app_config("show_estimated_times_in_dbl_slider", m_show_estimated_times ? "1" : "0"); } + if (ImGuiPureWrap::menu_item_with_icon(_u8L("Sequential slider applied only to top layer").c_str(), "", icon_sz, 0, m_seq_top_layer_only)) { + m_seq_top_layer_only = !m_seq_top_layer_only; + if (m_cb_change_app_config) + m_cb_change_app_config("seq_top_layer_only", m_seq_top_layer_only ? "1" : "0"); + } if (m_mode == MultiAsSingle && m_draw_mode == dmRegular && ImGuiPureWrap::menu_item_with_icon(_u8L("Set extruder sequence for the entire print").c_str(), "")) { if (m_ticks.edit_extruder_sequence(m_ctrl.GetMaxPos(), m_mode)) diff --git a/src/slic3r/GUI/DoubleSliderForLayers.hpp b/src/slic3r/GUI/DoubleSliderForLayers.hpp index cce1b84d33..ca00127ffb 100644 --- a/src/slic3r/GUI/DoubleSliderForLayers.hpp +++ b/src/slic3r/GUI/DoubleSliderForLayers.hpp @@ -91,6 +91,7 @@ public: void set_imgui_wrapper(Slic3r::GUI::ImGuiWrapper* imgui) { m_imgui = imgui; } void show_estimated_times(bool show) { m_show_estimated_times = show; } void show_ruler(bool show, bool show_bg) { m_show_ruler = show; m_show_ruler_bg = show_bg; } + void seq_top_layer_only(bool show) { m_seq_top_layer_only = show; } // manipulation with slider from keyboard @@ -151,6 +152,7 @@ private: bool m_show_ruler_bg { true }; bool m_show_cog_menu { false }; bool m_show_edit_menu { false }; + bool m_seq_top_layer_only { false }; int m_pos_on_move { -1 }; DrawMode m_draw_mode { dmRegular }; diff --git a/src/slic3r/GUI/GUI_Preview.cpp b/src/slic3r/GUI/GUI_Preview.cpp index 76619eeeab..36dd1c9208 100644 --- a/src/slic3r/GUI/GUI_Preview.cpp +++ b/src/slic3r/GUI/GUI_Preview.cpp @@ -301,6 +301,7 @@ void Preview::reload_print() m_loaded = false; load_print(); + m_layers_slider->seq_top_layer_only(wxGetApp().app_config->get_bool("seq_top_layer_only")); } void Preview::msw_rescale() @@ -403,6 +404,7 @@ void Preview::create_sliders() m_layers_slider->SetEmUnit(wxGetApp().em_unit()); m_layers_slider->set_imgui_wrapper(wxGetApp().imgui()); m_layers_slider->show_estimated_times(wxGetApp().app_config->get_bool("show_estimated_times_in_dbl_slider")); + m_layers_slider->seq_top_layer_only(wxGetApp().app_config->get_bool("seq_top_layer_only")); m_layers_slider->show_ruler(wxGetApp().app_config->get_bool("show_ruler_in_dbl_slider"), wxGetApp().app_config->get_bool("show_ruler_bg_in_dbl_slider")); m_layers_slider->SetDrawMode(wxGetApp().preset_bundle->printers.get_edited_preset().printer_technology() == ptSLA, @@ -410,8 +412,10 @@ void Preview::create_sliders() m_layers_slider->set_callback_on_thumb_move( [this]() -> void { Preview::on_layers_slider_scroll_changed(); } ); - m_layers_slider->set_callback_on_change_app_config([](const std::string& key, const std::string& val) -> void { + m_layers_slider->set_callback_on_change_app_config([this](const std::string& key, const std::string& val) -> void { wxGetApp().app_config->set(key, val); + if (key == "seq_top_layer_only") + reload_print(); }); if (wxGetApp().is_editor()) { diff --git a/src/slic3r/GUI/Preferences.cpp b/src/slic3r/GUI/Preferences.cpp index eafaa0b1b4..ae92250230 100644 --- a/src/slic3r/GUI/Preferences.cpp +++ b/src/slic3r/GUI/Preferences.cpp @@ -146,6 +146,7 @@ void PreferencesDialog::show(const std::string& highlight_opt_key /*= std::strin ,"default_action_on_select_preset" }) m_optgroup_general->set_value(opt_key, app_config->get(opt_key) == "none"); m_optgroup_general->set_value("default_action_on_dirty_project", app_config->get("default_action_on_dirty_project").empty()); + m_optgroup_gui->set_value("seq_top_layer_only", app_config->get_bool("seq_top_layer_only")); // update colors for color pickers of the labels update_color(m_sys_colour, wxGetApp().get_label_clr_sys());