From 4358e9ce351c5784e392a75d1ffcf2f54e1916ec Mon Sep 17 00:00:00 2001 From: milk Date: Sun, 27 Apr 2025 15:30:43 +0800 Subject: [PATCH] ENH:Optimization of File Transfer System Part2 jira: [STUDIO-11777] Change-Id: I12744db7d2e3b53425454d632533768c54524677 --- src/slic3r/CMakeLists.txt | 2 + src/slic3r/GUI/DeviceManager.hpp | 2 +- src/slic3r/GUI/PrePrintChecker.hpp | 2 + src/slic3r/GUI/Printer/PrinterFileSystem.cpp | 6 +- src/slic3r/GUI/Printer/PrinterFileSystem.h | 2 +- src/slic3r/GUI/SendToPrinter.cpp | 191 ++++++++++++------- src/slic3r/GUI/SendToPrinter.hpp | 8 + src/slic3r/GUI/Widgets/AnimaController.cpp | 77 ++++++++ src/slic3r/GUI/Widgets/AnimaController.hpp | 28 +++ src/slic3r/GUI/Widgets/ProgressBar.cpp | 42 ++-- 10 files changed, 263 insertions(+), 97 deletions(-) create mode 100644 src/slic3r/GUI/Widgets/AnimaController.cpp create mode 100644 src/slic3r/GUI/Widgets/AnimaController.hpp diff --git a/src/slic3r/CMakeLists.txt b/src/slic3r/CMakeLists.txt index 7de9212c4..602f5c1ed 100644 --- a/src/slic3r/CMakeLists.txt +++ b/src/slic3r/CMakeLists.txt @@ -8,6 +8,8 @@ set(SLIC3R_GUI_SOURCES pchheader.hpp GUI/Printer/PrinterFileSystem.cpp GUI/Printer/PrinterFileSystem.h + GUI/Widgets/AnimaController.hpp + GUI/Widgets/AnimaController.cpp GUI/Widgets/AxisCtrlButton.cpp GUI/Widgets/AxisCtrlButton.hpp GUI/Widgets/Button.cpp diff --git a/src/slic3r/GUI/DeviceManager.hpp b/src/slic3r/GUI/DeviceManager.hpp index f1ab4ab4a..492af82e8 100644 --- a/src/slic3r/GUI/DeviceManager.hpp +++ b/src/slic3r/GUI/DeviceManager.hpp @@ -1083,7 +1083,7 @@ public: bool is_support_filament_setting_inprinting{false}; bool is_support_internal_timelapse { false };// fun[28], support timelapse without SD card 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}; int bed_temperature_limit = -1; diff --git a/src/slic3r/GUI/PrePrintChecker.hpp b/src/slic3r/GUI/PrePrintChecker.hpp index 3210017fe..476e24423 100644 --- a/src/slic3r/GUI/PrePrintChecker.hpp +++ b/src/slic3r/GUI/PrePrintChecker.hpp @@ -37,6 +37,8 @@ enum PrintDialogStatus : unsigned int { PrintStatusConnectingServer, PrintStatusReadingTimeout, PrintStatusReading, + PrintStatusConnecting, + PrintStatusReconnecting, PrintStatusInUpgrading, PrintStatusModeNotFDM, PrintStatusInSystemPrinting, diff --git a/src/slic3r/GUI/Printer/PrinterFileSystem.cpp b/src/slic3r/GUI/Printer/PrinterFileSystem.cpp index 5abf58a45..aeca48cd2 100644 --- a/src/slic3r/GUI/Printer/PrinterFileSystem.cpp +++ b/src/slic3r/GUI/Printer/PrinterFileSystem.cpp @@ -1541,9 +1541,9 @@ void PrinterFileSystem::Reconnect(boost::unique_lock &l, int resul while (m_stopped) { if (m_session.owner == nullptr) return; - m_status = Status::Stopped; - SendChangedEvent(EVT_STATUS_CHANGED, m_status); - m_cond.wait(l); + m_status = Status::Reconnecting; + SendChangedEvent(EVT_STATUS_CHANGED, m_status); + m_cond.wait(l); } wxLogMessage("PrinterFileSystem::Reconnect Initializing"); m_status = Status::Initializing; diff --git a/src/slic3r/GUI/Printer/PrinterFileSystem.h b/src/slic3r/GUI/Printer/PrinterFileSystem.h index d9dbe1cdc..f8147b501 100644 --- a/src/slic3r/GUI/Printer/PrinterFileSystem.h +++ b/src/slic3r/GUI/Printer/PrinterFileSystem.h @@ -215,7 +215,7 @@ public: ListSyncing, ListReady, Failed, - Stopped, + Reconnecting, }; Status GetStatus() const { return m_status; } diff --git a/src/slic3r/GUI/SendToPrinter.cpp b/src/slic3r/GUI/SendToPrinter.cpp index 7855d683b..41dd7a9ff 100644 --- a/src/slic3r/GUI/SendToPrinter.cpp +++ b/src/slic3r/GUI/SendToPrinter.cpp @@ -268,8 +268,8 @@ SendToPrinterDialog::SendToPrinterDialog(Plater *plater) m_button_refresh->SetMinSize(SELECT_MACHINE_DIALOG_BUTTON_SIZE); m_button_refresh->SetCornerRadius(FromDIP(10)); 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*/ m_storage_panel = new wxPanel(this); @@ -278,11 +278,42 @@ SendToPrinterDialog::SendToPrinterDialog(Plater *plater) m_storage_panel->SetSizer(m_storage_sizer); 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->SetFont(::Label::Body_13); m_statictext_printer_msg->SetForegroundColour(*wxBLACK); 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 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 m_line_schedule = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(-1, 1)); m_line_schedule->SetBackgroundColour(wxColour(238, 238, 238)); @@ -352,7 +383,6 @@ SendToPrinterDialog::SendToPrinterDialog(Plater *plater) wxBoxSizer* sizer_print_failed_info = new wxBoxSizer(wxVERTICAL); m_sw_print_failed_info->SetSizer(sizer_print_failed_info); - wxBoxSizer* sizer_error_code = new wxBoxSizer(wxHORIZONTAL); wxBoxSizer* sizer_error_desc = 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(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_doc = new wxStaticText(m_sw_print_failed_info, wxID_ANY, ": "); 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(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->SetFont(::Label::Body_12); 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(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_connecting_panel, 0, wxALIGN_CENTER_HORIZONTAL, 0); 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_simplebook, 0, wxALIGN_CENTER_HORIZONTAL, 0); @@ -750,6 +779,9 @@ void SendToPrinterDialog::on_cancel(wxCloseEvent &event) } #endif m_tcp_try_connect = true; + m_tutk_try_connect = false; + m_ftp_try_connect = false; + m_connect_try_times = 0; this->EndModal(wxID_CANCEL); } @@ -1017,6 +1049,7 @@ std::vector SendToPrinterDialog::sort_string(std::vector 15 * 1000 / LIST_REFRESH_INTERVAL) { @@ -1127,6 +1160,9 @@ void SendToPrinterDialog::on_selection_changed(wxCommandEvent &event) DeviceManager* dev = Slic3r::GUI::wxGetApp().getDeviceManager(); if (!dev) return; m_tcp_try_connect = true; + m_tutk_try_connect = false; + m_ftp_try_connect = false; + m_connect_try_times = 0; MachineObject* obj = nullptr; for (int i = 0; i < m_list.size(); i++) { if (i == selection) { @@ -1236,7 +1272,7 @@ void SendToPrinterDialog::update_show_status() return; } #else - if (!obj_->is_support_brtc) { + if (!obj_->is_support_brtc || m_ftp_try_connect) { if (m_file_sys) { m_device_select.clear(); m_file_sys->Stop(true); @@ -1261,7 +1297,7 @@ void SendToPrinterDialog::update_show_status() m_file_sys = boost::make_shared(); 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(); boost::shared_ptr fs(wfs.lock()); if (!fs) return; @@ -1272,7 +1308,8 @@ void SendToPrinterDialog::update_show_status() switch (status) { case PrinterFileSystem::Initializing: - case PrinterFileSystem::Connecting: show_status(PrintDialogStatus::PrintStatusReading); break; + case PrinterFileSystem::Connecting: show_status(PrintDialogStatus::PrintStatusConnecting); break; + case PrinterFileSystem::ListSyncing: { show_status(PrintDialogStatus::PrintStatusReading); boost::uint32_t seq = fs->RequestMediaAbility(3); @@ -1292,20 +1329,22 @@ void SendToPrinterDialog::update_show_status() break; } case PrinterFileSystem::Failed: { - m_tcp_try_connect = false; - /*static int i = 0; - OutputDebugStringA(std::to_string(i).c_str()); - OutputDebugStringA("\n"); - if (i++ < 2)*/ - /* msg = _L("Attempting TCP connection, please wait."); - else*/ + if (m_connect_try_times < 3) { + bool is_lan = (obj_->connection_type() == "lan"); + + m_ftp_try_connect = is_lan || m_tutk_try_connect; + m_tutk_try_connect = !is_lan || m_tutk_try_connect; + m_tcp_try_connect = false; + } + else 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; - } - case PrinterFileSystem::Stopped: { - // fs->Retry(); - } + } + + case PrinterFileSystem::Reconnecting: show_status(PrintDialogStatus::PrintStatusReconnecting); + } if (!msg.empty()) { @@ -1443,6 +1482,37 @@ void SendToPrinterDialog::show_status(PrintDialogStatus status, std::vectorEnable(); + + //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 if (status == PrintDialogStatus::PrintStatusSending) { sending_mode(); @@ -1464,13 +1534,13 @@ void SendToPrinterDialog::show_status(PrintDialogStatus status, std::vectorStart(LIST_REFRESH_INTERVAL); + m_tcp_try_connect = true; + m_ftp_try_connect = false; + m_tutk_try_connect = false; + m_connect_try_times = 0; } else { m_refresh_timer->Stop(); - m_tcp_try_connect = true; } Layout(); @@ -1750,14 +1823,11 @@ void SendToPrinterDialog::fetchUrl(boost::weak_ptr wfs) NetworkAgent *agent = wxGetApp().getAgent(); std::string agent_version = agent ? agent->get_version() : ""; - if (agent) { - if (obj->connection_type() == "lan") { - // In LAN mode, use TCP connection + if (m_tcp_try_connect) { std::string devIP = obj->dev_ip; std::string accessCode = obj->get_access_code(); std::string tcp_url = "bambu:///local/" + devIP + "?port=6000&user=" + "bblp" + "&passwd=" + accessCode; - CallAfter([=] { boost::shared_ptr fs(wfs.lock()); if (!fs) return; @@ -1767,52 +1837,31 @@ void SendToPrinterDialog::fetchUrl(boost::weak_ptr wfs) fs->SetUrl("3"); } }); - } else { - // In non-LAN mode, try TCP connection first - if (m_tcp_try_connect) { - std::string devIP = obj->dev_ip; - std::string accessCode = obj->get_access_code(); - std::string tcp_url = "bambu:///local/" + devIP + "?port=6000&user=" + "bblp" + "&passwd=" + accessCode; - + } + else if (m_tutk_try_connect){ + std::string protocols[] = {"", "\"tutk\"", "\"agora\"", "\"tutk\",\"agora\""}; + 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) { + if (boost::algorithm::starts_with(url, "bambu:///")) { + url += "&device=" + m; + url += "&net_ver=" + v; + url += "&dev_ver=" + dv; + url += "&refresh_url=" + boost::lexical_cast(&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(tcp_url, "bambu:///")) { - fs->SetUrl(tcp_url); + if (boost::algorithm::starts_with(url, "bambu:///")) { + fs->SetUrl(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(&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"); - } - }); - }); - - } - - } - } diff --git a/src/slic3r/GUI/SendToPrinter.hpp b/src/slic3r/GUI/SendToPrinter.hpp index 843945bdd..f19fd8a3e 100644 --- a/src/slic3r/GUI/SendToPrinter.hpp +++ b/src/slic3r/GUI/SendToPrinter.hpp @@ -39,6 +39,7 @@ #include #include #include "Printer/PrinterFileSystem.h" +#include "Widgets/AnimaController.hpp" namespace Slic3r { namespace GUI { @@ -54,6 +55,7 @@ private: int m_current_filament_id; int m_print_error_code = 0; int timeout_count = 0; + int m_connect_try_times = 0; bool m_is_in_sending_mode{ false }; bool m_is_rename_mode{ false }; bool enable_prepare_mode{ true }; @@ -61,6 +63,8 @@ private: bool m_export_3mf_cancel{ false }; bool m_is_canceled{ false }; 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_extra; std::string m_print_info; @@ -89,11 +93,13 @@ private: wxPanel* m_line_materia{ nullptr }; wxBoxSizer* m_storage_sizer{ nullptr }; wxPanel* m_storage_panel{ nullptr }; + wxPanel * m_connecting_panel{nullptr}; wxSimplebook* m_simplebook{ nullptr }; wxStaticText* m_statictext_finish{ nullptr }; wxStaticText* m_stext_sending{ nullptr }; wxStaticText* m_staticText_bed_title{ nullptr }; wxStaticText* m_statictext_printer_msg{ nullptr }; + wxStaticText * m_connecting_printer_msg{nullptr}; wxStaticText* m_stext_printer_title{ nullptr }; wxStaticText* m_rename_text{ nullptr }; wxStaticText* m_stext_time{ nullptr }; @@ -108,8 +114,10 @@ private: wxBoxSizer* sizer_thumbnail; wxBoxSizer* m_sizer_scrollable_region; wxBoxSizer* m_sizer_main; + wxStaticText* m_file_name; PrintDialogStatus m_print_status{ PrintStatusInit }; + AnimaIcon * m_animaicon{nullptr}; std::shared_ptr m_send_job{nullptr}; std::vector m_bedtype_list; diff --git a/src/slic3r/GUI/Widgets/AnimaController.cpp b/src/slic3r/GUI/Widgets/AnimaController.cpp new file mode 100644 index 000000000..10f0061db --- /dev/null +++ b/src/slic3r/GUI/Widgets/AnimaController.cpp @@ -0,0 +1,77 @@ +#include "AnimaController.hpp" + +#include +#include +#ifdef __APPLE__ +#include "libslic3r/MacUtils.hpp" +#endif + +AnimaIcon::AnimaIcon(wxWindow *parent, wxWindowID id, std::vector 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); } +} + + diff --git a/src/slic3r/GUI/Widgets/AnimaController.hpp b/src/slic3r/GUI/Widgets/AnimaController.hpp new file mode 100644 index 000000000..ac8caffc6 --- /dev/null +++ b/src/slic3r/GUI/Widgets/AnimaController.hpp @@ -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 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 m_images; + wxTimer * m_timer; + int m_current_frame = 0; + int m_ivt; + int m_size; +}; + +#endif // !slic3r_GUI_AnimaController_hpp_ diff --git a/src/slic3r/GUI/Widgets/ProgressBar.cpp b/src/slic3r/GUI/Widgets/ProgressBar.cpp index a5ac91330..4cf5ab67e 100644 --- a/src/slic3r/GUI/Widgets/ProgressBar.cpp +++ b/src/slic3r/GUI/Widgets/ProgressBar.cpp @@ -15,7 +15,7 @@ ProgressBar::ProgressBar(wxWindow *parent, wxWindowID id, int max, const wxPoint { m_shownumber = shown; SetBackgroundColour(wxColour(255,255,255)); - + if (size.y >= miniHeight) { m_miniHeight = size.y; } 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; Refresh(); } -void ProgressBar::SetProgressForedColour(wxColour colour) +void ProgressBar::SetProgressForedColour(wxColour colour) { m_progress_background_colour = colour; Refresh(); } -void ProgressBar::SetProgressBackgroundColour(wxColour colour) -{ - m_progress_colour = colour; +void ProgressBar::SetProgressBackgroundColour(wxColour colour) +{ + m_progress_colour = colour; Refresh(); } @@ -86,29 +86,29 @@ void ProgressBar::Rescale() ; } -void ProgressBar::ShowNumber(bool shown) +void ProgressBar::ShowNumber(bool shown) { m_shownumber = shown; Refresh(); } -void ProgressBar::Disable(wxString text) -{ +void ProgressBar::Disable(wxString text) +{ if (m_disable) return; m_disable_text = text; m_disable = true; Refresh(); } -void ProgressBar::SetValue(int step) -{ +void ProgressBar::SetValue(int step) +{ m_disable = false; SetProgress(step); } -void ProgressBar::Reset() -{ - m_step = 0; +void ProgressBar::Reset() +{ + m_step = 0; SetValue(0); } @@ -126,9 +126,9 @@ void ProgressBar::SetProgress(int step) } -void ProgressBar::SetMinSize(const wxSize &size) -{ - if (size.y >= miniHeight) { +void ProgressBar::SetMinSize(const wxSize &size) +{ + if (size.y >= miniHeight) { m_miniHeight = size.y; } else { return; @@ -181,7 +181,7 @@ void ProgressBar::doRender(wxDC &dc) dc.DrawRoundedRectangle(0, 0, size.x, size.y, m_radius); } - //draw progress + //draw progress if (m_disable) { 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; } @@ -232,11 +232,11 @@ void ProgressBar::doRender(wxDC &dc) 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); }