ENH:adjust the UI of the Mapping pop-up window

jira:[none]

Change-Id: I26f07db9a9d4fd565fde1e58d01e2c60380f8492
This commit is contained in:
tao wang 2025-01-18 12:41:12 +08:00 committed by lane.wei
parent caa51852af
commit 8f11826bc0
4 changed files with 67 additions and 58 deletions

View File

@ -0,0 +1,3 @@
<svg width="24" height="25" viewBox="0 0 24 25" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M12 4.37012C14.1549 4.37012 16.2215 5.22614 17.7452 6.74987C19.269 8.27361 20.125 10.3402 20.125 12.4951C20.125 14.65 19.269 16.7166 17.7452 18.2404C16.2215 19.7641 14.1549 20.6201 12 20.6201C9.84512 20.6201 7.77849 19.7641 6.25476 18.2404C4.73102 16.7166 3.875 14.65 3.875 12.4951C3.875 10.3402 4.73102 8.27361 6.25476 6.74987C7.77849 5.22614 9.84512 4.37012 12 4.37012ZM12 22.4951C14.6522 22.4951 17.1957 21.4415 19.0711 19.5662C20.9464 17.6908 22 15.1473 22 12.4951C22 9.84295 20.9464 7.29941 19.0711 5.42405C17.1957 3.54869 14.6522 2.49512 12 2.49512C9.34784 2.49512 6.8043 3.54869 4.92893 5.42405C3.05357 7.29941 2 9.84295 2 12.4951C2 15.1473 3.05357 17.6908 4.92893 19.5662C6.8043 21.4415 9.34784 22.4951 12 22.4951ZM12 7.49512C11.4805 7.49512 11.0625 7.91309 11.0625 8.43262V12.8076C11.0625 13.3271 11.4805 13.7451 12 13.7451C12.5195 13.7451 12.9375 13.3271 12.9375 12.8076V8.43262C12.9375 7.91309 12.5195 7.49512 12 7.49512ZM13.25 16.2451C13.25 15.9136 13.1183 15.5957 12.8839 15.3612C12.6495 15.1268 12.3315 14.9951 12 14.9951C11.6685 14.9951 11.3505 15.1268 11.1161 15.3612C10.8817 15.5957 10.75 15.9136 10.75 16.2451C10.75 16.5766 10.8817 16.8946 11.1161 17.129C11.3505 17.3634 11.6685 17.4951 12 17.4951C12.3315 17.4951 12.6495 17.3634 12.8839 17.129C13.1183 16.8946 13.25 16.5766 13.25 16.2451Z" fill="#D01B1B"/>
</svg>

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@ -37,6 +37,7 @@ wxDEFINE_EVENT(EVT_SET_FINISH_MAPPING, wxCommandEvent);
m_transparent_mitem = ScalableBitmap(this, "transparent_material_item", 52);
//m_ams_wheel_mitem = ScalableBitmap(this, "ams_wheel", FromDIP(25));
m_ams_wheel_mitem = ScalableBitmap(this, "ams_wheel_narrow", 25);
m_ams_not_match = ScalableBitmap(this, "filament_not_mactch", 25);
m_material_coloul = mcolour;
m_material_name = mname;
@ -128,6 +129,17 @@ void MaterialItem::paintEvent(wxPaintEvent &evt)
void MaterialItem::render(wxDC &dc)
{
wxString mapping_txt = wxEmptyString;
if (m_ams_name.empty()) {
mapping_txt = "-";
} else {
mapping_txt = m_ams_name;
}
if (mapping_txt == "-") { m_match = false;}
else {m_match = true;}
#ifdef __WXMSW__
wxSize size = GetSize();
wxMemoryDC memdc;
@ -169,24 +181,24 @@ void MaterialItem::render(wxDC &dc)
dc.DrawText(m_material_name, wxPoint((GetSize().x - material_txt_size.x) / 2, ((float)GetSize().y * 2 / 5 - material_txt_size.y) / 2));
// mapping num
wxString mapping_txt = wxEmptyString;
if (m_ams_name.empty()) {
mapping_txt = "-";
} else {
mapping_txt = m_ams_name;
}
auto mapping_txt_size = dc.GetTextExtent(mapping_txt);
dc.SetTextForeground(StateColor::darkModeColorFor(wxColour(0x26, 0x2E, 0x30)));
dc.SetFont(::Label::Head_12);
m_text_pos_y =((float)GetSize().y * 3 / 5 - mapping_txt_size.y) / 2 + (float)GetSize().y * 2 / 5;
if (m_match) {
dc.DrawText(mapping_txt, wxPoint(GetSize().x / 2 + (GetSize().x / 2 - mapping_txt_size.x) / 2 - FromDIP(6), m_text_pos_y));
}
}
void MaterialItem::match(bool mat)
{
m_match = mat;
Refresh();
}
void MaterialItem::doRender(wxDC& dc)
{
wxSize size = GetSize();
@ -249,7 +261,6 @@ void MaterialItem::doRender(wxDC& dc)
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), MATERIAL_REC_WHEEL_SIZE.y);
}
@ -265,6 +276,7 @@ void MaterialItem::doRender(wxDC& dc)
dc.DrawRoundedRectangle(1, 1, MATERIAL_ITEM_SIZE.x - 1, MATERIAL_ITEM_SIZE.y - 1, 5);
}
#else
dc.SetPen(wxColour(0xAC, 0xAC, 0xAC));
dc.SetBrush(*wxTRANSPARENT_BRUSH);
dc.DrawRoundedRectangle(0, 0, MATERIAL_ITEM_SIZE.x, MATERIAL_ITEM_SIZE.y, 5);
@ -275,7 +287,7 @@ void MaterialItem::doRender(wxDC& dc)
dc.DrawRoundedRectangle(0, 0, MATERIAL_ITEM_SIZE.x, MATERIAL_ITEM_SIZE.y, 5);
}
#endif
if (m_text_pos_y > 0) {
if (m_text_pos_y > 0 && m_match) {
// 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(2), m_text_pos_y + FromDIP(3));
@ -284,8 +296,15 @@ void MaterialItem::doRender(wxDC& dc)
}
}
//wheel
dc.DrawBitmap(m_ams_wheel_mitem.bmp(), (GetSize().x / 2 - m_ams_wheel_mitem.GetBmpSize().x) / 2 + FromDIP(2), ((float)GetSize().y * 0.6 - m_ams_wheel_mitem.GetBmpSize().y) / 2 + (float)GetSize().y * 0.4);
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;
dc.DrawBitmap(m_ams_wheel_mitem.bmp(), wheel_left, wheel_top);
if (!m_match) {
wheel_left += m_ams_wheel_mitem.GetBmpSize().x;
dc.DrawBitmap(m_ams_not_match.bmp(), wheel_left + FromDIP(5), wheel_top);
}
}
AmsMapingPopup::AmsMapingPopup(wxWindow *parent)
@ -360,7 +379,6 @@ AmsMapingPopup::AmsMapingPopup(wxWindow *parent)
left_tips->SetFont(::Label::Body_13);
left_tips->SetLabel(_L("Select filament that installed to the left nozzle"));
auto right_tips = new Label(m_right_marea_panel);
right_tips->SetForegroundColour(0x262E30);
right_tips->SetBackgroundColour(*wxWHITE);
@ -368,7 +386,8 @@ AmsMapingPopup::AmsMapingPopup(wxWindow *parent)
right_tips->SetLabel(_L("Select filament that installed to the right nozzle"));
m_sizer_ams_left->Add(left_tips, 0, wxEXPAND|wxBOTTOM, FromDIP(8));
m_sizer_ams_left->Add(create_split_sizer(m_left_marea_panel, _L("Left AMS")), 0, wxEXPAND, 0);
m_left_split_ams_sizer = create_split_sizer(m_left_marea_panel, _L("Left AMS"));
m_sizer_ams_left->Add(m_left_split_ams_sizer, 0, wxEXPAND, 0);
m_sizer_ams_left->Add(m_sizer_ams_basket_left, 0, wxEXPAND|wxTOP, FromDIP(8));
m_sizer_ams_left->Add(create_split_sizer(m_left_marea_panel, _L("External")), 0, wxEXPAND|wxTOP, FromDIP(8));
//m_sizer_ams_left->Add(m_left_extra_slot, 0, wxEXPAND|wxTOP, FromDIP(8));
@ -391,19 +410,16 @@ AmsMapingPopup::AmsMapingPopup(wxWindow *parent)
m_sizer_ams->Add(m_right_marea_panel, 1, wxEXPAND, FromDIP(0));
m_warning_text = new wxStaticText(this, wxID_ANY, wxEmptyString);
m_warning_text = new Label(this);
m_warning_text->SetForegroundColour(wxColour(0xFF, 0x6F, 0x00));
m_warning_text->SetFont(::Label::Body_12);
auto cant_not_match_tip = _L("Note: Only the AMS slots loaded with the same material type can be selected.");
m_warning_text->SetLabel(format_text(cant_not_match_tip));
/*m_warning_text->SetMinSize(wxSize(FromDIP(248), FromDIP(-1)));
m_warning_text->Wrap(FromDIP(248));*/
/*m_warning_text->SetMinSize(wxSize(FromDIP(496), FromDIP(-1)));
m_warning_text->Wrap(FromDIP(496));*/
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(m_warning_text, 0, wxEXPAND | wxALL, FromDIP(6));
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));
SetSizer(m_sizer_main);
Layout();
@ -448,26 +464,6 @@ AmsMapingPopup::AmsMapingPopup(wxWindow *parent)
return sizer_split_ams;
}
wxString AmsMapingPopup::format_text(wxString &m_msg)
{
if (wxGetApp().app_config->get("language") != "zh_CN") { return m_msg; }
wxString out_txt = m_msg;
wxString count_txt = "";
int new_line_pos = 0;
for (int i = 0; i < m_msg.length(); i++) {
auto text_size = m_warning_text->GetTextExtent(count_txt);
if (text_size.x < (FromDIP(280))) {
count_txt += m_msg[i];
} else {
out_txt.insert(i - 1, '\n');
count_txt = "";
}
}
return out_txt;
}
void AmsMapingPopup::update_materials_list(std::vector<std::string> list)
{
m_materials_list = list;
@ -566,9 +562,11 @@ void AmsMapingPopup::update(MachineObject* obj)
/*ext*/
const auto& full_config = wxGetApp().preset_bundle->full_config();
size_t nozzle_nums = full_config.option<ConfigOptionFloatsNullable>("nozzle_diameter")->values.size();
if (nozzle_nums == 1) {
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();
//m_left_marea_panel->Show();
@ -581,11 +579,6 @@ void AmsMapingPopup::update(MachineObject* obj)
m_right_marea_panel->Hide();
m_left_extra_slot->Hide();
m_right_extra_slot->Hide();
if (m_show_type != ShowType::LEFT_AND_RIGHT)
{
m_warning_text->SetMinSize(wxSize(FromDIP(248), FromDIP(-1)));
m_warning_text->Wrap(FromDIP(248));
}
if (m_show_type == ShowType::LEFT)
{
m_left_marea_panel->Show();
@ -714,12 +707,25 @@ void AmsMapingPopup::update(MachineObject* obj)
m_sizer_ams_basket_left->Add(ams_mapping_item_container, 0, wxLEFT, 0);
}
if (m_sizer_ams_basket_left->GetChildren().size() <= 0) {
m_left_split_ams_sizer->Show(false);
} else {
m_left_split_ams_sizer->Show(true);
}
if (m_sizer_ams_basket_right->GetChildren().size() == 0) {
m_right_split_ams_sizer->Show(false);
} else {
m_right_split_ams_sizer->Show(true);
}
//m_warning_text->Show(m_has_unmatch_filament);
}
else if(ams_type == 4){ //4:n3s
}
}
Refresh();
Layout();
Fit();
}

