mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-05-20 20:03:47 +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) {
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2835,9 +2839,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);
|
||||||
@@ -3117,6 +3119,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;
|
||||||
|
|||||||
@@ -220,6 +220,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 update_printer_thumbnail();
|
void update_printer_thumbnail();
|
||||||
|
|||||||
@@ -469,8 +469,9 @@ int PresetComboBox::selected_connected_printer() 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->is_bbl_vendor();
|
bool is_bbl_vendor_preset = m_preset_bundle->is_bbl_vendor();
|
||||||
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;
|
||||||
@@ -513,12 +514,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
|
||||||
@@ -903,6 +918,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);
|
||||||
@@ -1186,38 +1208,32 @@ 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 && m_preset_bundle->is_bbl_vendor()) {
|
if (m_type == Preset::TYPE_FILAMENT && m_preset_bundle->is_bbl_vendor()) {
|
||||||
set_replace_text("Bambu", "BambuStudioBlack");
|
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
|
//BBS: add project embedded preset logic
|
||||||
if (!project_embedded_presets.empty())
|
add_presets(project_embedded_presets, selected_user_preset, L("Project-inside presets"));
|
||||||
{
|
add_presets(nonsys_presets, selected_user_preset, L("User presets"));
|
||||||
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
|
// BBS: move system to the end
|
||||||
if (!system_presets.empty())
|
add_presets(system_presets, selected_system_preset, L("System presets"));
|
||||||
{
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//BBS: remove unused pysical printer logic
|
//BBS: remove unused pysical printer logic
|
||||||
/*if (m_type == Preset::TYPE_PRINTER)
|
/*if (m_type == Preset::TYPE_PRINTER)
|
||||||
@@ -1258,6 +1274,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()) {
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ public:
|
|||||||
int selected_connected_printer() const;
|
int selected_connected_printer() 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; }
|
||||||
@@ -202,6 +202,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
|
||||||
|
|||||||
@@ -4006,7 +4006,9 @@ 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;
|
||||||
|
if (item) {
|
||||||
auto m = item->item;
|
auto m = item->item;
|
||||||
|
if (m) {
|
||||||
m_preview_colors_in_thumbnail[id] = m->m_material_coloul;
|
m_preview_colors_in_thumbnail[id] = m->m_material_coloul;
|
||||||
if (item->id < m_cur_colors_in_thumbnail.size()) {
|
if (item->id < m_cur_colors_in_thumbnail.size()) {
|
||||||
m_cur_colors_in_thumbnail[item->id] = m->m_ams_coloul;
|
m_cur_colors_in_thumbnail[item->id] = m->m_ams_coloul;
|
||||||
@@ -4014,6 +4016,11 @@ void SyncAmsInfoDialog::clone_thumbnail_data(bool allow_clone_ams_color)
|
|||||||
m_cur_colors_in_thumbnail.resize(item->id + 1);
|
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 {
|
||||||
|
BOOST_LOG_TRIVIAL(error) << "check error:SyncAmsInfoDialog::clone_thumbnail_data:item is nullptr";
|
||||||
|
}
|
||||||
iter++;
|
iter++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user