Skip to content

Commit 1e6d3e5

Browse files
committed
feat: show time-to-next-pause in Device Tab print status
Adds a "Pause in Xh Ym" label below the layer counter in the printing task panel whenever a scheduled PausePrint exists ahead of the current layer. The countdown is derived from the locally sliced gcode (layer Z-heights + custom gcode entries) and the printer's reported remaining time, updated on every status tick. Closes #10632 Closes #10562
1 parent 0a48d91 commit 1e6d3e5

2 files changed

Lines changed: 63 additions & 0 deletions

File tree

src/slic3r/GUI/StatusPanel.cpp

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
#include "StatusPanel.hpp"
22
#include "I18N.hpp"
3+
#include "Plater.hpp"
4+
#include "GLCanvas3D.hpp"
5+
#include "GCodeViewer.hpp"
6+
#include "libslic3r/CustomGCode.hpp"
37
#include "Widgets/Label.hpp"
48
#include "Widgets/Button.hpp"
59
#include "Widgets/StepCtrl.hpp"
@@ -1047,11 +1051,18 @@ void PrintingTaskPanel::create_panel(wxWindow *parent)
10471051
m_staticText_layers->SetForegroundColour(wxColour(107, 107, 107));
10481052
m_staticText_layers->Hide();
10491053

1054+
m_staticText_next_pause = new wxStaticText(penel_text, wxID_ANY, wxEmptyString);
1055+
m_staticText_next_pause->SetFont(wxFont(12, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false, wxT("HarmonyOS Sans SC")));
1056+
m_staticText_next_pause->SetForegroundColour(wxColour(107, 107, 107));
1057+
m_staticText_next_pause->Hide();
1058+
10501059
bSizer_text->Add(sizer_percent, 0, wxEXPAND, 0);
10511060
bSizer_text->Add(sizer_percent_icon, 0, wxEXPAND, 0);
10521061
bSizer_text->Add(0, 0, 1, wxEXPAND, 0);
10531062
bSizer_text->Add(m_staticText_layers, 0, wxALIGN_CENTER_VERTICAL | wxALL, 0);
10541063
bSizer_text->Add(0, 0, 0, wxLEFT, FromDIP(20));
1064+
bSizer_text->Add(m_staticText_next_pause, 0, wxALIGN_CENTER_VERTICAL | wxALL, 0);
1065+
bSizer_text->Add(0, 0, 0, wxLEFT, FromDIP(20));
10551066
bSizer_text->Add(m_staticText_progress_left, 0, wxALIGN_CENTER_VERTICAL | wxALL, 0);
10561067

10571068
m_printing_stage_panel = new wxPanel(penel_finish_time);
@@ -1657,6 +1668,19 @@ void PrintingTaskPanel::update_left_time(int mc_left_time)
16571668
}
16581669
}
16591670

1671+
void PrintingTaskPanel::update_next_pause(int seconds_to_pause)
1672+
{
1673+
if (!m_staticText_next_pause) return;
1674+
if (seconds_to_pause <= 0) {
1675+
m_staticText_next_pause->Hide();
1676+
return;
1677+
}
1678+
wxString label = wxString::Format(_L("Pause in %s"), get_bbl_monitor_time_dhm(seconds_to_pause));
1679+
m_staticText_next_pause->SetLabelText(label);
1680+
m_staticText_next_pause->Show();
1681+
m_staticText_next_pause->GetParent()->Layout();
1682+
}
1683+
16601684
void PrintingTaskPanel::update_layers_num(bool show, wxString num)
16611685
{
16621686
if ((show == m_staticText_layers->IsShown()) && (num == m_staticText_layers->GetLabelText())) { return; }
@@ -4184,6 +4208,43 @@ void StatusPanel::update_subtask(MachineObject *obj)
41844208
m_project_task_panel->enable_partskip_button(obj, true);
41854209
// update printing stage
41864210
m_project_task_panel->update_left_time(obj->mc_left_time);
4211+
4212+
// compute time to next scheduled pause from the current slice result
4213+
{
4214+
int next_pause_sec = -1;
4215+
if (obj->curr_layer > 0 && obj->total_layers > 1 && obj->mc_left_time > 0) {
4216+
try {
4217+
Plater* plater = wxGetApp().plater();
4218+
GLCanvas3D* canvas = plater ? plater->get_preview_canvas3D() : nullptr;
4219+
if (canvas) {
4220+
auto& viewer = canvas->get_gcode_viewer();
4221+
const std::vector<double> layers_zs = viewer.get_layers_zs();
4222+
const std::vector<CustomGCode::Item>& gcodes = viewer.get_custom_gcode_per_print_z();
4223+
if (!layers_zs.empty() && !gcodes.empty()) {
4224+
// current layer's Z (1-based, clamp to valid range)
4225+
int cur_idx = std::min((int)obj->curr_layer - 1, (int)layers_zs.size() - 1);
4226+
double cur_z = layers_zs[cur_idx];
4227+
// find the first PausePrint above current Z
4228+
for (const auto& item : gcodes) {
4229+
if (item.type == CustomGCode::PausePrint && item.print_z > cur_z) {
4230+
// map pause Z to layer index by lower_bound
4231+
auto it = std::lower_bound(layers_zs.begin(), layers_zs.end(), item.print_z);
4232+
int pause_layer = (int)std::distance(layers_zs.begin(), it) + 1;
4233+
int remaining_layers = obj->total_layers - obj->curr_layer;
4234+
int layers_to_pause = pause_layer - obj->curr_layer;
4235+
if (layers_to_pause > 0 && remaining_layers > 0) {
4236+
next_pause_sec = (int)((double)obj->mc_left_time * layers_to_pause / remaining_layers);
4237+
}
4238+
break;
4239+
}
4240+
}
4241+
}
4242+
}
4243+
} catch (...) {}
4244+
}
4245+
m_project_task_panel->update_next_pause(next_pause_sec);
4246+
}
4247+
41874248
if (obj->subtask_) {
41884249
m_project_task_panel->update_stage_value_with_machine(obj->get_curr_stage(), obj->subtask_->task_progress, obj);
41894250
m_project_task_panel->update_progress_percent(wxString::Format("%d", obj->subtask_->task_progress), "%");

src/slic3r/GUI/StatusPanel.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,7 @@ class PrintingTaskPanel : public wxPanel
308308
Label* m_staticText_finish_time;
309309
RectTextPanel* m_staticText_finish_day;
310310
wxStaticText* m_staticText_layers;
311+
wxStaticText* m_staticText_next_pause{nullptr};
311312
wxStaticText * m_has_rated_prompt;
312313
wxStaticText * m_request_failed_info;
313314
wxStaticBitmap* m_bitmap_thumbnail;
@@ -366,6 +367,7 @@ class PrintingTaskPanel : public wxPanel
366367
void update_left_time(wxString time);
367368
void update_finish_time(wxString finish_time);
368369
void update_left_time(int mc_left_time);
370+
void update_next_pause(int seconds_to_pause);
369371
void show_layers_num(bool show) { m_staticText_layers->Show(show); }
370372
void update_layers_num(bool show, wxString num = wxEmptyString);
371373
void show_priting_use_info(bool show, wxString time = wxEmptyString, wxString weight = wxEmptyString);

0 commit comments

Comments
 (0)