diff --git a/xs/src/libslic3r/GCodeTimeEstimator.cpp b/xs/src/libslic3r/GCodeTimeEstimator.cpp index 5543b5cc99..909cdc26c1 100644 --- a/xs/src/libslic3r/GCodeTimeEstimator.cpp +++ b/xs/src/libslic3r/GCodeTimeEstimator.cpp @@ -535,6 +535,21 @@ namespace Slic3r { _state.g1_line_id = 0; } + void GCodeTimeEstimator::set_extruder_id(unsigned int id) + { + _state.extruder_id = id; + } + + unsigned int GCodeTimeEstimator::get_extruder_id() const + { + return _state.extruder_id; + } + + void GCodeTimeEstimator::reset_extruder_id() + { + _state.extruder_id = 0; + } + void GCodeTimeEstimator::add_additional_time(float timeSec) { PROFILE_FUNC(); @@ -613,6 +628,7 @@ namespace Slic3r { set_additional_time(0.0f); + reset_extruder_id(); reset_g1_line_id(); _g1_line_ids.clear(); @@ -780,6 +796,11 @@ namespace Slic3r { } } + break; + } + case 'T': // Select Tools + { + _processT(line); break; } } @@ -1223,6 +1244,21 @@ namespace Slic3r { set_axis_max_jerk(E, line.e() * MMMIN_TO_MMSEC); } + void GCodeTimeEstimator::_processT(const GCodeReader::GCodeLine& line) + { + std::string cmd = line.cmd(); + if (cmd.length() > 1) + { + unsigned int id = (unsigned int)::strtol(cmd.substr(1).c_str(), nullptr, 10); + if (get_extruder_id() != id) + { + set_extruder_id(id); + + // ADD PROCESSING HERE + } + } + } + void GCodeTimeEstimator::_simulate_st_synchronize() { PROFILE_FUNC(); diff --git a/xs/src/libslic3r/GCodeTimeEstimator.hpp b/xs/src/libslic3r/GCodeTimeEstimator.hpp index 2dfefda0b0..f6194a170f 100644 --- a/xs/src/libslic3r/GCodeTimeEstimator.hpp +++ b/xs/src/libslic3r/GCodeTimeEstimator.hpp @@ -80,6 +80,7 @@ namespace Slic3r { float minimum_travel_feedrate; // mm/s float extrude_factor_override_percentage; unsigned int g1_line_id; + unsigned int extruder_id; }; public: @@ -300,6 +301,10 @@ namespace Slic3r { void increment_g1_line_id(); void reset_g1_line_id(); + void set_extruder_id(unsigned int id); + unsigned int get_extruder_id() const; + void reset_extruder_id(); + void add_additional_time(float timeSec); void set_additional_time(float timeSec); float get_additional_time() const; @@ -383,6 +388,9 @@ namespace Slic3r { // Set allowable instantaneous speed change void _processM566(const GCodeReader::GCodeLine& line); + // Processes T line (Select Tool) + void _processT(const GCodeReader::GCodeLine& line); + // Simulates firmware st_synchronize() call void _simulate_st_synchronize();