From 80d6479beeb1ba3bc248bc206fe808dce1758777 Mon Sep 17 00:00:00 2001 From: tao wang Date: Wed, 26 Apr 2023 09:22:26 +0800 Subject: [PATCH] NEW:support for filament backup and edit Change-Id: Id0a83e56df75253046cc07d972e9ad156690bbe7 --- resources/images/back_up_ts_bk.svg | 4 + resources/images/backup_current_use1.svg | 3 + resources/images/backup_current_use2.svg | 3 + resources/images/backup_tips_img.svg | 8 + src/slic3r/GUI/AmsMappingPopup.cpp | 458 ++++++++++++----------- src/slic3r/GUI/AmsMappingPopup.hpp | 86 ++--- src/slic3r/GUI/SelectMachine.cpp | 2 +- src/slic3r/GUI/StatusPanel.cpp | 2 +- src/slic3r/GUI/Widgets/AMSControl.hpp | 1 + 9 files changed, 295 insertions(+), 272 deletions(-) create mode 100644 resources/images/back_up_ts_bk.svg create mode 100644 resources/images/backup_current_use1.svg create mode 100644 resources/images/backup_current_use2.svg create mode 100644 resources/images/backup_tips_img.svg diff --git a/resources/images/back_up_ts_bk.svg b/resources/images/back_up_ts_bk.svg new file mode 100644 index 000000000..75a6cbe0d --- /dev/null +++ b/resources/images/back_up_ts_bk.svg @@ -0,0 +1,4 @@ + + + + diff --git a/resources/images/backup_current_use1.svg b/resources/images/backup_current_use1.svg new file mode 100644 index 000000000..c37817cfa --- /dev/null +++ b/resources/images/backup_current_use1.svg @@ -0,0 +1,3 @@ + + + diff --git a/resources/images/backup_current_use2.svg b/resources/images/backup_current_use2.svg new file mode 100644 index 000000000..30dfcdf41 --- /dev/null +++ b/resources/images/backup_current_use2.svg @@ -0,0 +1,3 @@ + + + diff --git a/resources/images/backup_tips_img.svg b/resources/images/backup_tips_img.svg new file mode 100644 index 000000000..0640f0739 --- /dev/null +++ b/resources/images/backup_tips_img.svg @@ -0,0 +1,8 @@ + + + + Layer 1 + + + + \ No newline at end of file diff --git a/src/slic3r/GUI/AmsMappingPopup.cpp b/src/slic3r/GUI/AmsMappingPopup.cpp index dfd3dce46..d8aa20558 100644 --- a/src/slic3r/GUI/AmsMappingPopup.cpp +++ b/src/slic3r/GUI/AmsMappingPopup.cpp @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include "Plater.hpp" @@ -606,11 +607,6 @@ void MappingItem::render(wxDC &dc) if (m_coloul.Alpha() == 0) txt_colour = wxColour(0x26, 0x2E, 0x30); dc.SetTextForeground(txt_colour); - /*if (dc.GetTextExtent(m_name).x > GetSize().x - 10) { - dc.SetFont(::Label::Body_10); - m_name = m_name.substr(0, 3) + "." + m_name.substr(m_name.length() - 1); - }*/ - auto txt_size = dc.GetTextExtent(m_tray_index); auto top = (GetSize().y - MAPPING_ITEM_REAL_SIZE.y) / 2 + FromDIP(8); dc.DrawText(m_tray_index, wxPoint((GetSize().x - txt_size.x) / 2, top)); @@ -1123,8 +1119,11 @@ void MappingContainer::doRender(wxDC& dc) } AmsReplaceMaterialDialog::AmsReplaceMaterialDialog(wxWindow* parent) - : DPIDialog(parent, wxID_ANY, _L("Filaments replace"), wxDefaultPosition, wxDefaultSize, wxSYSTEM_MENU | wxCAPTION | wxCLOSE_BOX) + : DPIDialog(parent, wxID_ANY, _L("Filaments Auto refill"), wxDefaultPosition, wxDefaultSize, wxSYSTEM_MENU | wxCAPTION | wxCLOSE_BOX) { +#ifdef __WINDOWS__ + SetDoubleBuffered(true); +#endif //__WINDOWS__ SetBackgroundColour(*wxWHITE); create(); wxGetApp().UpdateDlgDarkUI(this); @@ -1132,14 +1131,13 @@ AmsReplaceMaterialDialog::AmsReplaceMaterialDialog(wxWindow* parent) void AmsReplaceMaterialDialog::create() { - SetSize(wxSize(FromDIP(376), -1)); - SetMinSize(wxSize(FromDIP(376), -1)); - SetMaxSize(wxSize(FromDIP(376), -1)); + SetSize(wxSize(FromDIP(445), -1)); + SetMinSize(wxSize(FromDIP(445), -1)); + SetMaxSize(wxSize(FromDIP(445), -1)); // set icon for dialog std::string icon_path = (boost::format("%1%/images/BambuStudioTitle.ico") % resources_dir()).str(); SetIcon(wxIcon(encode_path(icon_path.c_str()), wxBITMAP_TYPE_ICO)); - SetSizeHints(wxDefaultSize, wxDefaultSize); m_main_sizer = new wxBoxSizer(wxVERTICAL); auto m_top_line = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(-1, 1), wxTAB_TRAVERSAL); @@ -1147,6 +1145,17 @@ void AmsReplaceMaterialDialog::create() m_main_sizer->Add(m_top_line, 0, wxEXPAND, 0); + auto label_title = new Label(this, _L("Auto refill")); + label_title->SetFont(Label::Head_14); + label_title->SetForegroundColour(0x00AE42); + auto label_txt = new Label(this, _L("When the current material run out,the printer will continue to print in the following order.")); + label_txt->SetFont(Label::Body_13); + label_txt->SetForegroundColour(0x323A3D); + label_txt->SetMinSize(wxSize(FromDIP(380), -1)); + label_txt->SetMaxSize(wxSize(FromDIP(380), -1)); + label_txt->Wrap(FromDIP(380)); + + m_groups_sizer = new wxWrapSizer( wxHORIZONTAL, wxWRAPSIZER_DEFAULT_FLAGS ); auto m_button_sizer = new wxBoxSizer(wxHORIZONTAL); StateColor btn_bg_white(std::pair(AMS_CONTROL_DISABLE_COLOUR, StateColor::Disabled), @@ -1160,26 +1169,32 @@ void AmsReplaceMaterialDialog::create() StateColor btn_text_white(std::pair(wxColour(255, 255, 254), StateColor::Disabled), std::pair(wxColour(38, 46, 48), StateColor::Enabled)); - auto m_button_close = new Button(this, _L("Close")); - m_button_close->SetCornerRadius(FromDIP(11)); - m_button_close->SetBackgroundColor(btn_bg_white); - m_button_close->SetBorderColor(btn_bd_white); - m_button_close->SetTextColor(btn_text_white); - m_button_close->SetFont(Label::Body_13); - m_button_close->SetMinSize(wxSize(FromDIP(42), FromDIP(24))); - m_button_close->Bind(wxEVT_BUTTON, [this](auto& e) { - EndModal(wxCLOSE); - }); + + StateColor btn_bg_green(std::pair(wxColour(27, 136, 68), StateColor::Pressed), std::pair(wxColour(0, 174, 66), StateColor::Normal)); + /* auto m_button_add = new Button(this, _L("Add substitute relationship")); + m_button_add->SetBackgroundColor(btn_bg_green); + m_button_add->SetBorderColor(wxColour(0, 174, 66)); + m_button_add->SetTextColor(wxColour(255, 255, 255)); + m_button_add->SetSize(wxSize(-1, FromDIP(24))); + m_button_add->SetMinSize(wxSize(-1, FromDIP(24))); + m_button_add->SetCornerRadius(FromDIP(12)); + + + m_button_add->Bind(wxEVT_BUTTON, [this](auto& e) { + EndModal(wxCLOSE); + });*/ m_button_sizer->Add( 0, 0, 1, wxEXPAND, 0 ); - m_button_sizer->Add(m_button_close, 0, wxALIGN_CENTER, 0); + //m_button_sizer->Add(m_button_add, 0, wxALIGN_CENTER, 0); - - m_groups_sizer = new wxBoxSizer(wxVERTICAL); m_main_sizer->Add(0,0,0, wxTOP, FromDIP(12)); - m_main_sizer->Add(m_groups_sizer,0,wxEXPAND|wxLEFT|wxRIGHT, FromDIP(16)); + m_main_sizer->Add(label_title,0, wxLEFT, FromDIP(30)); + m_main_sizer->Add(0,0,0, wxTOP, FromDIP(4)); + m_main_sizer->Add(label_txt,0, wxLEFT, FromDIP(30)); + m_main_sizer->Add(0,0,0, wxTOP, FromDIP(16)); + m_main_sizer->Add(m_groups_sizer,0, wxALIGN_CENTER, 0); m_main_sizer->Add(0,0,0, wxTOP, FromDIP(20)); - m_main_sizer->Add(m_button_sizer,0,wxEXPAND|wxLEFT|wxRIGHT, FromDIP(16)); + m_main_sizer->Add(m_button_sizer,0,wxALIGN_CENTER, FromDIP(16)); m_main_sizer->Add(0,0,0, wxTOP, FromDIP(20)); @@ -1233,19 +1248,18 @@ void AmsReplaceMaterialDialog::update_machine_obj(MachineObject* obj) for (int filam : m_obj->filam_bak) { auto status_list = GetStatus(filam); - wxColour group_color; + std::map group_info; std::string group_material; //get color & material for (auto i = 0; i < status_list.size(); i++) { if (status_list[i] && tray_list[i] != nullptr) { - group_color = AmsTray::decode_color(tray_list[i]->color); + group_info[wxGetApp().transition_tridid(i).ToStdString()] = AmsTray::decode_color(tray_list[i]->color); group_material = tray_list[i]->get_display_filament_type(); } } - m_groups_sizer->Add(create_split_line(wxString::Format("%s%d", _L("Group"), group_index), group_color, group_material, status_list), 0, wxEXPAND, 0); - m_groups_sizer->Add(0, 0, 0, wxTOP, FromDIP(12)); + m_groups_sizer->Add(create_backup_group(wxString::Format("%s%d", _L("Group"), group_index), group_info, group_material, status_list), 0, wxALL, FromDIP(10)); group_index++; } @@ -1253,92 +1267,10 @@ void AmsReplaceMaterialDialog::update_machine_obj(MachineObject* obj) Fit(); } -wxWindow* AmsReplaceMaterialDialog::create_split_line(wxString gname, wxColour col, wxString material, std::vector status_list) +AmsRMGroup* AmsReplaceMaterialDialog::create_backup_group(wxString gname, std::map group_info, wxString material, std::vector status_list) { - wxColour background_color = wxColour(0xF4F4F4); - - if (abs(col.Red() - background_color.Red()) <= 5 && - abs(col.Green() - background_color.Green()) <= 5 && - abs(col.Blue() - background_color.Blue()) <= 5) { - background_color = wxColour(0xE6E6E6); - } - - auto m_panel_group = new StaticBox(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE); - m_panel_group->SetCornerRadius(FromDIP(4)); - m_panel_group->SetBackgroundColor(StateColor(std::pair(background_color, StateColor::Normal))); - - m_panel_group->SetSize(wxSize(FromDIP(344), -1)); - m_panel_group->SetMinSize(wxSize(FromDIP(344), -1)); - m_panel_group->SetMaxSize(wxSize(FromDIP(344), -1)); - - wxBoxSizer* group_sizer = new wxBoxSizer(wxVERTICAL); - - //group title - wxBoxSizer* title_sizer = new wxBoxSizer(wxHORIZONTAL); - auto group_name = new Label(m_panel_group, gname); - group_name->SetFont(::Label::Head_12); - - Button* material_info = new Button(m_panel_group, material); - material_info->SetFont(Label::Head_12); - material_info->SetCornerRadius(FromDIP(2)); - material_info->SetBorderColor(background_color); - - if (col.GetLuminance() < 0.5) - material_info->SetTextColor(*wxWHITE); - else - material_info->SetTextColor(0x6B6B6B); - - material_info->SetMinSize(wxSize(-1, FromDIP(24))); - material_info->SetBackgroundColor(col); - - - title_sizer->Add(group_name, 0, wxALIGN_CENTER, 0); - title_sizer->Add(0, 0, 0, wxLEFT, FromDIP(10)); - title_sizer->Add(material_info, 0, wxALIGN_CENTER, 0); - - - //group item - wxGridSizer* grid_Sizer = new wxGridSizer(0, 8, 0, 0); - - for (int i = 0; i < status_list.size(); i++) { - if (status_list[i]) { - AmsRMItem* amsitem = new AmsRMItem(m_panel_group, wxID_ANY, wxDefaultPosition, wxDefaultSize); - amsitem->set_color(col); - - //set current tray - if (!m_obj->m_tray_now.empty() && m_obj->m_tray_now == std::to_string(i)) { - amsitem->set_focus(true); - } - - amsitem->set_type(RMTYPE_NORMAL); - amsitem->set_index(wxGetApp().transition_tridid(i).ToStdString()); - amsitem->SetBackgroundColour(background_color); - grid_Sizer->Add(amsitem, 0, wxALIGN_CENTER | wxTOP | wxBottom, FromDIP(10)); - } - } - - //add the first tray - for (int i = 0; i < status_list.size(); i++) { - if (status_list[i]) { - AmsRMItem* amsitem = new AmsRMItem(m_panel_group, wxID_ANY, wxDefaultPosition, wxDefaultSize); - amsitem->set_color(col); - amsitem->set_type(RMTYPE_VIRTUAL); - amsitem->set_index(wxGetApp().transition_tridid(i).ToStdString()); - amsitem->SetBackgroundColour(background_color); - grid_Sizer->Add(amsitem, 0, wxALIGN_CENTER | wxTOP | wxBottom, FromDIP(10)); - break; - } - } - - group_sizer->Add(0, 0, 0, wxTOP, FromDIP(10)); - group_sizer->Add(title_sizer, 0, wxEXPAND | wxLEFT | wxRIGHT, FromDIP(12)); - group_sizer->Add(grid_Sizer, 0, wxEXPAND | wxLEFT | wxRIGHT, FromDIP(12)); - group_sizer->Add(0, 0, 0, wxTOP, FromDIP(10)); - - m_panel_group->SetSizer(group_sizer); - m_panel_group->Layout(); - group_sizer->Fit(m_panel_group); - return m_panel_group; + auto grp = new AmsRMGroup(this, group_info, material, gname); + return grp; } void AmsReplaceMaterialDialog::paintEvent(wxPaintEvent& evt) @@ -1354,119 +1286,105 @@ void AmsReplaceMaterialDialog::on_dpi_changed(const wxRect& suggested_rect) } -AmsRMItem::AmsRMItem(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size) +AmsRMGroup::AmsRMGroup(wxWindow* parent, std::map group_info, wxString mname, wxString group_index) { - wxWindow::Create(parent, id, pos, size); + m_group_info.clear(); + m_group_info = group_info; + m_material_name = mname; + m_group_index = group_index; - SetSize(wxSize(FromDIP(42), FromDIP(32))); - SetMinSize(wxSize(FromDIP(42), FromDIP(32))); - SetMaxSize(wxSize(FromDIP(42), FromDIP(32))); + + /*m_group_info["A1"] = wxColour(255,0,255); + m_group_info["A2"] = wxColour(255,215,0); + m_group_info["A3"] = wxColour(0,191,255); + m_group_info["A4"] = wxColour(255,255,255); + m_group_info["A4"] = wxColour(218,165,32); + m_group_info["B1"] = wxColour(220, 20, 60); + m_group_info["B2"] = wxColour(255, 215, 0); + m_group_info["B3"] = wxColour(0, 191, 255); + m_group_info["B4"] = wxColour(218, 165, 32); + m_group_info["C1"] = wxColour(220, 20, 60); + m_group_info["C2"] = wxColour(255, 215, 0); + m_group_info["C3"] = wxColour(0, 191, 255); + m_group_info["C4"] = wxColour(218, 165, 32); + m_group_info["D1"] = wxColour(220, 20, 60); + m_group_info["D2"] = wxColour(255, 215, 0); + m_group_info["D3"] = wxColour(0, 191, 255);*/ - SetBackgroundColour(*wxWHITE); - - Bind(wxEVT_PAINT, &AmsRMItem::paintEvent, this); -} - -void AmsRMItem::paintEvent(wxPaintEvent& evt) -{ - wxPaintDC dc(this); - render(dc); -} - -void AmsRMItem::render(wxDC& dc) -{ -#ifdef __WXMSW__ - wxSize size = GetSize(); - wxMemoryDC memdc; - wxBitmap bmp(size.x, size.y); - memdc.SelectObject(bmp); - memdc.Blit({ 0, 0 }, size, &dc, { 0, 0 }); - - { - wxGCDC dc2(memdc); - doRender(dc2); - } - - memdc.SelectObject(wxNullBitmap); - dc.DrawBitmap(bmp, 0, 0); -#else - doRender(dc); -#endif -} - -void AmsRMItem::doRender(wxDC& dc) -{ - wxSize size = GetSize(); - - if (m_type == RMTYPE_NORMAL) { - dc.SetPen(wxPen(m_color, 2)); - dc.SetBrush(*wxTRANSPARENT_BRUSH); - } - else { - dc.SetPen(wxPen(m_color, 2, wxSHORT_DASH)); - dc.SetBrush(*wxTRANSPARENT_BRUSH); - } - - //top bottom line - dc.DrawLine(FromDIP(0), FromDIP(4), size.x - FromDIP(5), FromDIP(4)); - dc.DrawLine(FromDIP(0), size.y - FromDIP(4), size.x - FromDIP(5), size.y - FromDIP(4)); - - //left right line - dc.DrawLine(FromDIP(1), FromDIP(4), FromDIP(1), FromDIP(11)); - dc.DrawLine(FromDIP(1), FromDIP(22), FromDIP(1), size.y - FromDIP(4)); - - dc.DrawLine(size.x - FromDIP(5), FromDIP(4), size.x - FromDIP(5), FromDIP(11)); - dc.DrawLine(size.x - FromDIP(5), FromDIP(22), size.x - FromDIP(5), size.y - FromDIP(4)); - - //delta - dc.DrawLine(FromDIP(0), FromDIP(11), FromDIP(5), size.y / 2); - dc.DrawLine(FromDIP(0), FromDIP(22), FromDIP(5), size.y / 2); - - dc.DrawLine(size.x - FromDIP(5), FromDIP(11), size.x - FromDIP(1), size.y / 2); - dc.DrawLine(size.x - FromDIP(5), FromDIP(22), size.x - FromDIP(1), size.y / 2); - - - if (m_focus) { - dc.SetPen(wxPen(wxColour(0x00AE42), 2)); - dc.SetBrush(*wxTRANSPARENT_BRUSH); - dc.DrawLine(FromDIP(0), FromDIP(1), size.x - FromDIP(5), FromDIP(1)); - dc.DrawLine(FromDIP(0), size.y - FromDIP(1), size.x - FromDIP(5), size.y - FromDIP(1)); - } - - if (m_selected) { - } - - auto tsize = dc.GetMultiLineTextExtent(m_index); - auto tpot = wxPoint((size.x - tsize.x) / 2 - FromDIP(2), (size.y - tsize.y) / 2 + FromDIP(2)); - dc.SetTextForeground(wxColour(0x6B6B6B)); - dc.SetFont(::Label::Head_12); - dc.DrawText(m_index, tpot); -} - -AmsRMArrow::AmsRMArrow(wxWindow* parent) -{ wxWindow::Create(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize); + SetSize(wxSize(FromDIP(166), FromDIP(166))); + SetMinSize(wxSize(FromDIP(166), FromDIP(166))); + SetMaxSize(wxSize(FromDIP(166), FromDIP(166))); SetBackgroundColour(*wxWHITE); - Bind(wxEVT_PAINT, &AmsRMArrow::paintEvent, this); - m_bitmap_left = ScalableBitmap(this, "replace_arrow_left", 7); - m_bitmap_right = ScalableBitmap(this, "replace_arrow_right", 7); - m_bitmap_down = ScalableBitmap(this, "replace_arrow_down", 7); + backup_current_use_white = ScalableBitmap(this, "backup_current_use1",8); + backup_current_use_black = ScalableBitmap(this, "backup_current_use2", 8); + bitmap_backup_tips_0 = ScalableBitmap(this, "backup_tips_img", 90); + bitmap_editable = ScalableBitmap(this, "ams_editable", 14); + bitmap_bg = ScalableBitmap(this, "back_up_ts_bk", 162); + bitmap_editable_light = ScalableBitmap(this, "ams_editable_light", 14); - - SetSize(wxSize(FromDIP(16), FromDIP(32))); - SetMinSize(wxSize(FromDIP(16), FromDIP(32))); - SetMaxSize(wxSize(FromDIP(16), FromDIP(32))); + Bind(wxEVT_PAINT, &AmsRMGroup::paintEvent, this); + Bind(wxEVT_LEFT_DOWN, &AmsRMGroup::on_mouse_move, this); } -void AmsRMArrow::paintEvent(wxPaintEvent& evt) +double AmsRMGroup::GetAngle(wxPoint pointA, wxPoint pointB) +{ + double deltaX = pointA.x - pointB.x; + double deltaY = pointA.y - pointB.y; + double angle = atan2(deltaY, deltaX); + + angle = angle * 180.0 / M_PI; + + if (angle < 0) + angle += 360.0; + + return angle; +} + +void AmsRMGroup::on_mouse_move(wxMouseEvent& evt) +{ + wxSize size = GetSize(); + auto mouseX = evt.GetPosition().x; + auto mouseY = evt.GetPosition().y; + + auto click_angle = 360.0 - GetAngle(wxPoint(mouseX,mouseY), wxPoint(size.x / 2, size.x / 2)); + + + float ev_angle = 360.0 / m_group_info.size(); + float startAngle = 0.0; + float endAngle = 0.0; + + for (auto iter = m_group_info.rbegin(); iter != m_group_info.rend(); ++iter) { + std::string tray_name = iter->first; + wxColour tray_color = iter->second; + + int x = size.x / 2; + int y = size.y / 2; + int radius = size.x / 2; + endAngle += ev_angle; + + if (click_angle >= startAngle && click_angle < endAngle) { + //to do + set_index(tray_name); + Refresh(); + return; + } + + startAngle += ev_angle; + } + + evt.Skip(); +} + +void AmsRMGroup::paintEvent(wxPaintEvent& evt) { wxPaintDC dc(this); render(dc); } -void AmsRMArrow::render(wxDC& dc) +void AmsRMGroup::render(wxDC& dc) { #ifdef __WXMSW__ wxSize size = GetSize(); @@ -1487,17 +1405,121 @@ void AmsRMArrow::render(wxDC& dc) #endif } -void AmsRMArrow::doRender(wxDC& dc) +wxPoint AmsRMGroup::CalculateEndpoint(const wxPoint& startPoint, int angle, int length) +{ + int endX = startPoint.x + length * cos(angle * M_PI / 180); + int endY = startPoint.y + length * sin(angle * M_PI / 180); + return wxPoint(endX, endY); +} + +void AmsRMGroup::doRender(wxDC& dc) { wxSize size = GetSize(); + + float center_mask_radius = FromDIP(52); + float selected_radius = FromDIP(53); - dc.SetPen(wxPen(wxColour(0, 174, 66))); - dc.SetBrush(*wxTRANSPARENT_BRUSH); + float ev_angle = 360.0 / m_group_info.size(); + float startAngle = 0.0; + float endAngle = 0.0; + dc.DrawBitmap(bitmap_bg.bmp(), wxPoint((size.x - bitmap_bg.GetBmpSize().x) / 2, (size.y - bitmap_bg.GetBmpSize().y) / 2)); - dc.SetPen(wxPen(wxColour(0xACACAC))); - dc.SetBrush(wxBrush(wxColour(0xACACAC))); - dc.DrawCircle(size.x / 2, size.y / 2, FromDIP(7)); + for (auto iter = m_group_info.rbegin(); iter != m_group_info.rend(); ++iter) { + std::string tray_name = iter->first; + wxColour tray_color = iter->second; + + dc.SetPen(*wxTRANSPARENT_PEN); + + if (tray_color == *wxWHITE) dc.SetPen(wxPen(wxColour(0xEEEEEE), 2)); + dc.SetBrush(wxBrush(tray_color)); + + int x = size.x / 2; + int y = size.y / 2; + int radius = size.x / 2 - FromDIP(2); + endAngle += ev_angle; + + + //draw body + if (tray_color.Alpha() != 0) { + dc.DrawEllipticArc(x - radius, y - radius, radius * 2, radius * 2, startAngle, endAngle); + if (tray_color == *wxWHITE) dc.DrawEllipticArc(x - center_mask_radius, y - center_mask_radius, center_mask_radius * 2, center_mask_radius * 2, startAngle, endAngle); + } + + //draw selected + if (!m_selected_index.empty() && m_selected_index == tray_name) { + dc.SetPen(wxPen(0xCECECE, 2)); + dc.SetBrush(*wxTRANSPARENT_BRUSH); + dc.DrawEllipticArc(x - radius, y - radius, radius * 2, radius * 2, startAngle, endAngle); + dc.DrawEllipticArc(x - selected_radius, y - selected_radius,selected_radius * 2, selected_radius * 2, startAngle, endAngle); + } + + //... + startAngle += ev_angle; + } + + //draw text + startAngle = 0.0; + endAngle = 0.0; + for (auto iter = m_group_info.rbegin(); iter != m_group_info.rend(); ++iter) { + std::string tray_name = iter->first; + wxColour tray_color = iter->second; + + int x = size.x / 2; + int y = size.y / 2; + float radius = size.x / 2 - 15.0; + endAngle += ev_angle; + + float midAngle = (startAngle + endAngle) / 2; + float x_center = size.x / 2 + radius * cos(midAngle * M_PI / 180.0); + float y_center = size.y / 2 + radius * sin(midAngle * M_PI / 180.0); + + //draw tray + dc.SetFont(::Label::Body_12); + auto text_size = dc.GetTextExtent(tray_name); + dc.SetTextForeground(tray_color.GetLuminance() < 0.5 ? *wxWHITE : wxColour(0x262E30)); + dc.DrawText(tray_name, x_center - text_size.x / 2, size.y - y_center - text_size.y / 2); + + //draw split line + dc.SetPen(wxPen(*wxWHITE, 2)); + dc.SetBrush(*wxTRANSPARENT_BRUSH); + auto pos_sp_start = CalculateEndpoint(wxPoint(x, y), (360 - startAngle), size.x / 2 - FromDIP(3)); + dc.DrawLine(wxPoint(x, y), pos_sp_start); + + //draw current + //dc.DrawBitmap(backup_current_use_white.bmp(), x_center - text_size.x / 2 + FromDIP(3), size.y - y_center - text_size.y / 2 + FromDIP(11)); + //... + startAngle += ev_angle; + } + + //draw center mask + dc.SetPen(*wxTRANSPARENT_PEN); + dc.SetBrush(wxBrush(*wxWHITE)); + + int x = size.x / 2; + int y = size.y / 2; + dc.DrawEllipticArc(x - center_mask_radius, y - center_mask_radius, center_mask_radius * 2, center_mask_radius * 2, 0, 360); + + //draw center icon + dc.DrawBitmap(bitmap_backup_tips_0.bmp(), wxPoint((size.x - bitmap_backup_tips_0.GetBmpSize().x) / 2, (size.y - bitmap_backup_tips_0.GetBmpSize().y) / 2)); + //dc.DrawBitmap(bitmap_backup_tips_1.bmp(), wxPoint((size.x - bitmap_backup_tips_1.GetBmpSize().x) / 2, (size.y - bitmap_backup_tips_1.GetBmpSize().y) / 2)); + + //draw material + dc.SetTextForeground(wxColour(0x323A3D)); + dc.SetFont(Label::Head_15); + auto text_size = dc.GetTextExtent(m_material_name); + dc.DrawText(m_material_name, (size.x - text_size.x) / 2,(size.y - text_size.y) / 2 - FromDIP(12)); + + dc.SetFont(Label::Body_13); + text_size = dc.GetTextExtent(m_group_index); + dc.DrawText(m_group_index, (size.x - text_size.x) / 2, (size.y - text_size.y) / 2 + FromDIP(10)); + + /* if (wxGetApp().dark_mode()) { + dc.DrawBitmap(bitmap_editable_light.bmp(), wxPoint((size.x - bitmap_editable_light.GetBmpSize().x) / 2, (size.y - bitmap_editable_light.GetBmpSize().y) / 2 + FromDIP(15))); + } + else { + dc.DrawBitmap(bitmap_editable.bmp(), wxPoint((size.x - bitmap_editable_light.GetBmpSize().x) / 2, (size.y - bitmap_editable_light.GetBmpSize().y) / 2 + FromDIP(15))); + }*/ } }} // namespace Slic3r::GUI diff --git a/src/slic3r/GUI/AmsMappingPopup.hpp b/src/slic3r/GUI/AmsMappingPopup.hpp index ca4c720d5..d81552bfe 100644 --- a/src/slic3r/GUI/AmsMappingPopup.hpp +++ b/src/slic3r/GUI/AmsMappingPopup.hpp @@ -244,6 +244,35 @@ public: }; +class AmsRMGroup : public wxWindow +{ +public: + AmsRMGroup(wxWindow* parent, std::map group_info, wxString mname, wxString group_index); + ~AmsRMGroup() {}; + +public: + void set_index(std::string index) {m_selected_index = index;}; + void paintEvent(wxPaintEvent& evt); + void render(wxDC& dc); + void doRender(wxDC& dc); + void on_mouse_move(wxMouseEvent& evt); + + double GetAngle(wxPoint pointA, wxPoint pointB); + wxPoint CalculateEndpoint(const wxPoint& startPoint, int angle, int length); +private: + std::map m_group_info; + std::string m_selected_index; + ScalableBitmap backup_current_use_white; + ScalableBitmap backup_current_use_black; + ScalableBitmap bitmap_backup_tips_0; + ScalableBitmap bitmap_backup_tips_1; + ScalableBitmap bitmap_editable; + ScalableBitmap bitmap_bg; + ScalableBitmap bitmap_editable_light; + wxString m_material_name; + wxString m_group_index; +}; + class AmsReplaceMaterialDialog : public DPIDialog { public: @@ -251,68 +280,21 @@ public: ~AmsReplaceMaterialDialog() {}; public: - wxWindow* create_split_line(wxString gname, wxColour col, wxString material, std::vector status_list); + AmsRMGroup* create_backup_group(wxString gname, std::map group_info, wxString material, std::vector status_list); void create(); void update_machine_obj(MachineObject* obj); - void on_left_down(wxMouseEvent& evt); void paintEvent(wxPaintEvent& evt); - void on_dpi_changed(const wxRect &suggested_rect) override; + void on_dpi_changed(const wxRect& suggested_rect) override; std::vector GetStatus(unsigned int status); public: - wxBoxSizer* m_main_sizer{nullptr}; - wxBoxSizer* m_groups_sizer{nullptr}; + wxBoxSizer* m_main_sizer{ nullptr }; + wxWrapSizer* m_groups_sizer{ nullptr }; - MachineObject* m_obj{nullptr}; + MachineObject* m_obj{ nullptr }; }; -enum RMTYPE { - RMTYPE_NORMAL = 0, - RMTYPE_VIRTUAL = 1, -}; - -class AmsRMItem : public wxWindow -{ -public: - AmsRMItem(wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize); - ~AmsRMItem() {}; - -public: - void set_color(wxColour col) {m_color = col;}; - void set_type(RMTYPE type) {m_type = type;}; - void set_index(std::string index) {m_index = index;}; - void set_focus(bool focus) {m_focus = focus;}; - - void paintEvent(wxPaintEvent& evt); - void render(wxDC& dc); - void doRender(wxDC& dc); - -private: - RMTYPE m_type; - wxColour m_color; - std::string m_index; - bool m_focus = false; - bool m_selected = false; -}; - -class AmsRMArrow : public wxWindow -{ -public: - AmsRMArrow(wxWindow* parent); - ~AmsRMArrow() {}; - -public: - void paintEvent(wxPaintEvent& evt); - void render(wxDC& dc); - void doRender(wxDC& dc); - -private: - ScalableBitmap m_bitmap_left; - ScalableBitmap m_bitmap_right; - ScalableBitmap m_bitmap_down; -}; - wxDECLARE_EVENT(EVT_SET_FINISH_MAPPING, wxCommandEvent); }} // namespace Slic3r::GUI diff --git a/src/slic3r/GUI/SelectMachine.cpp b/src/slic3r/GUI/SelectMachine.cpp index 7f7577945..3a5606b78 100644 --- a/src/slic3r/GUI/SelectMachine.cpp +++ b/src/slic3r/GUI/SelectMachine.cpp @@ -1554,7 +1554,7 @@ void SelectMachineDialog::popup_filament_backup() { DeviceManager* dev = Slic3r::GUI::wxGetApp().getDeviceManager(); if (!dev) return; - if (dev->get_selected_machine() && dev->get_selected_machine()->filam_bak.size() > 0) { + if (dev->get_selected_machine()/* && dev->get_selected_machine()->filam_bak.size() > 0*/) { AmsReplaceMaterialDialog* m_replace_material_popup = new AmsReplaceMaterialDialog(this); m_replace_material_popup->update_machine_obj(dev->get_selected_machine()); m_replace_material_popup->ShowModal(); diff --git a/src/slic3r/GUI/StatusPanel.cpp b/src/slic3r/GUI/StatusPanel.cpp index 65b35af6d..7ca74727f 100644 --- a/src/slic3r/GUI/StatusPanel.cpp +++ b/src/slic3r/GUI/StatusPanel.cpp @@ -2842,7 +2842,7 @@ void StatusPanel::on_ams_unload(SimpleEvent &event) void StatusPanel::on_ams_filament_backup(SimpleEvent& event) { - if (obj && obj->filam_bak.size() > 0) { + if (obj /*&& obj->filam_bak.size() > 0*/) { AmsReplaceMaterialDialog* m_replace_material_popup = new AmsReplaceMaterialDialog(this); m_replace_material_popup->update_machine_obj(obj); m_replace_material_popup->ShowModal(); diff --git a/src/slic3r/GUI/Widgets/AMSControl.hpp b/src/slic3r/GUI/Widgets/AMSControl.hpp index 63e63929a..a8a811bed 100644 --- a/src/slic3r/GUI/Widgets/AMSControl.hpp +++ b/src/slic3r/GUI/Widgets/AMSControl.hpp @@ -13,6 +13,7 @@ #include #include +#define FILAMENT_BACKUP 1 #define AMS_CONTROL_BRAND_COLOUR wxColour(0, 174, 66) #define AMS_CONTROL_GRAY700 wxColour(107, 107, 107) #define AMS_CONTROL_GRAY800 wxColour(50, 58, 61)