mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-08 07:27:41 -06:00
Fix preview gcode misalignment caused by placeholder postprocess (#9529)
* Fix layer number placeholder process * Fix gcode move id misalignment when M73 is disabled * Fix gcode move id misalignment when M73 is enabled
This commit is contained in:
parent
dfdf9a3159
commit
ff9ce434a2
1 changed files with 12 additions and 7 deletions
|
@ -4233,15 +4233,19 @@ void GCodeProcessor::run_post_process()
|
||||||
}
|
}
|
||||||
|
|
||||||
// add the given gcode line to the cache
|
// add the given gcode line to the cache
|
||||||
void append_line(const std::string& line) {
|
void append_line(const std::string& line, const bool ignore_from_move = false) {
|
||||||
|
if (line.empty()) return;
|
||||||
|
|
||||||
m_lines.push_back({ line, m_times });
|
m_lines.push_back({ line, m_times });
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
m_statistics.add_line(line.length());
|
m_statistics.add_line(line.length());
|
||||||
#endif // NDEBUG
|
#endif // NDEBUG
|
||||||
m_size += line.length();
|
m_size += line.length();
|
||||||
++m_added_lines_counter;
|
++m_added_lines_counter;
|
||||||
assert(!m_gcode_lines_map.empty());
|
if (!ignore_from_move) {
|
||||||
m_gcode_lines_map.back().second = m_added_lines_counter;
|
assert(!m_gcode_lines_map.empty());
|
||||||
|
m_gcode_lines_map.back().second = m_added_lines_counter;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Insert the gcode lines required by the command cmd by backtracing into the cache
|
// Insert the gcode lines required by the command cmd by backtracing into the cache
|
||||||
|
@ -4458,6 +4462,7 @@ void GCodeProcessor::run_post_process()
|
||||||
char buf[128];
|
char buf[128];
|
||||||
sprintf(buf, "; total layer number: %u\n", m_layer_id);
|
sprintf(buf, "; total layer number: %u\n", m_layer_id);
|
||||||
export_lines.append_line(buf);
|
export_lines.append_line(buf);
|
||||||
|
processed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4534,7 +4539,7 @@ void GCodeProcessor::run_post_process()
|
||||||
time_in_minutes(machine.time - it->elapsed_time) };
|
time_in_minutes(machine.time - it->elapsed_time) };
|
||||||
if (last_exported_main[i] != to_export_main) {
|
if (last_exported_main[i] != to_export_main) {
|
||||||
export_lines.append_line(format_line_M73_main(machine.line_m73_main_mask.c_str(),
|
export_lines.append_line(format_line_M73_main(machine.line_m73_main_mask.c_str(),
|
||||||
to_export_main.first, to_export_main.second));
|
to_export_main.first, to_export_main.second), true);
|
||||||
last_exported_main[i] = to_export_main;
|
last_exported_main[i] = to_export_main;
|
||||||
}
|
}
|
||||||
// export remaining time to next printer stop
|
// export remaining time to next printer stop
|
||||||
|
@ -4545,7 +4550,7 @@ void GCodeProcessor::run_post_process()
|
||||||
if (last_exported_stop[i] != to_export_stop) {
|
if (last_exported_stop[i] != to_export_stop) {
|
||||||
if (to_export_stop > 0) {
|
if (to_export_stop > 0) {
|
||||||
if (last_exported_stop[i] != to_export_stop) {
|
if (last_exported_stop[i] != to_export_stop) {
|
||||||
export_lines.append_line(format_line_M73_stop_int(machine.line_m73_stop_mask.c_str(), to_export_stop));
|
export_lines.append_line(format_line_M73_stop_int(machine.line_m73_stop_mask.c_str(), to_export_stop), true);
|
||||||
last_exported_stop[i] = to_export_stop;
|
last_exported_stop[i] = to_export_stop;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4566,9 +4571,9 @@ void GCodeProcessor::run_post_process()
|
||||||
|
|
||||||
if (is_last) {
|
if (is_last) {
|
||||||
if (std::distance(machine.stop_times.begin(), it_stop) == static_cast<ptrdiff_t>(machine.stop_times.size() - 1))
|
if (std::distance(machine.stop_times.begin(), it_stop) == static_cast<ptrdiff_t>(machine.stop_times.size() - 1))
|
||||||
export_lines.append_line(format_line_M73_stop_int(machine.line_m73_stop_mask.c_str(), to_export_stop));
|
export_lines.append_line(format_line_M73_stop_int(machine.line_m73_stop_mask.c_str(), to_export_stop), true);
|
||||||
else
|
else
|
||||||
export_lines.append_line(format_line_M73_stop_float(machine.line_m73_stop_mask.c_str(), time_in_last_minute(it_stop->elapsed_time - it->elapsed_time)));
|
export_lines.append_line(format_line_M73_stop_float(machine.line_m73_stop_mask.c_str(), time_in_last_minute(it_stop->elapsed_time - it->elapsed_time)), true);
|
||||||
|
|
||||||
last_exported_stop[i] = to_export_stop;
|
last_exported_stop[i] = to_export_stop;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue