QoL: improve gcode marker (#11881)

QoL: Improve gcode marker
This commit is contained in:
SoftFever
2026-01-09 11:52:30 +08:00
committed by GitHub
parent 7ac84b1f17
commit 779f4a890d
6 changed files with 71 additions and 7 deletions

View File

@@ -82,6 +82,10 @@ struct PathVertex
// Segment estimated times
//
std::array<float, TIME_MODES_COUNT> times{ 0.0f, 0.0f };
//
// Layer duration in seconds
//
float layer_duration{ 0.0f };
//
// Return true if the segment is an extrusion move

View File

@@ -1034,6 +1034,11 @@ void ViewerImpl::load(GCodeInputData&& gcode_data)
}
}
// Populate layer_duration for each vertex from the accumulated layer times
for (PathVertex& v : m_vertices) {
v.layer_duration = m_layers.get_layer_time(m_settings.time_mode, static_cast<size_t>(v.layer_id));
}
if (!m_layers.empty())
m_layers.set_view_range(0, static_cast<uint32_t>(m_layers.count()) - 1);
@@ -1306,6 +1311,10 @@ void ViewerImpl::set_time_mode(ETimeMode mode)
{
m_settings.time_mode = mode;
m_settings.update_colors = true;
// Update layer_duration for all vertices based on the new time mode
for (PathVertex& v : m_vertices) {
v.layer_duration = m_layers.get_layer_time(mode, static_cast<size_t>(v.layer_id));
}
}
void ViewerImpl::set_layers_view_range(Interval::value_type min, Interval::value_type max)