From 92f4ba705ed075afcf0aec2ab9cc15ae1175b977 Mon Sep 17 00:00:00 2001 From: "chunmao.guo" Date: Wed, 25 Oct 2023 10:24:30 +0800 Subject: [PATCH] ENH: disable model download for P1s Change-Id: I6913f35015119adc8abfbd0a1f0e27c65f9d6c58 Jira: none --- resources/printers/BL-P001.json | 3 ++- resources/printers/BL-P002.json | 3 ++- resources/printers/C13.json | 3 ++- src/slic3r/GUI/DeviceManager.cpp | 1 + src/slic3r/GUI/DeviceManager.hpp | 1 + src/slic3r/GUI/ImageGrid.cpp | 8 +++++++- src/slic3r/GUI/ImageGrid.h | 3 +++ src/slic3r/GUI/MediaFilePanel.cpp | 14 +++++++++----- src/slic3r/GUI/MediaFilePanel.h | 2 +- 9 files changed, 28 insertions(+), 10 deletions(-) diff --git a/resources/printers/BL-P001.json b/resources/printers/BL-P001.json index 5a8653bc5..8584d6618 100644 --- a/resources/printers/BL-P001.json +++ b/resources/printers/BL-P001.json @@ -9,7 +9,8 @@ "remote": "enabled" }, "file": { - "remote": "enabled" + "remote": "enabled", + "model_download": "enabled" } }, "support_motor_noise_cali":false, diff --git a/resources/printers/BL-P002.json b/resources/printers/BL-P002.json index 1fd099499..4955fe450 100644 --- a/resources/printers/BL-P002.json +++ b/resources/printers/BL-P002.json @@ -9,7 +9,8 @@ "remote": "enabled" }, "file": { - "remote": "enabled" + "remote": "enabled", + "model_download": "enabled" } }, "support_motor_noise_cali":false, diff --git a/resources/printers/C13.json b/resources/printers/C13.json index 05997dc0e..02957cadd 100644 --- a/resources/printers/C13.json +++ b/resources/printers/C13.json @@ -9,7 +9,8 @@ "remote": "enabled" }, "file": { - "remote": "enabled" + "remote": "enabled", + "model_download": "enabled" } }, "support_motor_noise_cali":false, diff --git a/src/slic3r/GUI/DeviceManager.cpp b/src/slic3r/GUI/DeviceManager.cpp index 8777cdac9..14e8209ec 100644 --- a/src/slic3r/GUI/DeviceManager.cpp +++ b/src/slic3r/GUI/DeviceManager.cpp @@ -3512,6 +3512,7 @@ int MachineObject::parse_json(std::string payload) if (ipcam.contains("file")) { file_local = ipcam["file"].value("local", "disabled") == "enabled"; file_remote = ipcam["file"].value("remote", "disabled") == "enabled"; + file_model_download = ipcam["file"].value("model_download", "disabled") == "enabled"; } virtual_camera = ipcam.value("virtual_camera", "disabled") == "enabled"; if (ipcam.contains("rtsp_url")) { diff --git a/src/slic3r/GUI/DeviceManager.hpp b/src/slic3r/GUI/DeviceManager.hpp index 08e934734..0d68d90ed 100644 --- a/src/slic3r/GUI/DeviceManager.hpp +++ b/src/slic3r/GUI/DeviceManager.hpp @@ -689,6 +689,7 @@ public: bool liveview_remote{false}; bool file_local{false}; bool file_remote{false}; + bool file_model_download{false}; bool virtual_camera{false}; bool xcam_ai_monitoring{ false }; diff --git a/src/slic3r/GUI/ImageGrid.cpp b/src/slic3r/GUI/ImageGrid.cpp index 624c0539d..a4186bdae 100644 --- a/src/slic3r/GUI/ImageGrid.cpp +++ b/src/slic3r/GUI/ImageGrid.cpp @@ -122,6 +122,12 @@ void Slic3r::GUI::ImageGrid::SetSelecting(bool selecting) void Slic3r::GUI::ImageGrid::DoActionOnSelection(int action) { DoAction(-1, action); } +void Slic3r::GUI::ImageGrid::ShowDownload(bool show) +{ + m_show_download = show; + Refresh(); +} + void Slic3r::GUI::ImageGrid::Rescale() { m_title_mask = wxBitmap(); @@ -598,7 +604,7 @@ void Slic3r::GUI::ImageGrid::renderContent1(wxDC &dc, wxPoint const &pt, int ind // dc.GradientFillLinear({pt.x, pt.y, m_border_size.GetWidth(), 60}, wxColour(0x6F, 0x6F, 0x6F, 0x99), wxColour(0x6F, 0x6F, 0x6F, 0), wxBOTTOM); else if (m_file_sys->GetGroupMode() == PrinterFileSystem::G_NONE) { wxString nonHoverText; - wxString secondAction = _L("Download"); + wxString secondAction = m_show_download ? _L("Download") : ""; wxString thirdAction; int states = 0; // Draw download progress diff --git a/src/slic3r/GUI/ImageGrid.h b/src/slic3r/GUI/ImageGrid.h index 42cf8a06e..8bded4b1e 100644 --- a/src/slic3r/GUI/ImageGrid.h +++ b/src/slic3r/GUI/ImageGrid.h @@ -48,6 +48,8 @@ public: void DoActionOnSelection(int action); + void ShowDownload(bool show); + public: void Rescale(); @@ -126,6 +128,7 @@ private: // wxBitmap m_button_background; bool m_selecting = false; + bool m_show_download = false; enum HitType { HIT_NONE, diff --git a/src/slic3r/GUI/MediaFilePanel.cpp b/src/slic3r/GUI/MediaFilePanel.cpp index 66cd3a29d..dd68bd46b 100644 --- a/src/slic3r/GUI/MediaFilePanel.cpp +++ b/src/slic3r/GUI/MediaFilePanel.cpp @@ -202,23 +202,23 @@ void MediaFilePanel::SetMachineObject(MachineObject* obj) { std::string machine = obj ? obj->dev_id : ""; if (obj) { - m_supported = true; m_lan_mode = obj->is_lan_mode_printer(); m_lan_ip = obj->dev_ip; m_lan_passwd = obj->get_access_code(); m_dev_ver = obj->get_ota_version(); m_local_support = obj->file_local; m_remote_support = obj->file_remote; + m_model_download_support = obj->file_model_download; } else { - m_supported = false; m_lan_mode = false; m_lan_ip.clear(); m_lan_passwd.clear(); m_dev_ver.clear(); m_local_support = false; m_remote_support = false; + m_model_download_support = false; } - if (machine == m_machine) { + if (machine == m_machine && m_image_grid->GetFileSystem()) { if (m_waiting_enable && IsEnabled()) { auto fs = m_image_grid->GetFileSystem(); if (fs) fs->Retry(); @@ -237,7 +237,7 @@ void MediaFilePanel::SetMachineObject(MachineObject* obj) SetSelecting(false); if (m_machine.empty()) { m_image_grid->SetStatus(m_bmp_failed, _L("No printers.")); - } else if (!m_supported) { + } else if (!m_local_support && !m_remote_support) { m_image_grid->SetStatus(m_bmp_failed, _L("Initialize failed (Not supported on the current printer version)!")); } else { boost::shared_ptr fs(new PrinterFileSystem); @@ -252,6 +252,8 @@ void MediaFilePanel::SetMachineObject(MachineObject* obj) m_time_panel->Show(fs->GetFileType() < PrinterFileSystem::F_MODEL); //m_manage_panel->Show(fs->GetFileType() < PrinterFileSystem::F_MODEL); m_button_management->Enable(fs->GetCount() > 0); + bool download_support = fs->GetFileType() < PrinterFileSystem::F_MODEL || m_model_download_support; + m_image_grid->ShowDownload(download_support); if (fs->GetCount() == 0) SetSelecting(false); }); @@ -388,7 +390,9 @@ void MediaFilePanel::SetSelecting(bool selecting) { m_image_grid->SetSelecting(selecting); m_button_management->SetLabel(selecting ? _L("Cancel") : _L("Select")); - m_manage_panel->GetSizer()->Show(m_button_download, selecting); + auto fs = m_image_grid->GetFileSystem(); + bool download_support = fs && fs->GetFileType() < PrinterFileSystem::F_MODEL || m_model_download_support; + m_manage_panel->GetSizer()->Show(m_button_download, selecting && download_support); m_manage_panel->GetSizer()->Show(m_button_delete, selecting); m_manage_panel->Layout(); } diff --git a/src/slic3r/GUI/MediaFilePanel.h b/src/slic3r/GUI/MediaFilePanel.h index 2edd13949..8b9d84ae4 100644 --- a/src/slic3r/GUI/MediaFilePanel.h +++ b/src/slic3r/GUI/MediaFilePanel.h @@ -80,10 +80,10 @@ private: std::string m_lan_user; std::string m_lan_passwd; std::string m_dev_ver; - bool m_supported = false; bool m_lan_mode = false; bool m_local_support = false; bool m_remote_support = false; + bool m_model_download_support = false; bool m_waiting_enable = false; int m_last_mode = 0;