mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-16 11:17:51 -06:00
ENH: refine print progress display when sending a print
Change-Id: Ie31cc0c1f71f251b79cf5ac2da64cc61c77a4858 Signed-off-by: Stone Li <stone.li@bambulab.com>
This commit is contained in:
parent
b54870106d
commit
8f9d8b55eb
2 changed files with 56 additions and 25 deletions
|
@ -168,18 +168,26 @@ void PrintJob::process()
|
||||||
wxString error_text;
|
wxString error_text;
|
||||||
wxString msg_text;
|
wxString msg_text;
|
||||||
|
|
||||||
auto update_fn = [this, &msg, &curr_percent, &error_text](int stage, int code, std::string info) {
|
|
||||||
|
const int StagePercentPoint[(int)PrintingStageFinished + 1] = {
|
||||||
|
20, // PrintingStageCreate
|
||||||
|
30, // PrintingStageUpload
|
||||||
|
70, // PrintingStageWaiting
|
||||||
|
75, // PrintingStageRecord
|
||||||
|
99, // PrintingStageSending
|
||||||
|
100 // PrintingStageFinished
|
||||||
|
};
|
||||||
|
|
||||||
|
auto update_fn = [this, &msg, &curr_percent, &error_text, StagePercentPoint](int stage, int code, std::string info) {
|
||||||
if (stage == BBL::SendingPrintJobStage::PrintingStageCreate) {
|
if (stage == BBL::SendingPrintJobStage::PrintingStageCreate) {
|
||||||
if (this->connection_type == "lan") {
|
if (this->connection_type == "lan") {
|
||||||
msg = _L("Sending print job over LAN");
|
msg = _L("Sending print job over LAN");
|
||||||
} else {
|
} else {
|
||||||
msg = _L("Sending print job through cloud service");
|
msg = _L("Sending print job through cloud service");
|
||||||
}
|
}
|
||||||
curr_percent = 25;
|
|
||||||
}
|
}
|
||||||
else if (stage == BBL::SendingPrintJobStage::PrintingStageUpload) {
|
else if (stage == BBL::SendingPrintJobStage::PrintingStageUpload) {
|
||||||
curr_percent = 30;
|
if (code >= 0 && code <= 100 && !info.empty()) {
|
||||||
if (code == 0 && !info.empty()) {
|
|
||||||
if (this->connection_type == "lan") {
|
if (this->connection_type == "lan") {
|
||||||
msg = _L("Sending print job over LAN");
|
msg = _L("Sending print job over LAN");
|
||||||
} else {
|
} else {
|
||||||
|
@ -194,10 +202,8 @@ void PrintJob::process()
|
||||||
} else {
|
} else {
|
||||||
msg = _L("Sending print job through cloud service");
|
msg = _L("Sending print job through cloud service");
|
||||||
}
|
}
|
||||||
curr_percent = 50;
|
|
||||||
}
|
}
|
||||||
else if (stage == BBL::SendingPrintJobStage::PrintingStageRecord) {
|
else if (stage == BBL::SendingPrintJobStage::PrintingStageRecord) {
|
||||||
curr_percent = 70;
|
|
||||||
msg = _L("Sending print configuration");
|
msg = _L("Sending print configuration");
|
||||||
}
|
}
|
||||||
else if (stage == BBL::SendingPrintJobStage::PrintingStageSending) {
|
else if (stage == BBL::SendingPrintJobStage::PrintingStageSending) {
|
||||||
|
@ -206,10 +212,8 @@ void PrintJob::process()
|
||||||
} else {
|
} else {
|
||||||
msg = _L("Sending print job through cloud service");
|
msg = _L("Sending print job through cloud service");
|
||||||
}
|
}
|
||||||
curr_percent = 90;
|
|
||||||
}
|
}
|
||||||
else if (stage == BBL::SendingPrintJobStage::PrintingStageFinished) {
|
else if (stage == BBL::SendingPrintJobStage::PrintingStageFinished) {
|
||||||
curr_percent = 100;
|
|
||||||
msg = wxString::Format(_L("Successfully sent. Will automatically jump to the device page in %s s"), info);
|
msg = wxString::Format(_L("Successfully sent. Will automatically jump to the device page in %s s"), info);
|
||||||
} else {
|
} else {
|
||||||
if (this->connection_type == "lan") {
|
if (this->connection_type == "lan") {
|
||||||
|
@ -218,7 +222,18 @@ void PrintJob::process()
|
||||||
msg = _L("Sending print job through cloud service");
|
msg = _L("Sending print job through cloud service");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (code != 0) {
|
|
||||||
|
// update current percnet
|
||||||
|
if (stage >= 0 && stage <= (int) PrintingStageFinished) {
|
||||||
|
curr_percent = StagePercentPoint[stage];
|
||||||
|
if ((stage == BBL::SendingPrintJobStage::PrintingStageUpload
|
||||||
|
|| stage == BBL::SendingPrintJobStage::PrintingStageRecord)
|
||||||
|
&& (code > 0 && code <= 100)) {
|
||||||
|
curr_percent = (StagePercentPoint[stage + 1] - StagePercentPoint[stage]) * code / 100 + StagePercentPoint[stage];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (code > 100 || code < 0) {
|
||||||
error_text = this->get_http_error_msg(code, info);
|
error_text = this->get_http_error_msg(code, info);
|
||||||
msg += wxString::Format("[%s]", error_text);
|
msg += wxString::Format("[%s]", error_text);
|
||||||
}
|
}
|
||||||
|
|
|
@ -168,30 +168,37 @@ void SendJob::process()
|
||||||
wxString error_text;
|
wxString error_text;
|
||||||
wxString msg_text;
|
wxString msg_text;
|
||||||
|
|
||||||
auto update_fn = [this, &msg, &curr_percent, &error_text](int stage, int code, std::string info) {
|
const int StagePercentPoint[(int)PrintingStageFinished + 1] = {
|
||||||
|
20, // PrintingStageCreate
|
||||||
|
30, // PrintingStageUpload
|
||||||
|
99, // PrintingStageWaiting
|
||||||
|
99, // PrintingStageRecord
|
||||||
|
99, // PrintingStageSending
|
||||||
|
100 // PrintingStageFinished
|
||||||
|
};
|
||||||
|
|
||||||
|
auto update_fn = [this, &msg, &curr_percent, &error_text, StagePercentPoint](int stage, int code, std::string info) {
|
||||||
if (stage == SendingPrintJobStage::PrintingStageCreate) {
|
if (stage == SendingPrintJobStage::PrintingStageCreate) {
|
||||||
if (this->connection_type == "lan") {
|
if (this->connection_type == "lan") {
|
||||||
msg = _L("Sending gcode file over LAN");
|
msg = _L("Sending gcode file over LAN");
|
||||||
} else {
|
} else {
|
||||||
msg = _L("Sending gcode file to sdcard");
|
msg = _L("Sending gcode file to sdcard");
|
||||||
}
|
}
|
||||||
curr_percent = 25;
|
|
||||||
}
|
}
|
||||||
else if (stage == SendingPrintJobStage::PrintingStageUpload) {
|
else if (stage == SendingPrintJobStage::PrintingStageUpload) {
|
||||||
if (code == 0 && !info.empty()) {
|
if (code >= 0 && code <= 100 && !info.empty()) {
|
||||||
if (this->connection_type == "lan") {
|
if (this->connection_type == "lan") {
|
||||||
msg = _L("Sending gcode file over LAN");
|
msg = _L("Sending gcode file over LAN");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
msg = _L("Sending gcode file to sdcard");
|
msg = _L("Sending gcode file to sdcard");
|
||||||
}
|
}
|
||||||
msg += wxString::Format("(%s)", info);
|
if (!info.empty()) {
|
||||||
curr_percent = 40;
|
msg += wxString::Format("(%s)", info);
|
||||||
this->update_status(curr_percent, msg);
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (stage == SendingPrintJobStage::PrintingStageFinished) {
|
else if (stage == SendingPrintJobStage::PrintingStageFinished) {
|
||||||
curr_percent = 100;
|
|
||||||
msg = wxString::Format(_L("Successfully sent. Close current page in %s s"), info);
|
msg = wxString::Format(_L("Successfully sent. Close current page in %s s"), info);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -200,10 +207,19 @@ void SendJob::process()
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
msg = _L("Sending gcode file over LAN");
|
msg = _L("Sending gcode file over LAN");
|
||||||
//msg = _L("Sending gcode file through cloud service");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (code != 0) {
|
|
||||||
|
// update current percnet
|
||||||
|
if (stage >= 0 && stage <= (int) PrintingStageFinished) {
|
||||||
|
curr_percent = StagePercentPoint[stage];
|
||||||
|
if ((stage == BBL::SendingPrintJobStage::PrintingStageUpload) &&
|
||||||
|
(code > 0 && code <= 100)) {
|
||||||
|
curr_percent = (StagePercentPoint[stage + 1] - StagePercentPoint[stage]) * code / 100 + StagePercentPoint[stage];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (code < 0 || code > 100) {
|
||||||
error_text = this->get_http_error_msg(code, info);
|
error_text = this->get_http_error_msg(code, info);
|
||||||
msg += wxString::Format("[%s]", error_text);
|
msg += wxString::Format("[%s]", error_text);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue