diff --git a/resources/images/ams_mapping_container_1.svg b/resources/images/ams_mapping_container_1.svg
new file mode 100644
index 000000000..18b77cb30
--- /dev/null
+++ b/resources/images/ams_mapping_container_1.svg
@@ -0,0 +1,15 @@
+
diff --git a/resources/images/ams_mapping_container.svg b/resources/images/ams_mapping_container_4.svg
similarity index 100%
rename from resources/images/ams_mapping_container.svg
rename to resources/images/ams_mapping_container_4.svg
diff --git a/resources/images/mapping_item_checked.svg b/resources/images/mapping_item_checked.svg
new file mode 100644
index 000000000..d41ee84ae
--- /dev/null
+++ b/resources/images/mapping_item_checked.svg
@@ -0,0 +1,4 @@
+
diff --git a/src/slic3r/GUI/AmsMappingPopup.cpp b/src/slic3r/GUI/AmsMappingPopup.cpp
index 0136ae9b6..27db88185 100644
--- a/src/slic3r/GUI/AmsMappingPopup.cpp
+++ b/src/slic3r/GUI/AmsMappingPopup.cpp
@@ -587,7 +587,7 @@ AmsMapingPopup::AmsMapingPopup(wxWindow *parent, bool use_in_sync_dialog) :
auto title_panel = new wxPanel(this, wxID_ANY);
- title_panel->SetBackgroundColour(wxColour(0xF8, 0xF8, 0xF8));
+ title_panel->SetBackgroundColour("#ACACAC");
title_panel->SetSize(wxSize(-1, FromDIP(30)));
title_panel->SetMinSize(wxSize(-1, FromDIP(30)));
@@ -595,10 +595,10 @@ AmsMapingPopup::AmsMapingPopup(wxWindow *parent, bool use_in_sync_dialog) :
wxBoxSizer *title_sizer_h= new wxBoxSizer(wxHORIZONTAL);
wxBoxSizer *title_sizer_v = new wxBoxSizer(wxVERTICAL);
- auto title_text = new wxStaticText(title_panel, wxID_ANY, _L("AMS Slots"));
- title_text->SetForegroundColour(wxColour(0x32, 0x3A, 0x3D));
- title_text->SetFont(::Label::Head_13);
- title_sizer_v->Add(title_text, 0, wxALIGN_CENTER, 5);
+ m_title_text = new wxStaticText(title_panel, wxID_ANY, _L("AMS Slots"));
+ m_title_text->SetForegroundColour(wxColour(0x32, 0x3A, 0x3D));
+ m_title_text->SetFont(::Label::Head_13);
+ title_sizer_v->Add(m_title_text, 0, wxALIGN_CENTER, 5);
title_sizer_h->Add(title_sizer_v, 1, wxALIGN_CENTER, 5);
title_panel->SetSizer(title_sizer_h);
title_panel->Layout();
@@ -682,17 +682,9 @@ AmsMapingPopup::AmsMapingPopup(wxWindow *parent, bool use_in_sync_dialog) :
m_sizer_ams->Add(0, 0, 0, wxEXPAND, FromDIP(15));
m_sizer_ams->Add(m_right_marea_panel, 1, wxEXPAND, FromDIP(0));
-
- m_warning_text = new Label(this);
- m_warning_text->SetForegroundColour(wxColour(0xFF, 0x6F, 0x00));
- m_warning_text->SetFont(::Label::Body_12);
- m_warning_text->SetLabel(_L("Note: Only the AMS slots loaded with the same material type can be selected."));
-
m_sizer_main->Add(title_panel, 0, wxEXPAND | wxALL, FromDIP(2));
m_sizer_main->Add(m_sizer_ams, 0, wxEXPAND | wxLEFT | wxRIGHT, FromDIP(14));
- m_sizer_main->Add( 0, 0, 0, wxTOP, FromDIP(8));
- m_sizer_main->Add(m_warning_text, 0, wxEXPAND | wxLEFT | wxRIGHT, FromDIP(14));
- m_sizer_main->Add( 0, 0, 0, wxTOP, FromDIP(8));
+ m_sizer_main->Add( 0, 0, 0, wxTOP, FromDIP(14));
SetSizer(m_sizer_main);
Layout();
@@ -824,13 +816,72 @@ void AmsMapingPopup::update_ams_data_multi_machines()
add_ams_mapping(tray_datas, m_amsmapping_container_list[m_amsmapping_container_list_index], m_amsmapping_container_sizer_list[m_amsmapping_container_list_index]);
}
- m_warning_text->Show(m_has_unmatch_filament);
-
Layout();
Fit();
}
-void AmsMapingPopup::update(MachineObject* obj)
+void AmsMapingPopup::update_title(MachineObject* obj)
+{
+ const auto& full_config = wxGetApp().preset_bundle->full_config();
+ size_t nozzle_nums = full_config.option("nozzle_diameter")->values.size();
+ if (nozzle_nums > 1)
+ {
+ if (m_show_type == ShowType::LEFT)
+ {
+ m_title_text->SetLabelText(_L("Left Nozzle"));
+ return;
+ }
+ else if (m_show_type == ShowType::RIGHT)
+ {
+ m_title_text->SetLabelText(_L("Right Nozzle"));
+ return;
+ }
+ }
+
+ m_title_text->SetLabelText(_L("Nozzle"));
+}
+
+void AmsMapingPopup::update_items_check_state(const std::vector& ams_mapping_result)
+{
+ /*update check states*/
+ if (m_parent_item)
+ {
+ auto update_item_check_state = [&ams_mapping_result, this](MappingItem* item)
+ {
+ if (item)
+ {
+ for (const auto& mapping_res : ams_mapping_result)
+ {
+ if (mapping_res.id == this->m_current_filament_id)
+ {
+ if (mapping_res.ams_id == std::to_string(item->m_ams_id) &&
+ mapping_res.slot_id == std::to_string(item->m_slot_id))
+ {
+ item->set_checked(true);
+ }
+ else
+ {
+ item->set_checked(false);
+ }
+
+ return;
+ }
+ }
+
+ item->set_checked(false);
+ }
+ };
+
+ update_item_check_state(m_left_extra_slot);
+ update_item_check_state(m_right_extra_slot);
+ for (auto mapping_item : m_mapping_item_list)
+ {
+ update_item_check_state(mapping_item);
+ }
+ }
+}
+
+void AmsMapingPopup::update(MachineObject* obj, const std::vector& ams_mapping_result)
{
//BOOST_LOG_TRIVIAL(info) << "ams_mapping nozzle count " << obj->m_extder_data.nozzle.size();
BOOST_LOG_TRIVIAL(info) << "ams_mapping total count " << obj->amsList.size();
@@ -846,14 +897,13 @@ void AmsMapingPopup::update(MachineObject* obj)
m_amsmapping_container_sizer_list.clear();
m_mapping_item_list.clear();
+ /*title*/
+ update_title(obj);
/*ext*/
const auto& full_config = wxGetApp().preset_bundle->full_config();
size_t nozzle_nums = full_config.option("nozzle_diameter")->values.size();
- m_warning_text->SetMinSize(wxSize(FromDIP(248), FromDIP(-1)));
- m_warning_text->Wrap(FromDIP(248));
-
if (nozzle_nums == 1) {
m_left_marea_panel->Hide();
m_left_extra_slot->Hide();
@@ -891,8 +941,6 @@ void AmsMapingPopup::update(MachineObject* obj)
}
else if (m_show_type == ShowType::LEFT_AND_RIGHT)
{
- m_warning_text->SetMinSize(wxSize(FromDIP(496), FromDIP(-1)));
- m_warning_text->Wrap(FromDIP(496));
m_left_marea_panel->Show();
m_left_extra_slot->Show();
m_right_marea_panel->Show();
@@ -956,7 +1004,7 @@ void AmsMapingPopup::update(MachineObject* obj)
if (ams_type >=1 || ams_type <= 3) { //1:ams 2:ams-lite 3:n3f
auto sizer_mapping_list = new wxBoxSizer(wxHORIZONTAL);
- auto ams_mapping_item_container = new MappingContainer(nozzle_id == 0? m_right_marea_panel:m_left_marea_panel);
+ auto ams_mapping_item_container = new MappingContainer(nozzle_id == 0? m_right_marea_panel:m_left_marea_panel, ams_iter->second->trayList.size());
ams_mapping_item_container->SetSizer(sizer_mapping_list);
ams_mapping_item_container->Layout();
@@ -1021,13 +1069,13 @@ void AmsMapingPopup::update(MachineObject* obj)
} else {
m_right_split_ams_sizer->Show(true);
}
-
- //m_warning_text->Show(m_has_unmatch_filament);
}
else if(ams_type == 4){ //4:n3s
}
}
+ update_items_check_state(ams_mapping_result);
+
Refresh();
Layout();
Fit();
@@ -1205,6 +1253,7 @@ void AmsMapingPopup::paintEvent(wxPaintEvent &evt)
#endif //__WINDOWS__
m_transparent_mapping_item = ScalableBitmap(this, "transparent_mapping_item", FromDIP(60));
+ mapping_item_checked = ScalableBitmap(this, "mapping_item_checked", FromDIP(20));
SetBackgroundColour(StateColor::darkModeColorFor(*wxWHITE));
Bind(wxEVT_PAINT, &MappingItem::paintEvent, this);
}
@@ -1231,6 +1280,7 @@ void MappingItem::send_event(int fliament_id)
void MappingItem::msw_rescale()
{
+
}
void MappingItem::paintEvent(wxPaintEvent &evt)
@@ -1244,8 +1294,9 @@ void MappingItem::paintEvent(wxPaintEvent &evt)
void MappingItem::render(wxDC &dc)
{
+ wxSize size = GetSize();
+
#ifdef __WXMSW__
- wxSize size = GetSize();
wxMemoryDC memdc;
wxBitmap bmp(size.x, size.y);
memdc.SelectObject(bmp);
@@ -1262,6 +1313,13 @@ void MappingItem::render(wxDC &dc)
doRender(dc);
#endif
+ // checked
+ if (m_checked)
+ {
+ dc.DrawBitmap(mapping_item_checked.bmp(), size.x - mapping_item_checked.GetBmpWidth() - FromDIP(4), 0);
+ }
+ auto top = mapping_item_checked.GetBmpHeight() - FromDIP(4);
+
// materials name
dc.SetFont(::Label::Head_13);
@@ -1271,7 +1329,7 @@ void MappingItem::render(wxDC &dc)
dc.SetTextForeground(txt_colour);
auto txt_size = dc.GetTextExtent(m_tray_index);
- auto top = (GetSize().y - MAPPING_ITEM_REAL_SIZE.y) / 2 + FromDIP(8);
+ top += ((GetSize().y - MAPPING_ITEM_REAL_SIZE.y) / 2);
dc.DrawText(m_tray_index, wxPoint((GetSize().x - txt_size.x) / 2, top));
@@ -1291,6 +1349,24 @@ void MappingItem::set_data(wxColour colour, wxString name, TrayData data, bool u
m_name = name;
Refresh();
}
+
+ if (m_unmatch || (m_name == "-"))
+ {
+ SetToolTip(_L("Note: Only the AMS slots loaded with the same material type can be selected."));
+ }
+ else
+ {
+ SetToolTip(wxEmptyString);
+ }
+}
+
+void MappingItem::set_checked(bool checked)
+{
+ if (m_checked != checked)
+ {
+ m_checked = checked;
+ Refresh();
+ }
}
void MappingItem::doRender(wxDC &dc)
@@ -1752,7 +1828,7 @@ bool AmsIntroducePopup::ProcessLeftDown(wxMouseEvent& event) {
}
-MappingContainer::MappingContainer(wxWindow* parent)
+MappingContainer::MappingContainer(wxWindow* parent, int slots_num)
: wxPanel(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize)
{
#ifdef __WINDOWS__
@@ -1761,10 +1837,18 @@ MappingContainer::MappingContainer(wxWindow* parent)
SetBackgroundColour(StateColor::darkModeColorFor(*wxWHITE));
Bind(wxEVT_PAINT, &MappingContainer::paintEvent, this);
- ams_mapping_item_container = create_scaled_bitmap("ams_mapping_container", this, 78);
-
- SetMinSize(wxSize(FromDIP(230), FromDIP(78)));
- SetMaxSize(wxSize(FromDIP(230), FromDIP(78)));
+ if (slots_num == 1)
+ {
+ ams_mapping_item_container = create_scaled_bitmap("ams_mapping_container_1", this, 78);
+ SetMinSize(wxSize(FromDIP(74), FromDIP(78)));
+ SetMaxSize(wxSize(FromDIP(230), FromDIP(78)));
+ }
+ else
+ {
+ ams_mapping_item_container = create_scaled_bitmap("ams_mapping_container_4", this, 78);
+ SetMinSize(wxSize(FromDIP(230), FromDIP(78)));
+ SetMaxSize(wxSize(FromDIP(230), FromDIP(78)));
+ }
}
MappingContainer::~MappingContainer()
diff --git a/src/slic3r/GUI/AmsMappingPopup.hpp b/src/slic3r/GUI/AmsMappingPopup.hpp
index 31d204605..94b50211a 100644
--- a/src/slic3r/GUI/AmsMappingPopup.hpp
+++ b/src/slic3r/GUI/AmsMappingPopup.hpp
@@ -144,33 +144,41 @@ public:
MappingItem(wxWindow *parent);
~MappingItem();
- void update_data(TrayData data);
- void send_event(int fliament_id);
- void set_tray_index(wxString t_index) {m_tray_index = t_index;};
-
wxWindow*send_win{nullptr};
wxString m_tray_index;
wxColour m_coloul;
wxString m_name;
TrayData m_tray_data;
ScalableBitmap m_transparent_mapping_item;
+ ScalableBitmap mapping_item_checked;
bool m_unmatch{false};
int m_ams_id{255};
int m_slot_id{255};
+public:
+ void update_data(TrayData data);
+ void send_event(int fliament_id);
+ void set_data(wxColour colour, wxString name, TrayData data, bool unmatch = false);
+ void set_checked(bool checked);
+ void set_tray_index(wxString t_index) { m_tray_index = t_index; };
+
void msw_rescale();
+
+private:
void paintEvent(wxPaintEvent &evt);
void render(wxDC &dc);
- void set_data(wxColour colour, wxString name, TrayData data, bool unmatch = false);
void doRender(wxDC &dc);
+
+private:
+ bool m_checked = false;
};
class MappingContainer : public wxPanel
{
public:
wxBitmap ams_mapping_item_container;
- MappingContainer(wxWindow* parent);
+ MappingContainer(wxWindow* parent, int slots_num = 4);
~MappingContainer();
void paintEvent(wxPaintEvent& evt);
void render(wxDC& dc);
@@ -180,13 +188,15 @@ public:
class AmsMapingPopup : public PopupWindow
{
bool m_use_in_sync_dialog = false;
+ wxStaticText* m_title_text{ nullptr };
public:
AmsMapingPopup(wxWindow *parent,bool use_in_sync_dialog = false);
~AmsMapingPopup() {};
+ MaterialItem* m_parent_item{ nullptr };
+
wxWindow* send_win{ nullptr };
- Label* m_warning_text{nullptr};
std::vector m_materials_list;
std::vector m_amsmapping_container_sizer_list;
std::vector m_amsmapping_container_list;
@@ -205,7 +215,6 @@ public:
wxBoxSizer* m_sizer_ams_basket_left{ nullptr };
wxBoxSizer* m_sizer_ams_basket_right{ nullptr };
wxBoxSizer *m_sizer_list{nullptr};
- wxWindow *m_parent_item{nullptr};
MappingItem* m_left_extra_slot{nullptr};
MappingItem* m_right_extra_slot{nullptr};
@@ -228,7 +237,9 @@ public:
void set_send_win(wxWindow* win) {send_win = win;};
void update_materials_list(std::vector list);
void set_tag_texture(std::string texture);
- void update(MachineObject* obj);
+ void update(MachineObject* obj, const std::vector& ams_mapping_result);
+ void update_title(MachineObject* obj);
+ void update_items_check_state(const std::vector& ams_mapping_result);
void update_ams_data_multi_machines();
void add_ams_mapping(std::vector tray_data, wxWindow* container, wxBoxSizer* sizer);
void add_ext_ams_mapping(TrayData tray_data, MappingItem* item);
@@ -239,7 +250,7 @@ public:
virtual void OnDismiss() wxOVERRIDE;
virtual bool ProcessLeftDown(wxMouseEvent &event) wxOVERRIDE;
void paintEvent(wxPaintEvent &evt);
- void set_parent_item(wxWindow* item) {m_parent_item = item;};
+ void set_parent_item(MaterialItem* item) {m_parent_item = item;};
void set_show_type(ShowType type) { m_show_type = type; };
std::vector parse_ams_mapping(std::map amsList);
diff --git a/src/slic3r/GUI/SelectMachine.cpp b/src/slic3r/GUI/SelectMachine.cpp
index 43a5d11c2..90b30312d 100644
--- a/src/slic3r/GUI/SelectMachine.cpp
+++ b/src/slic3r/GUI/SelectMachine.cpp
@@ -3903,7 +3903,7 @@ void SelectMachineDialog::reset_and_sync_ams_list()
m_mapping_popup.set_current_filament_id(extruder);
m_mapping_popup.set_tag_texture(materials[extruder]);
m_mapping_popup.set_send_win(this);//fix bug:fisrt click is not valid
- m_mapping_popup.update(obj_);
+ m_mapping_popup.update(obj_, m_ams_mapping_result);
m_mapping_popup.Popup();
}
}
@@ -4406,7 +4406,7 @@ void SelectMachineDialog::set_default_from_sdcard()
m_mapping_popup.set_current_filament_id(fo.id);
m_mapping_popup.set_tag_texture(fo.type);
m_mapping_popup.set_send_win(this);
- m_mapping_popup.update(obj_);
+ m_mapping_popup.update(obj_, m_ams_mapping_result);
m_mapping_popup.Popup();
}
}
diff --git a/src/slic3r/GUI/SyncAmsInfoDialog.cpp b/src/slic3r/GUI/SyncAmsInfoDialog.cpp
index 43f7b72f4..a7e7c6a7e 100644
--- a/src/slic3r/GUI/SyncAmsInfoDialog.cpp
+++ b/src/slic3r/GUI/SyncAmsInfoDialog.cpp
@@ -2962,7 +2962,7 @@ void SyncAmsInfoDialog::reset_and_sync_ams_list()
m_mapping_popup.set_reset_callback(reset_call_back);
m_mapping_popup.set_tag_texture(materials[extruder]);
m_mapping_popup.set_send_win(this);
- m_mapping_popup.update(obj_);
+ m_mapping_popup.update(obj_, m_ams_mapping_result);
m_mapping_popup.Popup();
}
}