mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-11 19:59:01 +08:00
SPE-2676: Use correct gcode name for each bed when uploading to Connect instead of the one from Connect.
Pass changed filename from Connect.
This commit is contained in:
parent
83aa5b123a
commit
4bb316eb25
@ -6481,11 +6481,12 @@ void Plater::printables_to_connect_gcode(const std::string& url)
|
||||
|
||||
}
|
||||
|
||||
std::optional<PrintHostJob> Plater::get_connect_print_host_job() {
|
||||
std::optional<PrintHostJob> Plater::get_connect_print_host_job(bool multiple_beds)
|
||||
{
|
||||
assert(p->user_account->is_logged());
|
||||
std::string dialog_msg;
|
||||
{
|
||||
PrinterPickWebViewDialog dialog(this, dialog_msg);
|
||||
PrinterPickWebViewDialog dialog(this, dialog_msg, multiple_beds);
|
||||
if (dialog.ShowModal() != wxID_OK) {
|
||||
return std::nullopt;
|
||||
}
|
||||
@ -6538,13 +6539,13 @@ std::optional<PrintHostJob> Plater::get_connect_print_host_job() {
|
||||
|
||||
void Plater::connect_gcode()
|
||||
{
|
||||
if (auto upload_job{get_connect_print_host_job()}) {
|
||||
if (auto upload_job{get_connect_print_host_job(false)}) {
|
||||
p->export_gcode(fs::path(), false, std::move(*upload_job));
|
||||
}
|
||||
}
|
||||
|
||||
void Plater::connect_gcode_all() {
|
||||
auto optional_upload_job{get_connect_print_host_job()};
|
||||
auto optional_upload_job{get_connect_print_host_job(true)};
|
||||
if (!optional_upload_job) {
|
||||
return;
|
||||
}
|
||||
@ -6556,6 +6557,7 @@ void Plater::connect_gcode_all() {
|
||||
if (print_host_ptr == nullptr) {
|
||||
throw std::runtime_error{"Sending to connect requires PrusaConnectNew host."};
|
||||
}
|
||||
|
||||
const PrusaConnectNew connect{*print_host_ptr};
|
||||
|
||||
std::vector<std::pair< int, std::optional<fs::path> >> paths;
|
||||
@ -6566,13 +6568,32 @@ void Plater::connect_gcode_all() {
|
||||
paths.emplace_back(print_index, std::nullopt);
|
||||
continue;
|
||||
}
|
||||
// Prevously, filename from Connect FE was taken and used for each gcode file.
|
||||
// Now naming is same as in gcode export.
|
||||
fs::path default_filename{upload_job_template.upload_data.upload_path};
|
||||
this->with_mocked_fff_background_process(
|
||||
*print,
|
||||
this->p->gcode_results[print_index],
|
||||
print_index,
|
||||
[&](){
|
||||
const auto optional_file{this->get_default_output_file()};
|
||||
if (!optional_file) {
|
||||
return;
|
||||
}
|
||||
if (print_index != s_multiple_beds.get_number_of_beds() - 1 || default_filename.empty()) {
|
||||
const fs::path &default_file{*optional_file};
|
||||
default_filename = default_file.filename();
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
const fs::path filename{upload_job_template.upload_data.upload_path};
|
||||
paths.emplace_back(print_index, fs::path{
|
||||
filename.stem().string()
|
||||
+ "_bed" + std::to_string(print_index + 1)
|
||||
+ filename.extension().string()
|
||||
});
|
||||
const fs::path filename_fixed{
|
||||
default_filename.stem().string()
|
||||
+ "_bed"
|
||||
+ std::to_string(print_index + 1)
|
||||
+ default_filename.extension().string()
|
||||
};
|
||||
paths.emplace_back(print_index, filename_fixed);
|
||||
}
|
||||
|
||||
BulkExportDialog dialog{paths};
|
||||
|
@ -249,7 +249,7 @@ public:
|
||||
void send_gcode_inner(DynamicPrintConfig* physical_printer_config);
|
||||
void eject_drive();
|
||||
|
||||
std::optional<PrintHostJob> get_connect_print_host_job();
|
||||
std::optional<PrintHostJob> get_connect_print_host_job(bool multiple_beds);
|
||||
void connect_gcode();
|
||||
void connect_gcode_all();
|
||||
void printables_to_connect_gcode(const std::string& url);
|
||||
|
@ -452,13 +452,14 @@ void WebViewDialog::EndModal(int retCode)
|
||||
wxDialog::EndModal(retCode);
|
||||
}
|
||||
|
||||
PrinterPickWebViewDialog::PrinterPickWebViewDialog(wxWindow* parent, std::string& ret_val)
|
||||
PrinterPickWebViewDialog::PrinterPickWebViewDialog(wxWindow* parent, std::string& ret_val, bool multiple_beds)
|
||||
: WebViewDialog(parent
|
||||
, GUI::from_u8(Utils::ServiceConfig::instance().connect_select_printer_url())
|
||||
, _L("Choose a printer")
|
||||
, wxSize(parent->GetClientSize().x / 4 * 3, parent->GetClientSize().y/ 4 * 3)
|
||||
,{"_prusaSlicer"}
|
||||
, "connect_loading")
|
||||
, m_multiple_beds(multiple_beds)
|
||||
, m_ret_val(ret_val)
|
||||
{
|
||||
|
||||
@ -580,7 +581,9 @@ void PrinterPickWebViewDialog::request_compatible_printers_FFF() {
|
||||
|
||||
const std::string uuid = wxGetApp().plater()->get_user_account()->get_current_printer_uuid_from_connect(printer_model_serialized);
|
||||
const std::string filename = wxGetApp().plater()->get_upload_filename();
|
||||
//filament_abrasive
|
||||
|
||||
const std::string multiple_beds_value = m_multiple_beds ? "true" : "false";
|
||||
|
||||
std::string request = GUI::format(
|
||||
"{"
|
||||
"\"printerUuid\": \"%4%\", "
|
||||
@ -589,9 +592,10 @@ void PrinterPickWebViewDialog::request_compatible_printers_FFF() {
|
||||
"\"material\": %1%, "
|
||||
"\"filename\": \"%5%\", "
|
||||
"\"filament_abrasive\": %6%,"
|
||||
"\"high_flow\": %7%"
|
||||
"\"high_flow\": %7%,"
|
||||
"\"multiple_beds\": %8%"
|
||||
"}"
|
||||
, filament_type_serialized, nozzle_diameter_serialized, printer_model_serialized, uuid, filename, filament_abrasive_serialized, nozzle_high_flow_serialized);
|
||||
, filament_type_serialized, nozzle_diameter_serialized, printer_model_serialized, uuid, filename, filament_abrasive_serialized, nozzle_high_flow_serialized, multiple_beds_value);
|
||||
|
||||
wxString script = GUI::format_wxstr("window._prusaConnect_v2.requestCompatiblePrinter(%1%)", request);
|
||||
run_script(script);
|
||||
@ -609,13 +613,15 @@ void PrinterPickWebViewDialog::request_compatible_printers_SLA()
|
||||
const std::string material_type_serialized = selected_material.config.option("material_type")->serialize();
|
||||
const std::string uuid = wxGetApp().plater()->get_user_account()->get_current_printer_uuid_from_connect(printer_model_serialized);
|
||||
const std::string filename = wxGetApp().plater()->get_upload_filename();
|
||||
const std::string multiple_beds_value = m_multiple_beds ? "true" : "false";
|
||||
const std::string request = GUI::format(
|
||||
"{"
|
||||
"\"printerUuid\": \"%3%\", "
|
||||
"\"material\": \"%1%\", "
|
||||
"\"printerModel\": \"%2%\", "
|
||||
"\"filename\": \"%4%\" "
|
||||
"}", material_type_serialized, printer_model_serialized, uuid, filename);
|
||||
"\"filename\": \"%4%\", "
|
||||
"\"multiple_beds\": \"%5%\" "
|
||||
"}", material_type_serialized, printer_model_serialized, uuid, filename, multiple_beds_value);
|
||||
|
||||
wxString script = GUI::format_wxstr("window._prusaConnect_v2.requestCompatiblePrinter(%1%)", request);
|
||||
run_script(script);
|
||||
|
@ -95,7 +95,7 @@ protected:
|
||||
class PrinterPickWebViewDialog : public WebViewDialog, public ConnectRequestHandler
|
||||
{
|
||||
public:
|
||||
PrinterPickWebViewDialog(wxWindow* parent, std::string& ret_val);
|
||||
PrinterPickWebViewDialog(wxWindow* parent, std::string& ret_val, bool multiple_beds);
|
||||
void on_show(wxShowEvent& evt) override;
|
||||
void on_script_message(wxWebViewEvent& evt) override;
|
||||
protected:
|
||||
@ -110,6 +110,7 @@ protected:
|
||||
void on_connect_action_close_dialog(const std::string& message_data) override {assert(false);}
|
||||
private:
|
||||
std::string& m_ret_val;
|
||||
bool m_multiple_beds;
|
||||
};
|
||||
|
||||
class PrintablesConnectUploadDialog : public WebViewDialog, public ConnectRequestHandler
|
||||
|
Loading…
x
Reference in New Issue
Block a user