mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-11 16:57:53 -06:00
Merge branch 'master' of https://github.com/prusa3d/PrusaSlicer into dev
This commit is contained in:
commit
84f589ad5c
3 changed files with 19 additions and 1 deletions
|
@ -806,6 +806,11 @@ void GCode::_do_export(Print &print, FILE *file)
|
||||||
}
|
}
|
||||||
m_analyzer.set_extruder_offsets(extruder_offsets);
|
m_analyzer.set_extruder_offsets(extruder_offsets);
|
||||||
|
|
||||||
|
// send extruders count to analyzer to allow it to detect invalid extruder idxs
|
||||||
|
const ConfigOptionStrings* extruders_opt = dynamic_cast<const ConfigOptionStrings*>(print.config().option("extruder_colour"));
|
||||||
|
const ConfigOptionStrings* filamemts_opt = dynamic_cast<const ConfigOptionStrings*>(print.config().option("filament_colour"));
|
||||||
|
m_analyzer.set_extruders_count(std::max((unsigned int)extruders_opt->values.size(), (unsigned int)filamemts_opt->values.size()));
|
||||||
|
|
||||||
// tell analyzer about the gcode flavor
|
// tell analyzer about the gcode flavor
|
||||||
m_analyzer.set_gcode_flavor(print.config().gcode_flavor);
|
m_analyzer.set_gcode_flavor(print.config().gcode_flavor);
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,8 @@
|
||||||
#include "../Utils.hpp"
|
#include "../Utils.hpp"
|
||||||
#include "Print.hpp"
|
#include "Print.hpp"
|
||||||
|
|
||||||
|
#include <boost/log/trivial.hpp>
|
||||||
|
|
||||||
#include "Analyzer.hpp"
|
#include "Analyzer.hpp"
|
||||||
#include "PreviewData.hpp"
|
#include "PreviewData.hpp"
|
||||||
|
|
||||||
|
@ -107,6 +109,11 @@ void GCodeAnalyzer::set_extruder_offsets(const GCodeAnalyzer::ExtruderOffsetsMap
|
||||||
m_extruder_offsets = extruder_offsets;
|
m_extruder_offsets = extruder_offsets;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GCodeAnalyzer::set_extruders_count(unsigned int count)
|
||||||
|
{
|
||||||
|
m_extruders_count = count;
|
||||||
|
}
|
||||||
|
|
||||||
void GCodeAnalyzer::set_gcode_flavor(const GCodeFlavor& flavor)
|
void GCodeAnalyzer::set_gcode_flavor(const GCodeFlavor& flavor)
|
||||||
{
|
{
|
||||||
m_gcode_flavor = flavor;
|
m_gcode_flavor = flavor;
|
||||||
|
@ -131,6 +138,7 @@ void GCodeAnalyzer::reset()
|
||||||
|
|
||||||
m_moves_map.clear();
|
m_moves_map.clear();
|
||||||
m_extruder_offsets.clear();
|
m_extruder_offsets.clear();
|
||||||
|
m_extruders_count = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string& GCodeAnalyzer::process_gcode(const std::string& gcode)
|
const std::string& GCodeAnalyzer::process_gcode(const std::string& gcode)
|
||||||
|
@ -520,6 +528,9 @@ void GCodeAnalyzer::_processT(const std::string& cmd)
|
||||||
unsigned int id = (unsigned int)::strtol(cmd.substr(1).c_str(), nullptr, 10);
|
unsigned int id = (unsigned int)::strtol(cmd.substr(1).c_str(), nullptr, 10);
|
||||||
if (_get_extruder_id() != id)
|
if (_get_extruder_id() != id)
|
||||||
{
|
{
|
||||||
|
if (id >= m_extruders_count)
|
||||||
|
BOOST_LOG_TRIVIAL(error) << "GCodeAnalyzer encountered an invalid toolchange, maybe from a custom gcode.";
|
||||||
|
else
|
||||||
_set_extruder_id(id);
|
_set_extruder_id(id);
|
||||||
|
|
||||||
// stores tool change move
|
// stores tool change move
|
||||||
|
|
|
@ -108,6 +108,7 @@ private:
|
||||||
GCodeReader m_parser;
|
GCodeReader m_parser;
|
||||||
TypeToMovesMap m_moves_map;
|
TypeToMovesMap m_moves_map;
|
||||||
ExtruderOffsetsMap m_extruder_offsets;
|
ExtruderOffsetsMap m_extruder_offsets;
|
||||||
|
unsigned int m_extruders_count;
|
||||||
GCodeFlavor m_gcode_flavor;
|
GCodeFlavor m_gcode_flavor;
|
||||||
|
|
||||||
// The output of process_layer()
|
// The output of process_layer()
|
||||||
|
@ -117,6 +118,7 @@ public:
|
||||||
GCodeAnalyzer();
|
GCodeAnalyzer();
|
||||||
|
|
||||||
void set_extruder_offsets(const ExtruderOffsetsMap& extruder_offsets);
|
void set_extruder_offsets(const ExtruderOffsetsMap& extruder_offsets);
|
||||||
|
void set_extruders_count(unsigned int count);
|
||||||
|
|
||||||
void set_gcode_flavor(const GCodeFlavor& flavor);
|
void set_gcode_flavor(const GCodeFlavor& flavor);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue