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
(cherry picked from commit fcb4ca7a412dfc7c0897b96a3b4c528e6936c297)
This commit is contained in:
milk 2025-05-08 15:59:04 +08:00 committed by Noisyfox
parent 8065f11b60
commit 7c28b5ae52
4 changed files with 43 additions and 17 deletions

View file

@ -164,8 +164,15 @@ void SendJob::process(Ctl &ctl)
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

@ -5166,7 +5166,11 @@ std::vector<size_t> Plater::priv::load_files(const std::vector<fs::path>& input_
bool translate_old = false;
int current_width = 0, current_depth = 0, current_height = 0, 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();
// SoftFever: ugly fix so we can exist pa calib mode
background_process.fff_print()->calib_mode() = CalibMode::Calib_None;
@ -14828,6 +14832,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();
}
@ -14835,6 +14840,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

@ -634,6 +634,7 @@ public:
//BBS:
void fill_color(int extruder_id);
std::string get_3mf_filename() { return m_3mf_path; };
bool can_delete() const;
bool can_delete_all() const;
bool can_add_model() const;
@ -874,6 +875,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()
@ -889,7 +891,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

@ -831,13 +831,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";
@ -852,13 +856,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);
@ -878,7 +884,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;