FIX: print by object not support timelapse for I3

Jira: XXXX
Change-Id: I8354971843f1e020db0f6407348cfa220ad514f2
(cherry picked from commit 8e8d0c47bdc7f60be901575b1202a1fc0e1942db)
This commit is contained in:
zhimin.zeng 2023-09-14 17:51:58 +08:00 committed by Lane.Wei
parent 3225a1965d
commit d462a4af8e
8 changed files with 87 additions and 7 deletions

View File

@ -286,10 +286,11 @@ static constexpr const char* PLATER_NAME_ATTR = "plater_name";
static constexpr const char* PLATE_IDX_ATTR = "index";
static constexpr const char* SLICE_PREDICTION_ATTR = "prediction";
static constexpr const char* SLICE_WEIGHT_ATTR = "weight";
static constexpr const char* TIMELAPSE_TYPE_ATTR = "timelapse_type";
static constexpr const char* TIMELAPSE_ERROR_CODE_ATTR = "timelapse_error_code";
static constexpr const char* OUTSIDE_ATTR = "outside";
static constexpr const char* SUPPORT_USED_ATTR = "support_used";
static constexpr const char* LABEL_OBJECT_ENABLED_ATTR = "label_object_enabled";
static constexpr const char* TIMELAPSE_TYPE_ATTR = "timelapse_type";
static constexpr const char* SKIPPED_ATTR = "skipped";
static constexpr const char* OBJECT_TYPE = "object";
@ -7344,6 +7345,7 @@ void PlateData::parse_filament_info(GCodeProcessorResult *result)
//plate index
stream << " <" << METADATA_TAG << " " << KEY_ATTR << "=\"" << PLATE_IDX_ATTR << "\" " << VALUE_ATTR << "=\"" << plate_data->plate_index + 1 << "\"/>\n";
stream << " <" << METADATA_TAG << " " << KEY_ATTR << "=\"" << TIMELAPSE_TYPE_ATTR << "\" " << VALUE_ATTR << "=\"" << int(config.opt_enum<TimelapseType>("timelapse_type")) << "\"/>\n";
stream << " <" << METADATA_TAG << " " << KEY_ATTR << "=\"" << TIMELAPSE_ERROR_CODE_ATTR << "\" " << VALUE_ATTR << "=\"" << plate_data->timelapse_warning_code << "\"/>\n";
stream << " <" << METADATA_TAG << " " << KEY_ATTR << "=\"" << SLICE_PREDICTION_ATTR << "\" " << VALUE_ATTR << "=\"" << plate_data->get_gcode_prediction_str() << "\"/>\n";
stream << " <" << METADATA_TAG << " " << KEY_ATTR << "=\"" << SLICE_WEIGHT_ATTR << "\" " << VALUE_ATTR << "=\"" << plate_data->get_gcode_weight_str() << "\"/>\n";
stream << " <" << METADATA_TAG << " " << KEY_ATTR << "=\"" << OUTSIDE_ATTR << "\" " << VALUE_ATTR << "=\"" << std::boolalpha<< plate_data->toolpath_outside << "\"/>\n";

View File

@ -88,6 +88,7 @@ struct PlateData
bool is_sliced_valid = false;
bool toolpath_outside {false};
bool is_label_object_enabled {false};
int timelapse_warning_code = 0; // 1<<0 sprial vase, 1<<1 by object
std::vector<GCodeProcessorResult::SliceWarning> warnings;

View File

