ENH:Optimization of File Transfer System Part2

jira: [STUDIO-11777]

Change-Id: I12744db7d2e3b53425454d632533768c54524677
This commit is contained in:
milk 2025-04-27 15:30:43 +08:00 committed by lane.wei
parent aa52c99076
commit 4358e9ce35
10 changed files with 263 additions and 97 deletions

View File

@ -8,6 +8,8 @@ set(SLIC3R_GUI_SOURCES
pchheader.hpp pchheader.hpp
GUI/Printer/PrinterFileSystem.cpp GUI/Printer/PrinterFileSystem.cpp
GUI/Printer/PrinterFileSystem.h GUI/Printer/PrinterFileSystem.h
GUI/Widgets/AnimaController.hpp
GUI/Widgets/AnimaController.cpp
GUI/Widgets/AxisCtrlButton.cpp GUI/Widgets/AxisCtrlButton.cpp
GUI/Widgets/AxisCtrlButton.hpp GUI/Widgets/AxisCtrlButton.hpp
GUI/Widgets/Button.cpp GUI/Widgets/Button.cpp

View File

@ -1083,7 +1083,7 @@ public:
bool is_support_filament_setting_inprinting{false}; bool is_support_filament_setting_inprinting{false};
bool is_support_internal_timelapse { false };// fun[28], support timelapse without SD card bool is_support_internal_timelapse { false };// fun[28], support timelapse without SD card
bool is_support_command_homing { false };// fun[32] bool is_support_command_homing { false };// fun[32]
bool is_support_brtc { false }; // fun[31], support tcp and upload protocol bool is_support_brtc{false}; // fun[31], support tcp and upload protocol
bool installed_upgrade_kit{false}; bool installed_upgrade_kit{false};
int bed_temperature_limit = -1; int bed_temperature_limit = -1;

View File

@ -37,6 +37,8 @@ enum PrintDialogStatus : unsigned int {
PrintStatusConnectingServer, PrintStatusConnectingServer,
PrintStatusReadingTimeout, PrintStatusReadingTimeout,
PrintStatusReading, PrintStatusReading,
PrintStatusConnecting,
PrintStatusReconnecting,
PrintStatusInUpgrading, PrintStatusInUpgrading,
PrintStatusModeNotFDM, PrintStatusModeNotFDM,
PrintStatusInSystemPrinting, PrintStatusInSystemPrinting,

View File

@ -1541,9 +1541,9 @@ void PrinterFileSystem::Reconnect(boost::unique_lock<boost::mutex> &l, int resul
while (m_stopped) { while (m_stopped) {
if (m_session.owner == nullptr) if (m_session.owner == nullptr)
return; return;
m_status = Status::Stopped; m_status = Status::Reconnecting;
SendChangedEvent(EVT_STATUS_CHANGED, m_status); SendChangedEvent(EVT_STATUS_CHANGED, m_status);
m_cond.wait(l); m_cond.wait(l);
} }
wxLogMessage("PrinterFileSystem::Reconnect Initializing"); wxLogMessage("PrinterFileSystem::Reconnect Initializing");
m_status = Status::Initializing; m_status = Status::Initializing;

View File

@ -215,7 +215,7 @@ public:
ListSyncing, ListSyncing,
ListReady, ListReady,
Failed, Failed,
Stopped, Reconnecting,
}; };
Status GetStatus() const { return m_status; } Status GetStatus() const { return m_status; }

View File

@ -268,8 +268,8 @@ SendToPrinterDialog::SendToPrinterDialog(Plater *plater)
m_button_refresh->SetMinSize(SELECT_MACHINE_DIALOG_BUTTON_SIZE); m_button_refresh->SetMinSize(SELECT_MACHINE_DIALOG_BUTTON_SIZE);
m_button_refresh->SetCornerRadius(FromDIP(10)); m_button_refresh->SetCornerRadius(FromDIP(10));
m_button_refresh->Bind(wxEVT_BUTTON, &SendToPrinterDialog::on_refresh, this); m_button_refresh->Bind(wxEVT_BUTTON, &SendToPrinterDialog::on_refresh, this);
m_sizer_printer->Add(m_button_refresh, 0, wxALL | wxLEFT, FromDIP(5));
m_sizer_printer->Add(m_button_refresh, 0, wxALL | wxLEFT, FromDIP(5));
/*select storage*/ /*select storage*/
m_storage_panel = new wxPanel(this); m_storage_panel = new wxPanel(this);
@ -278,11 +278,42 @@ SendToPrinterDialog::SendToPrinterDialog(Plater *plater)
m_storage_panel->SetSizer(m_storage_sizer); m_storage_panel->SetSizer(m_storage_sizer);
m_storage_panel->Layout(); m_storage_panel->Layout();
// try to connect
m_statictext_printer_msg = new wxStaticText(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxALIGN_CENTER_HORIZONTAL); m_statictext_printer_msg = new wxStaticText(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxALIGN_CENTER_HORIZONTAL);
m_statictext_printer_msg->SetFont(::Label::Body_13); m_statictext_printer_msg->SetFont(::Label::Body_13);
m_statictext_printer_msg->SetForegroundColour(*wxBLACK); m_statictext_printer_msg->SetForegroundColour(*wxBLACK);
m_statictext_printer_msg->Hide(); m_statictext_printer_msg->Hide();
wxBoxSizer *m_sizer_connecting = new wxBoxSizer(wxHORIZONTAL);
m_connecting_panel = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxDefaultSize);
m_connecting_printer_msg = new wxStaticText(m_connecting_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxALIGN_CENTER_HORIZONTAL);
m_connecting_printer_msg->SetFont(::Label::Body_13);
m_connecting_printer_msg->SetForegroundColour(*wxBLACK);
m_connecting_printer_msg->SetLabel("Try to connect");
/*m_connecting_printer_msg->Hide();*/
m_connecting_printer_msg->Show();
std::vector<std::string> list{"ams_rfid_1", "ams_rfid_2", "ams_rfid_3", "ams_rfid_4"};
m_animaicon = new AnimaIcon(m_connecting_panel, wxID_ANY, list, "refresh_printer", 100);
m_sizer_connecting->Add(m_connecting_printer_msg, 1, wxALIGN_CENTER_VERTICAL | wxRIGHT, FromDIP(5));
m_sizer_connecting->Add(m_animaicon, 0, wxALIGN_CENTER_VERTICAL);
m_connecting_panel->SetSizer(m_sizer_connecting);
m_connecting_panel->Layout();
m_connecting_panel->Fit();
m_connecting_panel->Hide();
m_animaicon->Bind(wxEVT_LEFT_DOWN, [this](wxMouseEvent &e) {
if (m_file_sys) {
/* static int i = 0;
i++;
OutputDebugStringA(std::to_string(i).c_str());
OutputDebugStringA("\n");*/
m_file_sys->Retry();
}
});
// line schedule // line schedule
m_line_schedule = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(-1, 1)); m_line_schedule = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(-1, 1));
m_line_schedule->SetBackgroundColour(wxColour(238, 238, 238)); m_line_schedule->SetBackgroundColour(wxColour(238, 238, 238));
@ -352,7 +383,6 @@ SendToPrinterDialog::SendToPrinterDialog(Plater *plater)
wxBoxSizer* sizer_print_failed_info = new wxBoxSizer(wxVERTICAL); wxBoxSizer* sizer_print_failed_info = new wxBoxSizer(wxVERTICAL);
m_sw_print_failed_info->SetSizer(sizer_print_failed_info); m_sw_print_failed_info->SetSizer(sizer_print_failed_info);
wxBoxSizer* sizer_error_code = new wxBoxSizer(wxHORIZONTAL); wxBoxSizer* sizer_error_code = new wxBoxSizer(wxHORIZONTAL);
wxBoxSizer* sizer_error_desc = new wxBoxSizer(wxHORIZONTAL); wxBoxSizer* sizer_error_desc = new wxBoxSizer(wxHORIZONTAL);
wxBoxSizer* sizer_extra_info = new wxBoxSizer(wxHORIZONTAL); wxBoxSizer* sizer_extra_info = new wxBoxSizer(wxHORIZONTAL);
@ -374,7 +404,6 @@ SendToPrinterDialog::SendToPrinterDialog(Plater *plater)
sizer_error_code->Add(st_title_error_code_doc, 0, wxALL, 0); sizer_error_code->Add(st_title_error_code_doc, 0, wxALL, 0);
sizer_error_code->Add(m_st_txt_error_code, 0, wxALL, 0); sizer_error_code->Add(m_st_txt_error_code, 0, wxALL, 0);
auto st_title_error_desc = new wxStaticText(m_sw_print_failed_info, wxID_ANY, wxT("Error desc")); auto st_title_error_desc = new wxStaticText(m_sw_print_failed_info, wxID_ANY, wxT("Error desc"));
auto st_title_error_desc_doc = new wxStaticText(m_sw_print_failed_info, wxID_ANY, ": "); auto st_title_error_desc_doc = new wxStaticText(m_sw_print_failed_info, wxID_ANY, ": ");
m_st_txt_error_desc = new Label(m_sw_print_failed_info, wxEmptyString); m_st_txt_error_desc = new Label(m_sw_print_failed_info, wxEmptyString);
@ -409,7 +438,6 @@ SendToPrinterDialog::SendToPrinterDialog(Plater *plater)
sizer_extra_info->Add(st_title_extra_info_doc, 0, wxALL, 0); sizer_extra_info->Add(st_title_extra_info_doc, 0, wxALL, 0);
sizer_extra_info->Add(m_st_txt_extra_info, 0, wxALL, 0); sizer_extra_info->Add(m_st_txt_extra_info, 0, wxALL, 0);
m_link_network_state = new wxHyperlinkCtrl(m_sw_print_failed_info, wxID_ANY,_L("Check the status of current system services"),""); m_link_network_state = new wxHyperlinkCtrl(m_sw_print_failed_info, wxID_ANY,_L("Check the status of current system services"),"");
m_link_network_state->SetFont(::Label::Body_12); m_link_network_state->SetFont(::Label::Body_12);
m_link_network_state->Bind(wxEVT_LEFT_DOWN, [this](auto& e) {wxGetApp().link_to_network_check(); }); m_link_network_state->Bind(wxEVT_LEFT_DOWN, [this](auto& e) {wxGetApp().link_to_network_check(); });
@ -536,6 +564,7 @@ SendToPrinterDialog::SendToPrinterDialog(Plater *plater)
m_sizer_main->Add(m_storage_panel, 0, wxALIGN_CENTER | wxTOP, FromDIP(8)); m_sizer_main->Add(m_storage_panel, 0, wxALIGN_CENTER | wxTOP, FromDIP(8));
m_sizer_main->Add(0, 0, 0, wxEXPAND | wxTOP, FromDIP(11)); m_sizer_main->Add(0, 0, 0, wxEXPAND | wxTOP, FromDIP(11));
m_sizer_main->Add(m_statictext_printer_msg, 0, wxALIGN_CENTER_HORIZONTAL, 0); m_sizer_main->Add(m_statictext_printer_msg, 0, wxALIGN_CENTER_HORIZONTAL, 0);
m_sizer_main->Add(m_connecting_panel, 0, wxALIGN_CENTER_HORIZONTAL, 0);
m_sizer_main->Add(0, 1, 0, wxTOP, FromDIP(22)); m_sizer_main->Add(0, 1, 0, wxTOP, FromDIP(22));
m_sizer_main->Add(m_line_schedule, 0, wxEXPAND | wxLEFT | wxRIGHT, FromDIP(30)); m_sizer_main->Add(m_line_schedule, 0, wxEXPAND | wxLEFT | wxRIGHT, FromDIP(30));
m_sizer_main->Add(m_simplebook, 0, wxALIGN_CENTER_HORIZONTAL, 0); m_sizer_main->Add(m_simplebook, 0, wxALIGN_CENTER_HORIZONTAL, 0);
@ -750,6 +779,9 @@ void SendToPrinterDialog::on_cancel(wxCloseEvent &event)
} }
#endif #endif
m_tcp_try_connect = true; m_tcp_try_connect = true;
m_tutk_try_connect = false;
m_ftp_try_connect = false;
m_connect_try_times = 0;
this->EndModal(wxID_CANCEL); this->EndModal(wxID_CANCEL);
} }
@ -1017,6 +1049,7 @@ std::vector<std::string> SendToPrinterDialog::sort_string(std::vector<std::strin
return outputArray; return outputArray;
} }
bool SendToPrinterDialog::is_timeout() bool SendToPrinterDialog::is_timeout()
{ {
if (timeout_count > 15 * 1000 / LIST_REFRESH_INTERVAL) { if (timeout_count > 15 * 1000 / LIST_REFRESH_INTERVAL) {
@ -1127,6 +1160,9 @@ void SendToPrinterDialog::on_selection_changed(wxCommandEvent &event)
DeviceManager* dev = Slic3r::GUI::wxGetApp().getDeviceManager(); DeviceManager* dev = Slic3r::GUI::wxGetApp().getDeviceManager();
if (!dev) return; if (!dev) return;
m_tcp_try_connect = true; m_tcp_try_connect = true;
m_tutk_try_connect = false;
m_ftp_try_connect = false;
m_connect_try_times = 0;
MachineObject* obj = nullptr; MachineObject* obj = nullptr;
for (int i = 0; i < m_list.size(); i++) { for (int i = 0; i < m_list.size(); i++) {
if (i == selection) { if (i == selection) {
@ -1236,7 +1272,7 @@ void SendToPrinterDialog::update_show_status()
return; return;
} }
#else #else
if (!obj_->is_support_brtc) { if (!obj_->is_support_brtc || m_ftp_try_connect) {
if (m_file_sys) { if (m_file_sys) {
m_device_select.clear(); m_device_select.clear();
m_file_sys->Stop(true); m_file_sys->Stop(true);
@ -1261,7 +1297,7 @@ void SendToPrinterDialog::update_show_status()
m_file_sys = boost::make_shared<PrinterFileSystem>(); m_file_sys = boost::make_shared<PrinterFileSystem>();
m_file_sys->Attached(); m_file_sys->Attached();
m_file_sys->Bind(EVT_STATUS_CHANGED, [this, wfs = boost::weak_ptr(m_file_sys)](auto e) { m_file_sys->Bind(EVT_STATUS_CHANGED, [this, wfs = boost::weak_ptr(m_file_sys),obj_](auto e) {
e.Skip(); e.Skip();
boost::shared_ptr fs(wfs.lock()); boost::shared_ptr fs(wfs.lock());
if (!fs) return; if (!fs) return;
@ -1272,7 +1308,8 @@ void SendToPrinterDialog::update_show_status()
switch (status) { switch (status) {
case PrinterFileSystem::Initializing: case PrinterFileSystem::Initializing:
case PrinterFileSystem::Connecting: show_status(PrintDialogStatus::PrintStatusReading); break; case PrinterFileSystem::Connecting: show_status(PrintDialogStatus::PrintStatusConnecting); break;
case PrinterFileSystem::ListSyncing: { case PrinterFileSystem::ListSyncing: {
show_status(PrintDialogStatus::PrintStatusReading); show_status(PrintDialogStatus::PrintStatusReading);
boost::uint32_t seq = fs->RequestMediaAbility(3); boost::uint32_t seq = fs->RequestMediaAbility(3);
@ -1292,20 +1329,22 @@ void SendToPrinterDialog::update_show_status()
break; break;
} }
case PrinterFileSystem::Failed: { case PrinterFileSystem::Failed: {
m_tcp_try_connect = false; if (m_connect_try_times < 3) {
/*static int i = 0; bool is_lan = (obj_->connection_type() == "lan");
OutputDebugStringA(std::to_string(i).c_str());
OutputDebugStringA("\n"); m_ftp_try_connect = is_lan || m_tutk_try_connect;
if (i++ < 2)*/ m_tutk_try_connect = !is_lan || m_tutk_try_connect;
/* msg = _L("Attempting TCP connection, please wait."); m_tcp_try_connect = false;
else*/ }
else
msg = _L("Please check the network and try again, You can restart or update the printer if the issue persists."); msg = _L("Please check the network and try again, You can restart or update the printer if the issue persists.");
//fs->Stop(); fs->Stop();
m_connect_try_times++;
break; break;
} }
case PrinterFileSystem::Stopped: {
// fs->Retry(); case PrinterFileSystem::Reconnecting: show_status(PrintDialogStatus::PrintStatusReconnecting);
}
} }
if (!msg.empty()) { if (!msg.empty()) {
@ -1443,6 +1482,37 @@ void SendToPrinterDialog::show_status(PrintDialogStatus status, std::vector<wxSt
else else
m_comboBox_printer->Enable(); m_comboBox_printer->Enable();
//connecting
if(status == PrintDialogStatus::PrintStatusConnecting)
{
m_connecting_printer_msg->SetLabel("Try to connect.");
update_print_status_msg(wxEmptyString, true, true);
m_connecting_panel->Show();
m_animaicon->Play();
Layout();
Enable_Send_Button(false);
Enable_Refresh_Button(true);
return;
} else if (status == PrintDialogStatus::PrintStatusReconnecting) {
m_connecting_printer_msg->SetLabel("Click the spinning icon to retry.");
update_print_status_msg(wxEmptyString, true, true);
m_connecting_panel->Show();
m_animaicon->Stop();
m_animaicon->Enable();
Layout();
Enable_Send_Button(false);
Enable_Refresh_Button(true);
return;
}
else {
m_connecting_panel->Hide();
}
// m_panel_warn m_simplebook // m_panel_warn m_simplebook
if (status == PrintDialogStatus::PrintStatusSending) { if (status == PrintDialogStatus::PrintStatusSending) {
sending_mode(); sending_mode();
@ -1464,13 +1534,13 @@ void SendToPrinterDialog::show_status(PrintDialogStatus status, std::vector<wxSt
update_print_status_msg(msg_text, true, true); update_print_status_msg(msg_text, true, true);
Enable_Send_Button(true); Enable_Send_Button(true);
Enable_Refresh_Button(true); Enable_Refresh_Button(true);
} }
else if (status == PrintDialogStatus::PrintStatusReading) { else if (status == PrintDialogStatus::PrintStatusReading) {
wxString msg_text = _L("Synchronizing device information"); wxString msg_text = _L("Synchronizing device information");
update_print_status_msg(msg_text, false, true); update_print_status_msg(msg_text, false, true);
Enable_Send_Button(false); Enable_Send_Button(false);
Enable_Refresh_Button(true); Enable_Refresh_Button(true);
} }
else if (status == PrintDialogStatus::PrintStatusReadingFinished) { else if (status == PrintDialogStatus::PrintStatusReadingFinished) {
update_print_status_msg(wxEmptyString, false, true); update_print_status_msg(wxEmptyString, false, true);
@ -1694,9 +1764,12 @@ bool SendToPrinterDialog::Show(bool show)
if (show) { if (show) {
m_refresh_timer->Start(LIST_REFRESH_INTERVAL); m_refresh_timer->Start(LIST_REFRESH_INTERVAL);
m_tcp_try_connect = true;
m_ftp_try_connect = false;
m_tutk_try_connect = false;
m_connect_try_times = 0;
} else { } else {
m_refresh_timer->Stop(); m_refresh_timer->Stop();
m_tcp_try_connect = true;
} }
Layout(); Layout();
@ -1750,14 +1823,11 @@ void SendToPrinterDialog::fetchUrl(boost::weak_ptr<PrinterFileSystem> wfs)
NetworkAgent *agent = wxGetApp().getAgent(); NetworkAgent *agent = wxGetApp().getAgent();
std::string agent_version = agent ? agent->get_version() : ""; std::string agent_version = agent ? agent->get_version() : "";
if (agent) { if (agent) {
if (obj->connection_type() == "lan") { if (m_tcp_try_connect) {
// In LAN mode, use TCP connection
std::string devIP = obj->dev_ip; std::string devIP = obj->dev_ip;
std::string accessCode = obj->get_access_code(); std::string accessCode = obj->get_access_code();
std::string tcp_url = "bambu:///local/" + devIP + "?port=6000&user=" + "bblp" + "&passwd=" + accessCode; std::string tcp_url = "bambu:///local/" + devIP + "?port=6000&user=" + "bblp" + "&passwd=" + accessCode;
CallAfter([=] { CallAfter([=] {
boost::shared_ptr fs(wfs.lock()); boost::shared_ptr fs(wfs.lock());
if (!fs) return; if (!fs) return;
@ -1767,52 +1837,31 @@ void SendToPrinterDialog::fetchUrl(boost::weak_ptr<PrinterFileSystem> wfs)
fs->SetUrl("3"); fs->SetUrl("3");
} }
}); });
} else { }
// In non-LAN mode, try TCP connection first else if (m_tutk_try_connect){
if (m_tcp_try_connect) { std::string protocols[] = {"", "\"tutk\"", "\"agora\"", "\"tutk\",\"agora\""};
std::string devIP = obj->dev_ip; agent->get_camera_url(obj->dev_id + "|" + dev_ver + "|" + protocols[1], [this, wfs, m = dev_id, v = agent->get_version(), dv = dev_ver](std::string url) {
std::string accessCode = obj->get_access_code(); if (boost::algorithm::starts_with(url, "bambu:///")) {
std::string tcp_url = "bambu:///local/" + devIP + "?port=6000&user=" + "bblp" + "&passwd=" + accessCode; url += "&device=" + m;
url += "&net_ver=" + v;
url += "&dev_ver=" + dv;
url += "&refresh_url=" + boost::lexical_cast<std::string>(&refresh_agora_url);
url += "&cli_id=" + wxGetApp().app_config->get("slicer_uuid");
url += "&cli_ver=" + std::string(SLIC3R_VERSION);
}
BOOST_LOG_TRIVIAL(info) << "SendToPrinter::fetchUrl: camera_url: " << hide_passwd(url, {"?uid=", "authkey=", "passwd="});
std::cout << "SendToPrinter::fetchUrl: camera_url: " << hide_passwd(url, {"?uid=", "authkey=", "passwd="});
CallAfter([=] { CallAfter([=] {
boost::shared_ptr fs(wfs.lock()); boost::shared_ptr fs(wfs.lock());
if (!fs) return; if (!fs) return;
if (boost::algorithm::starts_with(url, "bambu:///")) {
if (boost::algorithm::starts_with(tcp_url, "bambu:///")) { fs->SetUrl(url);
fs->SetUrl(tcp_url); } else {
fs->SetUrl("3");
} }
}); });
});
} }
else {
// If the TCP connection fails, switch to TUTK connection
std::string protocols[] = {"", "\"tutk\"", "\"agora\"", "\"tutk\",\"agora\""};
agent->get_camera_url(obj->dev_id + "|" + dev_ver + "|" + protocols[1], // ʹÓà "tutk"
[this, wfs, m = dev_id, v = agent->get_version(), dv = dev_ver](std::string url) {
if (boost::algorithm::starts_with(url, "bambu:///")) {
url += "&device=" + m;
url += "&net_ver=" + v;
url += "&dev_ver=" + dv;
url += "&refresh_url=" + boost::lexical_cast<std::string>(&refresh_agora_url);
url += "&cli_id=" + wxGetApp().app_config->get("slicer_uuid");
url += "&cli_ver=" + std::string(SLIC3R_VERSION);
}
BOOST_LOG_TRIVIAL(info) << "SendToPrinter::fetchUrl: camera_url: " << hide_passwd(url, {"?uid=", "authkey=", "passwd="});
std::cout << "SendToPrinter::fetchUrl: camera_url: " << hide_passwd(url, {"?uid=", "authkey=", "passwd="});
CallAfter([=] {
boost::shared_ptr fs(wfs.lock());
if (!fs) return;
if (boost::algorithm::starts_with(url, "bambu:///")) {
fs->SetUrl(url);
} else {
fs->SetUrl("3");
}
});
});
}
}
} }

View File

@ -39,6 +39,7 @@
#include <wx/simplebook.h> #include <wx/simplebook.h>
#include <wx/hashmap.h> #include <wx/hashmap.h>
#include "Printer/PrinterFileSystem.h" #include "Printer/PrinterFileSystem.h"
#include "Widgets/AnimaController.hpp"
namespace Slic3r { namespace Slic3r {
namespace GUI { namespace GUI {
@ -54,6 +55,7 @@ private:
int m_current_filament_id; int m_current_filament_id;
int m_print_error_code = 0; int m_print_error_code = 0;
int timeout_count = 0; int timeout_count = 0;
int m_connect_try_times = 0;
bool m_is_in_sending_mode{ false }; bool m_is_in_sending_mode{ false };
bool m_is_rename_mode{ false }; bool m_is_rename_mode{ false };
bool enable_prepare_mode{ true }; bool enable_prepare_mode{ true };
@ -61,6 +63,8 @@ private:
bool m_export_3mf_cancel{ false }; bool m_export_3mf_cancel{ false };
bool m_is_canceled{ false }; bool m_is_canceled{ false };
bool m_tcp_try_connect{true}; bool m_tcp_try_connect{true};
bool m_tutk_try_connect{false};
bool m_ftp_try_connect{false};
std::string m_print_error_msg; std::string m_print_error_msg;
std::string m_print_error_extra; std::string m_print_error_extra;
std::string m_print_info; std::string m_print_info;
@ -89,11 +93,13 @@ private:
wxPanel* m_line_materia{ nullptr }; wxPanel* m_line_materia{ nullptr };
wxBoxSizer* m_storage_sizer{ nullptr }; wxBoxSizer* m_storage_sizer{ nullptr };
wxPanel* m_storage_panel{ nullptr }; wxPanel* m_storage_panel{ nullptr };
wxPanel * m_connecting_panel{nullptr};
wxSimplebook* m_simplebook{ nullptr }; wxSimplebook* m_simplebook{ nullptr };
wxStaticText* m_statictext_finish{ nullptr }; wxStaticText* m_statictext_finish{ nullptr };
wxStaticText* m_stext_sending{ nullptr }; wxStaticText* m_stext_sending{ nullptr };
wxStaticText* m_staticText_bed_title{ nullptr }; wxStaticText* m_staticText_bed_title{ nullptr };
wxStaticText* m_statictext_printer_msg{ nullptr }; wxStaticText* m_statictext_printer_msg{ nullptr };
wxStaticText * m_connecting_printer_msg{nullptr};
wxStaticText* m_stext_printer_title{ nullptr }; wxStaticText* m_stext_printer_title{ nullptr };
wxStaticText* m_rename_text{ nullptr }; wxStaticText* m_rename_text{ nullptr };
wxStaticText* m_stext_time{ nullptr }; wxStaticText* m_stext_time{ nullptr };
@ -108,8 +114,10 @@ private:
wxBoxSizer* sizer_thumbnail; wxBoxSizer* sizer_thumbnail;
wxBoxSizer* m_sizer_scrollable_region; wxBoxSizer* m_sizer_scrollable_region;
wxBoxSizer* m_sizer_main; wxBoxSizer* m_sizer_main;
wxStaticText* m_file_name; wxStaticText* m_file_name;
PrintDialogStatus m_print_status{ PrintStatusInit }; PrintDialogStatus m_print_status{ PrintStatusInit };
AnimaIcon * m_animaicon{nullptr};
std::shared_ptr<SendJob> m_send_job{nullptr}; std::shared_ptr<SendJob> m_send_job{nullptr};
std::vector<wxString> m_bedtype_list; std::vector<wxString> m_bedtype_list;

View File

@ -0,0 +1,77 @@
#include "AnimaController.hpp"
#include <wx/dcclient.h>
#include <wx/dcgraph.h>
#ifdef __APPLE__
#include "libslic3r/MacUtils.hpp"
#endif
AnimaIcon::AnimaIcon(wxWindow *parent, wxWindowID id, std::vector<std::string> img_list, std::string img_enable, int ivt)
: wxPanel(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize), m_ivt(ivt)
{
SetBackgroundColour((wxColour(255, 255, 255)));
m_size = 20;
//add ScalableBitmap
for (const auto &filename : img_list) m_images.emplace_back(create_scaled_bitmap(filename, this, m_size));
m_image_enable = create_scaled_bitmap(img_enable, this, m_size-8);
// show first wxStaticBitmap
if (!m_images.empty()) m_bitmap = new wxStaticBitmap(this, wxID_ANY, m_images[0], wxDefaultPosition, wxSize(FromDIP(m_size), FromDIP(m_size)));
m_timer = new wxTimer();
m_timer->SetOwner(this);
Bind(wxEVT_TIMER, [this](wxTimerEvent &) {
if (m_timer->IsRunning() && !m_images.empty()) {
m_current_frame = (m_current_frame + 1) % 4;
m_bitmap->SetBitmap(m_images[m_current_frame]);
}
});
m_bitmap->Bind(wxEVT_LEFT_DOWN, [this](wxMouseEvent &e) {
wxMouseEvent evt(wxEVT_LEFT_DOWN);
evt.SetEventObject(this);
wxPostEvent(this, evt);
});
m_bitmap->Bind(wxEVT_ENTER_WINDOW, [this](auto &e) {
if (!m_timer->IsRunning())
SetCursor(wxCursor(wxCURSOR_HAND));
else
SetCursor(wxCursor(wxCURSOR_ARROW));
e.Skip();
});
m_bitmap->Bind(wxEVT_LEAVE_WINDOW, [this](auto &e) {
SetCursor(wxCursor(wxCURSOR_ARROW));
e.Skip();
});
SetSize(wxSize(FromDIP(m_size), FromDIP(m_size)));
SetMaxSize(wxSize(FromDIP(m_size), FromDIP(m_size)));
SetMinSize(wxSize(FromDIP(m_size), FromDIP(m_size)));
Refresh();
Play();
}
void AnimaIcon::Play()
{
if (true)
m_timer->Start(m_ivt);
}
void AnimaIcon::Stop()
{
m_timer->Stop();
}
void AnimaIcon::Enable()
{
if (m_bitmap) { m_bitmap->SetBitmap(m_image_enable); }
}

View File

@ -0,0 +1,28 @@
#ifndef slic3r_GUI_AnimaController_hpp_
#define slic3r_GUI_AnimaController_hpp_
#include "../wxExtensions.hpp"
#include "Label.hpp"
class AnimaIcon : public wxPanel
{
public:
AnimaIcon(wxWindow *parent, wxWindowID id, std::vector<std::string> img_list, std::string img_enable, int ivt = 1000);
void Play();
void Stop();
void Enable();
bool IsRunning() const;
private:
wxBitmap m_image_enable;
wxStaticBitmap * m_bitmap{nullptr};
std::vector<wxBitmap> m_images;
wxTimer * m_timer;
int m_current_frame = 0;
int m_ivt;
int m_size;
};
#endif // !slic3r_GUI_AnimaController_hpp_

View File

@ -15,7 +15,7 @@ ProgressBar::ProgressBar(wxWindow *parent, wxWindowID id, int max, const wxPoint
{ {
m_shownumber = shown; m_shownumber = shown;
SetBackgroundColour(wxColour(255,255,255)); SetBackgroundColour(wxColour(255,255,255));
if (size.y >= miniHeight) { if (size.y >= miniHeight) {
m_miniHeight = size.y; m_miniHeight = size.y;
} else { } else {
@ -64,20 +64,20 @@ void ProgressBar::create(wxWindow *parent, wxWindowID id, const wxPoint &pos, w
} }
void ProgressBar::SetRadius(double radius) { void ProgressBar::SetRadius(double radius) {
m_radius = radius; m_radius = radius;
Refresh(); Refresh();
} }
void ProgressBar::SetProgressForedColour(wxColour colour) void ProgressBar::SetProgressForedColour(wxColour colour)
{ {
m_progress_background_colour = colour; m_progress_background_colour = colour;
Refresh(); Refresh();
} }
void ProgressBar::SetProgressBackgroundColour(wxColour colour) void ProgressBar::SetProgressBackgroundColour(wxColour colour)
{ {
m_progress_colour = colour; m_progress_colour = colour;
Refresh(); Refresh();
} }
@ -86,29 +86,29 @@ void ProgressBar::Rescale()
; ;
} }
void ProgressBar::ShowNumber(bool shown) void ProgressBar::ShowNumber(bool shown)
{ {
m_shownumber = shown; m_shownumber = shown;
Refresh(); Refresh();
} }
void ProgressBar::Disable(wxString text) void ProgressBar::Disable(wxString text)
{ {
if (m_disable) return; if (m_disable) return;
m_disable_text = text; m_disable_text = text;
m_disable = true; m_disable = true;
Refresh(); Refresh();
} }
void ProgressBar::SetValue(int step) void ProgressBar::SetValue(int step)
{ {
m_disable = false; m_disable = false;
SetProgress(step); SetProgress(step);
} }
void ProgressBar::Reset() void ProgressBar::Reset()
{ {
m_step = 0; m_step = 0;
SetValue(0); SetValue(0);
} }
@ -126,9 +126,9 @@ void ProgressBar::SetProgress(int step)
} }
void ProgressBar::SetMinSize(const wxSize &size) void ProgressBar::SetMinSize(const wxSize &size)
{ {
if (size.y >= miniHeight) { if (size.y >= miniHeight) {
m_miniHeight = size.y; m_miniHeight = size.y;
} else { } else {
return; return;
@ -181,7 +181,7 @@ void ProgressBar::doRender(wxDC &dc)
dc.DrawRoundedRectangle(0, 0, size.x, size.y, m_radius); dc.DrawRoundedRectangle(0, 0, size.x, size.y, m_radius);
} }
//draw progress //draw progress
if (m_disable) { if (m_disable) {
m_proportion = float(size.x * float(this->m_step) / float(this->m_max)); m_proportion = float(size.x * float(this->m_step) / float(this->m_max));
if (m_proportion < m_radius * 2 && m_proportion != 0) { m_proportion = m_radius * 2; } if (m_proportion < m_radius * 2 && m_proportion != 0) { m_proportion = m_radius * 2; }
@ -232,11 +232,11 @@ void ProgressBar::doRender(wxDC &dc)
dc.DrawText(text + wxString("%"), pt); dc.DrawText(text + wxString("%"), pt);
} }
} }
} }
void ProgressBar::DoSetSize(int x, int y, int width, int height, int sizeFlags) void ProgressBar::DoSetSize(int x, int y, int width, int height, int sizeFlags)
{ {
wxWindow::DoSetSize(x, y, width, height, sizeFlags); wxWindow::DoSetSize(x, y, width, height, sizeFlags);
} }