Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various improvements to SimplyPrint integration #4831

Merged
merged 25 commits into from
Jun 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
37ed6fc
Allow using BBL's device tab when 3rd party print host is used
Noisyfox Apr 1, 2024
ca11e8d
Add option to open SimplyPrint panel in device tab after uploading
Noisyfox Apr 1, 2024
674b2b3
Fix default print host for prusa connect
Noisyfox Apr 1, 2024
a7ed530
Do not set api key in device view when SimplyPrint is used
Noisyfox Apr 1, 2024
79e7c10
Sending 3mf file to SimplyPrint when using BBL printers
Noisyfox Apr 1, 2024
7f4fda2
Fix file extension when uploading 3mf
Noisyfox Apr 1, 2024
88a93f3
Prepare for large file uploading
Noisyfox Apr 5, 2024
1994118
Implement chunk upload
Noisyfox Apr 5, 2024
612ed77
Fix file uploading exceeding content size
Noisyfox Apr 9, 2024
995731e
Fix wrong field type
Noisyfox Apr 9, 2024
3630ad7
Add `temp=true` to all chunk upload calls
Noisyfox Apr 9, 2024
d9e2973
Add macro to enable test api
Noisyfox Apr 9, 2024
8ff0ff8
Merge branch 'main' into dev/simplyprint-improve
Noisyfox Apr 9, 2024
de1bc99
Fix another missing `temp=true`
Noisyfox Apr 9, 2024
b9ffa5b
Add delete token
Noisyfox Apr 10, 2024
0ccbb48
Try fixing build error on *nix systems
Noisyfox Apr 10, 2024
026e606
Merge branch 'main' into dev/simplyprint-improve
SoftFever Apr 15, 2024
aecff2c
Merge branch 'main' into dev/simplyprint-improve
Noisyfox Apr 19, 2024
0307bfb
Merge remote-tracking branch 'remote/main' into dev/simplyprint-improve
Noisyfox Apr 28, 2024
168dad8
Move the `bbl_use_print_host_webui` option to print host dialog. Also…
Noisyfox Apr 28, 2024
ea295d9
Merge branch 'main' into dev/simplyprint-improve
Noisyfox May 4, 2024
3b4ec68
Merge branch 'main' into dev/simplyprint-improve
Noisyfox Jun 18, 2024
25a51b5
Use a more generic option instead of SimplyPrint specific
Noisyfox Jun 18, 2024
4190b8f
Merge branch 'main' into dev/simplyprint-improve
SoftFever Jun 21, 2024
3e5590c
Merge branch 'main' into dev/simplyprint-improve
SoftFever Jun 21, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/libslic3r/PresetBundle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,20 @@ bool PresetBundle::use_bbl_network()
return use_bbl_network;
}

bool PresetBundle::use_bbl_device_tab() {
if (!is_bbl_vendor()) {
return false;
}

if (use_bbl_network()) {
return true;
}

const auto cfg = printers.get_edited_preset().config;
// Use bbl device tab if printhost webui url is not set
return cfg.opt_string("print_host_webui").empty();
}

