mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-11 08:47:52 -06:00
GCodeProcessor additions:
process G90 lines process G91 lines process G92 lines process M82 lines process M83 lines process T lines process extrusion role/width/height comment tags debug output
This commit is contained in:
parent
29cbfa7c9e
commit
956f7a4593
8 changed files with 349 additions and 84 deletions
|
@ -3,11 +3,19 @@
|
|||
|
||||
#if ENABLE_GCODE_VIEWER
|
||||
#include "../GCodeReader.hpp"
|
||||
#include "../Point.hpp"
|
||||
#include "../ExtrusionEntity.hpp"
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
class GCodeProcessor
|
||||
{
|
||||
public:
|
||||
static const std::string Extrusion_Role_Tag;
|
||||
static const std::string Width_Tag;
|
||||
static const std::string Height_Tag;
|
||||
|
||||
private:
|
||||
using AxisCoords = std::array<float, 4>;
|
||||
|
||||
enum class EUnits : unsigned char
|
||||
|
@ -33,16 +41,29 @@ namespace Slic3r {
|
|||
Num_Types
|
||||
};
|
||||
|
||||
public:
|
||||
struct MoveVertex
|
||||
{
|
||||
Vec3d position{ Vec3d::Zero() }; // mm
|
||||
float feedrate{ 0.0f }; // mm/s
|
||||
// type of the move terminating at this vertex
|
||||
EMoveType type{ EMoveType::Noop };
|
||||
};
|
||||
ExtrusionRole extrusion_role{ erNone };
|
||||
Vec3f position{ Vec3f::Zero() }; // mm
|
||||
float feedrate{ 0.0f }; // mm/s
|
||||
float width{ 0.0f }; // mm
|
||||
float height{ 0.0f }; // mm
|
||||
unsigned int extruder_id{ 0 };
|
||||
|
||||
public:
|
||||
typedef std::map<unsigned int, Vec2d> ExtruderOffsetsMap;
|
||||
std::string to_string() const
|
||||
{
|
||||
std::string str = std::to_string((int)type);
|
||||
str += ", " + std::to_string((int)extrusion_role);
|
||||
str += ", " + Slic3r::to_string((Vec3d)position.cast<double>());
|
||||
str += ", " + std::to_string(extruder_id);
|
||||
str += ", " + std::to_string(feedrate);
|
||||
str += ", " + std::to_string(width);
|
||||
str += ", " + std::to_string(height);
|
||||
return str;
|
||||
}
|
||||
};
|
||||
|
||||
struct Result
|
||||
{
|
||||
|
@ -56,25 +77,26 @@ namespace Slic3r {
|
|||
EUnits m_units;
|
||||
EPositioningType m_global_positioning_type;
|
||||
EPositioningType m_e_local_positioning_type;
|
||||
std::vector<Vec3f> m_extruder_offsets;
|
||||
|
||||
AxisCoords m_start_position; // mm
|
||||
AxisCoords m_end_position; // mm
|
||||
AxisCoords m_origin; // mm
|
||||
|
||||
float m_feedrate; // mm/s
|
||||
float m_width; // mm
|
||||
float m_height; // mm
|
||||
ExtrusionRole m_extrusion_role;
|
||||
unsigned int m_extruder_id;
|
||||
ExtruderOffsetsMap m_extruder_offsets;
|
||||
|
||||
Result m_result;
|
||||
|
||||
public:
|
||||
GCodeProcessor() { reset(); }
|
||||
|
||||
void apply_config(const PrintConfig& config) { m_parser.apply_config(config); }
|
||||
void apply_config(const PrintConfig& config);
|
||||
void reset();
|
||||
|
||||
void set_extruder_offsets(const ExtruderOffsetsMap& extruder_offsets) { m_extruder_offsets = extruder_offsets; }
|
||||
|
||||
const Result& get_result() const { return m_result; }
|
||||
Result&& extract_result() { return std::move(m_result); }
|
||||
|
||||
|
@ -86,11 +108,31 @@ namespace Slic3r {
|
|||
void process_gcode_line(const GCodeReader::GCodeLine& line);
|
||||
|
||||
// Process tags embedded into comments
|
||||
void process_comment(const GCodeReader::GCodeLine& line);
|
||||
void process_tags(const std::string& comment);
|
||||
|
||||
// Move
|
||||
void process_G1(const GCodeReader::GCodeLine& line);
|
||||
};
|
||||
|
||||
// Set to Absolute Positioning
|
||||
void processG90(const GCodeReader::GCodeLine& line);
|
||||
|
||||
// Set to Relative Positioning
|
||||
void processG91(const GCodeReader::GCodeLine& line);
|
||||
|
||||
// Set Position
|
||||
void processG92(const GCodeReader::GCodeLine& line);
|
||||
|
||||
// Set extruder to absolute mode
|
||||
void processM82(const GCodeReader::GCodeLine& line);
|
||||
|
||||
// Set extruder to relative mode
|
||||
void processM83(const GCodeReader::GCodeLine& line);
|
||||
|
||||
// Processes T line (Select Tool)
|
||||
void processT(const GCodeReader::GCodeLine& line);
|
||||
|
||||
void store_move_vertex(EMoveType type);
|
||||
};
|
||||
|
||||
} /* namespace Slic3r */
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue