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

Support for SimplyPrint cloud integration #4783

Open
wants to merge 22 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
bd7a1f0
Support for SimplyPrint cloud integration (#4525)
Noisyfox Mar 23, 2024
b0eb776
Various improvements to SimplyPrint integration (#4831)
Noisyfox Jun 21, 2024
a903eb4
Add PresetBundle::is_bbl_vendor from Orca
Ocraftyone Aug 25, 2024
3227354
Fix some compile errors
Ocraftyone Aug 25, 2024
3b56b26
UI Jobs Rework
tamasmeszaros Nov 30, 2021
7be7a27
Add WindowWorker.hpp
Ocraftyone Jul 27, 2024
fad58c8
Reimplement BBL Job methods
Ocraftyone Aug 26, 2024
cc23d4d
Update BBL Jobs
Ocraftyone Aug 29, 2024
22d3fc0
Change PrintHostPostUploadAction to None
Ocraftyone Aug 29, 2024
6e7a2f4
Fix signature of upload function to match overridden function
Ocraftyone Aug 29, 2024
b699d0a
Try fixing build with gcc 13.3 (SoftFever/OrcaSlicer#5991) (#5992)
Noisyfox Jul 7, 2024
980ce65
Update job calls throughout the GUI
Ocraftyone Sep 1, 2024
4b9dfd8
Fix error in SimplyPrint.cpp
Ocraftyone Sep 1, 2024
f69ec01
Fix dark mode and window radius
Noisyfox Sep 1, 2024
fb18cd4
Fix progress issue
Noisyfox Sep 6, 2024
1f31465
Fix BBLStatusBarSend not properly updating progress bar
Ocraftyone Sep 7, 2024
9a20998
Undo whitespace only changes
Ocraftyone Aug 7, 2024
338b81f
Use boost property trees in place of nlohmann json library
Ocraftyone Aug 8, 2024
7131b50
Update to correct Client ID and User-Agent
Ocraftyone Sep 8, 2024
07fe19b
Merge remote-tracking branch 'origin/master' into bbs-simplyprint-int…
Ocraftyone Sep 8, 2024
0c3cb20
Merge branch 'master' into bbs-simplyprint-integration
Ocraftyone Sep 18, 2024
4f932a1
Merge branch 'master' into bbs-simplyprint-integration
Ocraftyone Sep 20, 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
5 changes: 3 additions & 2 deletions src/libslic3r/Preset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -898,7 +898,7 @@ static std::vector<std::string> s_Preset_printer_options {
"best_object_pos","head_wrap_detect_zone","printer_notes",
"enable_long_retraction_when_cut","long_retractions_when_cut","retraction_distances_when_cut",
//OrcaSlicer
"host_type", "print_host", "printhost_apikey",
"host_type", "print_host", "printhost_apikey", "bbl_use_printhost",
"print_host_webui",
"printhost_cafile","printhost_port","printhost_authorization_type",
"printhost_user", "printhost_password", "printhost_ssl_ignore_revoke",
Expand Down Expand Up @@ -2490,7 +2490,7 @@ const std::string& PresetCollection::get_preset_name_by_alias(const std::string&
it_preset->is_visible && (it_preset->is_compatible || size_t(it_preset - m_presets.begin()) == m_idx_selected))
return it_preset->name;
}

return alias;
}

Expand Down Expand Up @@ -3033,6 +3033,7 @@ static std::vector<std::string> s_PhysicalPrinter_opts {
"preset_name", // temporary option to compatibility with older Slicer
"preset_names",
"printer_technology",
"bbl_use_printhost",
"host_type",
"print_host",
"printhost_apikey",
Expand Down
41 changes: 41 additions & 0 deletions src/libslic3r/PresetBundle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,47 @@ Semver PresetBundle::get_vendor_profile_version(std::string vendor_name)
return result_ver;
}

VendorType PresetBundle::get_current_vendor_type()
{
auto t = VendorType::Unknown;
auto config = &printers.get_edited_preset().config;
std::string vendor_name;
for (auto vendor_profile : vendors) {
for (auto vendor_model : vendor_profile.second.models)
if (vendor_model.name == config->opt_string("printer_model")) {
vendor_name = vendor_profile.first;
break;
}
}
if (!vendor_name.empty())
{
if(vendor_name.compare("BBL") == 0)
t = VendorType::Marlin_BBL;
}
return t;
}

bool PresetBundle::use_bbl_network()
{
const auto cfg = printers.get_edited_preset().config;
const bool use_bbl_network = is_bbl_vendor() && !cfg.opt_bool("bbl_use_printhost");
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
16 changes: 16 additions & 0 deletions src/libslic3r/PresetBundle.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@
#define VALIDATE_PRESETS_MODIFIED_GCODES 3


// define an enum class of vendor type
enum class VendorType {
Unknown = 0,
Klipper,
Marlin,
Marlin_BBL
};
namespace Slic3r {

// Bundle of Print + Filament + Printer presets.
Expand Down Expand Up @@ -80,6 +87,15 @@ class PresetBundle
//BBS: get vendor's current version
Semver get_vendor_profile_version(std::string vendor_name);

// Orca: get vendor type
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);
std::vector<Preset*> get_current_project_embedded_presets();
Expand Down
14 changes: 11 additions & 3 deletions src/libslic3r/PrintConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ static t_config_enum_values s_keys_map_PrintHostType{
{ "flashair", htFlashAir },
{ "astrobox", htAstroBox },
{ "repetier", htRepetier },
{ "mks", htMKS }
{ "mks", htMKS },
{ "simplyprint", htSimplyPrint },
};
CONFIG_OPTION_ENUM_DEFINE_STATIC_MAPS(PrintHostType)

Expand Down Expand Up @@ -449,6 +450,13 @@ void PrintConfigDef::init_common_params()
def->mode = comDevelop;
def->set_default_value(new ConfigOptionStrings());

def = this->add("bbl_use_printhost", coBool);
def->label = L("Use 3rd-party print host");
def->tooltip = L("Allow controlling BambuLab's printer through 3rd party print hosts");
def->mode = comAdvanced;
def->cli = ConfigOptionDef::nocli;
def->set_default_value(new ConfigOptionBool(false));

def = this->add("print_host", coString);
def->label = L("Hostname, IP or URL");
def->tooltip = L("Slic3r can upload G-code files to a printer host. This field should contain "
Expand All @@ -466,7 +474,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("Slic3r can upload G-code files to a printer host. This field should contain "
Expand Down Expand Up @@ -936,7 +943,6 @@ void PrintConfigDef::init_fff_params()
def->enum_labels.emplace_back(L("Outer and inner brim"));
#endif
def->enum_labels.emplace_back(L("No-brim"));

def->mode = comSimple;
def->set_default_value(new ConfigOptionEnum<BrimType>(btAutoBrim));

Expand Down Expand Up @@ -2492,13 +2498,15 @@ void PrintConfigDef::init_fff_params()
def->enum_values.push_back("astrobox");
def->enum_values.push_back("repetier");
def->enum_values.push_back("mks");
def->enum_values.push_back("simplyprint");
def->enum_labels.push_back("PrusaLink");
def->enum_labels.push_back("OctoPrint");
def->enum_labels.push_back("Duet");
def->enum_labels.push_back("FlashAir");
def->enum_labels.push_back("AstroBox");
def->enum_labels.push_back("Repetier");
def->enum_labels.push_back("MKS");
def->enum_labels.push_back("SimplyPrint");
def->mode = comAdvanced;
def->cli = ConfigOptionDef::nocli;
def->set_default_value(new ConfigOptionEnum<PrintHostType>(htOctoPrint));
Expand Down
8 changes: 4 additions & 4 deletions src/libslic3r/PrintConfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ enum class FuzzySkinType {
};

enum PrintHostType {
htPrusaLink, htOctoPrint, htDuet, htFlashAir, htAstroBox, htRepetier, htMKS
htPrusaLink, htOctoPrint, htDuet, htFlashAir, htAstroBox, htRepetier, htMKS, htSimplyPrint
};

enum AuthorizationType {
Expand Down Expand Up @@ -225,7 +225,7 @@ enum BedType {

// BBS
enum LayerSeq {
flsAuto,
flsAuto,
flsCutomize
};

Expand Down Expand Up @@ -885,8 +885,8 @@ PRINT_CONFIG_CLASS_DEFINE(
PRINT_CONFIG_CLASS_DEFINE(
GCodeConfig,

((ConfigOptionString, before_layer_change_gcode))
((ConfigOptionString, printing_by_object_gcode))
((ConfigOptionString, before_layer_change_gcode))
((ConfigOptionString, printing_by_object_gcode))
((ConfigOptionFloats, deretraction_speed))
//BBS
((ConfigOptionBool, enable_arc_fitting))
Expand Down
19 changes: 16 additions & 3 deletions src/slic3r/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -323,9 +323,13 @@ set(SLIC3R_GUI_SOURCES
GUI/UpdateDialogs.cpp
GUI/UpdateDialogs.hpp
GUI/Jobs/Job.hpp
GUI/Jobs/Job.cpp
GUI/Jobs/PlaterJob.hpp
GUI/Jobs/PlaterJob.cpp
GUI/Jobs/Worker.hpp
GUI/Jobs/BoostThreadWorker.hpp
GUI/Jobs/BoostThreadWorker.cpp
GUI/Jobs/UIThreadWorker.hpp
GUI/Jobs/BusyCursorJob.hpp
GUI/Jobs/PlaterWorker.hpp
GUI/Jobs/WindowWorker.hpp
GUI/Jobs/UpgradeNetworkJob.hpp
GUI/Jobs/UpgradeNetworkJob.cpp
GUI/Jobs/ArrangeJob.hpp
Expand All @@ -347,6 +351,8 @@ set(SLIC3R_GUI_SOURCES
GUI/Jobs/BindJob.cpp
GUI/Jobs/NotificationProgressIndicator.hpp
GUI/Jobs/NotificationProgressIndicator.cpp
GUI/Jobs/ThreadSafeQueue.hpp
GUI/Jobs/SLAImportDialog.hpp
GUI/PhysicalPrinterDialog.hpp
GUI/PhysicalPrinterDialog.cpp
GUI/ProgressStatusBar.hpp
Expand Down Expand Up @@ -502,6 +508,13 @@ set(SLIC3R_GUI_SOURCES
Utils/FontConfigHelp.hpp
Utils/FontUtils.cpp
Utils/FontUtils.hpp

GUI/OAuthDialog.cpp
GUI/OAuthDialog.hpp
GUI/Jobs/OAuthJob.cpp
GUI/Jobs/OAuthJob.hpp
Utils/SimplyPrint.cpp
Utils/SimplyPrint.hpp
)

if (WIN32)
Expand Down
2 changes: 1 addition & 1 deletion src/slic3r/GUI/BBLStatusBarSend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ void BBLStatusBarSend::set_status_text(const char *txt)
{
this->set_status_text(wxString::FromUTF8(txt));
get_panel()->GetParent()->Layout();
get_panel()->GetParent()->Update();
// get_panel()->GetParent()->Update();
}

void BBLStatusBarSend::msw_rescale() {
Expand Down
26 changes: 15 additions & 11 deletions src/slic3r/GUI/BackgroundSlicingProcess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -835,17 +835,21 @@ 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());
// 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).
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;
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());
// 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).
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());
ThumbnailsList thumbnails = this->render_thumbnails(
Expand Down
19 changes: 9 additions & 10 deletions src/slic3r/GUI/BindDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
#include "GUI_App.hpp"
#include "Plater.hpp"
#include "Widgets/WebView.hpp"
#include "Jobs/WindowWorker.hpp"
#include "Jobs/BoostThreadWorker.hpp"

namespace Slic3r {
namespace GUI {
Expand Down Expand Up @@ -668,6 +670,7 @@ PingCodeBindDialog::~PingCodeBindDialog() {
m_simplebook->SetBackgroundColour(*wxWHITE);

m_status_bar = std::make_shared<BBLStatusBarBind>(m_simplebook);
m_worker = std::make_unique<WindowWorker<BoostThreadWorker>>(this, m_status_bar, "bind_worker");

auto button_panel = new wxPanel(m_simplebook, wxID_ANY, wxDefaultPosition, BIND_DIALOG_BUTTON_PANEL_SIZE);
button_panel->SetBackgroundColour(*wxWHITE);
Expand Down Expand Up @@ -808,10 +811,7 @@ PingCodeBindDialog::~PingCodeBindDialog() {

void BindMachineDialog::on_destroy()
{
if (m_bind_job) {
m_bind_job->cancel();
m_bind_job->join();
}
m_worker->cancel_all();
}

void BindMachineDialog::on_close(wxCloseEvent &event)
Expand Down Expand Up @@ -867,18 +867,17 @@ PingCodeBindDialog::~PingCodeBindDialog() {
agent->track_update_property("dev_ota_version", m_machine_info->get_ota_version());

m_simplebook->SetSelection(0);
m_bind_job = std::make_shared<BindJob>(m_status_bar, wxGetApp().plater(),
m_machine_info->dev_id, m_machine_info->dev_ip, m_machine_info->bind_sec_link, m_machine_info->bind_ssdp_version);
auto bind_job = std::make_unique<BindJob>(m_machine_info->dev_id, m_machine_info->dev_ip, m_machine_info->bind_sec_link, m_machine_info->bind_ssdp_version);

if (m_machine_info && (m_machine_info->get_printer_series() == PrinterSeries::SERIES_X1)) {
m_bind_job->set_improved(false);
bind_job->set_improved(false);
}
else {
m_bind_job->set_improved(m_allow_notice);
bind_job->set_improved(m_allow_notice);
}

m_bind_job->set_event_handle(this);
m_bind_job->start();
bind_job->set_event_handle(this);
replace_job(*m_worker, std::move(bind_job));
}

void BindMachineDialog::on_dpi_changed(const wxRect &suggested_rect)
Expand Down
3 changes: 2 additions & 1 deletion src/slic3r/GUI/BindDialog.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "Jobs/BindJob.hpp"
#include "BBLStatusBar.hpp"
#include "BBLStatusBarBind.hpp"
#include "Jobs/Worker.hpp"

#define BIND_DIALOG_GREY200 wxColour(248, 248, 248)
#define BIND_DIALOG_GREY800 wxColour(50, 58, 61)
Expand Down Expand Up @@ -119,7 +120,7 @@ class BindMachineDialog : public DPIDialog
std::shared_ptr<int> m_tocken;

MachineObject * m_machine_info{nullptr};
std::shared_ptr<BindJob> m_bind_job;
std::unique_ptr<Worker> m_worker;
std::shared_ptr<BBLStatusBarBind> m_status_bar;

public:
Expand Down
8 changes: 1 addition & 7 deletions src/slic3r/GUI/CalibrationWizardPresetPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1490,13 +1490,7 @@ void CalibrationPresetPage::on_cali_finished_job()
void CalibrationPresetPage::on_cali_cancel_job()
{
BOOST_LOG_TRIVIAL(info) << "CalibrationWizard::print_job: enter canceled";
if (CalibUtils::print_job) {
if (CalibUtils::print_job->is_running()) {
BOOST_LOG_TRIVIAL(info) << "calibration_print_job: canceled";
CalibUtils::print_job->cancel();
}
CalibUtils::print_job->join();
}
CalibUtils::m_print_worker->cancel_all();

m_sending_panel->reset();
m_sending_panel->Show(false);
Expand Down
8 changes: 1 addition & 7 deletions src/slic3r/GUI/CalibrationWizardSavePage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1384,13 +1384,7 @@ void CalibrationFlowCoarseSavePage::on_cali_finished_job()
void CalibrationFlowCoarseSavePage::on_cali_cancel_job()
{
BOOST_LOG_TRIVIAL(info) << "CalibrationWizard::print_job: enter canceled";
if (CalibUtils::print_job) {
if (CalibUtils::print_job->is_running()) {
BOOST_LOG_TRIVIAL(info) << "calibration_print_job: canceled";
CalibUtils::print_job->cancel();
}
CalibUtils::print_job->join();
}
CalibUtils::m_print_worker->cancel_all();

m_sending_panel->reset();
m_sending_panel->Show(false);
Expand Down
Loading