From 9fcb67e6c7f84da06e2c4b8e1e9833aebff287a1 Mon Sep 17 00:00:00 2001 From: "qing.zhang" Date: Thu, 29 Dec 2022 12:40:28 +0800 Subject: [PATCH] FIX: add plate offset of placeholder Signed-off-by: qing.zhang Change-Id: Id16559e112b6db2759b95f97465d49ab85206e83 --- src/libslic3r/GCode.cpp | 9 +++++---- src/libslic3r/GCodeWriter.hpp | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index 47462c0a9..6a649d28f 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -1469,10 +1469,11 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato m_placeholder_parser.set("has_wipe_tower", has_wipe_tower); //m_placeholder_parser.set("has_single_extruder_multi_material_priming", has_wipe_tower && print.config().single_extruder_multi_material_priming); m_placeholder_parser.set("total_toolchanges", std::max(0, print.wipe_tower_data().number_of_toolchanges)); // Check for negative toolchanges (single extruder mode) and set to 0 (no tool change). + Vec2f plate_offset = m_writer.get_xy_offset(); { BoundingBoxf bbox(print.config().printable_area.values); - m_placeholder_parser.set("print_bed_min", new ConfigOptionFloats({ bbox.min.x(), bbox.min.y() })); - m_placeholder_parser.set("print_bed_max", new ConfigOptionFloats({ bbox.max.x(), bbox.max.y() })); + m_placeholder_parser.set("print_bed_min", new ConfigOptionFloats({ bbox.min.x() - plate_offset.x(), bbox.min.y() - plate_offset.y() })); + m_placeholder_parser.set("print_bed_max", new ConfigOptionFloats({ bbox.max.x() - plate_offset.x(), bbox.max.y() - plate_offset.y() })); m_placeholder_parser.set("print_bed_size", new ConfigOptionFloats({ bbox.size().x(), bbox.size().y() })); } { @@ -1487,8 +1488,8 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato pts->values.emplace_back(unscale(pt)); BoundingBoxf bbox(pts->values); m_placeholder_parser.set("first_layer_print_convex_hull", pts.release()); - m_placeholder_parser.set("first_layer_print_min", new ConfigOptionFloats({ bbox.min.x(), bbox.min.y() })); - m_placeholder_parser.set("first_layer_print_max", new ConfigOptionFloats({ bbox.max.x(), bbox.max.y() })); + m_placeholder_parser.set("first_layer_print_min", new ConfigOptionFloats({bbox.min.x() - plate_offset.x(), bbox.min.y() - plate_offset.y()})); + m_placeholder_parser.set("first_layer_print_max", new ConfigOptionFloats({bbox.max.x() - plate_offset.x(), bbox.max.y() - plate_offset.y()})); m_placeholder_parser.set("first_layer_print_size", new ConfigOptionFloats({ bbox.size().x(), bbox.size().y() })); } diff --git a/src/libslic3r/GCodeWriter.hpp b/src/libslic3r/GCodeWriter.hpp index 1a92abfbb..e752ee49c 100644 --- a/src/libslic3r/GCodeWriter.hpp +++ b/src/libslic3r/GCodeWriter.hpp @@ -79,7 +79,7 @@ public: //BBS: set offset for gcode writer void set_xy_offset(double x, double y) { m_x_offset = x; m_y_offset = y; } - + Vec2f get_xy_offset() { return Vec2f{m_x_offset, m_y_offset}; }; // To be called by the CoolingBuffer from another thread. static std::string set_fan(const GCodeFlavor gcode_flavor, unsigned int speed); // To be called by the main thread. It always emits the G-code, it does not remember the previous state.