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

@ -5,33 +5,34 @@
#include "slic3r/GUI/Plater.hpp"
#include "slic3r/GUI/GUI.hpp"
#include "slic3r/GUI/GUI_App.hpp"
#include "slic3r/GUI/format.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");
SendJob::SendJob(std::shared_ptr<ProgressIndicator> pri, Plater* plater, std::string dev_id)
: PlaterJob{ std::move(pri), plater },
SendJob::SendJob(std::string dev_id)
: m_plater{wxGetApp().plater()},
m_dev_id(dev_id)
{
m_print_job_completed_id = plater->get_send_finished_event();
m_print_job_completed_id = m_plater->get_send_finished_event();
}
void SendJob::prepare()
@ -45,16 +46,6 @@ void SendJob::prepare()
}
}
void SendJob::on_exception(const std::exception_ptr &eptr)
{
try {
if (eptr)
std::rethrow_exception(eptr);
} catch (std::exception &e) {
PlaterJob::on_exception(eptr);
}
}
wxString SendJob::get_http_error_msg(unsigned int status, std::string body)
{
int code = 0;
@ -112,10 +103,10 @@ inline std::string get_transform_string(int bytes)
return buffer;
}
void SendJob::process()
void SendJob::process(Ctl &ctl)
{
BBL::PrintParams params;
wxString msg;
std::string msg;
int curr_percent = 10;
NetworkAgent* m_agent = wxGetApp().getAgent();
AppConfig* config = wxGetApp().app_config;
@ -154,13 +145,15 @@ void SendJob::process()
/* display info */
msg = _L("Sending gcode file over LAN");
msg = _u8L("Sending gcode file over LAN");
/* if (this->connection_type == "lan") {
msg = _L("Sending gcode file over LAN");
msg = _u8L("Sending gcode file over LAN");
}
else {
msg = _L("Sending gcode file through cloud service");
msg = _u8L("Sending gcode file through cloud service");
}*/
ctl.call_on_main_thread([this] { prepare(); }).wait();
ctl.update_status(0, msg);
int total_plate_num = m_plater->get_partplate_list().get_plate_count();
@ -183,19 +176,19 @@ void SendJob::process()
}
if (plate == nullptr) {
BOOST_LOG_TRIVIAL(error) << "can not find plate with valid gcode file when sending to print, plate_index="<< job_data.plate_idx;
update_status(curr_percent, check_gcode_failed_str);
ctl.update_status(curr_percent, check_gcode_failed_str);
return;
}
}
/* check gcode is valid */
if (!plate->is_valid_gcode_file()) {
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;
}
@ -223,7 +216,7 @@ void SendJob::process()
params.use_ssl_for_ftp = m_local_use_ssl_for_ftp;
params.use_ssl_for_mqtt = m_local_use_ssl_for_mqtt;
wxString error_text;
wxString msg_text;
std::string msg_text;
const int StagePercentPoint[(int)PrintingStageFinished + 1] = {
20, // PrintingStageCreate
@ -235,36 +228,37 @@ void SendJob::process()
100 // PrintingStageFinished
};
auto update_fn = [this, &msg, &curr_percent, &error_text, StagePercentPoint](int stage, int code, std::string info) {
auto update_fn = [this, &ctl,
&msg, &curr_percent, &error_text, StagePercentPoint](int stage, int code, std::string info) {
if (stage == SendingPrintJobStage::PrintingStageCreate) {
if (this->connection_type == "lan") {
msg = _L("Sending gcode file over LAN");
msg = _u8L("Sending gcode file over LAN");
} else {
msg = _L("Sending gcode file to sdcard");
msg = _u8L("Sending gcode file to sdcard");
}
}
else if (stage == SendingPrintJobStage::PrintingStageUpload) {
if (code >= 0 && code <= 100 && !info.empty()) {
if (this->connection_type == "lan") {
msg = _L("Sending gcode file over LAN");
msg = _u8L("Sending gcode file over LAN");
}
else {
msg = _L("Sending gcode file to sdcard");
msg = _u8L("Sending gcode file to sdcard");
}
if (!info.empty()) {
msg += wxString::Format("(%s)", info);
msg += format("(%s)", info);
}
}
}
else if (stage == SendingPrintJobStage::PrintingStageFinished) {
msg = wxString::Format(_L("Successfully sent. Close current page in %s s"), info);
msg = format(_u8L("Successfully sent. Close current page in %s s"), info);
}
else {
if (this->connection_type == "lan") {
msg = _L("Sending gcode file over LAN");
msg = _u8L("Sending gcode file over LAN");
}
else {
msg = _L("Sending gcode file over LAN");
msg = _u8L("Sending gcode file over LAN");
}
}
@ -280,25 +274,25 @@ void SendJob::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();
};
@ -317,7 +311,7 @@ void SendJob::process()
&& this->has_sdcard) {
// try to send local with record
BOOST_LOG_TRIVIAL(info) << "send_job: try to send gcode to printer";
this->update_status(curr_percent, _L("Sending gcode file over LAN"));
ctl.update_status(curr_percent, _u8L("Sending gcode file over LAN"));
result = m_agent->start_send_gcode_to_sdcard(params, update_fn, cancel_fn, nullptr);
if (result == BAMBU_NETWORK_ERR_FTP_UPLOAD_FAILED) {
params.comments = "upload_failed";
@ -327,24 +321,24 @@ void SendJob::process()
if (result < 0) {
// try to send with cloud
BOOST_LOG_TRIVIAL(info) << "send_job: try to send gcode file to printer";
this->update_status(curr_percent, _L("Sending gcode file over LAN"));
ctl.update_status(curr_percent, _u8L("Sending gcode file over LAN"));
}
} else {
BOOST_LOG_TRIVIAL(info) << "send_job: try to send gcode file to printer";
this->update_status(curr_percent, _L("Sending gcode file over LAN"));
ctl.update_status(curr_percent, _u8L("Sending gcode file over LAN"));
}
} else {
if (this->has_sdcard) {
this->update_status(curr_percent, _L("Sending gcode file over LAN"));
ctl.update_status(curr_percent, _u8L("Sending gcode file over LAN"));
result = m_agent->start_send_gcode_to_sdcard(params, update_fn, cancel_fn, nullptr);
} else {
this->update_status(curr_percent, _L("An SD card needs to be inserted before sending to printer."));
ctl.update_status(curr_percent, _u8L("An SD card needs to be inserted before sending to printer."));
return;
}
}
if (was_canceled()) {
update_status(curr_percent, printjob_cancel_str);
if (ctl.was_canceled()) {
ctl.update_status(curr_percent, printjob_cancel_str);
return;
}
@ -374,7 +368,7 @@ void SendJob::process()
}
if (result != BAMBU_NETWORK_ERR_CANCELED) {
this->show_error_info(msg_text, 0, "", "");
ctl.show_error_info(msg_text, 0, "", "");
}
BOOST_LOG_TRIVIAL(error) << "send_job: failed, result = " << result;
@ -404,10 +398,18 @@ void SendJob::on_check_ip_address_success(std::function<void()> func)
}
void SendJob::finalize() {
if (was_canceled()) return;
void SendJob::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 SendJob::set_project_name(std::string name)