View File

@ -91,9 +91,11 @@ public:
ScalableBitmap m_arraw_bitmap_white;
ScalableBitmap m_transparent_mitem;
ScalableBitmap m_ams_wheel_mitem;
ScalableBitmap m_ams_not_match;
bool m_selected {false};
bool m_warning{false};
bool m_match {true};
void msw_rescale();
void set_ams_info(wxColour col, wxString txt, int ctype=0, std::vector<wxColour> cols= std::vector<wxColour>());
@ -107,6 +109,7 @@ public:
void on_left_down(wxMouseEvent &evt);
void paintEvent(wxPaintEvent &evt);
void render(wxDC &dc);
void match(bool mat);
void doRender(wxDC &dc);
};
@ -156,7 +159,7 @@ public:
~AmsMapingPopup() {};
wxWindow* send_win{ nullptr };
wxStaticText * m_warning_text{nullptr};
Label* m_warning_text{nullptr};
std::vector<std::string> m_materials_list;
std::vector<wxBoxSizer*> m_amsmapping_container_sizer_list;
std::vector<wxWindow*> m_amsmapping_container_list;
@ -181,6 +184,7 @@ public:
wxPanel* m_left_marea_panel;
wxPanel* m_right_marea_panel;
wxBoxSizer * m_left_split_ams_sizer{nullptr};
wxBoxSizer * m_right_split_ams_sizer{nullptr};
wxBoxSizer* m_sizer_split_ams_left;
@ -188,7 +192,6 @@ public:
void set_sizer_title(wxBoxSizer *sizer, wxString text);
wxBoxSizer* create_split_sizer(wxWindow* parent, wxString text);
wxString format_text(wxString &m_msg);
void set_send_win(wxWindow* win) {send_win = win;};
void update_materials_list(std::vector<std::string> list);
void set_tag_texture(std::string texture);

