diff --git a/resources/images/ams_fila_sync.svg b/resources/images/ams_fila_sync.svg
new file mode 100644
index 000000000..0b2e0b75e
--- /dev/null
+++ b/resources/images/ams_fila_sync.svg
@@ -0,0 +1,12 @@
+
diff --git a/src/libslic3r/PresetBundle.cpp b/src/libslic3r/PresetBundle.cpp
index 28dd90097..6a731dfda 100644
--- a/src/libslic3r/PresetBundle.cpp
+++ b/src/libslic3r/PresetBundle.cpp
@@ -1314,6 +1314,31 @@ void PresetBundle::set_num_filaments(unsigned int n, std::string new_color)
update_multi_material_filament_presets();
}
+unsigned int PresetBundle::sync_ams_list()
+{
+ std::vector filament_presets;
+ std::vector filament_colors;
+ for (auto &ams : filament_ams_list) {
+ auto filament_id = ams.opt_string("filament_id", 0u);
+ auto filament_color = ams.opt_string("filament_colour", 0u);
+ auto iter = std::find_if(filaments.begin(), filaments.end(), [&filament_id](auto &f) { return f.is_compatible && f.is_system && f.filament_id == filament_id; });
+ if (iter == filaments.end()) {
+ BOOST_LOG_TRIVIAL(warning) << __FUNCTION__ << boost::format(": filament_id %1% not found or system or compatible") % filament_id;
+ continue;
+ }
+ filament_presets.push_back(iter->name);
+ filament_colors.push_back(filament_color);
+ }
+ if (filament_presets.empty())
+ return 0;
+ this->filament_presets = filament_presets;
+ ConfigOptionStrings *filament_color = project_config.option("filament_colour");
+ filament_color->resize(filament_presets.size());
+ filament_color->values = filament_colors;
+ update_multi_material_filament_presets();
+ return filament_presets.size();
+}
+
//BBS: check whether this is the only edited filament
bool PresetBundle::is_the_only_edited_filament(unsigned int filament_index)
{
diff --git a/src/libslic3r/PresetBundle.hpp b/src/libslic3r/PresetBundle.hpp
index 0cd7aef99..edc80e587 100644
--- a/src/libslic3r/PresetBundle.hpp
+++ b/src/libslic3r/PresetBundle.hpp
@@ -79,6 +79,7 @@ public:
// BBS
void set_num_filaments(unsigned int n, std::string new_col = "");
+ unsigned int sync_ams_list();
//BBS: check whether this is the only edited filament
bool is_the_only_edited_filament(unsigned int filament_index);
diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp
index 0b19e9bdb..1f4e78d5a 100644
--- a/src/slic3r/GUI/GUI_App.cpp
+++ b/src/slic3r/GUI/GUI_App.cpp
@@ -1641,12 +1641,9 @@ void GUI_App::init_networking_callbacks()
if (obj) {
obj->parse_json(msg);
-
-#if !BBL_RELEASE_TO_PUBLIC
if (obj->is_ams_need_update) {
GUI::wxGetApp().sidebar().load_ams_list(obj->amsList);
}
-#endif
}
});
};
diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp
index f74295127..78298f8be 100644
--- a/src/slic3r/GUI/Plater.cpp
+++ b/src/slic3r/GUI/Plater.cpp
@@ -287,6 +287,7 @@ struct Sidebar::priv
wxStaticText* m_staticText_filament_settings;
ScalableButton * m_bpButton_add_filament;
ScalableButton * m_bpButton_del_filament;
+ ScalableButton * m_bpButton_ams_filament;
ScalableButton * m_bpButton_set_filament;
wxPanel* m_panel_filament_content;
wxScrolledWindow* m_scrolledWindow_filament_content;
@@ -636,6 +637,7 @@ Sidebar::Sidebar(Plater *parent)
bSizer39->Add(FromDIP(10), 0, 0, 0, 0 );
ScalableButton* add_btn = new ScalableButton(p->m_panel_filament_title, wxID_ANY, "add_filament");
+ add_btn->SetToolTip(_L("Add one filament"));
add_btn->Bind(wxEVT_BUTTON, [this, scrolled_sizer](wxCommandEvent& e){
// BBS: limit filament choices to 16
if (p->combos_filament.size() >= 16)
@@ -654,7 +656,8 @@ Sidebar::Sidebar(Plater *parent)
bSizer39->Add(FromDIP(10), 0, 0, 0, 0 );
ScalableButton* del_btn = new ScalableButton(p->m_panel_filament_title, wxID_ANY, "delete_filament");
- del_btn->Bind(wxEVT_BUTTON, [this, scrolled_sizer](wxCommandEvent& e){
+ del_btn->SetToolTip(_L("Remove last filament"));
+ del_btn->Bind(wxEVT_BUTTON, [this, scrolled_sizer](wxCommandEvent &e) {
if (p->combos_filament.size() <= 1)
return;
@@ -676,8 +679,20 @@ Sidebar::Sidebar(Plater *parent)
bSizer39->Add(del_btn, 0, wxALIGN_CENTER_VERTICAL, FromDIP(5));
bSizer39->Add(FromDIP(20), 0, 0, 0, 0);
+ ScalableButton *ams_btn = new ScalableButton(p->m_panel_filament_title, wxID_ANY, "ams_fila_sync", wxEmptyString, wxDefaultSize, wxDefaultPosition,
+ wxBU_EXACTFIT | wxNO_BORDER, false, 18);
+ ams_btn->SetToolTip(_L("Sync material list from AMS"));
+ ams_btn->Bind(wxEVT_BUTTON, [this, scrolled_sizer](wxCommandEvent &e) {
+ sync_ams_list();
+ });
+ p->m_bpButton_ams_filament = ams_btn;
+
+ bSizer39->Add(ams_btn, 0, wxALIGN_CENTER|wxALL, FromDIP(5));
+ bSizer39->Add(FromDIP(10), 0, 0, 0, 0 );
+
ScalableButton* set_btn = new ScalableButton(p->m_panel_filament_title, wxID_ANY, "settings");
- set_btn->Bind(wxEVT_BUTTON, [this](wxCommandEvent& e) {
+ set_btn->SetToolTip(_L("Set filaments to use"));
+ set_btn->Bind(wxEVT_BUTTON, [this](wxCommandEvent &e) {
// p->editing_filament = -1;
// wxGetApp().params_dialog()->Popup();
// wxGetApp().get_tab(Preset::TYPE_FILAMENT)->restore_last_select_item();
@@ -992,6 +1007,7 @@ void Sidebar::msw_rescale()
p->m_filament_icon->msw_rescale();
p->m_bpButton_add_filament->msw_rescale();
p->m_bpButton_del_filament->msw_rescale();
+ p->m_bpButton_ams_filament->msw_rescale();
p->m_bpButton_set_filament->msw_rescale();
p->m_flushing_volume_btn->Rescale();
//BBS
@@ -1171,42 +1187,9 @@ void Sidebar::load_ams_list(std::map const &list)
std::vector filament_ams_list;
for (auto ams : list) {
for (auto tray : ams.second->trayList) {
- if (tray.second->setting_id.empty())
- continue;
+ if (tray.second->setting_id.empty()) continue;
DynamicPrintConfig ams;
- auto & filaments = wxGetApp().preset_bundle->filaments.get_presets();
- auto iter = std::find_if(filaments.begin(), filaments.end(),
- [&tray](auto &f) { return f.filament_id == tray.second->setting_id; });
- if (iter != filaments.end()) {
- ams.set_key_value("filament_settings_id", new ConfigOptionStrings{tray.second->setting_id});
- } else {
- /* std::shared_ptr> preset(new std::map);
- (*preset)->setting_id = tray.second->setting_id;
- ams.set_key_value("filament_settings_id", new ConfigOptionStrings{tray.second->setting_id});
- //TODO: comment it currently
- NetworkAgent* agent = wxGetApp().getAgent();
- if (agent) {
- agent->get_setting(tray.second->setting_id, *preset, [preset] {
- wxGetApp().CallAfter([preset] {
- if ((*preset)->name.empty())
- return;
- PresetsConfigSubstitutions substitutions;
- wxGetApp().preset_bundle->filaments.load_user_presets({{(*preset)->name, *preset}},
- PRESET_FILAMENT_NAME, substitutions, ForwardCompatibilitySubstitutionRule::Enable);
- auto & ams_list = wxGetApp().preset_bundle->filament_ams_list;
- for (auto& ams : ams_list) {
- if (ams.opt_string("filament_settings_id", 0u) == (*preset)->setting_id) {
- ams.set_key_value("filament_settings_id", new ConfigOptionStrings{(*preset)->name});
- for (auto c : wxGetApp().sidebar().combos_filament()) c->update();
- break;
- }
- }
- });
- });
- }
- */
- continue;
- }
+ ams.set_key_value("filament_id", new ConfigOptionStrings{tray.second->setting_id});
ams.set_key_value("filament_colour", new ConfigOptionStrings{"#" + tray.second->color.substr(0, 6)});
filament_ams_list.emplace_back(std::move(ams));
}
@@ -1216,6 +1199,34 @@ void Sidebar::load_ams_list(std::map const &list)
c->update();
}
+void Sidebar::sync_ams_list()
+{
+ auto & list = wxGetApp().preset_bundle->filament_ams_list;
+ if (list.empty()) {
+ MessageDialog dlg(this,
+ _L("No AMS filaments. Please select a printer in 'Device' page to load AMS info."),
+ _L("Sync filaments with AMS"), wxOK);
+ dlg.ShowModal();
+ return;
+ }
+ MessageDialog dlg(this,
+ _L("Sync filaments with AMS will drop all current selected filament presets and colors. Do you want to continue?"),
+ _L("Sync filaments with AMS"), wxYES_NO);
+ if (dlg.ShowModal() != wxID_YES) return;
+ auto n = wxGetApp().preset_bundle->sync_ams_list();
+ if (n == 0) {
+ MessageDialog dlg(this,
+ _L("There are no compatible filaments, and sync is not performed."),
+ _L("Sync filaments with AMS"), wxOK);
+ dlg.ShowModal();
+ return;
+ }
+ wxGetApp().plater()->on_filaments_change(n);
+ for (auto &c : p->combos_filament)
+ c->update();
+ wxGetApp().get_tab(Preset::TYPE_PRINT)->update();
+}
+
ObjectList* Sidebar::obj_list()
{
// BBS
diff --git a/src/slic3r/GUI/Plater.hpp b/src/slic3r/GUI/Plater.hpp
index 5460ffcdd..9f7c42bda 100644
--- a/src/slic3r/GUI/Plater.hpp
+++ b/src/slic3r/GUI/Plater.hpp
@@ -117,7 +117,8 @@ public:
void on_filaments_change(size_t num_filaments);
// BBS
void on_bed_type_change(BedType bed_type);
- void load_ams_list(std::map const & list);
+ void load_ams_list(std::map const &list);
+ void sync_ams_list();
ObjectList* obj_list();
ObjectSettings* obj_settings();
diff --git a/src/slic3r/GUI/PresetComboBoxes.cpp b/src/slic3r/GUI/PresetComboBoxes.cpp
index 6bfe8a484..754f0345b 100644
--- a/src/slic3r/GUI/PresetComboBoxes.cpp
+++ b/src/slic3r/GUI/PresetComboBoxes.cpp
@@ -387,11 +387,11 @@ void PresetComboBox::add_ams_filaments(std::string selected, bool alias_name)
m_first_ams_filament = GetCount();
auto &filaments = m_collection->get_presets();
for (auto &f : m_preset_bundle->filament_ams_list) {
- std::string setting_id = f.opt_string("filament_settings_id", 0u);
+ std::string filament_id = f.opt_string("filament_id", 0u);
auto iter = std::find_if(filaments.begin(), filaments.end(),
- [&setting_id](auto &f) { return f.is_compatible && f.is_system && f.filament_id == setting_id; });
+ [&filament_id](auto &f) { return f.is_compatible && f.is_system && f.filament_id == filament_id; });
if (iter == filaments.end()) {
- BOOST_LOG_TRIVIAL(warning) << __FUNCTION__ << boost::format(": filament_id %1% not found or system or compatible") % setting_id;
+ BOOST_LOG_TRIVIAL(warning) << __FUNCTION__ << boost::format(": filament_id %1% not found or system or compatible") % filament_id;
continue;
}
const_cast(*iter).is_visible = true;
diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp
index dfc376eca..9debf820f 100644
--- a/src/slic3r/GUI/Tab.cpp
+++ b/src/slic3r/GUI/Tab.cpp
@@ -231,7 +231,7 @@ void Tab::create_preset_tab()
m_btn_compare_preset->SetToolTip(_L("Compare presets"));
// TRN "Save current Settings"
- m_btn_save_preset->SetToolTip(from_u8((boost::format(_utf8(L("Save current %s"))) % m_title).str()));
+ m_btn_save_preset->SetToolTip(wxString::Format(_L("Save current %s"), m_title));
m_btn_delete_preset->SetToolTip(_(L("Delete this preset")));
m_btn_delete_preset->Hide();
@@ -255,6 +255,7 @@ void Tab::create_preset_tab()
add_scaled_button(m_top_panel, &m_undo_btn, m_bmp_white_bullet.name());
add_scaled_button(m_top_panel, &m_undo_to_sys_btn, m_bmp_white_bullet.name());
add_scaled_button(m_top_panel, &m_btn_search, "search");
+ m_btn_search->SetToolTip(_L("Search in preset"));
//search input
m_search_item = new RoundedRectangle(m_top_panel, wxColour(238, 238, 238), wxDefaultPosition, wxSize(m_top_panel->GetSize().GetWidth(), 3 * wxGetApp().em_unit()), 8);
@@ -993,7 +994,7 @@ void Tab::update_undo_buttons()
m_undo_btn-> SetBitmap_(m_presets->get_edited_preset().is_dirty ? m_bmp_value_revert: m_bmp_white_bullet);
m_undo_to_sys_btn-> SetBitmap_(m_is_nonsys_values ? *m_bmp_non_system : m_bmp_value_lock);
- m_undo_btn->SetToolTip(m_is_modified_values ? m_ttg_value_revert : m_ttg_white_bullet);
+ m_undo_btn->SetToolTip(m_presets->get_edited_preset().is_dirty ? _L("Click to reset all settings to the last saved preset.") : m_ttg_white_bullet);
m_undo_to_sys_btn->SetToolTip(m_is_nonsys_values ? *m_ttg_non_system : m_ttg_value_lock);
}