* fixed logic error in PLA jamming gcode for P1S
* Fix use after free bug in LinesBucketQueue::emplace_back_bucket
I found a use after free bug in LinesBucketQueue::emplace_back_bucket. This was found by enabling address sanitizer.
The LinesBucketQueue class has two related members:
std::vector<LinesBucket> line_buckets;
std::priority_queue<LinesBucket *, std::vector<LinesBucket *>, LinesBucketPtrComp> line_bucket_ptr_queue;
line_bucket_ptr_queue holds pointers into line_buckets. However, since items are inserted into line_buckets one at a time, existing pointers that were stored inside line_bucket_ptr_queue become invalid. Specifically:
void LinesBucketQueue::emplace_back_bucket(ExtrusionLayers &&els, const void *objPtr, Point offset)
{
auto oldSize = line_buckets.capacity();
line_buckets.emplace_back(std::move(els), objPtr, offset); <--- Causes a reallocation, making previous pointers invalid
line_bucket_ptr_queue.push(&line_buckets.back()); <-- priority queue compares against old, now invalid pointers
...
The proposed fix is to calculate the required number of entries in ConflictChecker::find_inter_of_lines_in_diff_objs, and then calling line_buckets.reserve(count). This ensures that sufficient buffer is allocated up front and the pointers are stable as items are added.
* Updated to fix the handling of the capacity change, and removed the code I previously added to reserve upfront since it is not really needed
* Remove accidentally added whitespace
* Removed unused method
* ENH:add mz_zip_reader_extract_to_file_w api
to solove plugin install failed problem by special wide char
jira: none
Change-Id: Ic7d3efe3fdf852387650abf9df65803da9e46a60
(cherry picked from commit b68ad03717a63675fef2f3ef73d4058bf311adea)
* FIX: PrinterFileSystem report real connect error
Change-Id: I99d6ff7f6dcb1f53ccf59854f5f19d0bd39fa9fc
Jira: none
* rename preference name
* FIX:Relax restrictions on importing obj files
jira: none
Change-Id: I61a0156a8424a5f59922956918d37d38e2c3306a
* FIX: [6469] popup dialog too mach when reload object
Jira: 6469
Change-Id: I4097e3a3b018c7a676fea93bf63f8f778bb3148b
* FIX:fixed incorrect display of printer options page on Linux
jira:[STUDIO-6220]
Change-Id: Id1f084658b0b340b7f17ab97ba82c0fd3ae83fae
* FIX: handle exception of dividing by zero in arranging
jira: none
Change-Id: I0d20464dbe81a80293539100f06d72dee456a27b
(cherry picked from commit 94746ae9bf7f467243849570450567b4fdc78e3a)
* ENH:delete no use code
jira: none
Change-Id: I40e7ffa7ea47bb3cd4039eef9f6c28c604eb3abc
* FIX: PrinterFileSystem::FileRemoved
Change-Id: I891aaa8d58ff379dc1ebd8581064865a33388f74
* FIX: resend ttcode to printer on -90 error
Change-Id: I96dc45102a2759a9f1a0002f42c3a91b2c6b2d75
Jira: STUDIO-5947
(cherry picked from commit 97d687b7c88f8cd51b8eddd39120349d8eac42b1)
* FIX: fix some issue in multi machine
JIRA: STUDIO-6934 STUDIO-6888
1. Fix the issue of incomplete display caused by excessively long file names
2. Fix the issue of icon display being too large
3. Fix the issue of garbled Chinese characters in the task list
Change-Id: I36bc10bf2067f44aaa7e3651b58e526ea323c8ad
* FIX: Incorrect multiplier, when the multiplier is set to below 1
github: #3987 #3805
1. In some languages that use commas as decimal points, setting multiplier below 1 will resolve to 0
2. Unable to save multiplier correctly
Change-Id: I62bc55e270929ebb5e910eb79c6f97106e842b93
* Arrange
* FIX: wrong wipe tower when open 3mf file
1.wipe tower pos in 3mf was overwritten by default pos when opening 3mf
with a different printer profile.This patch fix it
jira: STUDIO-5890
Signed-off-by: xun.zhang <xun.zhang@bambulab.com>
Change-Id: I12e5d4b80a0ad86194db0682c1763ba4a9492521
* ENH: update A1 machine gcode
1.Adjust the y position of the A1 extrusion compensation line
jira:NEW
Signed-off-by: xun.zhang <xun.zhang@bambulab.com>
Change-Id: Iea690a0184ae10a47f53e1532272c31fc0a04cfa
* FIX: minor spelling mistake in gcode
github:#3477
Signed-off-by: xun.zhang <xun.zhang@bambulab.com>
Change-Id: Id3201bf8b8125ce060e2cac102ab2525877e27c1
* FIX: slice crash with height_range
github: 3917
Change-Id: Icdf83013213b47935b7a795ed75cc3d49057665d
* FIX: ERROR_RES_BUSY text
Change-Id: Ifde1a7b0c6ab915eb226c2072c46edd40f60cf9a
Jira: STUDIO-6436
* ENH:Unable to send printing without selecting a device
jira:[STUDIO-6850]
Change-Id: Ic537579727fd1618af364db93fce8fbbe4cd635a
* FIX:add exit_gizmo before slice model
jira: STUDIO-5531
Change-Id: Icddc9d73b3d91bb68e9768d13e48cbae0680e58e
* FIX: PrinterFileSystem report real connect error
Change-Id: Id6750cfa2a98fe8325ba677dabb606a0a701b495
* FIX: add can slice judgement in slice all plates processing
jira: STUDIO-6325
Change-Id: Ic7fb8cef000c03210bb77289a570ee6b60b6083e
* FIX:Fixed error in displaying the name of Bambu filaments
Change-Id: Ib42194c07b6eefe793eec81a588debc9d622d951
* FIX: text hidden in calibration tab
jira: STUDIO-6264
Change-Id: I24fbc590638a3213d948a973422e010486113923
* FIX: logic error in PLA fan control
github PR: #3948
Signed-off-by: xun.zhang <xun.zhang@bambulab.com>
Change-Id: I28e4a673e590e83d151e92cc82caab45012aeabe
* FIX:upgrade cluster algorithm to remove duplicate labels
jira: none
Change-Id: I4d68d8cd8e080932c7c308bc8f69e27546ffe309
* FIX: can not parse json float in ES on macOS
jira: STUDIO-5889
Change-Id: I622f4b474c378d77b0e43d67a320f023be2d5811
* ENH:Clear the value of the previous nozzle type
jira:[for nozzle check]
Change-Id: I9a932b833fb07de6cb0a91abe6372b0e91f273f1
* ENH: update A1 gcode
1.Modify the width of extrusion compensation line
jira:NEW
Signed-off-by: xun.zhang <xun.zhang@bambulab.com>
Change-Id: I90543758c866d74f2154e3135d7569109def84b8
* FIX: the height range is not valid in assemble object
github: 3876
Change-Id: Id38672bbf0c01bc9b9f0a3e2bf1052d945b45131
* FIX: calibration page text hidden in linux
jira: STUDIO-6264
Change-Id: If210abf64057eb2e9c2c5b11d41fa33f18684c72
* ENH:clear nozzle information
jira:[STUDIO-7050]
Change-Id: I15ca4973d09132ddb5cb5a56bedd795ba6976b27
* update plugin version
---------
Signed-off-by: xun.zhang <xun.zhang@bambulab.com>
Co-authored-by: afriede <me@afriede.dev>
Co-authored-by: Momin Al-Ghosien <momin@sanestudios.com>
Co-authored-by: zhou.xu <zhou.xu@bambulab.com>
Co-authored-by: chunmao.guo <chunmao.guo@bambulab.com>
Co-authored-by: maosheng.wei <maosheng.wei@bambulab.com>
Co-authored-by: tao wang <tao.wang@bambulab.com>
Co-authored-by: Arthur <arthur.tang@bambulab.com>
Co-authored-by: Kunlong Ma <kunlong.ma@bambulab.com>
Co-authored-by: xun.zhang <xun.zhang@bambulab.com>
Co-authored-by: zhimin.zeng <zhimin.zeng@bambulab.com>
Co-authored-by: liz.li <liz.li@bambulab.com>
497 lines
14 KiB
C++
497 lines
14 KiB
C++
#include "MultiMachinePage.hpp"
|
|
#include "GUI_App.hpp"
|
|
#include "MainFrame.hpp"
|
|
|
|
namespace Slic3r {
|
|
namespace GUI {
|
|
|
|
|
|
MultiMachinePage::MultiMachinePage(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style)
|
|
: wxPanel(parent, id, pos, size, style)
|
|
{
|
|
init_tabpanel();
|
|
m_main_sizer = new wxBoxSizer(wxHORIZONTAL);
|
|
m_main_sizer->Add(m_tabpanel, 1, wxEXPAND | wxLEFT, 0);
|
|
SetSizerAndFit(m_main_sizer);
|
|
Layout();
|
|
Fit();
|
|
|
|
wxGetApp().UpdateDarkUIWin(this);
|
|
|
|
init_timer();
|
|
Bind(wxEVT_TIMER, &MultiMachinePage::on_timer, this);
|
|
}
|
|
|
|
MultiMachinePage::~MultiMachinePage()
|
|
{
|
|
if (m_refresh_timer)
|
|
m_refresh_timer->Stop();
|
|
delete m_refresh_timer;
|
|
}
|
|
|
|
void MultiMachinePage::jump_to_send_page()
|
|
{
|
|
m_tabpanel->SetSelection(1);
|
|
}
|
|
|
|
void MultiMachinePage::on_sys_color_changed()
|
|
{
|
|
}
|
|
|
|
void MultiMachinePage::msw_rescale()
|
|
{
|
|
m_tabpanel->Rescale();
|
|
if (m_local_task_manager)
|
|
m_local_task_manager->msw_rescale();
|
|
if (m_cloud_task_manager)
|
|
m_cloud_task_manager->msw_rescale();
|
|
if (m_machine_manager)
|
|
m_machine_manager->msw_rescale();
|
|
|
|
this->Fit();
|
|
this->Layout();
|
|
this->Refresh();
|
|
}
|
|
|
|
bool MultiMachinePage::Show(bool show)
|
|
{
|
|
if (show) {
|
|
m_refresh_timer->Stop();
|
|
m_refresh_timer->SetOwner(this);
|
|
m_refresh_timer->Start(2000);
|
|
wxPostEvent(this, wxTimerEvent());
|
|
}
|
|
else {
|
|
m_refresh_timer->Stop();
|
|
}
|
|
|
|
auto page = m_tabpanel->GetCurrentPage();
|
|
if (page)
|
|
page->Show(show);
|
|
return wxPanel::Show(show);
|
|
}
|
|
|
|
void MultiMachinePage::init_tabpanel()
|
|
{
|
|
auto m_side_tools = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(FromDIP(220), FromDIP(18)));
|
|
wxBoxSizer* sizer_side_tools = new wxBoxSizer(wxHORIZONTAL);
|
|
sizer_side_tools->Add(m_side_tools, 1, wxEXPAND, 0);
|
|
m_tabpanel = new Tabbook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, sizer_side_tools, wxNB_LEFT | wxTAB_TRAVERSAL | wxNB_NOPAGETHEME);
|
|
m_tabpanel->SetBackgroundColour(wxColour("#FEFFFF"));
|
|
m_tabpanel->Bind(wxEVT_BOOKCTRL_PAGE_CHANGED, [this](wxBookCtrlEvent& e) {; });
|
|
|
|
m_local_task_manager = new LocalTaskManagerPage(m_tabpanel);
|
|
m_cloud_task_manager = new CloudTaskManagerPage(m_tabpanel);
|
|
m_machine_manager = new MultiMachineManagerPage(m_tabpanel);
|
|
|
|
m_tabpanel->AddPage(m_machine_manager, _L("Device"), "", true);
|
|
m_tabpanel->AddPage(m_local_task_manager, _L("Task Sending"), "", false);
|
|
m_tabpanel->AddPage(m_cloud_task_manager, _L("Task Sent"), "", false);
|
|
}
|
|
|
|
void MultiMachinePage::init_timer()
|
|
{
|
|
m_refresh_timer = new wxTimer();
|
|
//m_refresh_timer->SetOwner(this);
|
|
//m_refresh_timer->Start(8000);
|
|
//wxPostEvent(this, wxTimerEvent());
|
|
}
|
|
|
|
void MultiMachinePage::on_timer(wxTimerEvent& event)
|
|
{
|
|
m_local_task_manager->update_page();
|
|
m_cloud_task_manager->update_page();
|
|
m_machine_manager->update_page();
|
|
}
|
|
|
|
void MultiMachinePage::clear_page()
|
|
{
|
|
m_local_task_manager->refresh_user_device(true);
|
|
m_cloud_task_manager->refresh_user_device(true);
|
|
m_machine_manager->refresh_user_device(true);
|
|
}
|
|
|
|
DevicePickItem::DevicePickItem(wxWindow* parent, MachineObject* obj)
|
|
: DeviceItem(parent, obj)
|
|
{
|
|
SetBackgroundColour(*wxWHITE);
|
|
m_bitmap_check_disable = ScalableBitmap(this, "check_off_disabled", 18);
|
|
m_bitmap_check_off = ScalableBitmap(this, "check_off_focused", 18);
|
|
m_bitmap_check_on = ScalableBitmap(this, "check_on", 18);
|
|
|
|
|
|
SetMinSize(wxSize(FromDIP(400), FromDIP(30)));
|
|
SetMaxSize(wxSize(FromDIP(400), FromDIP(30)));
|
|
|
|
Bind(wxEVT_PAINT, &DevicePickItem::paintEvent, this);
|
|
Bind(wxEVT_ENTER_WINDOW, &DevicePickItem::OnEnterWindow, this);
|
|
Bind(wxEVT_LEAVE_WINDOW, &DevicePickItem::OnLeaveWindow, this);
|
|
Bind(wxEVT_LEFT_DOWN, &DevicePickItem::OnLeftDown, this);
|
|
Bind(wxEVT_MOTION, &DevicePickItem::OnMove, this);
|
|
Bind(EVT_MULTI_DEVICE_SELECTED, &DevicePickItem::OnSelectedDevice, this);
|
|
wxGetApp().UpdateDarkUIWin(this);
|
|
}
|
|
|
|
void DevicePickItem::DrawTextWithEllipsis(wxDC& dc, const wxString& text, int maxWidth, int left, int top /*= 0*/)
|
|
{
|
|
wxSize size = GetSize();
|
|
wxFont font = dc.GetFont();
|
|
|
|
wxSize textSize = dc.GetTextExtent(text);
|
|
dc.SetTextForeground(StateColor::darkModeColorFor(wxColour(50, 58, 61)));
|
|
int textWidth = textSize.GetWidth();
|
|
|
|
if (textWidth > maxWidth) {
|
|
wxString truncatedText = text;
|
|
int ellipsisWidth = dc.GetTextExtent("...").GetWidth();
|
|
int numChars = text.length();
|
|
|
|
for (int i = numChars - 1; i >= 0; --i) {
|
|
truncatedText = text.substr(0, i) + "...";
|
|
int truncatedWidth = dc.GetTextExtent(truncatedText).GetWidth();
|
|
|
|
if (truncatedWidth <= maxWidth - ellipsisWidth) {
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (top == 0) {
|
|
dc.DrawText(truncatedText, left, (size.y - textSize.y) / 2);
|
|
}
|
|
else {
|
|
dc.DrawText(truncatedText, left, (size.y - textSize.y) / 2 - top);
|
|
}
|
|
|
|
}
|
|
else {
|
|
if (top == 0) {
|
|
dc.DrawText(text, left, (size.y - textSize.y) / 2);
|
|
}
|
|
else {
|
|
dc.DrawText(text, left, (size.y - textSize.y) / 2 - top);
|
|
}
|
|
}
|
|
}
|
|
|
|
void DevicePickItem::OnEnterWindow(wxMouseEvent& evt)
|
|
{
|
|
m_hover = true;
|
|
Refresh(false);
|
|
}
|
|
|
|
void DevicePickItem::OnLeaveWindow(wxMouseEvent& evt)
|
|
{
|
|
m_hover = false;
|
|
Refresh(false);
|
|
}
|
|
|
|
void DevicePickItem::OnSelectedDevice(wxCommandEvent& evt)
|
|
{
|
|
auto dev_id = evt.GetString();
|
|
auto state = evt.GetInt();
|
|
if (state == 0) {
|
|
state_selected = 1;
|
|
}
|
|
else if (state == 1) {
|
|
state_selected = 0;
|
|
}
|
|
Refresh(false);
|
|
evt.Skip();
|
|
|
|
post_event(wxCommandEvent(EVT_MULTI_DEVICE_SELECTED_FINHSH));
|
|
}
|
|
|
|
void DevicePickItem::OnLeftDown(wxMouseEvent& evt)
|
|
{
|
|
int left = FromDIP(15);
|
|
auto mouse_pos = ClientToScreen(evt.GetPosition());
|
|
auto item = this->ClientToScreen(wxPoint(0, 0));
|
|
|
|
if (mouse_pos.x > (item.x + left) &&
|
|
mouse_pos.x < (item.x + left + m_bitmap_check_disable.GetBmpWidth()) &&
|
|
mouse_pos.y > item.y &&
|
|
mouse_pos.y < (item.y + DEVICE_ITEM_MAX_HEIGHT)) {
|
|
|
|
post_event(wxCommandEvent(EVT_MULTI_DEVICE_SELECTED));
|
|
}
|
|
}
|
|
|
|
void DevicePickItem::OnMove(wxMouseEvent& evt)
|
|
{
|
|
int left = FromDIP(15);
|
|
auto mouse_pos = ClientToScreen(evt.GetPosition());
|
|
auto item = this->ClientToScreen(wxPoint(0, 0));
|
|
|
|
if (mouse_pos.x > (item.x + left) &&
|
|
mouse_pos.x < (item.x + left + m_bitmap_check_disable.GetBmpWidth()) &&
|
|
mouse_pos.y > item.y &&
|
|
mouse_pos.y < (item.y + DEVICE_ITEM_MAX_HEIGHT)) {
|
|
SetCursor(wxCURSOR_HAND);
|
|
}
|
|
else {
|
|
SetCursor(wxCURSOR_ARROW);
|
|
}
|
|
}
|
|
|
|
void DevicePickItem::paintEvent(wxPaintEvent& evt)
|
|
{
|
|
wxPaintDC dc(this);
|
|
render(dc);
|
|
}
|
|
|
|
void DevicePickItem::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 DevicePickItem::doRender(wxDC& dc)
|
|
{
|
|
wxSize size = GetSize();
|
|
dc.SetPen(wxPen(*wxBLACK));
|
|
|
|
int left = FromDIP(PICK_LEFT_PADDING_LEFT);
|
|
|
|
|
|
//checkbox
|
|
if (state_selected == 0) {
|
|
dc.DrawBitmap(m_bitmap_check_off.bmp(), wxPoint(left, (size.y - m_bitmap_check_disable.GetBmpSize().y) / 2));
|
|
}
|
|
else if (state_selected == 1) {
|
|
dc.DrawBitmap(m_bitmap_check_on.bmp(), wxPoint(left, (size.y - m_bitmap_check_disable.GetBmpSize().y) / 2));
|
|
}
|
|
|
|
left += FromDIP(PICK_LEFT_PRINTABLE);
|
|
|
|
//dev names
|
|
DrawTextWithEllipsis(dc, wxString::FromUTF8(get_obj()->dev_name), FromDIP(PICK_LEFT_DEV_NAME), left);
|
|
left += FromDIP(PICK_LEFT_DEV_NAME);
|
|
}
|
|
void DevicePickItem::post_event(wxCommandEvent&& event)
|
|
{
|
|
event.SetEventObject(this);
|
|
event.SetString(obj_->dev_id);
|
|
event.SetInt(state_selected);
|
|
wxPostEvent(this, event);
|
|
}
|
|
|
|
void DevicePickItem::DoSetSize(int x, int y, int width, int height, int sizeFlags /*= wxSIZE_AUTO*/)
|
|
{
|
|
wxWindow::DoSetSize(x, y, width, height, sizeFlags);
|
|
}
|
|
|
|
MultiMachinePickPage::MultiMachinePickPage(Plater* plater /*= nullptr*/)
|
|
: DPIDialog(static_cast<wxWindow*>(wxGetApp().mainframe), wxID_ANY,
|
|
_L("Edit multiple printers"),
|
|
wxDefaultPosition, wxDefaultSize, wxCAPTION | wxCLOSE_BOX | wxRESIZE_BORDER)
|
|
{
|
|
#ifdef __WINDOWS__
|
|
SetDoubleBuffered(true);
|
|
#endif //__WINDOWS__
|
|
|
|
app_config = get_app_config();
|
|
|
|
SetBackgroundColour(*wxWHITE);
|
|
// icon
|
|
std::string icon_path = (boost::format("%1%/images/OrcaSlicerTitle.ico") % resources_dir()).str();
|
|
SetIcon(wxIcon(encode_path(icon_path.c_str()), wxBITMAP_TYPE_ICO));
|
|
|
|
wxBoxSizer* main_sizer = new wxBoxSizer(wxVERTICAL);
|
|
|
|
auto line_top = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(-1, 1), wxTAB_TRAVERSAL);
|
|
line_top->SetBackgroundColour(wxColour(166, 169, 170));
|
|
|
|
m_label = new Label(this, _L("Select connected printetrs (0/6)"));
|
|
|
|
scroll_macine_list = new wxScrolledWindow(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxVSCROLL);
|
|
scroll_macine_list->SetSize(wxSize(FromDIP(400), FromDIP(10 * 30)));
|
|
scroll_macine_list->SetMinSize(wxSize(FromDIP(400), FromDIP(10 * 30)));
|
|
scroll_macine_list->SetMaxSize(wxSize(FromDIP(400), FromDIP(10 * 30)));
|
|
scroll_macine_list->SetBackgroundColour(*wxWHITE);
|
|
scroll_macine_list->SetScrollRate(0, 5);
|
|
|
|
sizer_machine_list = new wxBoxSizer(wxVERTICAL);
|
|
scroll_macine_list->SetSizer(sizer_machine_list);
|
|
scroll_macine_list->Layout();
|
|
|
|
main_sizer->Add(line_top, 0, wxEXPAND, 0);
|
|
main_sizer->AddSpacer(FromDIP(10));
|
|
main_sizer->Add(m_label, 0, wxLEFT, FromDIP(20));
|
|
main_sizer->Add(scroll_macine_list, 0, wxLEFT|wxRIGHT, FromDIP(20));
|
|
main_sizer->AddSpacer(FromDIP(10));
|
|
|
|
SetSizer(main_sizer);
|
|
Layout();
|
|
Fit();
|
|
Centre(wxBOTH);
|
|
|
|
wxGetApp().UpdateDlgDarkUI(this);
|
|
}
|
|
|
|
MultiMachinePickPage::~MultiMachinePickPage()
|
|
{
|
|
|
|
}
|
|
|
|
int MultiMachinePickPage::get_selected_count()
|
|
{
|
|
int count = 0;
|
|
for (auto it = m_device_items.begin(); it != m_device_items.end(); it++) {
|
|
if (it->second->state_selected == 1) {
|
|
count++;
|
|
}
|
|
}
|
|
return count;
|
|
}
|
|
|
|
void MultiMachinePickPage::update_selected_count()
|
|
{
|
|
std::vector<std::string> selected_multi_devices;
|
|
|
|
int count = 0;
|
|
for (auto it = m_device_items.begin(); it != m_device_items.end(); it++) {
|
|
if (it->second->state_selected == 1 ) {
|
|
selected_multi_devices.push_back(it->second->obj_->dev_id);
|
|
count++;
|
|
}
|
|
}
|
|
|
|
m_selected_count = count;
|
|
m_label->SetLabel(wxString::Format(_L("Select Connected Printetrs (%d/6)"), m_selected_count));
|
|
|
|
if (m_selected_count > PICK_DEVICE_MAX) {
|
|
MessageDialog msg_wingow(nullptr, wxString::Format(_L("The maximum number of printers that can be selected is %d"), PICK_DEVICE_MAX), "", wxAPPLY | wxOK);
|
|
if (msg_wingow.ShowModal() == wxOK) {
|
|
return;
|
|
}
|
|
}
|
|
|
|
for (int i = 0; i < PICK_DEVICE_MAX; i++) {
|
|
app_config->erase("multi_devices",std::to_string(i));
|
|
}
|
|
|
|
for (int j = 0; j < selected_multi_devices.size(); j++) {
|
|
app_config->set_str("multi_devices", std::to_string(j), selected_multi_devices[j]);
|
|
}
|
|
app_config->save();
|
|
}
|
|
|
|
void MultiMachinePickPage::on_dpi_changed(const wxRect& suggested_rect)
|
|
{
|
|
|
|
}
|
|
|
|
void MultiMachinePickPage::on_sys_color_changed()
|
|
{
|
|
|
|
}
|
|
|
|
void MultiMachinePickPage::refresh_user_device()
|
|
{
|
|
std::vector<std::string> selected_multi_devices;
|
|
|
|
for(int i = 0; i < PICK_DEVICE_MAX; i++){
|
|
auto dev_id = app_config->get("multi_devices", std::to_string(i));
|
|
selected_multi_devices.push_back(dev_id);
|
|
}
|
|
|
|
sizer_machine_list->Clear(false);
|
|
Slic3r::DeviceManager* dev = Slic3r::GUI::wxGetApp().getDeviceManager();
|
|
if (!dev) {
|
|
for (auto it = m_device_items.begin(); it != m_device_items.end(); it++) {
|
|
wxWindow* child = it->second;
|
|
child->Destroy();
|
|
}
|
|
return;
|
|
}
|
|
|
|
auto user_machine = dev->get_my_cloud_machine_list();
|
|
auto task_manager = wxGetApp().getTaskManager();
|
|
|
|
std::vector<std::string> subscribe_list;
|
|
|
|
for (auto it = user_machine.begin(); it != user_machine.end(); ++it) {
|
|
DevicePickItem* di = new DevicePickItem(scroll_macine_list, it->second);
|
|
|
|
di->Bind(EVT_MULTI_DEVICE_SELECTED_FINHSH, [this, di](auto& e) {
|
|
int count = get_selected_count();
|
|
if (count > PICK_DEVICE_MAX) {
|
|
di->unselected();
|
|
return;
|
|
}
|
|
update_selected_count();
|
|
});
|
|
|
|
/* if (m_device_items.find(it->first) != m_device_items.end()) {
|
|
auto item = m_device_items[it->first];
|
|
if (item->state_selected == 1 && di->state_printable <= 2)
|
|
di->state_selected = item->state_selected;
|
|
item->Destroy();
|
|
}*/
|
|
m_device_items[it->first] = di;
|
|
|
|
//update state
|
|
if (task_manager) {
|
|
m_device_items[it->first]->state_local_task = task_manager->query_task_state(it->first);
|
|
}
|
|
|
|
//update selected
|
|
auto dev_it = std::find(selected_multi_devices.begin(), selected_multi_devices.end(), it->second->dev_id );
|
|
if (dev_it != selected_multi_devices.end()) {
|
|
di->state_selected = 1;
|
|
}
|
|
|
|
sizer_machine_list->Add(di, 0, wxALL | wxEXPAND, 0);
|
|
subscribe_list.push_back(it->first);
|
|
}
|
|
|
|
dev->subscribe_device_list(subscribe_list);
|
|
|
|
sizer_machine_list->Layout();
|
|
Layout();
|
|
Fit();
|
|
}
|
|
|
|
void MultiMachinePickPage::on_confirm(wxCommandEvent& event)
|
|
{
|
|
|
|
}
|
|
|
|
bool MultiMachinePickPage::Show(bool show)
|
|
{
|
|
if (show) {
|
|
refresh_user_device();
|
|
update_selected_count();
|
|
//m_refresh_timer->Stop();
|
|
//m_refresh_timer->SetOwner(this);
|
|
//m_refresh_timer->Start(4000);
|
|
//wxPostEvent(this, wxTimerEvent());
|
|
}
|
|
else {
|
|
//m_refresh_timer->Stop();
|
|
Slic3r::DeviceManager* dev = Slic3r::GUI::wxGetApp().getDeviceManager();
|
|
if (dev) {
|
|
dev->subscribe_device_list(std::vector<std::string>());
|
|
}
|
|
}
|
|
return wxDialog::Show(show);
|
|
}
|
|
|
|
} // namespace GUI
|
|
} // namespace Slic3r
|