ENH:After re-importing the multi-plate Gcode.3mf file, sending all plates to the printer results in information loss

jira: [STUDIO-11531]

Change-Id: Icfbf56ac1f6610f70c3ed192f765e3381ad8ddb6
This commit is contained in:
milk 2025-05-08 15:59:04 +08:00 committed by lane.wei
parent 09d8050037
commit fcb4ca7a41
4 changed files with 44 additions and 18 deletions

View File

@ -206,8 +206,15 @@ void SendJob::process()
params.dev_id = m_dev_id;
params.project_name = m_project_name + ".gcode.3mf";
params.preset_name = wxGetApp().preset_bundle->prints.get_selected_preset_name();
params.filename = job_data._3mf_path.string();
if (wxGetApp().plater()->using_exported_file())
params.filename = wxGetApp().plater()->get_3mf_filename();
else
params.filename = job_data._3mf_path.string();
params.config_filename = job_data._3mf_config_path.string();
params.plate_index = curr_plate_idx;
params.ams_mapping = this->task_ams_mapping;
params.connection_type = this->connection_type;

View File

@ -5246,7 +5246,11 @@ std::vector<size_t> Plater::priv::load_files(const std::vector<fs::path>& input_
bool translate_old = false;
int current_width, current_depth, current_height, project_filament_count = 1;
if (input_files.empty()) { return std::vector<size_t>(); }
if (input_files.empty())
return std::vector<size_t>();
if (!input_files.empty())
q->m_3mf_path = input_files[0].string();
// BBS
int filaments_cnt = config->opt<ConfigOptionStrings>("filament_colour")->values.size();
@ -13794,6 +13798,7 @@ void Plater::export_gcode_3mf(bool export_all)
default_output_file = into_path(get_export_gcode_filename(".gcode.3mf", false, export_all));
if (default_output_file.empty()) {
try {
start_dir = appconfig.get_last_output_dir("", false);
wxString filename = get_export_gcode_filename(".gcode.3mf", true, export_all);
std::string full_filename = start_dir + "/" + filename.utf8_string();
@ -14983,6 +14988,7 @@ int Plater::send_gcode(int plate_idx, Export3mfProgressFn proFn)
{
int result = 0;
/* generate 3mf */
if (plate_idx == PLATE_CURRENT_IDX) {
p->m_print_job_data.plate_idx = get_partplate_list().get_curr_plate_index();
}
@ -14990,6 +14996,7 @@ int Plater::send_gcode(int plate_idx, Export3mfProgressFn proFn)
p->m_print_job_data.plate_idx = plate_idx;
}
PartPlate* plate = get_partplate_list().get_curr_plate();
try {
p->m_print_job_data._3mf_path = fs::path(plate->get_tmp_gcode_path());

View File

@ -601,7 +601,7 @@ public:
//BBS:
void edit_text();
bool can_edit_text() const;
std::string get_3mf_filename() { return m_3mf_path; };
bool can_delete() const;
bool can_delete_all() const;
bool can_add_model() const;
@ -846,6 +846,7 @@ public:
static bool has_illegal_filename_characters(const std::string& name);
static void show_illegal_characters_warning(wxWindow* parent);
std::string get_preview_only_filename() { return m_preview_only_filename; };
bool last_arrange_job_is_finished()
@ -859,7 +860,7 @@ public:
private:
struct priv;
std::unique_ptr<priv> p;
std::string m_3mf_path;
// Set true during PopupMenu() tracking to suppress immediate error message boxes.
// The error messages are collected to m_tracking_popup_menu_error_message instead and these error messages
// are shown after the pop-up dialog closes.

View File

@ -844,13 +844,17 @@ void SendToPrinterDialog::on_ok(wxCommandEvent &event)
// enter sending mode
sending_mode();
result = m_plater->send_gcode(m_print_plate_idx, [this](int export_stage, int current, int total, bool &cancel) {
if (this->m_is_canceled) return;
bool cancelled = false;
wxString msg = _L("Preparing print job");
m_status_bar->update_status(msg, cancelled, 10, true);
m_export_3mf_cancel = cancel = cancelled;
});
if (wxGetApp().plater()->using_exported_file())
result = 0;
else {
result = m_plater->send_gcode(m_print_plate_idx, [this](int export_stage, int current, int total, bool &cancel) {
if (this->m_is_canceled) return;
bool cancelled = false;
wxString msg = _L("Preparing print job");
m_status_bar->update_status(msg, cancelled, 10, true);
m_export_3mf_cancel = cancel = cancelled;
});
}
if (m_is_canceled || m_export_3mf_cancel) {
BOOST_LOG_TRIVIAL(info) << "send_job: m_export_3mf_cancel or m_is_canceled";
@ -865,13 +869,15 @@ void SendToPrinterDialog::on_ok(wxCommandEvent &event)
}
// export config 3mf if needed
if (!obj_->is_lan_mode_printer()) {
result = m_plater->export_config_3mf(m_print_plate_idx);
if (result < 0) {
BOOST_LOG_TRIVIAL(info) << "export_config_3mf failed, result = " << result;
return;
if(!wxGetApp().plater()->using_exported_file() && !obj_->is_lan_mode_printer()) {
result = m_plater->export_config_3mf(m_print_plate_idx);
if (result < 0) {
BOOST_LOG_TRIVIAL(info) << "export_config_3mf failed, result = " << result;
return;
}
}
}
if (m_is_canceled || m_export_3mf_cancel) {
BOOST_LOG_TRIVIAL(info) << "send_job: m_export_3mf_cancel or m_is_canceled";
//m_status_bar->set_status_text(task_canceled_text);
@ -891,7 +897,12 @@ void SendToPrinterDialog::on_ok(wxCommandEvent &event)
PrintPrepareData print_data;
m_plater->get_print_job_data(&print_data);
std::string project_name = m_current_project_name.utf8_string() + ".3mf";
std::string _3mf_path = print_data._3mf_path.string();
std::string _3mf_path;
if (wxGetApp().plater()->using_exported_file())
_3mf_path = wxGetApp().plater()->get_3mf_filename();
else
_3mf_path = print_data._3mf_path.string();
auto it = std::find_if(m_ability_list.begin(), m_ability_list.end(), [](const std::string& s) {
return s != EMMC_STORAGE;