diff --git a/src/libslic3r/GCode/GCodeProcessor.cpp b/src/libslic3r/GCode/GCodeProcessor.cpp index ae414ad44..beb340a5d 100644 --- a/src/libslic3r/GCode/GCodeProcessor.cpp +++ b/src/libslic3r/GCode/GCodeProcessor.cpp @@ -356,6 +356,10 @@ void GCodeProcessor::apply_config(const DynamicPrintConfig& config) m_filament_diameters.push_back(static_cast(diam)); } } + + const ConfigOptionPoints* bed_shape = config.option("bed_shape"); + if (bed_shape != nullptr) + m_result.bed_shape = bed_shape->values; } void GCodeProcessor::enable_stealth_time_estimator(bool enabled) diff --git a/src/libslic3r/GCode/GCodeProcessor.hpp b/src/libslic3r/GCode/GCodeProcessor.hpp index b2d702f7f..1def93e74 100644 --- a/src/libslic3r/GCode/GCodeProcessor.hpp +++ b/src/libslic3r/GCode/GCodeProcessor.hpp @@ -210,11 +210,27 @@ namespace Slic3r { { unsigned int id; std::vector moves; +#if ENABLE_GCODE_VIEWER_AS_STATE + Pointfs bed_shape; +#endif // ENABLE_GCODE_VIEWER_AS_STATE #if ENABLE_GCODE_VIEWER_STATISTICS long long time{ 0 }; - void reset() { time = 0; moves = std::vector(); } + void reset() + { + time = 0; + moves = std::vector(); +#if ENABLE_GCODE_VIEWER_AS_STATE + bed_shape = Pointfs(); +#endif // ENABLE_GCODE_VIEWER_AS_STATE + } #else - void reset() { moves = std::vector(); } + void reset() + { + moves = std::vector(); +#if ENABLE_GCODE_VIEWER_AS_STATE + bed_shape = Pointfs(); +#endif // ENABLE_GCODE_VIEWER_AS_STATE + } #endif // ENABLE_GCODE_VIEWER_STATISTICS }; diff --git a/src/slic3r/GUI/GCodeViewer.cpp b/src/slic3r/GUI/GCodeViewer.cpp index 418223503..817e7e650 100644 --- a/src/slic3r/GUI/GCodeViewer.cpp +++ b/src/slic3r/GUI/GCodeViewer.cpp @@ -323,14 +323,20 @@ void GCodeViewer::load(const GCodeProcessor::Result& gcode_result, const Print& #if ENABLE_GCODE_VIEWER_AS_STATE if (wxGetApp().mainframe->get_mode() == MainFrame::EMode::GCodeViewer) { - // adjust printbed size in dependence of toolpaths bbox - const double margin = 10.0; - Vec2d min(m_paths_bounding_box.min(0) - margin, m_paths_bounding_box.min(1) - margin); - Vec2d max(m_paths_bounding_box.max(0) + margin, m_paths_bounding_box.max(1) + margin); - Pointfs bed_shape = { { min(0), min(1) }, - { max(0), min(1) }, - { max(0), max(1) }, - { min(0), max(1) } }; + Pointfs bed_shape; + if (!gcode_result.bed_shape.empty()) + // bed shape detected in the gcode + bed_shape = gcode_result.bed_shape; + else { + // adjust printbed size in dependence of toolpaths bbox + const double margin = 10.0; + Vec2d min(m_paths_bounding_box.min(0) - margin, m_paths_bounding_box.min(1) - margin); + Vec2d max(m_paths_bounding_box.max(0) + margin, m_paths_bounding_box.max(1) + margin); + bed_shape = { { min(0), min(1) }, + { max(0), min(1) }, + { max(0), max(1) }, + { min(0), max(1) } }; + } wxGetApp().plater()->set_bed_shape(bed_shape, "", ""); } #endif // ENABLE_GCODE_VIEWER_AS_STATE