View File

@ -548,7 +548,7 @@ SelectMachineDialog::SelectMachineDialog(Plater *plater)
m_txt_change_filament_times->SetBackgroundColour(*wxWHITE);
m_txt_change_filament_times->SetLabel(wxEmptyString);
m_change_filament_times_sizer->Add(m_img_change_filament_times, 0, wxTOP, FromDIP(2));
m_change_filament_times_sizer->Add(m_txt_change_filament_times, 0, wxTOP, 0);
m_change_filament_times_sizer->Add(m_txt_change_filament_times, 0, wxTOP, FromDIP(2));
/*Advanced Options*/
wxBoxSizer* sizer_split_options = new wxBoxSizer(wxHORIZONTAL);
@ -1102,11 +1102,8 @@ void SelectMachineDialog::sync_ams_mapping_result(std::vector<FilamentInfo> &res
if (f->tray_id == VIRTUAL_TRAY_MAIN_ID || f->tray_id == VIRTUAL_TRAY_DEPUTY_ID)
{
ams_id = "Ext";
}
else if (f->tray_id >= 0) {
}else if (f->tray_id >= 0) {
ams_id = wxGetApp().transition_tridid(f->tray_id);
//ams_id = wxString::Format("%02d", f->tray_id + 1);
} else {
ams_id = "-";
}