ENH:add "sync filaments status" logic
jira: none Change-Id: I7a74641e6d8e1d1d713d4d97af370a8c0a87f154
This commit is contained in:
parent
eab6384c6c
commit
abfa726162
|
@ -1258,8 +1258,12 @@ void Sidebar::priv::update_sync_status(const MachineObject *obj)
|
||||||
if (preset_bundle && preset_bundle->printers.get_edited_preset().get_printer_type(preset_bundle) == obj->printer_type) {
|
if (preset_bundle && preset_bundle->printers.get_edited_preset().get_printer_type(preset_bundle) == obj->printer_type) {
|
||||||
panel_printer_preset->ShowBadge(true);
|
panel_printer_preset->ShowBadge(true);
|
||||||
printer_synced = true;
|
printer_synced = true;
|
||||||
|
|
||||||
|
wxGetApp().plater()->sidebar().udpate_combos_filament_badge();
|
||||||
} else {
|
} else {
|
||||||
clear_all_sync_status();
|
clear_all_sync_status();
|
||||||
|
|
||||||
|
wxGetApp().plater()->sidebar().clear_combos_filament_badge();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2957,9 +2961,7 @@ void Sidebar::sync_ams_list(bool is_from_big_sync_btn)
|
||||||
c->ShowBadge(true);
|
c->ShowBadge(true);
|
||||||
};
|
};
|
||||||
{ // badge ams filament
|
{ // badge ams filament
|
||||||
for (auto &c : p->combos_filament) {//clear flag
|
clear_combos_filament_badge();
|
||||||
c->ShowBadge(false);
|
|
||||||
}
|
|
||||||
if (sync_result.direct_sync) {
|
if (sync_result.direct_sync) {
|
||||||
for (auto &c : p->combos_filament) {
|
for (auto &c : p->combos_filament) {
|
||||||
badge_combox_filament(c);
|
badge_combox_filament(c);
|
||||||
|
@ -3232,6 +3234,25 @@ std::vector<PlaterPresetComboBox*>& Sidebar::combos_filament()
|
||||||
return p->combos_filament;
|
return p->combos_filament;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Sidebar::clear_combos_filament_badge()
|
||||||
|
{
|
||||||
|
auto &combos_filament = p->combos_filament;
|
||||||
|
for (auto &c : combos_filament) { // clear flag
|
||||||
|
c->ShowBadge(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Sidebar::udpate_combos_filament_badge() {
|
||||||
|
auto &combos_filament = p->combos_filament;
|
||||||
|
for (auto &c : combos_filament) {
|
||||||
|
auto selection = c->GetSelection();
|
||||||
|
auto select_flag = c->GetFlag(selection);
|
||||||
|
auto ok = select_flag == (int) PresetComboBox::FilamentAMSType::FROM_AMS;
|
||||||
|
c->ShowBadge(ok);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
Search::OptionsSearcher& Sidebar::get_searcher()
|
Search::OptionsSearcher& Sidebar::get_searcher()
|
||||||
{
|
{
|
||||||
return p->searcher;
|
return p->searcher;
|
||||||
|
@ -10598,6 +10619,8 @@ bool Plater::try_sync_preset_with_connected_printer()
|
||||||
TipsDialog dlg(wxGetApp().mainframe, _L("Tips"), tips, "sync_after_load_file_show_flag", wxYES_NO,option_map);
|
TipsDialog dlg(wxGetApp().mainframe, _L("Tips"), tips, "sync_after_load_file_show_flag", wxYES_NO,option_map);
|
||||||
if (dlg.ShowModal() == wxID_YES) {
|
if (dlg.ShowModal() == wxID_YES) {
|
||||||
sync_printer_preset = true;
|
sync_printer_preset = true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -207,6 +207,8 @@ public:
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::vector<PlaterPresetComboBox*>& combos_filament();
|
std::vector<PlaterPresetComboBox*>& combos_filament();
|
||||||
|
void clear_combos_filament_badge();
|
||||||
|
void udpate_combos_filament_badge();
|
||||||
Search::OptionsSearcher& get_searcher();
|
Search::OptionsSearcher& get_searcher();
|
||||||
std::string& get_search_line();
|
std::string& get_search_line();
|
||||||
void set_is_gcode_file(bool flag);
|
void set_is_gcode_file(bool flag);
|
||||||
|
|
|
@ -496,8 +496,9 @@ int PresetComboBox::selected_connected_printer(int index) const
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PresetComboBox::add_ams_filaments(std::string selected, bool alias_name)
|
bool PresetComboBox::add_ams_filaments(std::string selected, bool alias_name)
|
||||||
{
|
{
|
||||||
|
bool selected_in_ams = false;
|
||||||
bool is_bbl_vendor_preset = m_preset_bundle->printers.get_edited_preset().is_bbl_vendor_preset(m_preset_bundle);
|
bool is_bbl_vendor_preset = m_preset_bundle->printers.get_edited_preset().is_bbl_vendor_preset(m_preset_bundle);
|
||||||
if (is_bbl_vendor_preset && !m_preset_bundle->filament_ams_list.empty()) {
|
if (is_bbl_vendor_preset && !m_preset_bundle->filament_ams_list.empty()) {
|
||||||
bool dual_extruder = (m_preset_bundle->filament_ams_list.begin()->first & 0x10000) == 0;
|
bool dual_extruder = (m_preset_bundle->filament_ams_list.begin()->first & 0x10000) == 0;
|
||||||
|
@ -540,12 +541,26 @@ void PresetComboBox::add_ams_filaments(std::string selected, bool alias_name)
|
||||||
auto color = tray.opt_string("filament_colour", 0u);
|
auto color = tray.opt_string("filament_colour", 0u);
|
||||||
auto name = tray.opt_string("tray_name", 0u);
|
auto name = tray.opt_string("tray_name", 0u);
|
||||||
wxBitmap bmp(*get_extruder_color_icon(color, name, icon_width, 16));
|
wxBitmap bmp(*get_extruder_color_icon(color, name, icon_width, 16));
|
||||||
int item_id = Append(get_preset_name(*iter), bmp.ConvertToImage(), &m_first_ams_filament + entry.first);
|
auto text = get_preset_name(*iter);
|
||||||
|
int item_id = Append(text, bmp.ConvertToImage(), &m_first_ams_filament + entry.first);
|
||||||
SetFlag(GetCount() - 1, (int) FilamentAMSType::FROM_AMS);
|
SetFlag(GetCount() - 1, (int) FilamentAMSType::FROM_AMS);
|
||||||
|
if (text == selected) {
|
||||||
|
DynamicPrintConfig *cfg = &wxGetApp().preset_bundle->project_config;
|
||||||
|
if (cfg) {
|
||||||
|
auto colors = static_cast<ConfigOptionStrings *>(cfg->option("filament_colour")->clone());
|
||||||
|
if (m_filament_idx < colors->values.size()) {
|
||||||
|
auto cur_color = colors->values[m_filament_idx];
|
||||||
|
if (color == cur_color) {
|
||||||
|
selected_in_ams = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
//validate_selection(id->value == selected); // can not select
|
//validate_selection(id->value == selected); // can not select
|
||||||
}
|
}
|
||||||
m_last_ams_filament = GetCount();
|
m_last_ams_filament = GetCount();
|
||||||
}
|
}
|
||||||
|
return selected_in_ams;
|
||||||
}
|
}
|
||||||
|
|
||||||
int PresetComboBox::selected_ams_filament() const
|
int PresetComboBox::selected_ams_filament() const
|
||||||
|
@ -937,6 +952,13 @@ void PlaterPresetComboBox::OnSelect(wxCommandEvent &evt)
|
||||||
evt.Skip();
|
evt.Skip();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PlaterPresetComboBox::update_badge_according_flag() {
|
||||||
|
auto selection = GetSelection();
|
||||||
|
auto select_flag = GetFlag(selection);
|
||||||
|
auto ok = select_flag == (int) PresetComboBox::FilamentAMSType::FROM_AMS;
|
||||||
|
ShowBadge(ok);
|
||||||
|
}
|
||||||
|
|
||||||
bool PlaterPresetComboBox::switch_to_tab()
|
bool PlaterPresetComboBox::switch_to_tab()
|
||||||
{
|
{
|
||||||
Tab* tab = wxGetApp().get_tab(m_type);
|
Tab* tab = wxGetApp().get_tab(m_type);
|
||||||
|
@ -1205,17 +1227,17 @@ void PlaterPresetComboBox::update()
|
||||||
}
|
}
|
||||||
//if (m_type == Preset::TYPE_PRINTER)
|
//if (m_type == Preset::TYPE_PRINTER)
|
||||||
// add_connected_printers("", true);
|
// add_connected_printers("", true);
|
||||||
|
bool selected_in_ams = false;
|
||||||
if (m_type == Preset::TYPE_FILAMENT) {
|
if (m_type == Preset::TYPE_FILAMENT) {
|
||||||
set_replace_text("Bambu", "BambuStudioBlack");
|
set_replace_text("Bambu", "BambuStudioBlack");
|
||||||
add_ams_filaments(into_u8(selected_user_preset.empty() ? selected_system_preset : selected_user_preset), true);
|
selected_in_ams = add_ams_filaments(into_u8(selected_user_preset.empty() ? selected_system_preset : selected_user_preset), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::string> filament_orders = {"Bambu PLA Basic", "Bambu PLA Matte", "Bambu PETG HF", "Bambu ABS", "Bambu PLA Silk", "Bambu PLA-CF",
|
std::vector<std::string> filament_orders = {"Bambu PLA Basic", "Bambu PLA Matte", "Bambu PETG HF", "Bambu ABS", "Bambu PLA Silk", "Bambu PLA-CF",
|
||||||
"Bambu PLA Galaxy", "Bambu PLA Metal", "Bambu PLA Marble", "Bambu PETG-CF", "Bambu PETG Translucent", "Bambu ABS-GF"};
|
"Bambu PLA Galaxy", "Bambu PLA Metal", "Bambu PLA Marble", "Bambu PETG-CF", "Bambu PETG Translucent", "Bambu ABS-GF"};
|
||||||
std::vector<std::string> first_vendors = {"Bambu Lab", "Generic"};
|
std::vector<std::string> first_vendors = {"Bambu Lab", "Generic"};
|
||||||
std::vector<std::string> first_types = {"PLA", "PETG", "ABS", "TPU"};
|
std::vector<std::string> first_types = {"PLA", "PETG", "ABS", "TPU"};
|
||||||
auto add_presets = [this, &preset_descriptions, &filament_orders, &preset_filament_vendors, &first_vendors, &preset_filament_types, &first_types]
|
auto add_presets = [this, &preset_descriptions, &filament_orders, &preset_filament_vendors, &first_vendors, &preset_filament_types, &first_types, &selected_in_ams]
|
||||||
(std::map<wxString, wxBitmap *> const &presets, wxString const &selected, std::string const &group) {
|
(std::map<wxString, wxBitmap *> const &presets, wxString const &selected, std::string const &group) {
|
||||||
if (!presets.empty()) {
|
if (!presets.empty()) {
|
||||||
set_label_marker(Append(separator(group), wxNullBitmap));
|
set_label_marker(Append(separator(group), wxNullBitmap));
|
||||||
|
@ -1246,7 +1268,11 @@ void PlaterPresetComboBox::update()
|
||||||
});
|
});
|
||||||
for (auto it : list) {
|
for (auto it : list) {
|
||||||
SetItemTooltip(Append(it->first, *it->second), preset_descriptions[it->first]);
|
SetItemTooltip(Append(it->first, *it->second), preset_descriptions[it->first]);
|
||||||
validate_selection(it->first == selected);
|
bool is_selected = it->first == selected;
|
||||||
|
validate_selection(is_selected);
|
||||||
|
if (is_selected && selected_in_ams) {
|
||||||
|
SetFlag(GetCount() - 1, (int) FilamentAMSType::FROM_AMS);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (std::map<wxString, wxBitmap *>::const_iterator it = presets.begin(); it != presets.end(); ++it) {
|
for (std::map<wxString, wxBitmap *>::const_iterator it = presets.begin(); it != presets.end(); ++it) {
|
||||||
|
@ -1304,6 +1330,9 @@ void PlaterPresetComboBox::update()
|
||||||
}
|
}
|
||||||
|
|
||||||
update_selection();
|
update_selection();
|
||||||
|
if (m_type == Preset::TYPE_FILAMENT) {
|
||||||
|
update_badge_according_flag();
|
||||||
|
}
|
||||||
Thaw();
|
Thaw();
|
||||||
|
|
||||||
if (!tooltip.IsEmpty()) {
|
if (!tooltip.IsEmpty()) {
|
||||||
|
|
|
@ -80,7 +80,7 @@ public:
|
||||||
int selected_connected_printer(int index) const;
|
int selected_connected_printer(int index) const;
|
||||||
|
|
||||||
// BBS: ams
|
// BBS: ams
|
||||||
void add_ams_filaments(std::string selected, bool alias_name = false);
|
bool add_ams_filaments(std::string selected, bool alias_name = false);
|
||||||
int selected_ams_filament() const;
|
int selected_ams_filament() const;
|
||||||
|
|
||||||
void set_filament_idx(const int extr_idx) { m_filament_idx = extr_idx; }
|
void set_filament_idx(const int extr_idx) { m_filament_idx = extr_idx; }
|
||||||
|
@ -207,6 +207,7 @@ public:
|
||||||
void update() override;
|
void update() override;
|
||||||
void msw_rescale() override;
|
void msw_rescale() override;
|
||||||
void OnSelect(wxCommandEvent& evt) override;
|
void OnSelect(wxCommandEvent& evt) override;
|
||||||
|
void update_badge_according_flag();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// BBS
|
// BBS
|
||||||
|
|
|
@ -4013,13 +4013,20 @@ void SyncAmsInfoDialog::clone_thumbnail_data(bool allow_clone_ams_color)
|
||||||
while (iter != m_materialList.end()) {
|
while (iter != m_materialList.end()) {
|
||||||
int id = iter->first;
|
int id = iter->first;
|
||||||
Material *item = iter->second;
|
Material *item = iter->second;
|
||||||
auto m = item->item;
|
if (item) {
|
||||||
m_preview_colors_in_thumbnail[id] = m->m_material_coloul;
|
auto m = item->item;
|
||||||
if (item->id < m_cur_colors_in_thumbnail.size()) {
|
if (m) {
|
||||||
m_cur_colors_in_thumbnail[item->id] = m->m_ams_coloul;
|
m_preview_colors_in_thumbnail[id] = m->m_material_coloul;
|
||||||
} else { // exist empty or unrecognized type ams in machine
|
if (item->id < m_cur_colors_in_thumbnail.size()) {
|
||||||
m_cur_colors_in_thumbnail.resize(item->id + 1);
|
m_cur_colors_in_thumbnail[item->id] = m->m_ams_coloul;
|
||||||
m_cur_colors_in_thumbnail[item->id] = m->m_ams_coloul;
|
} else { // exist empty or unrecognized type ams in machine
|
||||||
|
m_cur_colors_in_thumbnail.resize(item->id + 1);
|
||||||
|
m_cur_colors_in_thumbnail[item->id] = m->m_ams_coloul;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
BOOST_LOG_TRIVIAL(error) << "check error:SyncAmsInfoDialog::clone_thumbnail_data:item is nullptr";
|
||||||
}
|
}
|
||||||
iter++;
|
iter++;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue