From fbde7de98a671a9667bd866ab58646f025130f22 Mon Sep 17 00:00:00 2001 From: enricoturri1966 Date: Fri, 9 Apr 2021 12:52:11 +0200 Subject: [PATCH 1/4] Do not convert custom gcode extrusion to travel --- src/libslic3r/GCode/GCodeProcessor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libslic3r/GCode/GCodeProcessor.cpp b/src/libslic3r/GCode/GCodeProcessor.cpp index 7a1790971..d5be041f4 100644 --- a/src/libslic3r/GCode/GCodeProcessor.cpp +++ b/src/libslic3r/GCode/GCodeProcessor.cpp @@ -2187,7 +2187,7 @@ void GCodeProcessor::process_G1(const GCodeReader::GCodeLine& line) #endif // ENABLE_GCODE_VIEWER_DATA_CHECKING } - if (type == EMoveType::Extrude && (m_extrusion_role == erCustom || m_width == 0.0f || m_height == 0.0f)) + if (type == EMoveType::Extrude && (m_width == 0.0f || m_height == 0.0f)) type = EMoveType::Travel; // time estimate section From 94b28f9b8d2fd1036c2d49572e9050897dcddc92 Mon Sep 17 00:00:00 2001 From: enricoturri1966 Date: Sat, 10 Apr 2021 11:07:08 +0200 Subject: [PATCH 2/4] Do not use custom gcode in out of bed detection --- src/slic3r/GUI/GCodeViewer.cpp | 2 +- src/slic3r/GUI/GLCanvas3D.cpp | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/slic3r/GUI/GCodeViewer.cpp b/src/slic3r/GUI/GCodeViewer.cpp index eacf69c91..67a489c7b 100644 --- a/src/slic3r/GUI/GCodeViewer.cpp +++ b/src/slic3r/GUI/GCodeViewer.cpp @@ -1714,7 +1714,7 @@ void GCodeViewer::load_toolpaths(const GCodeProcessor::Result& gcode_result) // for the gcode viewer we need to take in account all moves to correctly size the printbed m_paths_bounding_box.merge(move.position.cast()); else { - if (move.type == EMoveType::Extrude && move.width != 0.0f && move.height != 0.0f) + if (move.type == EMoveType::Extrude && move.extrusion_role != erCustom && move.width != 0.0f && move.height != 0.0f) m_paths_bounding_box.merge(move.position.cast()); } } diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index 7bbdc72b1..0dea34eae 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -4996,8 +4996,9 @@ void GLCanvas3D::_render_background() const if (!m_volumes.empty()) use_error_color &= _is_any_volume_outside(); else { - BoundingBoxf3 test_volume = (m_config != nullptr) ? print_volume(*m_config) : BoundingBoxf3(); - use_error_color &= (test_volume.radius() > 0.0) ? !test_volume.contains(m_gcode_viewer.get_paths_bounding_box()) : false; + const BoundingBoxf3 test_volume = (m_config != nullptr) ? print_volume(*m_config) : BoundingBoxf3(); + const BoundingBoxf3& paths_volume = m_gcode_viewer.get_paths_bounding_box(); + use_error_color &= (test_volume.radius() > 0.0 && paths_volume.radius() > 0.0) ? !test_volume.contains(paths_volume) : false; } } From 57a73c576933091f7c4fc0aab9f9e50fe04a05b5 Mon Sep 17 00:00:00 2001 From: rtyr <36745189+rtyr@users.noreply.github.com> Date: Thu, 15 Apr 2021 10:42:55 +0200 Subject: [PATCH 3/4] Updated MK2 and MK3 bed textures. --- resources/profiles/PrusaResearch/mk2.svg | 886 ++++++++++++++++++++++- resources/profiles/PrusaResearch/mk3.svg | 884 +++++++++++++++++++++- 2 files changed, 1768 insertions(+), 2 deletions(-) diff --git a/resources/profiles/PrusaResearch/mk2.svg b/resources/profiles/PrusaResearch/mk2.svg index b8fa8d0cd..6214a5552 100644 --- a/resources/profiles/PrusaResearch/mk2.svg +++ b/resources/profiles/PrusaResearch/mk2.svg @@ -1 +1,885 @@ -MK2_bottom \ No newline at end of file + + + + + + image/svg+xml + + MK2_bottom + + + + + MK2_bottom + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/resources/profiles/PrusaResearch/mk3.svg b/resources/profiles/PrusaResearch/mk3.svg index c8f53373b..03b24d572 100644 --- a/resources/profiles/PrusaResearch/mk3.svg +++ b/resources/profiles/PrusaResearch/mk3.svg @@ -1 +1,883 @@ -MK3_bottom \ No newline at end of file + + + + + + image/svg+xml + + MK3_bottom + + + + + MK3_bottom + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 52583bbe3024324de15dba8844ddd31c5c15ecdf Mon Sep 17 00:00:00 2001 From: enricoturri1966 Date: Thu, 22 Apr 2021 15:15:19 +0200 Subject: [PATCH 4/4] Extrusions in custom start g-code forced to be at first layer height level --- src/libslic3r/GCode/GCodeProcessor.cpp | 33 +++++++++++++++++++++++--- src/libslic3r/GCode/GCodeProcessor.hpp | 4 ++++ src/libslic3r/Technologies.hpp | 2 ++ src/slic3r/GUI/GCodeViewer.cpp | 4 ++++ 4 files changed, 40 insertions(+), 3 deletions(-) diff --git a/src/libslic3r/GCode/GCodeProcessor.cpp b/src/libslic3r/GCode/GCodeProcessor.cpp index d5be041f4..5813364ea 100644 --- a/src/libslic3r/GCode/GCodeProcessor.cpp +++ b/src/libslic3r/GCode/GCodeProcessor.cpp @@ -857,6 +857,12 @@ void GCodeProcessor::apply_config(const PrintConfig& config) m_time_processor.export_remaining_time_enabled = config.remaining_times.value; m_use_volumetric_e = config.use_volumetric_e; + +#if ENABLE_START_GCODE_VISUALIZATION + const ConfigOptionFloatOrPercent* first_layer_height = config.option("first_layer_height"); + if (first_layer_height != nullptr) + m_first_layer_height = std::abs(first_layer_height->value); +#endif // ENABLE_START_GCODE_VISUALIZATION } void GCodeProcessor::apply_config(const DynamicPrintConfig& config) @@ -1035,6 +1041,12 @@ void GCodeProcessor::apply_config(const DynamicPrintConfig& config) const ConfigOptionBool* use_volumetric_e = config.option("use_volumetric_e"); if (use_volumetric_e != nullptr) m_use_volumetric_e = use_volumetric_e->value; + +#if ENABLE_START_GCODE_VISUALIZATION + const ConfigOptionFloatOrPercent* first_layer_height = config.option("first_layer_height"); + if (first_layer_height != nullptr) + m_first_layer_height = std::abs(first_layer_height->value); +#endif // ENABLE_START_GCODE_VISUALIZATION } void GCodeProcessor::enable_stealth_time_estimator(bool enabled) @@ -1082,6 +1094,10 @@ void GCodeProcessor::reset() m_filament_diameters = std::vector(Min_Extruder_Count, 1.75f); m_extruded_last_z = 0.0f; +#if ENABLE_START_GCODE_VISUALIZATION + m_first_layer_height = 0.0f; + m_processing_start_custom_gcode = false; +#endif // ENABLE_START_GCODE_VISUALIZATION m_g1_line_id = 0; m_layer_id = 0; m_cp_color.reset(); @@ -1443,6 +1459,9 @@ void GCodeProcessor::process_tags(const std::string_view comment) // extrusion role tag if (boost::starts_with(comment, reserved_tag(ETags::Role))) { m_extrusion_role = ExtrusionEntity::string_to_role(comment.substr(reserved_tag(ETags::Role).length())); +#if ENABLE_START_GCODE_VISUALIZATION + m_processing_start_custom_gcode = (m_extrusion_role == erCustom && m_g1_line_id == 0); +#endif // ENABLE_START_GCODE_VISUALIZATION return; } @@ -2187,7 +2206,11 @@ void GCodeProcessor::process_G1(const GCodeReader::GCodeLine& line) #endif // ENABLE_GCODE_VIEWER_DATA_CHECKING } +#if ENABLE_START_GCODE_VISUALIZATION if (type == EMoveType::Extrude && (m_width == 0.0f || m_height == 0.0f)) +#else + if (type == EMoveType::Extrude && (m_extrusion_role == erCustom || m_width == 0.0f || m_height == 0.0f)) +#endif // ENABLE_START_GCODE_VISUALIZATION type = EMoveType::Travel; // time estimate section @@ -2303,13 +2326,13 @@ void GCodeProcessor::process_G1(const GCodeReader::GCodeLine& line) // Calculate the jerk depending on whether the axis is coasting in the same direction or reversing a direction. float jerk = (v_exit > v_entry) ? - (((v_entry > 0.0f) || (v_exit < 0.0f)) ? + ((v_entry > 0.0f || v_exit < 0.0f) ? // coasting (v_exit - v_entry) : // axis reversal std::max(v_exit, -v_entry)) : // v_exit <= v_entry - (((v_entry < 0.0f) || (v_exit > 0.0f)) ? + ((v_entry < 0.0f || v_exit > 0.0f) ? // coasting (v_entry - v_exit) : // axis reversal @@ -2330,7 +2353,7 @@ void GCodeProcessor::process_G1(const GCodeReader::GCodeLine& line) float vmax_junction_threshold = vmax_junction * 0.99f; // Not coasting. The machine will stop and start the movements anyway, better to start the segment from start. - if ((prev.safe_feedrate > vmax_junction_threshold) && (curr.safe_feedrate > vmax_junction_threshold)) + if (prev.safe_feedrate > vmax_junction_threshold && curr.safe_feedrate > vmax_junction_threshold) vmax_junction = curr.safe_feedrate; } @@ -2815,7 +2838,11 @@ void GCodeProcessor::store_move_vertex(EMoveType type) m_extrusion_role, m_extruder_id, m_cp_color.current, +#if ENABLE_START_GCODE_VISUALIZATION + Vec3f(m_end_position[X], m_end_position[Y], m_processing_start_custom_gcode ? m_first_layer_height : m_end_position[Z]) + m_extruder_offsets[m_extruder_id], +#else Vec3f(m_end_position[X], m_end_position[Y], m_end_position[Z]) + m_extruder_offsets[m_extruder_id], +#endif // ENABLE_START_GCODE_VISUALIZATION m_end_position[E] - m_start_position[E], m_feedrate, m_width, diff --git a/src/libslic3r/GCode/GCodeProcessor.hpp b/src/libslic3r/GCode/GCodeProcessor.hpp index cf55bf86e..3dc30cf69 100644 --- a/src/libslic3r/GCode/GCodeProcessor.hpp +++ b/src/libslic3r/GCode/GCodeProcessor.hpp @@ -490,6 +490,10 @@ namespace Slic3r { ExtruderTemps m_extruder_temps; std::vector m_filament_diameters; float m_extruded_last_z; +#if ENABLE_START_GCODE_VISUALIZATION + float m_first_layer_height; // mm + bool m_processing_start_custom_gcode; +#endif // ENABLE_START_GCODE_VISUALIZATION unsigned int m_g1_line_id; unsigned int m_layer_id; CpColor m_cp_color; diff --git a/src/libslic3r/Technologies.hpp b/src/libslic3r/Technologies.hpp index 303ffe927..cba9cee14 100644 --- a/src/libslic3r/Technologies.hpp +++ b/src/libslic3r/Technologies.hpp @@ -59,6 +59,8 @@ #define ENABLE_EXTENDED_M73_LINES (1 && ENABLE_VALIDATE_CUSTOM_GCODE) // Enable a modified version of automatic downscale on load of objects too big #define ENABLE_MODIFIED_DOWNSCALE_ON_LOAD_OBJECTS_TOO_BIG (1 && ENABLE_2_4_0_ALPHA0) +// Enable visualization of start gcode as regular toolpaths +#define ENABLE_START_GCODE_VISUALIZATION (1 && ENABLE_2_4_0_ALPHA0) #endif // _prusaslicer_technologies_h_ diff --git a/src/slic3r/GUI/GCodeViewer.cpp b/src/slic3r/GUI/GCodeViewer.cpp index 67a489c7b..32aba5724 100644 --- a/src/slic3r/GUI/GCodeViewer.cpp +++ b/src/slic3r/GUI/GCodeViewer.cpp @@ -1714,7 +1714,11 @@ void GCodeViewer::load_toolpaths(const GCodeProcessor::Result& gcode_result) // for the gcode viewer we need to take in account all moves to correctly size the printbed m_paths_bounding_box.merge(move.position.cast()); else { +#if ENABLE_START_GCODE_VISUALIZATION if (move.type == EMoveType::Extrude && move.extrusion_role != erCustom && move.width != 0.0f && move.height != 0.0f) +#else + if (move.type == EMoveType::Extrude && move.width != 0.0f && move.height != 0.0f) +#endif // ENABLE_START_GCODE_VISUALIZATION m_paths_bounding_box.merge(move.position.cast()); } }