mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-11 16:57:53 -06:00
Time Estimator and GCode Analyzer - Fixed handling of commands G90, G91, M82 and M83 - Fixes #812
This commit is contained in:
parent
d384ed6e96
commit
bf295b9039
4 changed files with 54 additions and 48 deletions
|
@ -97,8 +97,8 @@ GCodeAnalyzer::GCodeAnalyzer()
|
|||
void GCodeAnalyzer::reset()
|
||||
{
|
||||
_set_units(Millimeters);
|
||||
_set_positioning_xyz_type(Absolute);
|
||||
_set_positioning_e_type(Relative);
|
||||
_set_global_positioning_type(Absolute);
|
||||
_set_e_local_positioning_type(Absolute);
|
||||
_set_extrusion_role(erNone);
|
||||
_set_extruder_id(DEFAULT_EXTRUDER_ID);
|
||||
_set_mm3_per_mm(Default_mm3_per_mm);
|
||||
|
@ -237,13 +237,13 @@ void GCodeAnalyzer::_process_gcode_line(GCodeReader&, const GCodeReader::GCodeLi
|
|||
}
|
||||
|
||||
// Returns the new absolute position on the given axis in dependence of the given parameters
|
||||
float axis_absolute_position_from_G1_line(GCodeAnalyzer::EAxis axis, const GCodeReader::GCodeLine& lineG1, GCodeAnalyzer::EUnits units, GCodeAnalyzer::EPositioningType type, float current_absolute_position)
|
||||
float axis_absolute_position_from_G1_line(GCodeAnalyzer::EAxis axis, const GCodeReader::GCodeLine& lineG1, GCodeAnalyzer::EUnits units, bool is_relative, float current_absolute_position)
|
||||
{
|
||||
float lengthsScaleFactor = (units == GCodeAnalyzer::Inches) ? INCHES_TO_MM : 1.0f;
|
||||
if (lineG1.has(Slic3r::Axis(axis)))
|
||||
{
|
||||
float ret = lineG1.value(Slic3r::Axis(axis)) * lengthsScaleFactor;
|
||||
return (type == GCodeAnalyzer::Absolute) ? ret : current_absolute_position + ret;
|
||||
return is_relative ? current_absolute_position + ret : ret;
|
||||
}
|
||||
else
|
||||
return current_absolute_position;
|
||||
|
@ -256,7 +256,11 @@ void GCodeAnalyzer::_processG1(const GCodeReader::GCodeLine& line)
|
|||
float new_pos[Num_Axis];
|
||||
for (unsigned char a = X; a < Num_Axis; ++a)
|
||||
{
|
||||
new_pos[a] = axis_absolute_position_from_G1_line((EAxis)a, line, units, (a == E) ? _get_positioning_e_type() : _get_positioning_xyz_type(), _get_axis_position((EAxis)a));
|
||||
bool is_relative = (_get_global_positioning_type() == Relative);
|
||||
if (a == E)
|
||||
is_relative |= (_get_e_local_positioning_type() == Relative);
|
||||
|
||||
new_pos[a] = axis_absolute_position_from_G1_line((EAxis)a, line, units, is_relative, _get_axis_position((EAxis)a));
|
||||
}
|
||||
|
||||
// updates feedrate from line, if present
|
||||
|
@ -319,12 +323,12 @@ void GCodeAnalyzer::_processG23(const GCodeReader::GCodeLine& line)
|
|||
|
||||
void GCodeAnalyzer::_processG90(const GCodeReader::GCodeLine& line)
|
||||
{
|
||||
_set_positioning_xyz_type(Absolute);
|
||||
_set_global_positioning_type(Absolute);
|
||||
}
|
||||
|
||||
void GCodeAnalyzer::_processG91(const GCodeReader::GCodeLine& line)
|
||||
{
|
||||
_set_positioning_xyz_type(Relative);
|
||||
_set_global_positioning_type(Relative);
|
||||
}
|
||||
|
||||
void GCodeAnalyzer::_processG92(const GCodeReader::GCodeLine& line)
|
||||
|
@ -367,12 +371,12 @@ void GCodeAnalyzer::_processG92(const GCodeReader::GCodeLine& line)
|
|||
|
||||
void GCodeAnalyzer::_processM82(const GCodeReader::GCodeLine& line)
|
||||
{
|
||||
_set_positioning_e_type(Absolute);
|
||||
_set_e_local_positioning_type(Absolute);
|
||||
}
|
||||
|
||||
void GCodeAnalyzer::_processM83(const GCodeReader::GCodeLine& line)
|
||||
{
|
||||
_set_positioning_e_type(Relative);
|
||||
_set_e_local_positioning_type(Relative);
|
||||
}
|
||||
|
||||
void GCodeAnalyzer::_processT(const GCodeReader::GCodeLine& line)
|
||||
|
@ -466,24 +470,24 @@ GCodeAnalyzer::EUnits GCodeAnalyzer::_get_units() const
|
|||
return m_state.units;
|
||||
}
|
||||
|
||||
void GCodeAnalyzer::_set_positioning_xyz_type(GCodeAnalyzer::EPositioningType type)
|
||||
void GCodeAnalyzer::_set_global_positioning_type(GCodeAnalyzer::EPositioningType type)
|
||||
{
|
||||
m_state.positioning_xyz_type = type;
|
||||
m_state.global_positioning_type = type;
|
||||
}
|
||||
|
||||
GCodeAnalyzer::EPositioningType GCodeAnalyzer::_get_positioning_xyz_type() const
|
||||
GCodeAnalyzer::EPositioningType GCodeAnalyzer::_get_global_positioning_type() const
|
||||
{
|
||||
return m_state.positioning_xyz_type;
|
||||
return m_state.global_positioning_type;
|
||||
}
|
||||
|
||||
void GCodeAnalyzer::_set_positioning_e_type(GCodeAnalyzer::EPositioningType type)
|
||||
void GCodeAnalyzer::_set_e_local_positioning_type(GCodeAnalyzer::EPositioningType type)
|
||||
{
|
||||
m_state.positioning_e_type = type;
|
||||
m_state.e_local_positioning_type = type;
|
||||
}
|
||||
|
||||
GCodeAnalyzer::EPositioningType GCodeAnalyzer::_get_positioning_e_type() const
|
||||
GCodeAnalyzer::EPositioningType GCodeAnalyzer::_get_e_local_positioning_type() const
|
||||
{
|
||||
return m_state.positioning_e_type;
|
||||
return m_state.e_local_positioning_type;
|
||||
}
|
||||
|
||||
void GCodeAnalyzer::_set_extrusion_role(ExtrusionRole extrusion_role)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue