Port Emboss & SVG gizmo from PrusaSlicer (#2819)

* Rework UI jobs to make them more understandable and flexible.

* Update Orca specific jobs

* Fix progress issue

* Fix dark mode and window radius

* Update cereal version from 1.2.2 to 1.3.0

(cherry picked from commit prusa3d/PrusaSlicer@057232a275)

* Initial port of Emboss gizmo

* Bump up CGAL version to 5.4

(cherry picked from commit prusa3d/PrusaSlicer@1bf9dee3e7)

* Fix text rotation

* Fix test dragging

* Add text gizmo to right click menu

* Initial port of SVG gizmo

* Fix text rotation

* Fix Linux build

* Fix "from surface"

* Fix -90 rotation

* Fix icon path

* Fix loading font with non-ascii name

* Fix storing non-utf8 font descriptor in 3mf file

* Fix filtering with non-utf8 characters

* Emboss: Use Orca style input dialog

* Fix build on macOS

* Fix tooltip color in light mode

* InputText: fixed incorrect padding when FrameBorder > 0. (ocornut/imgui#4794, ocornut/imgui#3781)
InputTextMultiline: fixed vertical tracking with large values of FramePadding.y. (ocornut/imgui#3781, ocornut/imgui#4794)

(cherry picked from commit ocornut/imgui@072caa4a90)
(cherry picked from commit ocornut/imgui@bdd2a94315)

* SVG: Use Orca style input dialog

* Fix job progress update

* Fix crash when select editing text in preview screen

* Use Orca checkbox style

* Fix issue that toolbar icons are kept regenerated

* Emboss: Fix text & icon alignment

* SVG: Fix text & icon alignment

* Emboss: fix toolbar icon mouse hover state

* Add a simple subtle outline effect by drawing back faces using wireframe mode

* Disable selection outlines

* Show outline in white if the model color is too dark

* Make the outline algorithm more reliable

* Enable cull face, which fix render on Linux

* Fix `disable_cullface`

* Post merge fix

* Optimize selection rendering

* Fix scale gizmo

* Emboss: Fix text rotation if base object is scaled

* Fix volume synchronize

* Fix emboss rotation

* Emboss: Fix advance toggle

* Fix text position after reopened the project

* Make font style preview darker

* Make font style preview selector height shorter

---------

Co-authored-by: tamasmeszaros <meszaros.q@gmail.com>
Co-authored-by: ocornut <omarcornut@gmail.com>
Co-authored-by: SoftFever <softfeverever@gmail.com>
This commit is contained in:
Noisyfox 2023-12-09 22:46:18 +08:00 committed by GitHub
parent 7a8e1929ee
commit 933aa3050b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
197 changed files with 27190 additions and 2454 deletions

View file

@ -6,38 +6,39 @@
#include "slic3r/GUI/GUI.hpp"
#include "slic3r/GUI/GUI_App.hpp"
#include "slic3r/GUI/MainFrame.hpp"
#include "slic3r/GUI/format.hpp"
#include "bambu_networking.hpp"
namespace Slic3r {
namespace GUI {
static wxString check_gcode_failed_str = _L("Abnormal print file data. Please slice again.");
static wxString printjob_cancel_str = _L("Task canceled.");
static wxString timeout_to_upload_str = _L("Upload task timed out. Please check the network status and try again.");
static wxString failed_in_cloud_service_str = _L("Cloud service connection failed. Please try again.");
static wxString file_is_not_exists_str = _L("Print file not found. please slice again.");
static wxString file_over_size_str = _L("The print file exceeds the maximum allowable size (1GB). Please simplify the model and slice again.");
static wxString print_canceled_str = _L("Task canceled.");
static wxString send_print_failed_str = _L("Failed to send the print job. Please try again.");
static wxString upload_ftp_failed_str = _L("Failed to upload file to ftp. Please try again.");
static auto check_gcode_failed_str = _u8L("Abnormal print file data. Please slice again.");
static auto printjob_cancel_str = _u8L("Task canceled.");
static auto timeout_to_upload_str = _u8L("Upload task timed out. Please check the network status and try again.");
static auto failed_in_cloud_service_str = _u8L("Cloud service connection failed. Please try again.");
static auto file_is_not_exists_str = _u8L("Print file not found. please slice again.");
static auto file_over_size_str = _u8L("The print file exceeds the maximum allowable size (1GB). Please simplify the model and slice again.");
static auto print_canceled_str = _u8L("Task canceled.");
static auto send_print_failed_str = _u8L("Failed to send the print job. Please try again.");
static auto upload_ftp_failed_str = _u8L("Failed to upload file to ftp. Please try again.");
static wxString desc_network_error = _L("Check the current status of the bambu server by clicking on the link above.");
static wxString desc_file_too_large = _L("The size of the print file is too large. Please adjust the file size and try again.");
static wxString desc_fail_not_exist = _L("Print file not found, Please slice it again and send it for printing.");
static wxString desc_upload_ftp_failed = _L("Failed to upload print file to FTP. Please check the network status and try again.");
static auto desc_network_error = _u8L("Check the current status of the bambu server by clicking on the link above.");
static auto desc_file_too_large = _u8L("The size of the print file is too large. Please adjust the file size and try again.");
static auto desc_fail_not_exist = _u8L("Print file not found, Please slice it again and send it for printing.");
static auto desc_upload_ftp_failed = _u8L("Failed to upload print file to FTP. Please check the network status and try again.");
static wxString sending_over_lan_str = _L("Sending print job over LAN");
static wxString sending_over_cloud_str = _L("Sending print job through cloud service");
static auto sending_over_lan_str = _u8L("Sending print job over LAN");
static auto sending_over_cloud_str = _u8L("Sending print job through cloud service");
static wxString wait_sending_finish = _L("Print task sending times out.");
static wxString desc_wait_sending_finish = _L("The printer timed out while receiving a print job. Please check if the network is functioning properly and send the print again.");
static auto wait_sending_finish = _u8L("Print task sending times out.");
static auto desc_wait_sending_finish = _u8L("The printer timed out while receiving a print job. Please check if the network is functioning properly and send the print again.");
PrintJob::PrintJob(std::shared_ptr<ProgressIndicator> pri, Plater* plater, std::string dev_id)
: PlaterJob{ std::move(pri), plater },
PrintJob::PrintJob(std::string dev_id)
: m_plater{wxGetApp().plater()},
m_dev_id(dev_id),
m_is_calibration_task(false)
{
m_print_job_completed_id = plater->get_print_finished_event();
m_print_job_completed_id = m_plater->get_print_finished_event();
}
void PrintJob::prepare()
@ -52,16 +53,6 @@ void PrintJob::prepare()
}
}
void PrintJob::on_exception(const std::exception_ptr &eptr)
{
try {
if (eptr)
std::rethrow_exception(eptr);
} catch (std::exception &e) {
PlaterJob::on_exception(eptr);
}
}
void PrintJob::on_success(std::function<void()> success)
{
m_success_fun = success;
@ -131,22 +122,25 @@ wxString PrintJob::get_http_error_msg(unsigned int status, std::string body)
return wxEmptyString;
}
void PrintJob::process()
void PrintJob::process(Ctl &ctl)
{
/* display info */
wxString msg;
std::string msg;
wxString error_str;
int curr_percent = 10;
NetworkAgent* m_agent = wxGetApp().getAgent();
AppConfig* config = wxGetApp().app_config;
if (this->connection_type == "lan") {
msg = _L("Sending print job over LAN");
msg = _u8L("Sending print job over LAN");
}
else {
msg = _L("Sending print job through cloud service");
msg = _u8L("Sending print job through cloud service");
}
ctl.update_status(0, msg);
ctl.call_on_main_thread([this] { prepare(); }).wait();
int result = -1;
unsigned int http_code;
std::string http_body;
@ -162,12 +156,12 @@ void PrintJob::process()
/* check gcode is valid */
if (!plate->is_valid_gcode_file() && m_print_type == "from_normal") {
update_status(curr_percent, check_gcode_failed_str);
ctl.update_status(curr_percent, check_gcode_failed_str);
return;
}
if (was_canceled()) {
update_status(curr_percent, printjob_cancel_str);
if (ctl.was_canceled()) {
ctl.update_status(curr_percent, printjob_cancel_str);
return;
}
}
@ -299,7 +293,7 @@ void PrintJob::process()
}
wxString error_text;
wxString msg_text;
std::string msg_text;
const int StagePercentPoint[(int)PrintingStageFinished + 1] = {
@ -315,7 +309,7 @@ void PrintJob::process()
bool is_try_lan_mode = false;
bool is_try_lan_mode_failed = false;
auto update_fn = [this,
auto update_fn = [this, &ctl,
&is_try_lan_mode,
&is_try_lan_mode_failed,
&msg,
@ -327,49 +321,49 @@ void PrintJob::process()
if (stage == BBL::SendingPrintJobStage::PrintingStageCreate && !is_try_lan_mode_failed) {
if (this->connection_type == "lan") {
msg = _L("Sending print job over LAN");
msg = _u8L("Sending print job over LAN");
} else {
msg = _L("Sending print job through cloud service");
msg = _u8L("Sending print job through cloud service");
}
}
else if (stage == BBL::SendingPrintJobStage::PrintingStageUpload && !is_try_lan_mode_failed) {
if (code >= 0 && code <= 100 && !info.empty()) {
if (this->connection_type == "lan") {
msg = _L("Sending print job over LAN");
msg = _u8L("Sending print job over LAN");
} else {
msg = _L("Sending print job through cloud service");
msg = _u8L("Sending print job through cloud service");
}
msg += wxString::Format("(%s)", info);
msg += format("(%s)", info);
}
}
else if (stage == BBL::SendingPrintJobStage::PrintingStageWaiting) {
if (this->connection_type == "lan") {
msg = _L("Sending print job over LAN");
msg = _u8L("Sending print job over LAN");
} else {
msg = _L("Sending print job through cloud service");
msg = _u8L("Sending print job through cloud service");
}
}
else if (stage == BBL::SendingPrintJobStage::PrintingStageRecord && !is_try_lan_mode) {
msg = _L("Sending print configuration");
msg = _u8L("Sending print configuration");
}
else if (stage == BBL::SendingPrintJobStage::PrintingStageSending && !is_try_lan_mode) {
if (this->connection_type == "lan") {
msg = _L("Sending print job over LAN");
msg = _u8L("Sending print job over LAN");
} else {
msg = _L("Sending print job through cloud service");
msg = _u8L("Sending print job through cloud service");
}
}
else if (stage == BBL::SendingPrintJobStage::PrintingStageFinished) {
msg = wxString::Format(_L("Successfully sent. Will automatically jump to the device page in %ss"), info);
msg = format(_u8L("Successfully sent. Will automatically jump to the device page in %ss"), info);
if (m_print_job_completed_id == wxGetApp().plater()->get_send_calibration_finished_event()) {
msg = wxString::Format(_L("Successfully sent. Will automatically jump to the next page in %ss"), info);
msg = format(_u8L("Successfully sent. Will automatically jump to the next page in %ss"), info);
}
this->update_percent_finish();
ctl.clear_percent();
} else {
if (this->connection_type == "lan") {
msg = _L("Sending print job over LAN");
msg = _u8L("Sending print job over LAN");
} else {
msg = _L("Sending print job through cloud service");
msg = _u8L("Sending print job through cloud service");
}
}
@ -386,22 +380,22 @@ void PrintJob::process()
//get errors
if (code > 100 || code < 0 || stage == BBL::SendingPrintJobStage::PrintingStageERROR) {
if (code == BAMBU_NETWORK_ERR_PRINT_WR_FILE_OVER_SIZE || code == BAMBU_NETWORK_ERR_PRINT_SP_FILE_OVER_SIZE) {
m_plater->update_print_error_info(code, desc_file_too_large.ToStdString(), info);
m_plater->update_print_error_info(code, desc_file_too_large, info);
}else if (code == BAMBU_NETWORK_ERR_PRINT_WR_FILE_NOT_EXIST || code == BAMBU_NETWORK_ERR_PRINT_SP_FILE_NOT_EXIST){
m_plater->update_print_error_info(code, desc_fail_not_exist.ToStdString(), info);
m_plater->update_print_error_info(code, desc_fail_not_exist, info);
}else if (code == BAMBU_NETWORK_ERR_PRINT_LP_UPLOAD_FTP_FAILED || code == BAMBU_NETWORK_ERR_PRINT_SG_UPLOAD_FTP_FAILED) {
m_plater->update_print_error_info(code, desc_upload_ftp_failed.ToStdString(), info);
m_plater->update_print_error_info(code, desc_upload_ftp_failed, info);
}else {
m_plater->update_print_error_info(code, desc_network_error.ToStdString(), info);
m_plater->update_print_error_info(code, desc_network_error, info);
}
}
else {
this->update_status(curr_percent, msg);
ctl.update_status(curr_percent, msg);
}
};
auto cancel_fn = [this]() {
return was_canceled();
auto cancel_fn = [&ctl]() {
return ctl.was_canceled();
};
@ -444,7 +438,7 @@ void PrintJob::process()
boost::this_thread::sleep_for(boost::chrono::milliseconds(1000));
}
//this->update_status(curr_percent, _L("Print task sending times out."));
m_plater->update_print_error_info(BAMBU_NETWORK_ERR_TIMEOUT, wait_sending_finish.ToStdString(), desc_wait_sending_finish.ToStdString());
m_plater->update_print_error_info(BAMBU_NETWORK_ERR_TIMEOUT, wait_sending_finish, desc_wait_sending_finish);
BOOST_LOG_TRIVIAL(info) << "print_job: timeout, cancel the job" << obj->job_id_;
/* handle tiemout */
obj->command_task_cancel(curr_job_id);
@ -475,7 +469,7 @@ void PrintJob::process()
}
else {
BOOST_LOG_TRIVIAL(info) << "print_job: use ftp send print only";
this->update_status(curr_percent, _L("Sending print job over LAN"));
ctl.update_status(curr_percent, _u8L("Sending print job over LAN"));
is_try_lan_mode = true;
result = m_agent->start_local_print_with_record(params, update_fn, cancel_fn, wait_fn);
if (result < 0) {
@ -492,7 +486,7 @@ void PrintJob::process()
&& this->has_sdcard) {
// try to send local with record
BOOST_LOG_TRIVIAL(info) << "print_job: try to start local print with record";
this->update_status(curr_percent, _L("Sending print job over LAN"));
ctl.update_status(curr_percent, _u8L("Sending print job over LAN"));
result = m_agent->start_local_print_with_record(params, update_fn, cancel_fn, wait_fn);
if (result == 0) {
params.comments = "";
@ -507,22 +501,22 @@ void PrintJob::process()
is_try_lan_mode_failed = true;
// try to send with cloud
BOOST_LOG_TRIVIAL(warning) << "print_job: try to send with cloud";
this->update_status(curr_percent, _L("Sending print job through cloud service"));
ctl.update_status(curr_percent, _u8L("Sending print job through cloud service"));
result = m_agent->start_print(params, update_fn, cancel_fn, wait_fn);
}
}
else {
BOOST_LOG_TRIVIAL(info) << "print_job: send with cloud";
this->update_status(curr_percent, _L("Sending print job through cloud service"));
ctl.update_status(curr_percent, _u8L("Sending print job through cloud service"));
result = m_agent->start_print(params, update_fn, cancel_fn, wait_fn);
}
}
} else {
if (this->has_sdcard) {
this->update_status(curr_percent, _L("Sending print job over LAN"));
ctl.update_status(curr_percent, _u8L("Sending print job over LAN"));
result = m_agent->start_local_print(params, update_fn, cancel_fn);
} else {
this->update_status(curr_percent, _L("An SD card needs to be inserted before printing via LAN."));
ctl.update_status(curr_percent, _u8L("An SD card needs to be inserted before printing via LAN."));
return;
}
}
@ -542,13 +536,13 @@ void PrintJob::process()
msg_text = upload_ftp_failed_str;
} else if (result == BAMBU_NETWORK_ERR_CANCELED) {
msg_text = print_canceled_str;
this->update_status(0, msg_text);
ctl.update_status(0, msg_text);
} else {
msg_text = send_print_failed_str;
}
if (result != BAMBU_NETWORK_ERR_CANCELED) {
this->show_error_info(msg_text, 0, "", "");
ctl.show_error_info(msg_text, 0, "", "");
}
BOOST_LOG_TRIVIAL(error) << "print_job: failed, result = " << result;
@ -574,10 +568,17 @@ void PrintJob::process()
}
}
void PrintJob::finalize() {
if (was_canceled()) return;
void PrintJob::finalize(bool canceled, std::exception_ptr &eptr) {
try {
if (eptr)
std::rethrow_exception(eptr);
eptr = nullptr;
} catch (...) {
eptr = std::current_exception();
}
Job::finalize();
if (canceled || eptr)
return;
}
void PrintJob::set_project_name(std::string name)
@ -601,10 +602,10 @@ void PrintJob::on_check_ip_address_success(std::function<void()> func)
m_enter_ip_address_fun_success = func;
}
void PrintJob::connect_to_local_mqtt()
{
this->update_status(0, wxEmptyString);
}
// void PrintJob::connect_to_local_mqtt()
// {
// this->update_status(0, wxEmptyString);
// }
void PrintJob::set_calibration_task(bool is_calibration)
{