From 2f4ff6577a57ac74e99990549f44954a1401ed9c Mon Sep 17 00:00:00 2001 From: bubnikv Date: Thu, 25 May 2017 22:52:28 +0200 Subject: [PATCH] With single_extruder_multi_material enabled, don't append a tool selection (Txx) to the extruder temperature settings (M104 and M109). --- xs/src/libslic3r/GCode.cpp | 8 +++----- xs/src/libslic3r/GCodeWriter.cpp | 23 ++++++++++------------- xs/src/libslic3r/GCodeWriter.hpp | 4 +++- 3 files changed, 16 insertions(+), 19 deletions(-) diff --git a/xs/src/libslic3r/GCode.cpp b/xs/src/libslic3r/GCode.cpp index e4440fb87..a443c3544 100644 --- a/xs/src/libslic3r/GCode.cpp +++ b/xs/src/libslic3r/GCode.cpp @@ -511,7 +511,7 @@ bool GCode::do_export(FILE *file, Print &print) } // Calculate wiping points if needed - if (print.config.ooze_prevention.value) { + if (print.config.ooze_prevention.value && ! print.config.single_extruder_multi_material) { Points skirt_points; for (const ExtrusionEntity *ee : print.skirt.entities) for (const ExtrusionPath &path : dynamic_cast(ee)->paths) @@ -680,8 +680,6 @@ void GCode::_print_first_layer_extruder_temperatures(FILE *file, Print &print, u if (print.config.single_extruder_multi_material.value) { // Set temperature of the first printing extruder only. int temp = print.config.first_layer_temperature.get_at(first_printing_extruder_id); - if (print.config.ooze_prevention.value) - temp += print.config.standby_temperature_delta.value; if (temp > 0) write(file, m_writer.set_temperature(temp, wait, first_printing_extruder_id)); } else { @@ -1985,7 +1983,7 @@ std::string GCode::set_extruder(unsigned int extruder_id) m_wipe.reset_path(); // append custom toolchange G-code - if (m_writer.extruder() != NULL && !m_config.toolchange_gcode.value.empty()) { + if (m_writer.extruder() != nullptr && !m_config.toolchange_gcode.value.empty()) { PlaceholderParser pp = m_placeholder_parser; pp.set("previous_extruder", m_writer.extruder()->id); pp.set("next_extruder", extruder_id); @@ -1994,7 +1992,7 @@ std::string GCode::set_extruder(unsigned int extruder_id) // if ooze prevention is enabled, park current extruder in the nearest // standby point and set it to the standby temperature - if (m_ooze_prevention.enable && m_writer.extruder() != NULL) + if (m_ooze_prevention.enable && m_writer.extruder() != nullptr) gcode += m_ooze_prevention.pre_toolchange(*this); // append the toolchange command gcode += m_writer.toolchange(extruder_id); diff --git a/xs/src/libslic3r/GCodeWriter.cpp b/xs/src/libslic3r/GCodeWriter.cpp index cbbaeaec1..2b22ec038 100644 --- a/xs/src/libslic3r/GCodeWriter.cpp +++ b/xs/src/libslic3r/GCodeWriter.cpp @@ -13,15 +13,14 @@ namespace Slic3r { -void -GCodeWriter::apply_print_config(const PrintConfig &print_config) +void GCodeWriter::apply_print_config(const PrintConfig &print_config) { this->config.apply(print_config, true); this->_extrusion_axis = this->config.get_extrusion_axis(); + this->m_single_extruder_multi_material = print_config.single_extruder_multi_material.value; } -void -GCodeWriter::set_extruders(const std::vector &extruder_ids) +void GCodeWriter::set_extruders(const std::vector &extruder_ids) { for (unsigned int extruder_id : extruder_ids) this->extruders.insert(Extruder(extruder_id, &this->config)); @@ -32,8 +31,7 @@ GCodeWriter::set_extruders(const std::vector &extruder_ids) this->multiple_extruders = (*std::max_element(extruder_ids.begin(), extruder_ids.end())) > 0; } -std::string -GCodeWriter::preamble() +std::string GCodeWriter::preamble() { std::ostringstream gcode; @@ -53,8 +51,7 @@ GCodeWriter::preamble() return gcode.str(); } -std::string -GCodeWriter::postamble() const +std::string GCodeWriter::postamble() const { std::ostringstream gcode; if (FLAVOR_IS(gcfMachinekit)) @@ -62,8 +59,7 @@ GCodeWriter::postamble() const return gcode.str(); } -std::string -GCodeWriter::set_temperature(unsigned int temperature, bool wait, int tool) const +std::string GCodeWriter::set_temperature(unsigned int temperature, bool wait, int tool) const { if (wait && (FLAVOR_IS(gcfMakerWare) || FLAVOR_IS(gcfSailfish))) return ""; @@ -85,7 +81,9 @@ GCodeWriter::set_temperature(unsigned int temperature, bool wait, int tool) cons gcode << "S"; } gcode << temperature; - if (tool != -1 && (this->multiple_extruders || FLAVOR_IS(gcfMakerWare) || FLAVOR_IS(gcfSailfish))) { + if (tool != -1 && + ( (this->multiple_extruders && ! this->m_single_extruder_multi_material) || + FLAVOR_IS(gcfMakerWare) || FLAVOR_IS(gcfSailfish)) ) { gcode << " T" << tool; } gcode << " ; " << comment << "\n"; @@ -96,8 +94,7 @@ GCodeWriter::set_temperature(unsigned int temperature, bool wait, int tool) cons return gcode.str(); } -std::string -GCodeWriter::set_bed_temperature(unsigned int temperature, bool wait) const +std::string GCodeWriter::set_bed_temperature(unsigned int temperature, bool wait) const { std::string code, comment; if (wait && FLAVOR_IS_NOT(gcfTeacup)) { diff --git a/xs/src/libslic3r/GCodeWriter.hpp b/xs/src/libslic3r/GCodeWriter.hpp index a3b88bca5..0f5becd82 100644 --- a/xs/src/libslic3r/GCodeWriter.hpp +++ b/xs/src/libslic3r/GCodeWriter.hpp @@ -17,6 +17,7 @@ public: GCodeWriter() : multiple_extruders(false), _extrusion_axis("E"), _extruder(nullptr), + m_single_extruder_multi_material(false), _last_acceleration(0), _last_fan_speed(0), _lifted(0) {} Extruder* extruder() { return this->_extruder; } @@ -61,12 +62,13 @@ public: private: std::string _extrusion_axis; + bool m_single_extruder_multi_material; Extruder* _extruder; unsigned int _last_acceleration; unsigned int _last_fan_speed; double _lifted; Pointf3 _pos; - + std::string _travel_to_z(double z, const std::string &comment); std::string _retract(double length, double restart_extra, const std::string &comment); };