From 578921257d14e2c07611dfbb89cda5f9dc776e0c Mon Sep 17 00:00:00 2001 From: enricoturri1966 Date: Tue, 30 May 2023 08:51:01 +0200 Subject: [PATCH] SPE-1739: Fixed calculation of gcode preview sequential slider endpoints --- src/libslic3r/GCode.cpp | 1 + src/libslic3r/GCode/GCodeProcessor.cpp | 5 +---- src/libslic3r/GCode/GCodeProcessor.hpp | 5 +++++ src/slic3r/GUI/GCodeViewer.cpp | 16 +++++++++++----- 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index 36b4e3564..54177d213 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -901,6 +901,7 @@ namespace DoExport { silent_time_estimator_enabled = (config.gcode_flavor == gcfMarlinLegacy || config.gcode_flavor == gcfMarlinFirmware) && config.silent_mode; processor.reset(); + processor.initialize_result_moves(); processor.apply_config(config); processor.enable_stealth_time_estimator(silent_time_estimator_enabled); } diff --git a/src/libslic3r/GCode/GCodeProcessor.cpp b/src/libslic3r/GCode/GCodeProcessor.cpp index d71dd347a..5a6c2d5be 100644 --- a/src/libslic3r/GCode/GCodeProcessor.cpp +++ b/src/libslic3r/GCode/GCodeProcessor.cpp @@ -1071,8 +1071,7 @@ void GCodeProcessor::process_file(const std::string& filename, std::function extract from result size_t last_travel_s_id = 0; + size_t first_travel_s_id = 0; seams_count = 0; for (size_t i = 0; i < m_moves_count; ++i) { const GCodeProcessorResult::MoveVertex& move = gcode_result.moves[i]; @@ -2163,8 +2164,10 @@ void GCodeViewer::load_toolpaths(const GCodeProcessorResult& gcode_result) // layers zs const double* const last_z = m_layers.empty() ? nullptr : &m_layers.get_zs().back(); const double z = static_cast(move.position.z()); - if (last_z == nullptr || z < *last_z - EPSILON || *last_z + EPSILON < z) - m_layers.append(z, { last_travel_s_id, move_id }); + if (last_z == nullptr || z < *last_z - EPSILON || *last_z + EPSILON < z) { + const size_t start_it = (m_layers.empty() && first_travel_s_id != 0) ? first_travel_s_id : last_travel_s_id; + m_layers.append(z, { start_it, move_id }); + } else m_layers.get_ranges().back().last = move_id; } @@ -2177,7 +2180,8 @@ void GCodeViewer::load_toolpaths(const GCodeProcessorResult& gcode_result) else if (move.type == EMoveType::Travel) { if (move_id - last_travel_s_id > 1 && !m_layers.empty()) m_layers.get_ranges().back().last = move_id; - + else if (m_layers.empty() && first_travel_s_id == 0) + first_travel_s_id = move_id; last_travel_s_id = move_id; } } @@ -2433,8 +2437,10 @@ void GCodeViewer::refresh_render_paths(bool keep_sequential_current_first, bool for (size_t i = 0; i < buffer.paths.size(); ++i) { const Path& path = buffer.paths[i]; if (path.type == EMoveType::Travel) { - if (!is_travel_in_layers_range(i, m_layers_z_range[0], m_layers_z_range[1])) - continue; + if (path.sub_paths.front().first.s_id > m_layers_z_range[0]) { + if (!is_travel_in_layers_range(i, m_layers_z_range[0], m_layers_z_range[1])) + continue; + } } else if (!is_in_layers_range(path, m_layers_z_range[0], m_layers_z_range[1])) continue;