Various improvements to SimplyPrint integration (#4831)

* Allow using BBL's device tab when 3rd party print host is used

* Add option to open SimplyPrint panel in device tab after uploading

* Fix default print host for prusa connect

* Do not set api key in device view when SimplyPrint is used

* Sending 3mf file to SimplyPrint when using BBL printers

* Fix file extension when uploading 3mf

* Prepare for large file uploading

* Implement chunk upload

* Fix file uploading exceeding content size

* Fix wrong field type

* Add `temp=true` to all chunk upload calls

* Add macro to enable test api

* Merge branch 'main' into dev/simplyprint-improve

* Fix another missing `temp=true`

* Add delete token

* Try fixing build error on *nix systems

* Merge branch 'main' into dev/simplyprint-improve

* Merge branch 'main' into dev/simplyprint-improve

* Merge remote-tracking branch 'remote/main' into dev/simplyprint-improve

# Conflicts:
#	src/slic3r/GUI/BackgroundSlicingProcess.cpp

* Move the `bbl_use_print_host_webui` option to print host dialog. Also make it a derived option of `print_host_webui` instead.

* Merge branch 'main' into dev/simplyprint-improve

# Conflicts:
#	src/slic3r/GUI/MainFrame.cpp
#	src/slic3r/GUI/Plater.cpp

* Merge branch 'main' into dev/simplyprint-improve

# Conflicts:
#	src/slic3r/GUI/Plater.cpp

* Use a more generic option instead of SimplyPrint specific

* Merge branch 'main' into dev/simplyprint-improve

* Merge branch 'main' into dev/simplyprint-improve
This commit is contained in:
Noisyfox 2024-06-21 19:48:00 +08:00 committed by GitHub
parent b7a0b30578
commit cd6cd0786f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
17 changed files with 505 additions and 110 deletions

View file

@ -130,6 +130,8 @@ void PhysicalPrinterDialog::build_printhost_settings(ConfigOptionsGroup* m_optgr
this->update_printhost_buttons();
if (opt_key == "printhost_port")
this->update_ports();
if (opt_key == "bbl_use_print_host_webui")
this->update_webui();
};
m_optgroup->append_single_option_line("host_type");
@ -253,6 +255,19 @@ void PhysicalPrinterDialog::build_printhost_settings(ConfigOptionsGroup* m_optgr
option.opt.width = Field::def_width_wider();
m_optgroup->append_single_option_line(option);
{
// For bbl printers, we build a fake option to control whether the original device tab should be used
ConfigOptionDef def;
def.type = coBool;
def.width = Field::def_width();
def.label = L("View print host webui in Device tab");
def.tooltip = L("Replace the BambuLab's device tab with print host webui");
def.set_default_value(new ConfigOptionBool(false));
auto option = Option(def, "bbl_use_print_host_webui");
m_optgroup->append_single_option_line(option);
}
m_optgroup->append_single_option_line("printhost_authorization_type");
option = m_optgroup->get_option("printhost_apikey");
@ -402,6 +417,30 @@ void PhysicalPrinterDialog::update_ports() {
}
}
void PhysicalPrinterDialog::update_webui()
{
const PrinterTechnology tech = Preset::printer_technology(*m_config);
if (tech == ptFFF) {
const auto opt = m_config->option<ConfigOptionEnum<PrintHostType>>("host_type");
if (opt->value == htSimplyPrint) {
bool bbl_use_print_host_webui = false;
if (Field* printhost_webui_field = m_optgroup->get_field("bbl_use_print_host_webui"); printhost_webui_field) {
if (CheckBox* temp = dynamic_cast<CheckBox*>(printhost_webui_field); temp) {
bbl_use_print_host_webui = boost::any_cast<bool>(temp->get_value());
}
}
const std::string v = bbl_use_print_host_webui ? "https://simplyprint.io/panel" : "";
if (Field* printhost_webui_field = m_optgroup->get_field("print_host_webui"); printhost_webui_field) {
if (wxTextCtrl* temp = dynamic_cast<TextCtrl*>(printhost_webui_field)->text_ctrl(); temp) {
temp->SetValue(v);
}
}
m_config->opt_string("print_host_webui") = v;
}
}
}
void PhysicalPrinterDialog::update_printhost_buttons()
{
std::unique_ptr<PrintHost> host(PrintHost::get_print_host(m_config));
@ -504,7 +543,8 @@ void PhysicalPrinterDialog::update(bool printer_change)
m_optgroup->show_field("host_type");
m_optgroup->enable_field("print_host");
m_optgroup->enable_field("print_host_webui");
m_optgroup->show_field("print_host_webui");
m_optgroup->hide_field("bbl_use_print_host_webui");
m_optgroup->enable_field("printhost_cafile");
m_optgroup->enable_field("printhost_ssl_ignore_revoke");
if (m_printhost_cafile_browse_btn)
@ -516,21 +556,12 @@ void PhysicalPrinterDialog::update(bool printer_change)
const auto current_host = temp->GetValue();
if (current_host == L"https://connect.prusa3d.com" ||
current_host == L"https://app.obico.io" ||
current_host == "https://simplyprint.io") {
current_host == "https://simplyprint.io" || current_host == "https://simplyprint.io/panel") {
temp->SetValue(wxString());
m_config->opt_string("print_host") = "";
}
}
}
if (Field* printhost_webui_field = m_optgroup->get_field("print_host_webui"); printhost_webui_field) {
if (wxTextCtrl* temp = dynamic_cast<TextCtrl*>(printhost_webui_field)->text_ctrl(); temp) {
const auto current_host = temp->GetValue();
if (current_host == "https://simplyprint.io/panel") {
temp->SetValue(wxString());
m_config->opt_string("print_host_webui") = "";
}
}
}
if (opt->value == htPrusaLink) { // PrusaConnect does NOT allow http digest
m_optgroup->show_field("printhost_authorization_type");
AuthorizationType auth_type = m_config->option<ConfigOptionEnum<AuthorizationType>>("printhost_authorization_type")->value;
@ -548,6 +579,7 @@ void PhysicalPrinterDialog::update(bool printer_change)
if (Field* printhost_field = m_optgroup->get_field("print_host"); printhost_field) {
if (wxTextCtrl* temp = dynamic_cast<TextCtrl*>(printhost_field)->text_ctrl(); temp && temp->GetValue().IsEmpty()) {
temp->SetValue(L"https://connect.prusa3d.com");
m_config->opt_string("print_host") = "https://connect.prusa3d.com";
}
}
} else if (opt->value == htObico) { // automatically show default obico address
@ -562,17 +594,33 @@ void PhysicalPrinterDialog::update(bool printer_change)
if (Field* printhost_field = m_optgroup->get_field("print_host"); printhost_field) {
printhost_field->disable();
if (wxTextCtrl* temp = dynamic_cast<TextCtrl*>(printhost_field)->text_ctrl(); temp && temp->GetValue().IsEmpty()) {
temp->SetValue("https://simplyprint.io");
}
m_config->opt_string("print_host") = "https://simplyprint.io";
}
if (Field* printhost_webui_field = m_optgroup->get_field("print_host_webui"); printhost_webui_field) {
printhost_webui_field->disable();
if (wxTextCtrl* temp = dynamic_cast<TextCtrl*>(printhost_webui_field)->text_ctrl(); temp && temp->GetValue().IsEmpty()) {
temp->SetValue("https://simplyprint.io/panel");
}
m_config->opt_string("print_host") = "https://simplyprint.io/panel";
}
const auto current_webui = m_config->opt_string("print_host_webui");
if (!current_webui.empty()) {
if (Field* printhost_webui_field = m_optgroup->get_field("print_host_webui"); printhost_webui_field) {
if (wxTextCtrl* temp = dynamic_cast<TextCtrl*>(printhost_webui_field)->text_ctrl(); temp) {
temp->SetValue("https://simplyprint.io/panel");
}
}
m_config->opt_string("print_host_webui") = "https://simplyprint.io/panel";
}
// For bbl printers, show option to control the device tab
if (wxGetApp().preset_bundle->is_bbl_vendor()) {
m_optgroup->show_field("bbl_use_print_host_webui");
const bool use_print_host_webui = !current_webui.empty();
if (Field* printhost_webui_field = m_optgroup->get_field("bbl_use_print_host_webui"); printhost_webui_field) {
if (CheckBox* temp = dynamic_cast<CheckBox*>(printhost_webui_field); temp) {
temp->set_value(use_print_host_webui);
}
}
}
m_optgroup->hide_field("print_host_webui");
m_optgroup->hide_field("printhost_apikey");
m_optgroup->disable_field("printhost_cafile");
m_optgroup->disable_field("printhost_ssl_ignore_revoke");