mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-05-17 02:22:17 +00:00
ENH:add "sync filaments status" logic
jira: none Change-Id: I7a74641e6d8e1d1d713d4d97af370a8c0a87f154 (cherry picked from commit abfa7261625dfd90ad276baf9afd66a3368303f1)
This commit is contained in:
@@ -1214,8 +1214,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) {
|
||||
panel_printer_preset->ShowBadge(true);
|
||||
printer_synced = true;
|
||||
|
||||
wxGetApp().plater()->sidebar().udpate_combos_filament_badge();
|
||||
} else {
|
||||
clear_all_sync_status();
|
||||
|
||||
wxGetApp().plater()->sidebar().clear_combos_filament_badge();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2835,9 +2839,7 @@ void Sidebar::sync_ams_list(bool is_from_big_sync_btn)
|
||||
c->ShowBadge(true);
|
||||
};
|
||||
{ // badge ams filament
|
||||
for (auto &c : p->combos_filament) {//clear flag
|
||||
c->ShowBadge(false);
|
||||
}
|
||||
clear_combos_filament_badge();
|
||||
if (sync_result.direct_sync) {
|
||||
for (auto &c : p->combos_filament) {
|
||||
badge_combox_filament(c);
|
||||
@@ -3117,6 +3119,25 @@ std::vector<PlaterPresetComboBox*>& Sidebar::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()
|
||||
{
|
||||
return p->searcher;
|
||||
|
||||
@@ -220,6 +220,8 @@ public:
|
||||
#endif
|
||||
|
||||
std::vector<PlaterPresetComboBox*>& combos_filament();
|
||||
void clear_combos_filament_badge();
|
||||
void udpate_combos_filament_badge();
|
||||
Search::OptionsSearcher& get_searcher();
|
||||
std::string& get_search_line();
|
||||
void update_printer_thumbnail();
|
||||
|
||||
@@ -469,8 +469,9 @@ int PresetComboBox::selected_connected_printer() const
|
||||
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->is_bbl_vendor();
|
||||
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;
|
||||
@@ -513,12 +514,26 @@ void PresetComboBox::add_ams_filaments(std::string selected, bool alias_name)
|
||||
auto color = tray.opt_string("filament_colour", 0u);
|
||||
auto name = tray.opt_string("tray_name", 0u);
|
||||
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);
|
||||
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
|
||||
}
|
||||
m_last_ams_filament = GetCount();
|
||||
}
|
||||
return selected_in_ams;
|
||||
}
|
||||
|
||||
int PresetComboBox::selected_ams_filament() const
|
||||
@@ -903,6 +918,13 @@ void PlaterPresetComboBox::OnSelect(wxCommandEvent &evt)
|
||||
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()
|
||||
{
|
||||
Tab* tab = wxGetApp().get_tab(m_type);
|
||||
@@ -1186,38 +1208,32 @@ void PlaterPresetComboBox::update()
|
||||
}
|
||||
//if (m_type == Preset::TYPE_PRINTER)
|
||||
// add_connected_printers("", true);
|
||||
|
||||
bool selected_in_ams = false;
|
||||
if (m_type == Preset::TYPE_FILAMENT && m_preset_bundle->is_bbl_vendor()) {
|
||||
set_replace_text("Bambu", "BambuStudioBlack");
|
||||
add_ams_filaments(into_u8(selected_user_preset), true);
|
||||
selected_in_ams = add_ams_filaments(into_u8(selected_user_preset), true);
|
||||
}
|
||||
|
||||
auto add_presets = [this, &preset_descriptions, &selected_in_ams]
|
||||
(std::vector<PresetItemInfo> const &presets, wxString const &selected, std::string const &group) {
|
||||
if (!presets.empty()) {
|
||||
set_label_marker(Append(separator(group), wxNullBitmap));
|
||||
for (auto it = presets.begin(); it != presets.end(); ++it) {
|
||||
SetItemTooltip(Append(it->name, *it->bitmap), preset_descriptions[it->name]);
|
||||
bool is_selected = it->name == selected;
|
||||
validate_selection(is_selected);
|
||||
if (is_selected && selected_in_ams) {
|
||||
SetFlag(GetCount() - 1, (int) FilamentAMSType::FROM_AMS);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
//BBS: add project embedded preset logic
|
||||
if (!project_embedded_presets.empty())
|
||||
{
|
||||
set_label_marker(Append(separator(L("Project-inside presets")), wxNullBitmap));
|
||||
for (auto it = project_embedded_presets.begin(); it != project_embedded_presets.end(); ++it) {
|
||||
SetItemTooltip(Append(it->name, *it->bitmap), preset_descriptions[it->name]);
|
||||
validate_selection(it->name == selected_user_preset);
|
||||
}
|
||||
}
|
||||
if (!nonsys_presets.empty())
|
||||
{
|
||||
set_label_marker(Append(separator(L("User presets")), wxNullBitmap));
|
||||
for (auto it = nonsys_presets.begin(); it != nonsys_presets.end(); ++it) {
|
||||
SetItemTooltip(Append(it->name, *it->bitmap), preset_descriptions[it->name]);
|
||||
validate_selection(it->name == selected_user_preset);
|
||||
}
|
||||
}
|
||||
//BBS: move system to the end
|
||||
if (!system_presets.empty())
|
||||
{
|
||||
set_label_marker(Append(separator(L("System presets")), wxNullBitmap));
|
||||
for (auto it = system_presets.begin(); it != system_presets.end(); ++it) {
|
||||
SetItemTooltip(Append(it->name, *it->bitmap), preset_descriptions[it->name]);
|
||||
validate_selection(it->name == selected_system_preset);
|
||||
}
|
||||
}
|
||||
add_presets(project_embedded_presets, selected_user_preset, L("Project-inside presets"));
|
||||
add_presets(nonsys_presets, selected_user_preset, L("User presets"));
|
||||
// BBS: move system to the end
|
||||
add_presets(system_presets, selected_system_preset, L("System presets"));
|
||||
|
||||
//BBS: remove unused pysical printer logic
|
||||
/*if (m_type == Preset::TYPE_PRINTER)
|
||||
@@ -1258,6 +1274,9 @@ void PlaterPresetComboBox::update()
|
||||
}
|
||||
|
||||
update_selection();
|
||||
if (m_type == Preset::TYPE_FILAMENT) {
|
||||
update_badge_according_flag();
|
||||
}
|
||||
Thaw();
|
||||
|
||||
if (!tooltip.IsEmpty()) {
|
||||
|
||||
@@ -76,7 +76,7 @@ public:
|
||||
int selected_connected_printer() const;
|
||||
|
||||
// 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;
|
||||
|
||||
void set_filament_idx(const int extr_idx) { m_filament_idx = extr_idx; }
|
||||
@@ -202,6 +202,7 @@ public:
|
||||
void update() override;
|
||||
void msw_rescale() override;
|
||||
void OnSelect(wxCommandEvent& evt) override;
|
||||
void update_badge_according_flag();
|
||||
|
||||
private:
|
||||
// BBS
|
||||
|
||||
@@ -4006,13 +4006,20 @@ void SyncAmsInfoDialog::clone_thumbnail_data(bool allow_clone_ams_color)
|
||||
while (iter != m_materialList.end()) {
|
||||
int id = iter->first;
|
||||
Material *item = iter->second;
|
||||
auto m = item->item;
|
||||
m_preview_colors_in_thumbnail[id] = m->m_material_coloul;
|
||||
if (item->id < m_cur_colors_in_thumbnail.size()) {
|
||||
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;
|
||||
if (item) {
|
||||
auto m = item->item;
|
||||
if (m) {
|
||||
m_preview_colors_in_thumbnail[id] = m->m_material_coloul;
|
||||
if (item->id < m_cur_colors_in_thumbnail.size()) {
|
||||
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++;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user