//BBS: load project embedded presets
PresetsConfigSubstitutions PresetBundle::load_project_embedded_presets(std::vector<Preset*> project_presets, ForwardCompatibilitySubstitutionRule substitution_rule)
{
Expand Down
3 changes: 3 additions & 0 deletions src/libslic3r/PresetBundle.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,10 @@ class PresetBundle
VendorType get_current_vendor_type();
// Vendor related handy functions
bool is_bbl_vendor() { return get_current_vendor_type() == VendorType::Marlin_BBL; }
// Whether using bbl network for print upload
bool use_bbl_network();
// Whether using bbl's device tab
bool use_bbl_device_tab();

//BBS: project embedded preset logic
PresetsConfigSubstitutions load_project_embedded_presets(std::vector<Preset*> project_presets, ForwardCompatibilitySubstitutionRule substitution_rule);
Expand Down
1 change: 0 additions & 1 deletion src/libslic3r/PrintConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,6 @@ void PrintConfigDef::init_common_params()
def->cli = ConfigOptionDef::nocli;
def->set_default_value(new ConfigOptionString(""));


def = this->add("printhost_apikey", coString);
def->label = L("API Key / Password");
def->tooltip = L("Orca Slicer can upload G-code files to a printer host. This field should contain "
Expand Down
36 changes: 20 additions & 16 deletions src/slic3r/GUI/BackgroundSlicingProcess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -901,23 +901,27 @@ void BackgroundSlicingProcess::prepare_upload()
/ boost::filesystem::unique_path("." SLIC3R_APP_KEY ".upload.%%%%-%%%%-%%%%-%%%%");

if (m_print == m_fff_print) {
m_print->set_status(95, _utf8(L("Running post-processing scripts")));
std::string error_message;
if (copy_file(m_temp_output_path, source_path.string(), error_message) != SUCCESS)
throw Slic3r::RuntimeError(_utf8(L("Copying of the temporary G-code to the output G-code failed")));
m_upload_job.upload_data.upload_path = m_fff_print->print_statistics().finalize_output_path(m_upload_job.upload_data.upload_path.string());
// Orca: skip post-processing scripts for BBL printers as we have run them already in finalize_gcode()
// todo: do we need to copy the file?
if (m_upload_job.upload_data.use_3mf) {
source_path = m_upload_job.upload_data.source_path;
} else {
m_print->set_status(95, _utf8(L("Running post-processing scripts")));
std::string error_message;
if (copy_file(m_temp_output_path, source_path.string(), error_message) != SUCCESS)
throw Slic3r::RuntimeError(_utf8(L("Copying of the temporary G-code to the output G-code failed")));
m_upload_job.upload_data.upload_path = m_fff_print->print_statistics().finalize_output_path(m_upload_job.upload_data.upload_path.string());
// Orca: skip post-processing scripts for BBL printers as we have run them already in finalize_gcode()
// todo: do we need to copy the file?

// Make a copy of the source path, as run_post_process_scripts() is allowed to change it when making a copy of the source file
// (not here, but when the final target is a file).
if (!m_fff_print->is_BBL_printer()) {
std::string source_path_str = source_path.string();
std::string output_name_str = m_upload_job.upload_data.upload_path.string();
if (run_post_process_scripts(source_path_str, false, m_upload_job.printhost->get_name(), output_name_str,
m_fff_print->full_print_config()))
m_upload_job.upload_data.upload_path = output_name_str;
}
// Make a copy of the source path, as run_post_process_scripts() is allowed to change it when making a copy of the source file
// (not here, but when the final target is a file).
if (!m_fff_print->is_BBL_printer()) {
std::string source_path_str = source_path.string();
std::string output_name_str = m_upload_job.upload_data.upload_path.string();
if (run_post_process_scripts(source_path_str, false, m_upload_job.printhost->get_name(), output_name_str,
m_fff_print->full_print_config()))
m_upload_job.upload_data.upload_path = output_name_str;
}
}
} else {
m_upload_job.upload_data.upload_path = m_sla_print->print_statistics().finalize_output_path(m_upload_job.upload_data.upload_path.string());

Expand Down
36 changes: 29 additions & 7 deletions src/slic3r/GUI/MainFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1615,7 +1615,7 @@ wxBoxSizer* MainFrame::create_side_tools()
SidePopup* p = new SidePopup(this);

if (wxGetApp().preset_bundle
&& !wxGetApp().preset_bundle->use_bbl_network()) {
&& !wxGetApp().preset_bundle->is_bbl_vendor()) {
// ThirdParty Buttons
SideButton* export_gcode_btn = new SideButton(p, _L("Export G-code file"), "");
export_gcode_btn->SetCornerRadius(0);
Expand Down Expand Up @@ -1715,10 +1715,32 @@ wxBoxSizer* MainFrame::create_side_tools()
p->Dismiss();
});

bool support_send = true;
bool support_print_all = true;

const auto preset_bundle = wxGetApp().preset_bundle;
if (preset_bundle) {
if (preset_bundle->use_bbl_network()) {
// BBL network support everything
} else {
support_send = false; // All 3rd print hosts do not have the send options

auto cfg = preset_bundle->printers.get_edited_preset().config;
const auto host_type = cfg.option<ConfigOptionEnum<PrintHostType>>("host_type")->value;

// Only simply print support uploading all plates
support_print_all = host_type == PrintHostType::htSimplyPrint;
}
}

p->append_button(print_plate_btn);
p->append_button(print_all_btn);
p->append_button(send_to_printer_btn);
p->append_button(send_to_printer_all_btn);
if (support_print_all) {
p->append_button(print_all_btn);
}
if (support_send) {
p->append_button(send_to_printer_btn);
p->append_button(send_to_printer_all_btn);
}
if (enable_multi_machine) {
SideButton* print_multi_machine_btn = new SideButton(p, _L("Send to Multi-device"), "");
print_multi_machine_btn->SetCornerRadius(0);
Expand Down Expand Up @@ -3636,14 +3658,14 @@ void MainFrame::load_printer_url(wxString url, wxString apikey)
void MainFrame::load_printer_url()
{
PresetBundle &preset_bundle = *wxGetApp().preset_bundle;
if (preset_bundle.use_bbl_network())
if (preset_bundle.use_bbl_device_tab())
return;

auto cfg = preset_bundle.printers.get_edited_preset().config;
wxString url = cfg.opt_string("print_host_webui").empty() ? cfg.opt_string("print_host") : cfg.opt_string("print_host_webui");
wxString apikey;
if (cfg.has("printhost_apikey") && (cfg.option<ConfigOptionEnum<PrintHostType>>("host_type")->value == htPrusaLink ||
cfg.option<ConfigOptionEnum<PrintHostType>>("host_type")->value == htPrusaConnect))
const auto host_type = cfg.option<ConfigOptionEnum<PrintHostType>>("host_type")->value;
if (cfg.has("printhost_apikey") && (host_type == htPrusaLink || host_type == htPrusaConnect))
apikey = cfg.opt_string("printhost_apikey");
if (!url.empty()) {
if (!url.Lower().starts_with("http"))
Expand Down
82 changes: 65 additions & 17 deletions src/slic3r/GUI/PhysicalPrinterDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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)
Expand All @@ -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;
Expand All @@ -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
Expand All @@ -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");
temp->SetValue("https://simplyprint.io/panel");
}
m_config->opt_string("print_host") = "https://simplyprint.io";
m_config->opt_string("print_host") = "https://simplyprint.io/panel";
}
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");

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");
Expand Down
1 change: 1 addition & 0 deletions src/slic3r/GUI/PhysicalPrinterDialog.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ class PhysicalPrinterDialog : public DPIDialog
void update_printhost_buttons();
void update_printers();
void update_ports();
void update_webui();

protected:
void on_dpi_changed(const wxRect& suggested_rect) override;
Expand Down
Loading
Loading