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 @@
-
\ No newline at end of file
+
+
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 @@
-
\ No newline at end of file
+
+
diff --git a/src/libslic3r/GCode/GCodeProcessor.cpp b/src/libslic3r/GCode/GCodeProcessor.cpp
index 7a1790971..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 38aa56e8b..f3e1e1733 100644
--- a/src/slic3r/GUI/GCodeViewer.cpp
+++ b/src/slic3r/GUI/GCodeViewer.cpp
@@ -1716,7 +1716,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());
}
}
diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp
index da8c84605..6dcd30c29 100644
--- a/src/slic3r/GUI/GLCanvas3D.cpp
+++ b/src/slic3r/GUI/GLCanvas3D.cpp
@@ -4999,8 +4999,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;
}
}