Improve gcode preview flow rate scale (#9319)

* Ignore very tiny extrusions in flow rate scale (SoftFever/OrcaSlicer#9190)

* Don't show flow rate if it's not extrusion

* Merge branch 'main' into bugfox/gcode-viewer-flow-scale
This commit is contained in:
Noisyfox 2025-04-23 23:37:08 +08:00 committed by GitHub
parent 66cab434b8
commit e2b16f527a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 15 additions and 4 deletions

View file

@ -1150,6 +1150,7 @@ void GCodeProcessor::reset()
m_forced_width = 0.0f;
m_forced_height = 0.0f;
m_mm3_per_mm = 0.0f;
m_travel_dist = 0.0f;
m_fan_speed = 0.0f;
m_z_offset = 0.0f;
@ -2648,7 +2649,8 @@ void GCodeProcessor::process_G1(const GCodeReader::GCodeLine& line, const std::o
EMoveType type = move_type(delta_pos);
if (type == EMoveType::Extrude) {
float delta_xyz = std::sqrt(sqr(delta_pos[X]) + sqr(delta_pos[Y]) + sqr(delta_pos[Z]));
const float delta_xyz = std::sqrt(sqr(delta_pos[X]) + sqr(delta_pos[Y]) + sqr(delta_pos[Z]));
m_travel_dist = delta_xyz;
float volume_extruded_filament = area_filament_cross_section * delta_pos[E];
float area_toolpath_cross_section = volume_extruded_filament / delta_xyz;
@ -3125,7 +3127,8 @@ void GCodeProcessor::process_G2_G3(const GCodeReader::GCodeLine& line)
EMoveType type = move_type(delta_pos[E]);
float delta_xyz = std::sqrt(sqr(arc_length) + sqr(delta_pos[Z]));
const float delta_xyz = std::sqrt(sqr(arc_length) + sqr(delta_pos[Z]));
m_travel_dist = delta_xyz;
if (type == EMoveType::Extrude) {
float volume_extruded_filament = area_filament_cross_section * delta_pos[E];
float area_toolpath_cross_section = volume_extruded_filament / delta_xyz;
@ -4783,6 +4786,7 @@ void GCodeProcessor::store_move_vertex(EMoveType type, EMovePathType path_type)
m_width,
m_height,
m_mm3_per_mm,
m_travel_dist,
m_fan_speed,
m_extruder_temps[m_extruder_id],
static_cast<float>(m_result.moves.size()),