From 2f7946333dd41497d6a490f46f82e6a66af3b43c Mon Sep 17 00:00:00 2001 From: "chunmao.guo" Date: Mon, 28 Nov 2022 17:31:06 +0800 Subject: [PATCH] ENH: [STUDIO-1477] indicators for that has object configs Change-Id: I4556b049cd6aa128a05f69c00fa14d8ea5bb3f39 --- src/slic3r/GUI/ParamsPanel.cpp | 38 +++++++++++++++++++++++++ src/slic3r/GUI/ParamsPanel.hpp | 5 ++++ src/slic3r/GUI/Plater.cpp | 4 +++ src/slic3r/GUI/Tab.cpp | 2 +- src/slic3r/GUI/Tab.hpp | 2 +- src/slic3r/GUI/Widgets/SwitchButton.cpp | 7 ++++- src/slic3r/GUI/Widgets/SwitchButton.hpp | 7 +++-- 7 files changed, 60 insertions(+), 5 deletions(-) diff --git a/src/slic3r/GUI/ParamsPanel.cpp b/src/slic3r/GUI/ParamsPanel.cpp index e7c0104bb..ebfecb8e4 100644 --- a/src/slic3r/GUI/ParamsPanel.cpp +++ b/src/slic3r/GUI/ParamsPanel.cpp @@ -16,6 +16,7 @@ #include "Widgets/Label.hpp" #include "Widgets/SwitchButton.hpp" #include "Widgets/Button.hpp" +#include "GUI_Factories.hpp" namespace Slic3r { @@ -676,6 +677,43 @@ void ParamsPanel::switch_to_object(bool with_tips) } } +void ParamsPanel::notify_object_config_changed() +{ + auto & model = wxGetApp().model(); + bool has_config = false; + for (auto obj : model.objects) { + if (!obj->config.empty()) { + SettingsFactory::Bundle cat_options = SettingsFactory::get_bundle(&obj->config.get(), true); + if (cat_options.size() > 0) { + has_config = true; + break; + } + } + for (auto volume : obj->volumes) { + if (!volume->config.empty()) { + SettingsFactory::Bundle cat_options = SettingsFactory::get_bundle(&volume->config.get(), true); + if (cat_options.size() > 0) { + has_config = true; + break; + } + } + } + if (has_config) break; + } + if (has_config == m_has_object_config) return; + m_has_object_config = has_config; + if (has_config) + m_mode_region->SetTextColor2(StateColor(std::pair{*wxWHITE, (int) StateColor::Checked}, std::pair{wxGetApp().get_label_clr_modified(), 0})); + else + m_mode_region->SetTextColor2(StateColor()); + m_mode_region->Rescale(); +} + +void ParamsPanel::switch_to_object_if_has_object_configs() +{ + if (m_has_object_config) m_mode_region->SetValue(true); +} + void ParamsPanel::free_sizers() { if (m_top_sizer) diff --git a/src/slic3r/GUI/ParamsPanel.hpp b/src/slic3r/GUI/ParamsPanel.hpp index 848e546d6..81bc48aca 100644 --- a/src/slic3r/GUI/ParamsPanel.hpp +++ b/src/slic3r/GUI/ParamsPanel.hpp @@ -120,6 +120,8 @@ class ParamsPanel : public wxPanel wxPanel* m_current_tab { nullptr }; + bool m_has_object_config { false }; + struct Highlighter { void set_timer_owner(wxEvtHandler *owner, int timerid = wxID_ANY); @@ -154,6 +156,9 @@ class ParamsPanel : public wxPanel void switch_to_global(); void switch_to_object(bool with_tips = false); + void notify_object_config_changed(); + void switch_to_object_if_has_object_configs(); + StaticBox* get_top_panel() { return m_top_panel; } wxPanel* filament_panel() { return m_tab_filament; } diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 723de0a60..2bdc7bffd 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -3801,6 +3801,8 @@ void Plater::priv::object_list_changed() bool can_slice = !model.objects.empty() && !export_in_progress && model_fits && part_plate->has_printable_instances(); BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(": can_slice %1%, model_fits= %2%, export_in_progress %3%, has_printable_instances %4% ")%can_slice %model_fits %export_in_progress %part_plate->has_printable_instances(); main_frame->update_slice_print_status(MainFrame::eEventObjectUpdate, can_slice); + + wxGetApp().params_panel()->notify_object_config_changed(); } void Plater::priv::select_curr_plate_all() @@ -7394,6 +7396,8 @@ void Plater::load_project(wxString const& filename2, else p->dirty_state.update_from_undo_redo_stack(true); up_to_date(true, true); + + wxGetApp().params_panel()->switch_to_object_if_has_object_configs(); } // BBS: save logic diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index ae8d102ce..eb1a0752c 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -2234,7 +2234,7 @@ void TabPrintModel::on_value_change(const std::string& opt_key, const boost::any config.second->touch(); notify_changed(config.first); } - + wxGetApp().params_panel()->notify_object_config_changed(); } void TabPrintModel::reload_config() diff --git a/src/slic3r/GUI/Tab.hpp b/src/slic3r/GUI/Tab.hpp index 1569cd209..8bd3a3923 100644 --- a/src/slic3r/GUI/Tab.hpp +++ b/src/slic3r/GUI/Tab.hpp @@ -463,7 +463,7 @@ public: void reset_model_config(); - bool has_key(std::string const & key); + bool has_key(std::string const &key); protected: virtual void activate_selected_page(std::function throw_if_canceled); diff --git a/src/slic3r/GUI/Widgets/SwitchButton.cpp b/src/slic3r/GUI/Widgets/SwitchButton.cpp index 38743654c..dd7e95e04 100644 --- a/src/slic3r/GUI/Widgets/SwitchButton.cpp +++ b/src/slic3r/GUI/Widgets/SwitchButton.cpp @@ -33,6 +33,11 @@ void SwitchButton::SetTextColor(StateColor const& color) text_color = color; } +void SwitchButton::SetTextColor2(StateColor const &color) +{ + text_color2 = color; +} + void SwitchButton::SetTrackColor(StateColor const& color) { track_color = color; @@ -116,7 +121,7 @@ void SwitchButton::Rescale() } memdc.SetTextForeground(text_color.colorForStates(state ^ StateColor::Checked)); memdc.DrawText(labels[0], {BS + (thumbSize.x - textSize[0].x) / 2, BS + (thumbSize.y - textSize[0].y) / 2}); - memdc.SetTextForeground(text_color.colorForStates(state)); + memdc.SetTextForeground(text_color2.count() == 0 ? text_color.colorForStates(state) : text_color2.colorForStates(state)); memdc.DrawText(labels[1], {trackSize.x - thumbSize.x - BS + (thumbSize.x - textSize[1].x) / 2, BS + (thumbSize.y - textSize[1].y) / 2}); memdc.SelectObject(wxNullBitmap); #ifdef __WXOSX__ diff --git a/src/slic3r/GUI/Widgets/SwitchButton.hpp b/src/slic3r/GUI/Widgets/SwitchButton.hpp index 25581f376..71436d13e 100644 --- a/src/slic3r/GUI/Widgets/SwitchButton.hpp +++ b/src/slic3r/GUI/Widgets/SwitchButton.hpp @@ -16,7 +16,9 @@ public: void SetTextColor(StateColor const &color); - void SetTrackColor(StateColor const &color); + void SetTextColor2(StateColor const &color); + + void SetTrackColor(StateColor const &color); void SetThumbColor(StateColor const &color); @@ -32,7 +34,8 @@ private: ScalableBitmap m_off; wxString labels[2]; - StateColor text_color; + StateColor text_color; + StateColor text_color2; StateColor track_color; StateColor thumb_color; };