NEW:Display AMS mapping relationship in override mode

jira: none
Change-Id: Iac0b3563df2f76710a5bc461adab6dd8335ee62d
This commit is contained in:
zhou.xu 2025-01-23 15:15:59 +08:00 committed by lane.wei
parent f95f88de0d
commit 69f28a711f
6 changed files with 286 additions and 57 deletions

View File

@ -1808,23 +1808,25 @@ void PresetBundle::update_num_filaments(unsigned int to_del_flament_id)
update_multi_material_filament_presets(to_del_flament_id);
}
std::vector<std::string> PresetBundle::get_ams_colors() {
std::vector<std::string> ams_filament_colors;
std::vector<std::string> ams_filament_presets;
auto is_double_extruder = get_printer_extruder_count() == 2;
void PresetBundle::get_ams_cobox_infos(AMSComboInfo& combox_info)
{
combox_info.clear();
for (auto &entry : filament_ams_list) {
auto &ams = entry.second;
auto filament_id = ams.opt_string("filament_id", 0u);
auto filament_color = ams.opt_string("filament_colour", 0u);
auto ams_name = ams.opt_string("tray_name", 0u);
auto filament_changed = !ams.has("filament_changed") || ams.opt_bool("filament_changed");
auto filament_multi_color = ams.opt<ConfigOptionStrings>("filament_multi_colors")->values;
if (filament_id.empty()) {
continue;
}
if (!filament_changed && this->filament_presets.size() > ams_filament_presets.size()) {
ams_filament_presets.push_back(this->filament_presets[ams_filament_presets.size()]);
ams_filament_colors.push_back(filament_color);
ams_multi_color_filment.push_back(filament_multi_color);
if (!filament_changed && this->filament_presets.size() > combox_info.ams_filament_presets.size()) {
combox_info.ams_filament_presets.push_back(this->filament_presets[combox_info.ams_filament_presets.size()]);
combox_info.ams_filament_colors.push_back(filament_color);
combox_info.ams_multi_color_filment.push_back(filament_multi_color);
combox_info.ams_names.push_back(ams_name);
continue;
}
auto iter = std::find_if(filaments.begin(), filaments.end(),
@ -1839,10 +1841,11 @@ std::vector<std::string> PresetBundle::get_ams_colors() {
}
if (iter == filaments.end()) {
// Prefer old selection
if (ams_filament_presets.size() < this->filament_presets.size()) {
ams_filament_presets.push_back(this->filament_presets[ams_filament_presets.size()]);
ams_filament_colors.push_back(filament_color);
ams_multi_color_filment.push_back(filament_multi_color);
if (combox_info.ams_filament_presets.size() < this->filament_presets.size()) {
combox_info.ams_filament_presets.push_back(this->filament_presets[combox_info.ams_filament_presets.size()]);
combox_info.ams_filament_colors.push_back(filament_color);
combox_info.ams_multi_color_filment.push_back(filament_multi_color);
combox_info.ams_names.push_back(ams_name);
continue;
}
iter = std::find_if(filaments.begin(), filaments.end(), [&filament_type](auto &f) { return f.is_compatible && f.is_system; });
@ -1851,10 +1854,11 @@ std::vector<std::string> PresetBundle::get_ams_colors() {
}
filament_id = iter->filament_id;
}
ams_filament_presets.push_back(iter->name);
ams_filament_colors.push_back(filament_color);
combox_info.ams_filament_presets.push_back(iter->name);
combox_info.ams_filament_colors.push_back(filament_color);
combox_info.ams_multi_color_filment.push_back(filament_multi_color);
combox_info.ams_names.push_back(ams_name);
}
return ams_filament_colors;
}
unsigned int PresetBundle::sync_ams_list(unsigned int &unknowns, bool use_map, std::map<int, AMSMapInfo> &maps,bool enable_append, MergeFilamentInfo &merge_info)

View File

@ -27,6 +27,22 @@ struct AMSMapInfo
std::string ams_id{""};
std::string slot_id{""};
};
struct AMSComboInfo
{
std::vector<std::string> ams_filament_colors;
std::vector<std::vector<std::string>> ams_multi_color_filment;
std::vector<std::string> ams_filament_presets;
std::vector<std::string> ams_names;
void clear() {
ams_filament_colors.clear();
ams_multi_color_filment.clear();
ams_filament_presets.clear();
ams_names.clear();
}
bool empty() {
return ams_names.empty();
}
};
struct MergeFilamentInfo {
std::vector<std::vector<int>> merges;
bool is_empty() { return merges.empty();}
@ -108,7 +124,7 @@ public:
void set_num_filaments(unsigned int n, std::string new_col = "");
void update_num_filaments(unsigned int to_del_flament_id);
std::vector<std::string> get_ams_colors();
void get_ams_cobox_infos(AMSComboInfo &combox_info);
unsigned int sync_ams_list(unsigned int &unknowns, bool use_map, std::map<int, AMSMapInfo> &maps,bool enable_append, MergeFilamentInfo& merge_info);
//BBS: check whether this is the only edited filament
bool is_the_only_edited_filament(unsigned int filament_index);

View File

@ -66,6 +66,12 @@ void MaterialItem::msw_rescale() {
m_ams_wheel_mitem.msw_rescale();
}
void MaterialItem::allow_paint_dropdown(bool flag) {
if (m_dropdown_allow_painted != flag) {
m_dropdown_allow_painted = flag;
}
}
void MaterialItem::set_ams_info(wxColour col, wxString txt, int ctype, std::vector<wxColour> cols)
{
auto need_refresh = false;
@ -250,10 +256,10 @@ void MaterialItem::doRender(wxDC& dc)
dc.SetBrush(wxBrush(m_ams_cols[i]));
float x = left + ((float)MATERIAL_REC_WHEEL_SIZE.x) * i / cols_size;
if (i != cols_size - 1) {
dc.DrawRoundedRectangle(x, up, ((float) MATERIAL_REC_WHEEL_SIZE.x) / cols_size + FromDIP(3) - FromDIP(LEFT_OFFSET), MATERIAL_REC_WHEEL_SIZE.y, 3);
dc.DrawRoundedRectangle(x - FromDIP(LEFT_OFFSET), up, ((float) MATERIAL_REC_WHEEL_SIZE.x) / cols_size + FromDIP(3), MATERIAL_REC_WHEEL_SIZE.y, 3);
}
else {
dc.DrawRoundedRectangle(x, up, ((float) MATERIAL_REC_WHEEL_SIZE.x) / cols_size - FromDIP(1) - FromDIP(LEFT_OFFSET), MATERIAL_REC_WHEEL_SIZE.y, 3);
dc.DrawRoundedRectangle(x - FromDIP(LEFT_OFFSET), up, ((float) MATERIAL_REC_WHEEL_SIZE.x) / cols_size - FromDIP(1), MATERIAL_REC_WHEEL_SIZE.y, 3);
}
}
}
@ -262,7 +268,7 @@ void MaterialItem::doRender(wxDC& dc)
if (m_match) {
dc.SetPen(*wxTRANSPARENT_PEN);
dc.SetBrush(wxBrush(wxColour(acolor)));
dc.DrawRectangle((size.x / 2 - MATERIAL_REC_WHEEL_SIZE.x) / 2 + FromDIP(3), up, MATERIAL_REC_WHEEL_SIZE.x - FromDIP(1) - FromDIP(LEFT_OFFSET),
dc.DrawRectangle((size.x / 2 - MATERIAL_REC_WHEEL_SIZE.x) / 2 + FromDIP(3) - FromDIP(LEFT_OFFSET), up, MATERIAL_REC_WHEEL_SIZE.x - FromDIP(1),
MATERIAL_REC_WHEEL_SIZE.y);
}
}
@ -331,6 +337,10 @@ void MaterialItem::doRender(wxDC& dc)
MaterialSyncItem::~MaterialSyncItem() {}
int MaterialSyncItem::get_real_offset() {
int real_left_offset = m_dropdown_allow_painted ? LEFT_OFFSET : -2;
return real_left_offset;
}
void MaterialSyncItem::render(wxDC &dc)
{
@ -347,7 +357,12 @@ void MaterialSyncItem::render(wxDC &dc)
} else {
m_match = true;
}
dc.SetFont(::Label::Body_12);
if (dc.GetTextExtent(m_material_name).x > GetSize().x - 10) {
dc.SetFont(::Label::Body_10);
}
auto mapping_txt_size = dc.GetTextExtent(mapping_txt);
m_text_pos_y = ((float) GetSize().y * 3 / 5 - mapping_txt_size.y) / 2 + (float) GetSize().y * 2 / 5;
#ifdef __WXMSW__
wxSize size = GetSize();
wxMemoryDC memdc;
@ -381,18 +396,17 @@ void MaterialSyncItem::render(wxDC &dc)
if (mcolor.Alpha() == 0) { material_name_colour = wxColour(0x26, 0x2E, 0x30); }
dc.SetTextForeground(material_name_colour);
if (dc.GetTextExtent(m_material_name).x > GetSize().x - 10) { dc.SetFont(::Label::Body_10); }
if (dc.GetTextExtent(m_material_name).x > GetSize().x - 10) {
dc.SetFont(::Label::Body_10);
}
auto material_txt_size = dc.GetTextExtent(m_material_name);
dc.DrawText(m_material_name, wxPoint((GetSize().x - material_txt_size.x) / 2, ((float) GetSize().y * 2 / 5 - material_txt_size.y) / 2));
auto mapping_txt_size = dc.GetTextExtent(mapping_txt);
m_text_pos_y = ((float) GetSize().y * 3 / 5 - mapping_txt_size.y) / 2 + (float) GetSize().y * 2 / 5;
int real_left_offset = get_real_offset();
if (m_match) {
dc.SetTextForeground(StateColor::darkModeColorFor(wxColour(0x26, 0x2E, 0x30)));
dc.SetFont(::Label::Head_12);
dc.DrawText(mapping_txt, wxPoint(GetSize().x / 2 + (GetSize().x / 2 - mapping_txt_size.x) / 2 - FromDIP(8)- FromDIP(LEFT_OFFSET), m_text_pos_y));
dc.DrawText(mapping_txt, wxPoint(GetSize().x / 2 + (GetSize().x / 2 - mapping_txt_size.x) / 2 - FromDIP(8) - FromDIP(real_left_offset), m_text_pos_y));
}
else {
dc.SetTextForeground(material_name_colour);
@ -436,6 +450,7 @@ void MaterialSyncItem::doRender(wxDC &dc)
auto up = (size.y * 0.4 + (size.y * 0.6 - MATERIAL_REC_WHEEL_SIZE.y) / 2);
auto right = left + MATERIAL_REC_WHEEL_SIZE.x;
dc.SetPen(*wxTRANSPARENT_PEN);
int real_left_offset = get_real_offset();
// bottom
if (m_match) {
if (m_ams_cols.size() > 1) {
@ -453,16 +468,16 @@ void MaterialSyncItem::doRender(wxDC &dc)
dc.SetBrush(wxBrush(m_ams_cols[i]));
float x = left + ((float) MATERIAL_REC_WHEEL_SIZE.x) * i / cols_size;
if (i != cols_size - 1) {
dc.DrawRoundedRectangle(x, up, ((float) MATERIAL_REC_WHEEL_SIZE.x) / cols_size + FromDIP(3) - FromDIP(LEFT_OFFSET), MATERIAL_REC_WHEEL_SIZE.y, 3);
dc.DrawRoundedRectangle(x - FromDIP(real_left_offset), up, ((float) MATERIAL_REC_WHEEL_SIZE.x) / cols_size + FromDIP(3), MATERIAL_REC_WHEEL_SIZE.y, 3);
} else {
dc.DrawRoundedRectangle(x, up, ((float) MATERIAL_REC_WHEEL_SIZE.x) / cols_size - FromDIP(1) - FromDIP(LEFT_OFFSET), MATERIAL_REC_WHEEL_SIZE.y, 3);
dc.DrawRoundedRectangle(x - FromDIP(real_left_offset), up, ((float) MATERIAL_REC_WHEEL_SIZE.x) / cols_size - FromDIP(1), MATERIAL_REC_WHEEL_SIZE.y, 3);
}
}
}
} else {
dc.SetPen(*wxTRANSPARENT_PEN);
dc.SetBrush(wxBrush(wxColour(acolor)));
dc.DrawRectangle((size.x / 2 - MATERIAL_REC_WHEEL_SIZE.x) / 2 + FromDIP(3), up, MATERIAL_REC_WHEEL_SIZE.x - FromDIP(1) - FromDIP(LEFT_OFFSET),
dc.DrawRectangle((size.x / 2 - MATERIAL_REC_WHEEL_SIZE.x) / 2 + FromDIP(3) - FromDIP(real_left_offset), up, MATERIAL_REC_WHEEL_SIZE.x - FromDIP(1),
MATERIAL_REC_WHEEL_SIZE.y);
}
}
@ -497,21 +512,22 @@ void MaterialSyncItem::doRender(wxDC &dc)
dc.DrawRoundedRectangle(FromDIP(1), FromDIP(1), MATERIAL_ITEM_SIZE.x - FromDIP(1), MATERIAL_ITEM_SIZE.y - FromDIP(1), 5);
}
#endif
if (m_text_pos_y > 0 && m_match) {
if (m_text_pos_y > 0 && m_match && m_dropdown_allow_painted) {
// arrow (remove arrow)
if ((acolor.Red() > 160 && acolor.Green() > 160 && acolor.Blue() > 160) && (acolor.Red() < 180 && acolor.Green() < 180 && acolor.Blue() < 180)) {
dc.DrawBitmap(m_arraw_bitmap_white.bmp(), size.x - m_arraw_bitmap_white.GetBmpSize().x - FromDIP(4)- FromDIP(LEFT_OFFSET), m_text_pos_y + FromDIP(3));
dc.DrawBitmap(m_arraw_bitmap_white.bmp(), size.x - m_arraw_bitmap_white.GetBmpSize().x - FromDIP(4) - FromDIP(real_left_offset), m_text_pos_y + FromDIP(3));
} else {
dc.DrawBitmap(m_arraw_bitmap_gray.bmp(), size.x - m_arraw_bitmap_gray.GetBmpSize().x - FromDIP(4)- FromDIP(LEFT_OFFSET), m_text_pos_y + FromDIP(3));
dc.DrawBitmap(m_arraw_bitmap_gray.bmp(), size.x - m_arraw_bitmap_gray.GetBmpSize().x - FromDIP(4) - FromDIP(real_left_offset), m_text_pos_y + FromDIP(3));
}
}
auto wheel_left = (GetSize().x / 2 - m_ams_wheel_mitem.GetBmpSize().x) / 2 + FromDIP(2);
auto wheel_top = ((float) GetSize().y * 0.6 - m_ams_wheel_mitem.GetBmpSize().y) / 2 + (float) GetSize().y * 0.4;
if (m_match) {// different with parent
if (acolor.Alpha() == 0) {
dc.DrawBitmap(m_filament_wheel_transparent.bmp(), wheel_left - FromDIP(LEFT_OFFSET), wheel_top);
dc.DrawBitmap(m_filament_wheel_transparent.bmp(), wheel_left - FromDIP(real_left_offset), wheel_top);
} else {
dc.DrawBitmap(m_ams_wheel_mitem.bmp(), wheel_left - FromDIP(LEFT_OFFSET), wheel_top);
dc.DrawBitmap(m_ams_wheel_mitem.bmp(), wheel_left - FromDIP(real_left_offset), wheel_top);
}
}
//not draw m_ams_not_match

View File

@ -73,6 +73,8 @@ class MaterialItem: public wxPanel
{
protected:
int m_text_pos_y = -1;
bool m_dropdown_allow_painted = true;
public:
MaterialItem(wxWindow *parent, wxColour mcolour, wxString mname);
~MaterialItem();
@ -98,6 +100,7 @@ public:
bool m_match {true};
void msw_rescale();
void allow_paint_dropdown(bool flag);
void set_ams_info(wxColour col, wxString txt, int ctype=0, std::vector<wxColour> cols= std::vector<wxColour>());
void disable();
@ -118,7 +121,7 @@ class MaterialSyncItem : public MaterialItem
public:
MaterialSyncItem(wxWindow *parent, wxColour mcolour, wxString mname);
~MaterialSyncItem();
int get_real_offset();
void render(wxDC &dc) override;
void doRender(wxDC &dc) override;
};

View File

@ -24,6 +24,7 @@ using namespace Slic3r::GUI;
#define BUTTON_SIZE wxSize(FromDIP(58), FromDIP(24))
#define SyncAmsInfoDialogWidth FromDIP(675)
#define SyncLabelWidth FromDIP(640)
#define SyncAttentionTipWidth FromDIP(550)
namespace Slic3r { namespace GUI {
wxDEFINE_EVENT(EVT_CLEAR_IPADDRESS, wxCommandEvent);
wxDEFINE_EVENT(EVT_UPDATE_USER_MACHINE_LIST, wxCommandEvent);
@ -92,6 +93,7 @@ bool SyncAmsInfoDialog::Show(bool show)
bool dirty_filament = is_dirty_filament();
if (!m_input_info.connected_printer || m_is_empty_project || dirty_filament) {
show_color_panel(false);
show_ams_controls(false);
m_filament_left_panel->Show(false); // empty_project
m_filament_right_panel->Show(false);
m_are_you_sure_title->Show(false);
@ -130,8 +132,7 @@ void SyncAmsInfoDialog::updata_ui_data_after_connected_printer() {
m_two_thumbnail_panel->Show(true);
m_attention_text->Show();
m_tip_text->Show();
show_ams_controls(true);
//m_specify_color_cluster_title->Show();
m_button_cancel->Show();
}
@ -363,32 +364,42 @@ void SyncAmsInfoDialog::update_when_change_map_mode(int idx)
show_color_panel(true);
m_confirm_title->SetLabel(m_undone_str);
m_after_map_text->SetLabel(_L("After mapping"));
m_tip_text->SetLabel(m_tip_attention_color_map);
} else if (m_map_mode == MapModeEnum::Override) {
show_color_panel(false);
m_confirm_title->Show();
m_confirm_title->SetLabel(m_override_undone_str);
m_are_you_sure_title->Show();
m_after_map_text->SetLabel(_L("After overwriting"));
m_tip_text->SetLabel(m_tip_attention_override);
}
update_map_when_change_map_mode();
Layout();
Fit();
}
void SyncAmsInfoDialog::update_map_when_change_map_mode() {
wxColour SyncAmsInfoDialog::decode_ams_color(const std::string &color_str) {
auto temp_str = color_str;
if (temp_str.front() == '#') {
temp_str = temp_str.substr(1);
}
if (temp_str.size() == 6) {
temp_str += "FF";
}
return AmsTray::decode_color(temp_str);
}
void SyncAmsInfoDialog::update_map_when_change_map_mode()
{
if (m_map_mode == MapModeEnum::ColorMap) {
m_cur_colors_in_thumbnail = m_back_cur_colors_in_thumbnail;
} else if (m_map_mode == MapModeEnum::Override) {
auto ams_colors = wxGetApp().preset_bundle->get_ams_colors();
if (m_ams_combo_info.empty()) {
wxGetApp().preset_bundle->get_ams_cobox_infos(m_ams_combo_info);
}
for (size_t i = 0; i < m_preview_colors_in_thumbnail.size(); i++) {
if (i < ams_colors.size()) {
auto color_str = ams_colors[i];
if (color_str.front() == '#') {
color_str = color_str.substr(1);
}
if (color_str.size() == 6) {
color_str += "FF";
}
auto result = AmsTray::decode_color(color_str);
if (i < m_ams_combo_info.ams_filament_colors.size()) {
auto result = decode_ams_color(m_ams_combo_info.ams_filament_colors[i]);
m_cur_colors_in_thumbnail[i] = result;
}
else {
@ -427,8 +438,6 @@ void SyncAmsInfoDialog::update_panel_status(PageType page)
void SyncAmsInfoDialog::show_color_panel(bool flag, bool update_layout)
{
//show_sizer(m_plate_combox_sizer, flag);
m_filament_panel->Show(flag); // empty_project
show_ams_controls(flag);
show_advanced_settings(flag);
m_confirm_title->Show(flag);
m_are_you_sure_title->Show(flag);
@ -936,6 +945,18 @@ SyncAmsInfoDialog::SyncAmsInfoDialog(wxWindow *parent, SyncInfo &info) :
//sizer_split_filament->Add(m_sizer_autorefill, 0, wxALIGN_CENTER, 0);
/*filament area*/
//overrider fix filament
m_fix_filament_panel = new StaticBox(this);
m_fix_filament_panel->SetBorderWidth(0);
m_fix_filament_panel->SetMinSize(wxSize(FromDIP(637), -1));
m_fix_filament_panel->SetMaxSize(wxSize(FromDIP(637), -1));
m_fix_filament_panel_sizer = new wxBoxSizer(wxVERTICAL);
m_fix_sizer_ams_mapping = new wxFlexGridSizer(0, SYNC_FLEX_GRID_COL, FromDIP(6), FromDIP(7));
m_fix_filament_panel_sizer->Add(m_fix_sizer_ams_mapping, 0, wxEXPAND | wxLEFT | wxRIGHT, FromDIP(10));
m_fix_filament_panel->SetSizer(m_fix_filament_panel_sizer);
m_fix_filament_panel->Layout();
m_fix_filament_panel->Fit();
/*1 extruder*/
m_filament_panel = new StaticBox(this);
//m_filament_panel->SetBackgroundColour(wxColour(0xF8F8F8));
@ -1203,6 +1224,8 @@ SyncAmsInfoDialog::SyncAmsInfoDialog(wxWindow *parent, SyncInfo &info) :
// m_sizer_main->Add(m_basic_panel, 0, wxEXPAND | wxLEFT | wxRIGHT, FromDIP(15));
//m_sizer_main->Add(sizer_split_filament, 1, wxEXPAND | wxLEFT | wxRIGHT, FromDIP(15));
m_sizer_main->Add(m_filament_panel, 0, wxALIGN_CENTER | wxLEFT | wxRIGHT, FromDIP(15));
m_sizer_main->Add(m_fix_filament_panel, 0, wxALIGN_CENTER | wxLEFT | wxRIGHT, FromDIP(15));
m_fix_filament_panel->Show(false);
m_sizer_main->Add(m_sizer_filament_2extruder, 0, wxEXPAND | wxLEFT | wxRIGHT, FromDIP(15));
//m_sizer_main->Add(m_statictext_ams_msg, 0, wxALIGN_CENTER | wxLEFT | wxRIGHT, FromDIP(15));
@ -1218,10 +1241,14 @@ SyncAmsInfoDialog::SyncAmsInfoDialog(wxWindow *parent, SyncInfo &info) :
wxBoxSizer *tip_sizer = new wxBoxSizer(wxHORIZONTAL);
m_attention_text = new wxStaticText(this, wxID_ANY, _L("Attention") + ": ");
tip_sizer->Add(m_attention_text, 0, wxALIGN_LEFT | wxTOP, FromDIP(2));
m_tip_text = new wxStaticText(this, wxID_ANY, _L("Only synchronize filament type and color, not including AMS slot information."));
m_tip_attention_color_map = _L("Only synchronize filament type and color, not including AMS slot information.");
m_tip_attention_override = _L("Replace the project filaments list sequentially based on printer filaments. And unused printer filaments will be automatically added to the end of the list.");
m_tip_text = new Label(this, m_tip_attention_color_map, LB_AUTO_WRAP);
m_tip_text->SetMinSize(wxSize(SyncAttentionTipWidth, -1));
m_tip_text->SetMaxSize(wxSize(SyncAttentionTipWidth, -1));
m_tip_text->SetForegroundColour(wxColour(107, 107, 107, 100));
tip_sizer->Add(m_tip_text, 0, wxALIGN_LEFT | wxTOP, FromDIP(2));
tip_sizer->AddSpacer(FromDIP(25));
tip_sizer->AddSpacer(FromDIP(20));
bSizer->Add(tip_sizer, 0, wxEXPAND | wxLEFT, FromDIP(25));
add_two_image_control();
@ -1277,12 +1304,12 @@ SyncAmsInfoDialog::SyncAmsInfoDialog(wxWindow *parent, SyncInfo &info) :
wxBoxSizer *confirm_boxsizer = new wxBoxSizer(wxVERTICAL);
m_override_undone_str = _L("The project's filament list will be directly replaced with the information of all filaments from the printer. This action cannot be undone.");
m_override_undone_str = _L("After being synced, this action cannot be undone.");
m_undone_str = _L("After being synced, the project's filament presets and colors will be replaced with the mapped filament types and colors. This action cannot be undone.");
m_confirm_title = new Label(this, m_undone_str, LB_AUTO_WRAP);
m_confirm_title->SetMinSize(wxSize(SyncLabelWidth, -1));
m_confirm_title->SetMaxSize(wxSize(SyncLabelWidth, -1));
confirm_boxsizer->Add(m_confirm_title, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxTOP, FromDIP(10));
confirm_boxsizer->Add(m_confirm_title, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxTOP | wxRIGHT, FromDIP(10));
m_are_you_sure_title = new wxStaticText(this, wxID_ANY,_L("Are you sure to synchronize the filaments?"));
//m_are_you_sure_title->SetFont(Label::Head_14);
confirm_boxsizer->Add(m_are_you_sure_title, 0, wxALIGN_LEFT | wxTOP, FromDIP(0));
@ -3933,6 +3960,154 @@ void SyncAmsInfoDialog::reset_and_sync_ams_list()
// reset_ams_material();//show "-"
}
void SyncAmsInfoDialog::generate_override_fix_ams_list()
{
if (m_generate_fix_sizer_ams_mapping) {
return;
}
m_generate_fix_sizer_ams_mapping = true;
// for black list
std::vector<std::string> materials;
std::vector<std::string> brands;
std::vector<std::string> display_materials;
std::vector<std::string> m_filaments_id;
auto preset_bundle = wxGetApp().preset_bundle;
for (auto filament_name : preset_bundle->filament_presets) {
for (int f_index = 0; f_index < preset_bundle->filaments.size(); f_index++) {
PresetCollection *filament_presets = &wxGetApp().preset_bundle->filaments;
Preset * preset = &filament_presets->preset(f_index);
int size = preset_bundle->filaments.size();
if (preset && filament_name.compare(preset->name) == 0) {
std::string display_filament_type;
std::string filament_type = preset->config.get_filament_type(display_filament_type);
std::string m_filament_id = preset->filament_id;
display_materials.push_back(display_filament_type);
materials.push_back(filament_type);
m_filaments_id.push_back(m_filament_id);
std::string m_vendor_name = "";
auto vendor = dynamic_cast<ConfigOptionStrings *>(preset->config.option("filament_vendor"));
if (vendor && (vendor->values.size() > 0)) {
std::string vendor_name = vendor->values[0];
m_vendor_name = vendor_name;
}
brands.push_back(m_vendor_name);
}
}
}
if (m_ams_combo_info.empty()) {
wxGetApp().preset_bundle->get_ams_cobox_infos(m_ams_combo_info);
}
std::vector<int> extruders(wxGetApp().plater()->get_extruders_colors().size());
std::iota(extruders.begin(), extruders.end(), 1);
BitmapCache bmcache;
MaterialHash::iterator iter = m_fix_materialList.begin();
while (iter != m_fix_materialList.end()) {
int id = iter->first;
Material *item = iter->second;
item->item->Destroy();
delete item;
iter++;
}
m_fix_sizer_ams_mapping->Clear();
m_fix_materialList.clear();
m_fix_filaments.clear();
bool use_double_extruder = get_is_double_extruder();
if (use_double_extruder) {
const auto &project_config = preset_bundle->project_config;
m_filaments_map = wxGetApp().plater()->get_partplate_list().get_curr_plate()->get_real_filament_maps(project_config);
}
auto contronal_index = 0;
bool is_first_row = true;
for (auto i = 0; i < extruders.size(); i++) {
auto extruder = extruders[i] - 1;
auto colour = wxGetApp().preset_bundle->project_config.opt_string("filament_colour", (unsigned int) extruder);
unsigned char rgb[4];
bmcache.parse_color4(colour, rgb);
auto colour_rgb = wxColour((int) rgb[0], (int) rgb[1], (int) rgb[2], (int) rgb[3]);
if (extruder >= extruders.size() || extruder < 0 || extruder >= m_ams_combo_info.ams_filament_colors.size())
continue;
if (contronal_index % SYNC_FLEX_GRID_COL == 0) {
wxBoxSizer *ams_tip_sizer = new wxBoxSizer(wxVERTICAL);
if (is_first_row) {
is_first_row = false;
auto tip0_text = new wxStaticText(m_fix_filament_panel, wxID_ANY, _CTX(L_CONTEXT("Original", "Sync_AMS"), "Sync_AMS"));
tip0_text->SetForegroundColour(wxColour(107, 107, 107, 100));
ams_tip_sizer->Add(tip0_text, 0, wxALIGN_LEFT | wxTOP, FromDIP(2));
auto tip1_text = new wxStaticText(m_fix_filament_panel, wxID_ANY, _L("AMS"));
tip1_text->SetForegroundColour(wxColour(107, 107, 107, 100));
ams_tip_sizer->Add(tip1_text, 0, wxALIGN_LEFT | wxTOP, FromDIP(6));
}
m_fix_sizer_ams_mapping->Add(ams_tip_sizer, 0, wxALIGN_LEFT | wxTOP, FromDIP(2));
contronal_index++;
}
MaterialSyncItem *item = nullptr;
if (use_double_extruder) {
if (m_filaments_map[extruder] == 1) {
item = new MaterialSyncItem(m_fix_filament_panel, colour_rgb, _L(display_materials[extruder])); // m_filament_left_panel//special
m_fix_sizer_ams_mapping->Add(item, 0, wxALL, FromDIP(5)); // m_sizer_ams_mapping_left
} else if (m_filaments_map[extruder] == 2) {
item = new MaterialSyncItem(m_fix_filament_panel, colour_rgb, _L(display_materials[extruder])); // m_filament_right_panel
m_fix_sizer_ams_mapping->Add(item, 0, wxALL, FromDIP(5)); // m_sizer_ams_mapping_right
} else {
BOOST_LOG_TRIVIAL(error) << "check error:MaterialItem *item = nullptr";
continue;
}
} else {
item = new MaterialSyncItem(m_fix_filament_panel, colour_rgb, _L(display_materials[extruder]));
m_fix_sizer_ams_mapping->Add(item, 0, wxALL, FromDIP(5));
}
contronal_index++;
item->allow_paint_dropdown(false);
item->SetToolTip(_L("Upper half area: Original\nLower half area: Filament in AMS\nAnd you cannot click it to modify"));
Material *material_item = new Material();
material_item->id = extruder;
material_item->item = item;
m_fix_materialList[i] = material_item;
// build for ams mapping
if (extruder < materials.size() && extruder >= 0) {
FilamentInfo info;
info.id = extruder;
info.type = materials[extruder];
info.brand = brands[extruder];
info.filament_id = m_filaments_id[extruder];
info.color = wxString::Format("#%02X%02X%02X%02X", colour_rgb.Red(), colour_rgb.Green(), colour_rgb.Blue(), colour_rgb.Alpha()).ToStdString();
m_fix_filaments.push_back(info);
}
}
{
if (!m_ams_combo_info.empty()) {
auto index = 0;
for (auto it = m_fix_materialList.begin(); it != m_fix_materialList.end(); it++) {
if (index >= m_ams_combo_info.ams_filament_colors.size() || index >= extruders.size()) {
break;
}
auto ams_color = decode_ams_color(m_ams_combo_info.ams_filament_colors[index]);
wxString ams_id = m_ams_combo_info.ams_names[index];
std::vector<wxColour> cols;
for (auto col : m_ams_combo_info.ams_multi_color_filment[index]) {
cols.push_back(decode_ams_color(col));
}
it->second->item->set_ams_info(ams_color, ams_id, 0, cols);
index++;
}
}
}
m_fix_filament_panel->Show(); // SyncAmsInfoDialog::reset_and_sync_ams_list()
m_fix_sizer_ams_mapping->SetCols(SYNC_FLEX_GRID_COL);
m_fix_sizer_ams_mapping->Layout();
m_fix_filament_panel_sizer->Layout();
}
void SyncAmsInfoDialog::clone_thumbnail_data(bool allow_clone_ams_color)
{
// record preview_colors
@ -4092,11 +4267,14 @@ void SyncAmsInfoDialog::show_ams_controls(bool flag)
void SyncAmsInfoDialog::update_thumbnail_data_accord_plate_index(bool allow_clone_ams_color)
{
if (m_map_mode == MapModeEnum::Override) {
show_ams_controls(false);
show_advanced_settings(false);
m_filament_panel->Show(false);
m_fix_filament_panel->Show();
generate_override_fix_ams_list();
} else if (m_map_mode == MapModeEnum::ColorMap) {
show_ams_controls(true);
show_advanced_settings(true);
m_filament_panel->Show();
m_fix_filament_panel->Show(false);
}
// change thumbnail_data
ThumbnailData &input_data = m_specify_plate_idx == -1 ? m_plater->get_partplate_list().get_curr_plate()->thumbnail_data :

View File

@ -152,6 +152,13 @@ protected:
StaticBox *m_filament_left_panel{nullptr};
StaticBox *m_filament_right_panel{nullptr};
StaticBox * m_fix_filament_panel{nullptr};
wxFlexGridSizer *m_fix_sizer_ams_mapping{nullptr};
MaterialHash m_fix_materialList;
wxBoxSizer * m_fix_filament_panel_sizer{nullptr};
std::vector<FilamentInfo> m_fix_filaments;
bool m_generate_fix_sizer_ams_mapping = false;
wxBoxSizer *m_filament_panel_sizer;
wxBoxSizer *m_filament_panel_left_sizer;
wxBoxSizer *m_filament_panel_right_sizer;
@ -194,6 +201,7 @@ public:
void on_set_finish_mapping(wxCommandEvent &evt);
void on_print_job_cancel(wxCommandEvent &evt);
void reset_and_sync_ams_list();
void generate_override_fix_ams_list();
void clone_thumbnail_data(bool allow_clone_ams_color);
void record_edge_pixels_data();
wxColour adjust_color_for_render(const wxColour &color);
@ -286,6 +294,7 @@ private:
void update_when_change_plate(int);
void update_when_change_map_mode(int);
void update_map_when_change_map_mode();
wxColour decode_ams_color(const std::string &color);
void update_when_change_map_mode(wxCommandEvent &e);
void update_panel_status(PageType page);
void show_color_panel(bool,bool update_layout = true);
@ -303,9 +312,12 @@ private:
Button * m_button_ok = nullptr;
Button * m_button_cancel = nullptr;
AMSComboInfo m_ams_combo_info;
Label *m_after_map_text{nullptr};
wxStaticText *m_attention_text{nullptr};
wxStaticText* m_tip_text{nullptr};
wxString m_tip_attention_color_map;
wxString m_tip_attention_override;
Label* m_tip_text{nullptr};
//wxStaticText *m_specify_color_cluster_title = nullptr;
//wxStaticText* m_used_colors_tip_text{nullptr};
wxStaticText* m_warning_text{nullptr};