@ -1175,6 +1175,13 @@ void GCode::do_export(Print* print, const char* path, GCodeProcessorResult* resu
BOOST_LOG_TRIVIAL(debug) << "Start processing gcode, " << log_memory_info();
// Post-process the G-code to update time stamps.
m_timelapse_warning_code = 0;
if (m_config.printer_structure.value == PrinterStructure::psI3 && m_spiral_vase) {
m_timelapse_warning_code += 1;
}
if (m_config.printer_structure.value == PrinterStructure::psI3 && print->config().print_sequence == PrintSequence::ByObject) {
m_timelapse_warning_code += (1 << 1);
}
m_processor.result().timelapse_warning_code = m_timelapse_warning_code;
m_processor.finalize(true);
// DoExport::update_print_estimated_times_stats(m_processor, print->m_print_statistics);
@ -2889,7 +2896,10 @@ GCode::LayerResult GCode::process_layer(
PrinterStructure printer_structure = m_config.printer_structure.value;
bool need_insert_timelapse_gcode_for_traditional = false;
if (printer_structure == PrinterStructure::psI3 && !m_spiral_vase && (!m_wipe_tower || !m_wipe_tower->enable_timelapse_print())) {
if (printer_structure == PrinterStructure::psI3 &&
!m_spiral_vase &&
(!m_wipe_tower || !m_wipe_tower->enable_timelapse_print()) &&
print.config().print_sequence == PrintSequence::ByLayer) {
need_insert_timelapse_gcode_for_traditional = true;
}
bool has_insert_timelapse_gcode = false;
@ -2911,7 +2921,7 @@ GCode::LayerResult GCode::process_layer(
gcode += this->change_layer(print_z); // this will increase m_layer_index
m_layer = &layer;
m_object_layer_over_raft = false;
if (printer_structure == PrinterStructure::psI3 && !need_insert_timelapse_gcode_for_traditional && !m_spiral_vase) {
if (printer_structure == PrinterStructure::psI3 && !need_insert_timelapse_gcode_for_traditional && !m_spiral_vase && print.config().print_sequence == PrintSequence::ByLayer) {
std::string timepals_gcode = insert_timelapse_gcode();
gcode += timepals_gcode;
m_writer.set_current_position_clear(false);
@ -3562,8 +3572,6 @@ GCode::LayerResult GCode::process_layer(
log_memory_info();
if (!has_wipe_tower && need_insert_timelapse_gcode_for_traditional && !has_insert_timelapse_gcode) {
if (m_timelapse_warning_code == 0)
m_timelapse_warning_code = 1;
gcode += this->retract(false, false, LiftType::NormalLift);
m_writer.add_object_change_labels(gcode);

View File

@ -321,6 +321,26 @@ void ConfigManipulation::update_print_fff_config(DynamicPrintConfig* config, con
is_msg_dlg_already_exist = false;
}
if (config->opt_enum<PrintSequence>("print_sequence") == PrintSequence::ByObject) {
auto printer_structure_opt = wxGetApp().preset_bundle->printers.get_edited_preset().config.option<ConfigOptionEnum<PrinterStructure>>("printer_structure");
if (printer_structure_opt && printer_structure_opt->value == PrinterStructure::psI3) {
wxString msg_text = _(L("When print by object, machines with I3 structure will not generate timelapse videos."));
if (is_global_config)
msg_text += "\n\n" + _(L("Still print by object?"));
MessageDialog dialog(m_msg_dlg_parent, msg_text, "", wxICON_WARNING | (is_global_config ? wxYES | wxNO : wxOK));
auto answer = dialog.ShowModal();
if (answer == wxID_NO) {
is_msg_dlg_already_exist = true;
DynamicPrintConfig new_conf = *config;
new_conf.set_key_value("print_sequence", new ConfigOptionEnum<TimelapseType>(tlTraditional));
apply(config, &new_conf);
is_msg_dlg_already_exist = false;
}
}
}
//BBS
//if (config->opt_enum<PerimeterGeneratorType>("wall_generator") == PerimeterGeneratorType::Arachne &&
// config->opt_bool("enable_overhang_speed"))

View File

@ -5050,6 +5050,8 @@ int PartPlateList::store_to_3mf_structure(PlateDataPtrs& plate_data_list, bool w
plate_data_item->gcode_prediction = std::to_string(
(int) m_plate_list[i]->get_slice_result()->print_statistics.modes[static_cast<size_t>(PrintEstimatedStatistics::ETimeMode::Normal)].time);
plate_data_item->toolpath_outside = m_plate_list[i]->m_gcode_result->toolpath_outside;
plate_data_item->timelapse_warning_code = m_plate_list[i]->m_gcode_result->timelapse_warning_code;
m_plate_list[i]->set_timelapse_warning_code(plate_data_item->timelapse_warning_code);
plate_data_item->is_label_object_enabled = m_plate_list[i]->m_gcode_result->label_object_enabled;
Print *print = nullptr;
m_plate_list[i]->get_print((PrintBase **) &print, nullptr, nullptr);
@ -5122,6 +5124,8 @@ int PartPlateList::load_from_3mf_structure(PlateDataPtrs& plate_data_list)
ps.total_used_filament *= 1000; //koef
gcode_result->toolpath_outside = plate_data_list[i]->toolpath_outside;
gcode_result->label_object_enabled = plate_data_list[i]->is_label_object_enabled;
gcode_result->timelapse_warning_code = plate_data_list[i]->timelapse_warning_code;
m_plate_list[index]->set_timelapse_warning_code(plate_data_list[i]->timelapse_warning_code);
m_plate_list[index]->slice_filaments_info = plate_data_list[i]->slice_filaments_info;
gcode_result->warnings = plate_data_list[i]->warnings;
if (m_plater && !plate_data_list[i]->thumbnail_file.empty()) {

View File

@ -146,6 +146,7 @@ private:
GLUquadricObject* m_quadric;
int m_hover_id;
bool m_selected;
int m_timelapse_warning_code = 0;
// BBS
DynamicPrintConfig m_config;
@ -266,7 +267,8 @@ public:
// set the plate's name
void set_plate_name(const std::string &name);
void set_timelapse_warning_code(int code) { m_timelapse_warning_code = code; }
int timelapse_warning_code() { return m_timelapse_warning_code; }
//get the print's object, result and index
void get_print(PrintBase **print, GCodeResult **result, int *index);

View File

@ -1671,6 +1671,7 @@ void SelectMachineDialog::update_select_layout(MachineObject *obj)
if (obj && obj->is_support_timelapse && is_show_timelapse()) {
select_timelapse->Show();
update_timelapse_enable_status();
} else {
select_timelapse->Hide();
}
@ -2154,6 +2155,17 @@ void SelectMachineDialog::show_status(PrintDialogStatus status, std::vector<wxSt
update_print_status_msg(msg_text, true, true);
Enable_Send_Button(false);
Enable_Refresh_Button(true);
} else if (status == PrintDialogStatus::PrintStatusTimelapseWarning) {
int error_code = get_timelapse_warning_code();
wxString msg_text;
if (error_code & 1) {
msg_text = _L("When enable spiral vase mode, machines with I3 structure will not generate timelapse videos.");
} else if ((error_code >> 1) & 1) {
msg_text = _L("When print by object, machines with I3 structure will not generate timelapse videos.");
}
update_print_status_msg(msg_text, true, true);
Enable_Send_Button(true);
Enable_Refresh_Button(true);
}
// m_panel_warn m_simplebook
@ -3345,6 +3357,11 @@ void SelectMachineDialog::update_show_status()
}
}
if (get_timelapse_warning_code() != 0) {
show_status(PrintDialogStatus::PrintStatusTimelapseWarning);
return;
}
// no ams
if (!obj_->has_ams() || !m_checkbox_list["use_ams"]->GetValue()) {
if (!has_tips(obj_))
@ -3412,6 +3429,29 @@ void SelectMachineDialog::update_show_status()
}
}
int SelectMachineDialog::get_timelapse_warning_code()
{
PartPlate *plate = m_plater->get_partplate_list().get_curr_plate();
return plate->timelapse_warning_code();
}
void SelectMachineDialog::update_timelapse_enable_status()
{
AppConfig *config = wxGetApp().app_config;
if (get_timelapse_warning_code() == 0) {
if (!config || config->get("print", "timelapse") == "0")
m_checkbox_list["timelapse"]->SetValue(false);
else
m_checkbox_list["timelapse"]->SetValue(true);
select_timelapse->Enable(true);
} else {
m_checkbox_list["timelapse"]->SetValue(false);
select_timelapse->Enable(false);
if (config) { config->set_str("print", "timelapse", "0"); }
}
}
bool SelectMachineDialog::is_show_timelapse()
{
auto compare_version = [](const std::string &version1, const std::string &version2) -> bool {

View File

@ -272,7 +272,8 @@ enum PrintDialogStatus {
PrintStatusNotSupportedSendToSDCard,
PrintStatusNotSupportedPrintAll,
PrintStatusBlankPlate,
PrintStatusUnsupportedPrinter
PrintStatusUnsupportedPrinter,
PrintStatusTimelapseWarning
};
std::string get_print_status_info(PrintDialogStatus status);
@ -443,6 +444,8 @@ public:
void update_print_error_info(int code, std::string msg, std::string extra);
void set_flow_calibration_state(bool state);
bool is_show_timelapse();
int get_timelapse_warning_code();
void update_timelapse_enable_status();
bool is_same_printer_model();
bool is_blocking_printing();
bool is_same_nozzle_diameters(std::string& nozzle_type, std::string& nozzle_diameter);