GCode Anayzer take in account extruder offsets

This commit is contained in:
Enrico Turri 2019-03-05 15:03:56 +01:00
parent 4f122fed70
commit 8a29ec2204
4 changed files with 51 additions and 1 deletions

View file

@ -101,6 +101,13 @@ GCodeAnalyzer::GCodeAnalyzer()
reset();
}
#if ENABLE_ANALYZER_EXTRUDER_OFFSET
void GCodeAnalyzer::set_extruder_offsets(const std::vector<Vec2d>& extruder_offsets)
{
m_extruder_offsets = extruder_offsets;
}
#endif // ENABLE_ANALYZER_EXTRUDER_OFFSET
void GCodeAnalyzer::reset()
{
_set_units(Millimeters);
@ -118,6 +125,9 @@ void GCodeAnalyzer::reset()
_reset_axes_position();
m_moves_map.clear();
#if ENABLE_ANALYZER_EXTRUDER_OFFSET
m_extruder_offsets.clear();
#endif // ENABLE_ANALYZER_EXTRUDER_OFFSET
}
const std::string& GCodeAnalyzer::process_gcode(const std::string& gcode)
@ -654,7 +664,24 @@ void GCodeAnalyzer::_store_move(GCodeAnalyzer::GCodeMove::EType type)
it = m_moves_map.insert(TypeToMovesMap::value_type(type, GCodeMovesList())).first;
// store move
#if ENABLE_ANALYZER_EXTRUDER_OFFSET
Vec3d extruder_offset = Vec3d::Zero();
unsigned int extruder_id = _get_extruder_id();
std::cout << extruder_id << std::endl;
if (extruder_id < m_extruder_offsets.size())
{
Vec2d offset = m_extruder_offsets[extruder_id];
extruder_offset = Vec3d(offset(0), offset(1), 0.0);
}
Vec3d start_position = _get_start_position() + extruder_offset;
Vec3d end_position = _get_end_position() + extruder_offset;
it->second.emplace_back(type, _get_extrusion_role(), extruder_id, _get_mm3_per_mm(), _get_width(), _get_height(), _get_feedrate(), start_position, end_position, _get_delta_extrusion(), _get_cp_color_id());
#else
it->second.emplace_back(type, _get_extrusion_role(), _get_extruder_id(), _get_mm3_per_mm(), _get_width(), _get_height(), _get_feedrate(), _get_start_position(), _get_end_position(), _get_delta_extrusion(), _get_cp_color_id());
#endif // ENABLE_ANALYZER_EXTRUDER_OFFSET
}
bool GCodeAnalyzer::_is_valid_extrusion_role(int value) const