From 618716b5448992dc0548c460704292b80254704f Mon Sep 17 00:00:00 2001 From: "xin.zhang" Date: Wed, 2 Apr 2025 19:49:36 +0800 Subject: [PATCH] ENH: show why can not set timelapse jira: [STUDIO-11109] Change-Id: Id6347a6b0e5f6ead0a5ad534790b42adf9f01c4a (cherry picked from commit 9a80a45a82f5db6f85fadbde977529d39d8036b1) --- src/slic3r/GUI/DeviceManager.cpp | 20 ++++++++-- src/slic3r/GUI/DeviceManager.hpp | 2 +- src/slic3r/GUI/SelectMachine.cpp | 19 +++++++--- src/slic3r/GUI/SelectMachine.hpp | 63 ++++++++++++++++++++------------ 4 files changed, 70 insertions(+), 34 deletions(-) diff --git a/src/slic3r/GUI/DeviceManager.cpp b/src/slic3r/GUI/DeviceManager.cpp index 632eefcb8a..9e3902abc4 100644 --- a/src/slic3r/GUI/DeviceManager.cpp +++ b/src/slic3r/GUI/DeviceManager.cpp @@ -1756,10 +1756,10 @@ bool MachineObject::is_studio_cmd(int sequence_id) return false; } -bool MachineObject::canEnableTimelapse() const +bool MachineObject::canEnableTimelapse(wxString &error_message) const { - if (!is_support_timelapse) - { + if (!is_support_timelapse) { + error_message = _L("Timelapse is not supported on this printer."); return false; } @@ -1768,7 +1768,19 @@ bool MachineObject::canEnableTimelapse() const return true; } - return sdcard_state == MachineObject::SdcardState::HAS_SDCARD_NORMAL; + if (sdcard_state != MachineObject::SdcardState::HAS_SDCARD_NORMAL) { + if (sdcard_state == MachineObject::SdcardState::NO_SDCARD) { + error_message = _L("Timelapse is not supported while the SD card does not exist."); + } else if (sdcard_state == MachineObject::SdcardState::HAS_SDCARD_ABNORMAL) { + error_message = _L("Timelapse is not supported while the SD card is unavailable."); + } else if (sdcard_state == MachineObject::SdcardState::HAS_SDCARD_READONLY) { + error_message = _L("Timelapse is not supported while the SD card is readonly."); + } + + return false; + } + + return true; } int MachineObject::command_select_extruder(int id) diff --git a/src/slic3r/GUI/DeviceManager.hpp b/src/slic3r/GUI/DeviceManager.hpp index 5c772c8abf..0d698e12a6 100644 --- a/src/slic3r/GUI/DeviceManager.hpp +++ b/src/slic3r/GUI/DeviceManager.hpp @@ -1150,7 +1150,7 @@ public: bool is_studio_cmd(int seq); /* quick check*/ - bool canEnableTimelapse() const; + bool canEnableTimelapse(wxString& error_message) const; /* command commands */ int command_get_version(bool with_retry = true); diff --git a/src/slic3r/GUI/SelectMachine.cpp b/src/slic3r/GUI/SelectMachine.cpp index 957faf130f..f9c23c4540 100644 --- a/src/slic3r/GUI/SelectMachine.cpp +++ b/src/slic3r/GUI/SelectMachine.cpp @@ -1005,9 +1005,10 @@ void SelectMachineDialog::update_select_layout(MachineObject *obj) } /*STUDIO-9197*/ - if (obj && obj->canEnableTimelapse()) + wxString error_messgae; + if (obj && obj->canEnableTimelapse(error_messgae)) { - m_checkbox_list["timelapse"]->Enable(); + m_checkbox_list["timelapse"]->enable(true); if (config->get("print", "timelapse") == "1" && !has_timelapse_warning()) { m_checkbox_list["timelapse"]->setValue("on"); config->set_str("print", "timelapse", "1"); @@ -1018,10 +1019,11 @@ void SelectMachineDialog::update_select_layout(MachineObject *obj) } else { - m_checkbox_list["timelapse"]->Disable(); + m_checkbox_list["timelapse"]->enable(false); m_checkbox_list["timelapse"]->setValue("off"); config->set_str("print", "timelapse", "0"); } + m_checkbox_list["timelapse"]->update_tooltip(error_messgae); update_options_layout(); Layout(); @@ -4797,7 +4799,7 @@ std::string SelectMachineDialog::get_print_status_info(PrintDialogStatus status) m_printoption_title = new Label(this, title); m_printoption_title->SetFont(Label::Body_13); - m_printoption_title->SetBackgroundColour(0xF8F8F8); + //m_printoption_title->SetBackgroundColour(0xF8F8F8); m_printoption_title->SetToolTip(tips); m_printoption_item = new PrintOptionItem(this, m_ops, param); @@ -4860,6 +4862,11 @@ void PrintOption::update_options(std::vector ops, const wxString &tips) if (m_printoption_item->GetToolTipText() != tips) { m_printoption_item->SetToolTip(tips); } } +void PrintOption::update_tooltip(const wxString &tips) { + if (m_printoption_title->GetToolTipText() != tips) { m_printoption_title->SetToolTip(tips); } + if (m_printoption_item->GetToolTipText() != tips) { m_printoption_item->SetToolTip(tips); } +} + std::string PrintOption::getValue() { return m_printoption_item->getValue(); @@ -4930,6 +4937,8 @@ void PrintOptionItem::render(wxDC &dc) void PrintOptionItem::on_left_down(wxMouseEvent &evt) { + if (!m_enabled) { return;} + auto pos = ClientToScreen(evt.GetPosition()); auto rect = ClientToScreen(wxPoint(0, 0)); auto select_size = GetSize().x / m_ops.size(); @@ -4967,7 +4976,7 @@ void PrintOptionItem::doRender(wxDC &dc) auto size = GetSize(); dc.SetPen(wxPen(*wxTRANSPARENT_PEN)); dc.SetBrush(GetBackgroundColour()); - dc.DrawRoundedRectangle(0, 0, size.x, size.y, 5); + dc.DrawRoundedRectangle(0, 0, size.x, size.y, FromDIP(5)); auto left = FromDIP(4); diff --git a/src/slic3r/GUI/SelectMachine.hpp b/src/slic3r/GUI/SelectMachine.hpp index cbadb0ddf4..37b5390ca1 100644 --- a/src/slic3r/GUI/SelectMachine.hpp +++ b/src/slic3r/GUI/SelectMachine.hpp @@ -215,21 +215,25 @@ struct POItem class PrintOptionItem : public wxPanel { + ScalableBitmap m_selected_bk; + std::vector m_ops; + std::string selected_key; + std::string m_param; + + bool m_enabled = true; + public: PrintOptionItem(wxWindow *parent, std::vector ops, std::string param = ""); ~PrintOptionItem(){}; - void OnPaint(wxPaintEvent &event); - void render(wxDC &dc); - void on_left_down(wxMouseEvent &evt); - void doRender(wxDC &dc); - ScalableBitmap m_selected_bk; - std::vector m_ops; - std::string selected_key; - std::string m_param; +public: + bool Enable(bool enable) override { m_enabled = enable; return m_enabled;} - void setValue(std::string value); - void update_options(std::vector ops){ + void setValue(std::string value); + std::string getValue(); + + void msw_rescale() { m_selected_bk.msw_rescale(); Refresh();}; + void update_options(std::vector ops){ m_ops = ops; selected_key = ""; auto width = ops.size() * FromDIP(56) + FromDIP(8); @@ -238,31 +242,42 @@ public: SetMaxSize(wxSize(width, height)); Refresh(); }; - std::string getValue(); -public: - void msw_rescale() { m_selected_bk.msw_rescale(); Refresh(); }; +private: + void OnPaint(wxPaintEvent &event); + void render(wxDC &dc); + void on_left_down(wxMouseEvent &evt); + void doRender(wxDC &dc); }; class PrintOption : public wxPanel { +private: + std::string m_param; + std::vector m_ops; + Label *m_printoption_title{nullptr}; + PrintOptionItem *m_printoption_item{nullptr}; + public: PrintOption(wxWindow *parent, wxString title, wxString tips, std::vector ops, std::string param = ""); ~PrintOption(){}; + +public: + void enable(bool en) { m_printoption_item->Enable(en); } + + void setValue(std::string value); + std::string getValue(); + int getValueInt(); + + void update_options(std::vector ops, const wxString &tips); + void update_tooltip(const wxString &tips); + + void msw_rescale() { m_printoption_item->msw_rescale(); }; + +private: void OnPaint(wxPaintEvent &event); void render(wxDC &dc); void doRender(wxDC &dc); - void msw_rescale() { m_printoption_item->msw_rescale(); }; - void enable(bool en){m_printoption_item->Enable(en);}; - - std::string m_param; - std::vector m_ops; - Label* m_printoption_title{nullptr}; - PrintOptionItem* m_printoption_item{nullptr}; - void setValue(std::string value); - void update_options(std::vector ops, const wxString &tips); - std::string getValue(); - int getValueInt(); }; class ThumbnailPanel : public wxPanel