mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-05-14 00:52:04 +00:00
@@ -1629,7 +1629,29 @@ void GCodeViewer::update_sequential_view_current(unsigned int first, unsigned in
|
||||
levels.push_back(std::make_pair(value, libvgcode::convert(color_range.get_color_at(value))));
|
||||
levels.back().second.a(0.5f);
|
||||
}
|
||||
m_sequential_view.marker.set_actual_speed_data(actual_speed_data);
|
||||
|
||||
// ORCA Compress consecutive duplicate speeds with 0.1 precision
|
||||
auto sameSpeed = [](float a, float b) {
|
||||
return static_cast<int>(std::roundf(a * 10.0f)) == static_cast<int>(std::roundf(b * 10.0f));
|
||||
};
|
||||
std::vector<SequentialView::ActualSpeedImguiWidget::Item> compressed;
|
||||
if (!actual_speed_data.empty()) {
|
||||
compressed.push_back(actual_speed_data[0]);
|
||||
for (int i = 1; i < (int)actual_speed_data.size(); ++i) {
|
||||
const bool same_as_prev = sameSpeed(actual_speed_data[i].speed, actual_speed_data[i - 1].speed);
|
||||
const bool same_as_next = (i + 1 < (int)actual_speed_data.size()) && sameSpeed(actual_speed_data[i].speed, actual_speed_data[i + 1].speed);
|
||||
if (!same_as_prev) {
|
||||
if (!sameSpeed(compressed.back().speed, actual_speed_data[i - 1].speed))
|
||||
compressed.push_back(actual_speed_data[i - 1]);
|
||||
compressed.push_back(actual_speed_data[i]);
|
||||
} else if (!same_as_next)
|
||||
compressed.push_back(actual_speed_data[i]);
|
||||
}
|
||||
if (compressed.back().pos != actual_speed_data.back().pos)
|
||||
compressed.push_back(actual_speed_data.back());
|
||||
}
|
||||
|
||||
m_sequential_view.marker.set_actual_speed_data(compressed);
|
||||
m_sequential_view.marker.set_actual_speed_y_range(std::make_pair(interval[0], interval[1]));
|
||||
m_sequential_view.marker.set_actual_speed_levels(levels);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user