From 08b6369ae42dec14c1eb8bb1acf44dee9e0c6ba6 Mon Sep 17 00:00:00 2001 From: enricoturri1966 Date: Fri, 1 Dec 2023 12:28:37 +0100 Subject: [PATCH] New gcode visualization integration - Removed GCodeProcessorResult::spiral_vase_layers --- src/libslic3r/GCode/GCodeProcessor.cpp | 50 +++++++++++++++ src/libslic3r/GCode/GCodeProcessor.hpp | 14 +++++ src/slic3r/GUI/GCodeViewer.cpp | 6 +- src/slic3r/GUI/GCodeViewer.hpp | 10 +-- src/slic3r/GUI/LibVGCode/LibVGCodeWrapper.cpp | 10 ++- .../GUI/LibVGCode/include/GCodeInputData.hpp | 7 ++- .../GUI/LibVGCode/include/PathVertex.hpp | 61 +++++++++++++++++++ src/slic3r/GUI/LibVGCode/include/Viewer.hpp | 1 - src/slic3r/GUI/LibVGCode/src/Settings.hpp | 1 + src/slic3r/GUI/LibVGCode/src/Viewer.cpp | 5 -- src/slic3r/GUI/LibVGCode/src/ViewerImpl.cpp | 22 ++++--- src/slic3r/GUI/LibVGCode/src/ViewerImpl.hpp | 2 - 12 files changed, 158 insertions(+), 31 deletions(-) diff --git a/src/libslic3r/GCode/GCodeProcessor.cpp b/src/libslic3r/GCode/GCodeProcessor.cpp index 88faa120ef..489b1373b6 100644 --- a/src/libslic3r/GCode/GCodeProcessor.cpp +++ b/src/libslic3r/GCode/GCodeProcessor.cpp @@ -524,7 +524,15 @@ void GCodeProcessorResult::reset() { filament_densities = std::vector(MIN_EXTRUDERS_COUNT, DEFAULT_FILAMENT_DENSITY); filament_cost = std::vector(MIN_EXTRUDERS_COUNT, DEFAULT_FILAMENT_COST); custom_gcode_per_print_z = std::vector(); +//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ +#if ENABLE_NEW_GCODE_VIEWER + spiral_vase_mode = false; +#else +//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ spiral_vase_layers = std::vector>>(); +//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ +#endif // ENABLE_NEW_GCODE_VIEWER +//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ conflict_result = std::nullopt; time = 0; } @@ -544,7 +552,15 @@ void GCodeProcessorResult::reset() { filament_densities = std::vector(MIN_EXTRUDERS_COUNT, DEFAULT_FILAMENT_DENSITY); filament_cost = std::vector(MIN_EXTRUDERS_COUNT, DEFAULT_FILAMENT_COST); custom_gcode_per_print_z = std::vector(); +//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ +#if ENABLE_NEW_GCODE_VIEWER + spiral_vase_mode = false; +#else +//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ spiral_vase_layers = std::vector>>(); +//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ +#endif // ENABLE_NEW_GCODE_VIEWER +//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ conflict_result = std::nullopt; } #endif // ENABLE_GCODE_VIEWER_STATISTICS @@ -728,7 +744,15 @@ for (size_t i = 0; i < static_cast(PrintEstimatedStatistics::ETimeMode:: const ConfigOptionBool* spiral_vase = config.option("spiral_vase"); if (spiral_vase != nullptr) +//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ +#if ENABLE_NEW_GCODE_VIEWER + m_result.spiral_vase_mode = spiral_vase->value; +#else +//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ m_spiral_vase_active = spiral_vase->value; +//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ +#endif // ENABLE_NEW_GCODE_VIEWER +//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ const ConfigOptionFloat* z_offset = config.option("z_offset"); if (z_offset != nullptr) @@ -1010,7 +1034,15 @@ void GCodeProcessor::apply_config(const DynamicPrintConfig& config) const ConfigOptionBool* spiral_vase = config.option("spiral_vase"); if (spiral_vase != nullptr) +//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ +#if ENABLE_NEW_GCODE_VIEWER + m_result.spiral_vase_mode = spiral_vase->value; +#else +//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ m_spiral_vase_active = spiral_vase->value; +//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ +#endif // ENABLE_NEW_GCODE_VIEWER +//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ const ConfigOptionFloat* z_offset = config.option("z_offset"); if (z_offset != nullptr) @@ -1081,7 +1113,13 @@ void GCodeProcessor::reset() m_options_z_corrector.reset(); +//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ +#if !ENABLE_NEW_GCODE_VIEWER +//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ m_spiral_vase_active = false; +//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ +#endif // !ENABLE_NEW_GCODE_VIEWER +//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ m_kissslicer_toolchange_time_correction = 0.0f; m_single_extruder_multi_material = false; @@ -2081,6 +2119,9 @@ void GCodeProcessor::process_tags(const std::string_view comment, bool producers // layer change tag if (comment == reserved_tag(ETags::Layer_Change)) { ++m_layer_id; +//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ +#if !ENABLE_NEW_GCODE_VIEWER +//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ if (m_spiral_vase_active) { if (m_result.moves.empty() || m_result.spiral_vase_layers.empty()) // add a placeholder for layer height. the actual value will be set inside process_G1() method @@ -2093,6 +2134,9 @@ void GCodeProcessor::process_tags(const std::string_view comment, bool producers m_result.spiral_vase_layers.push_back({ FLT_MAX, { move_id, move_id } }); } } +//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ +#endif // !ENABLE_NEW_GCODE_VIEWER +//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ return; } @@ -2985,6 +3029,9 @@ void GCodeProcessor::process_G1(const std::array, 4>& axes m_seams_detector.set_first_vertex(m_result.moves.back().position - m_extruder_offsets[m_extruder_id]); } +//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ +#if !ENABLE_NEW_GCODE_VIEWER +//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ if (m_spiral_vase_active && !m_result.spiral_vase_layers.empty()) { if (m_result.spiral_vase_layers.back().first == FLT_MAX && delta_pos[Z] >= 0.0) // replace layer height placeholder with correct value @@ -2992,6 +3039,9 @@ void GCodeProcessor::process_G1(const std::array, 4>& axes if (!m_result.moves.empty()) m_result.spiral_vase_layers.back().second.second = m_result.moves.size() - 1; } +//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ +#endif // !ENABLE_NEW_GCODE_VIEWER +//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ // store move store_move_vertex(type, origin == G1DiscretizationOrigin::G2G3); diff --git a/src/libslic3r/GCode/GCodeProcessor.hpp b/src/libslic3r/GCode/GCodeProcessor.hpp index b437c9a5a5..1cc12460d7 100644 --- a/src/libslic3r/GCode/GCodeProcessor.hpp +++ b/src/libslic3r/GCode/GCodeProcessor.hpp @@ -201,7 +201,15 @@ namespace Slic3r { PrintEstimatedStatistics print_statistics; std::vector custom_gcode_per_print_z; +//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ +#if ENABLE_NEW_GCODE_VIEWER + bool spiral_vase_mode; +#else +//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ std::vector>> spiral_vase_layers; +//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ +#endif // ENABLE_NEW_GCODE_VIEWER +//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ConflictResultOpt conflict_result; @@ -665,7 +673,13 @@ namespace Slic3r { SeamsDetector m_seams_detector; OptionsZCorrector m_options_z_corrector; size_t m_last_default_color_id; +//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ +#if !ENABLE_NEW_GCODE_VIEWER +//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ bool m_spiral_vase_active; +//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ +#endif // !ENABLE_NEW_GCODE_VIEWER +//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ float m_kissslicer_toolchange_time_correction; #if ENABLE_GCODE_VIEWER_STATISTICS std::chrono::time_point m_start_time; diff --git a/src/slic3r/GUI/GCodeViewer.cpp b/src/slic3r/GUI/GCodeViewer.cpp index eebbc5bb59..75c558143f 100644 --- a/src/slic3r/GUI/GCodeViewer.cpp +++ b/src/slic3r/GUI/GCodeViewer.cpp @@ -1130,7 +1130,7 @@ void GCodeViewer::init() //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ #if ENABLE_NEW_GCODE_VIEWER -void GCodeViewer::load(const GCodeProcessorResult & gcode_result, const Print & print, const std::vector&str_tool_colors) +void GCodeViewer::load(const GCodeProcessorResult& gcode_result, const Print& print, const std::vector&str_tool_colors) { m_new_viewer.set_top_layer_only_view_range(get_app_config()->get_bool("seq_top_layer_only")); @@ -1194,6 +1194,8 @@ void GCodeViewer::load(const GCodeProcessorResult & gcode_result, const Print & if (wxGetApp().is_editor()) m_contained_in_bed = wxGetApp().plater()->build_volume().all_paths_inside(gcode_result, m_paths_bounding_box); + + m_extruders_count = gcode_result.extruders_count; #else //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ void GCodeViewer::load(const GCodeProcessorResult & gcode_result, const Print & print) @@ -1437,7 +1439,6 @@ void GCodeViewer::reset() #if !ENABLE_NEW_GCODE_VIEWER //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ m_tool_colors = std::vector(); - m_extruders_count = 0; m_extruder_ids = std::vector(); m_extrusions.reset_ranges(); m_layers.reset(); @@ -1449,6 +1450,7 @@ void GCodeViewer::reset() //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ #endif // !ENABLE_NEW_GCODE_VIEWER //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ + m_extruders_count = 0; m_print_statistics.reset(); m_custom_gcode_per_print_z = std::vector(); m_sequential_view.gcode_window.reset(); diff --git a/src/slic3r/GUI/GCodeViewer.hpp b/src/slic3r/GUI/GCodeViewer.hpp index abf8b723d2..1e50ac42ee 100644 --- a/src/slic3r/GUI/GCodeViewer.hpp +++ b/src/slic3r/GUI/GCodeViewer.hpp @@ -897,12 +897,12 @@ private: Layers m_layers; std::array m_layers_z_range; std::vector m_roles; - size_t m_extruders_count; std::vector m_extruder_ids; Extrusions m_extrusions; //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ #endif // !ENABLE_NEW_GCODE_VIEWER //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ + size_t m_extruders_count; std::vector m_filament_diameters; std::vector m_filament_densities; SequentialView m_sequential_view; @@ -1085,15 +1085,7 @@ public: void toggle_gcode_window_visibility() { m_sequential_view.gcode_window.toggle_visibility(); } std::vector& get_custom_gcode_per_print_z() { return m_custom_gcode_per_print_z; } -//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ -#if ENABLE_NEW_GCODE_VIEWER - size_t get_extruders_count() { return m_new_viewer.get_extruders_count(); } -#else -//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ size_t get_extruders_count() { return m_extruders_count; } -//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ -#endif // ENABLE_NEW_GCODE_VIEWER -//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ void invalidate_legend() { m_legend_resizer.reset(); } diff --git a/src/slic3r/GUI/LibVGCode/LibVGCodeWrapper.cpp b/src/slic3r/GUI/LibVGCode/LibVGCodeWrapper.cpp index 8c1f26e23d..4a3f88ca1b 100644 --- a/src/slic3r/GUI/LibVGCode/LibVGCodeWrapper.cpp +++ b/src/slic3r/GUI/LibVGCode/LibVGCodeWrapper.cpp @@ -5,6 +5,10 @@ #include "libslic3r/libslic3r.h" #include "LibVGCodeWrapper.hpp" +//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ +#if ENABLE_NEW_GCODE_VIEWER +//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ + namespace libvgcode { Vec3 convert(const Slic3r::Vec3f& v) @@ -226,9 +230,13 @@ GCodeInputData convert(const Slic3r::GCodeProcessorResult& result) } ret.vertices.shrink_to_fit(); - ret.extruders_count = static_cast(result.extruders_count); + ret.spiral_vase_mode = result.spiral_vase_mode; return ret; } } // namespace libvgcode + +//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ +#endif // ENABLE_NEW_GCODE_VIEWER +//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ diff --git a/src/slic3r/GUI/LibVGCode/include/GCodeInputData.hpp b/src/slic3r/GUI/LibVGCode/include/GCodeInputData.hpp index c83d826f43..050db781db 100644 --- a/src/slic3r/GUI/LibVGCode/include/GCodeInputData.hpp +++ b/src/slic3r/GUI/LibVGCode/include/GCodeInputData.hpp @@ -17,12 +17,13 @@ namespace libvgcode { struct GCodeInputData { // - // Count of extruders + // Whether or not the gcode was generated with spiral vase mode enabled. + // Required to properly detect fictitious layer changes when spiral vase mode is enabled. // - uint8_t extruders_count{ 0 }; + bool spiral_vase_mode{ false }; // - // List of path vertices + // List of path vertices (gcode moves) // std::vector vertices; }; diff --git a/src/slic3r/GUI/LibVGCode/include/PathVertex.hpp b/src/slic3r/GUI/LibVGCode/include/PathVertex.hpp index 7cc8038bd1..ec781900db 100644 --- a/src/slic3r/GUI/LibVGCode/include/PathVertex.hpp +++ b/src/slic3r/GUI/LibVGCode/include/PathVertex.hpp @@ -14,30 +14,91 @@ namespace libvgcode { +// +// Struct representating a gcode move (toolpath segment) +// struct PathVertex { + // + // Segment end position + // Vec3 position{ 0.0f, 0.0f, 0.0f }; + // + // Segment height + // float height{ 0.0f }; + // + // Segment width + // float width{ 0.0f }; + // + // Segment speed + // float feedrate{ 0.0f }; + // + // Segment fan speed + // float fan_speed{ 0.0f }; + // + // Segment temperature + // float temperature{ 0.0f }; + // + // Segment volumetric rate + // float volumetric_rate{ 0.0f }; #if !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS float weight{ 0.0f }; #endif // !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS + // + // Segment extrusion role + // EGCodeExtrusionRole role{ EGCodeExtrusionRole::None }; + // + // Segment move type + // EMoveType type{ EMoveType::Noop }; + // + // Segment gcode line id + // uint32_t gcode_id{ 0 }; + // + // Segment layer id + // uint32_t layer_id{ 0 }; + // + // Segment extruder id + // uint8_t extruder_id{ 0 }; + // + // Segment color id + // uint8_t color_id{ 0 }; + // + // Segment estimated times + // std::array times{ 0.0f, 0.0f }; + // + // Return true if the segment is an extrusion move + // bool is_extrusion() const; + // + // Return true if the segment is an travel move + // bool is_travel() const; + // + // Return true if the segment is an option + // See: EOptionType + // bool is_option() const; + // + // Return true if the segment is a wipe move + // bool is_wipe() const; + // + // Return true if the segment was generated by custom gcode + // bool is_custom_gcode() const; }; diff --git a/src/slic3r/GUI/LibVGCode/include/Viewer.hpp b/src/slic3r/GUI/LibVGCode/include/Viewer.hpp index 4f33dd5a56..2e17271c95 100644 --- a/src/slic3r/GUI/LibVGCode/include/Viewer.hpp +++ b/src/slic3r/GUI/LibVGCode/include/Viewer.hpp @@ -53,7 +53,6 @@ public: size_t get_layer_id_at(float z) const; - size_t get_extruders_count() const; size_t get_used_extruders_count() const; const std::vector& get_used_extruders_ids() const; diff --git a/src/slic3r/GUI/LibVGCode/src/Settings.hpp b/src/slic3r/GUI/LibVGCode/src/Settings.hpp index 122e1c4d97..161397b80d 100644 --- a/src/slic3r/GUI/LibVGCode/src/Settings.hpp +++ b/src/slic3r/GUI/LibVGCode/src/Settings.hpp @@ -24,6 +24,7 @@ struct Settings EViewType view_type{ EViewType::FeatureType }; ETimeMode time_mode{ ETimeMode::Normal }; bool top_layer_only_view_range{ false }; + bool spiral_vase_mode{ false }; std::map options_visibility{ { { EOptionType::Travels, false }, diff --git a/src/slic3r/GUI/LibVGCode/src/Viewer.cpp b/src/slic3r/GUI/LibVGCode/src/Viewer.cpp index c7b5ade023..85a1dc710f 100644 --- a/src/slic3r/GUI/LibVGCode/src/Viewer.cpp +++ b/src/slic3r/GUI/LibVGCode/src/Viewer.cpp @@ -112,11 +112,6 @@ size_t Viewer::get_layer_id_at(float z) const return m_impl->get_layer_id_at(z); } -size_t Viewer::get_extruders_count() const -{ - return m_impl->get_extruders_count(); -} - size_t Viewer::get_used_extruders_count() const { return m_impl->get_used_extruders_count(); diff --git a/src/slic3r/GUI/LibVGCode/src/ViewerImpl.cpp b/src/slic3r/GUI/LibVGCode/src/ViewerImpl.cpp index c544b28036..3fad4b4deb 100644 --- a/src/slic3r/GUI/LibVGCode/src/ViewerImpl.cpp +++ b/src/slic3r/GUI/LibVGCode/src/ViewerImpl.cpp @@ -383,7 +383,6 @@ void ViewerImpl::reset() m_view_range.reset(); m_extrusion_roles.reset(); m_travels_time = { 0.0f, 0.0f }; - m_extruders_count = 0; m_used_extruders_ids.clear(); m_vertices.clear(); m_valid_lines_bitset.clear(); @@ -412,7 +411,7 @@ void ViewerImpl::load(GCodeInputData&& gcode_data) m_loading = true; m_vertices = std::move(gcode_data.vertices); - m_extruders_count = gcode_data.extruders_count; + m_settings.spiral_vase_mode = gcode_data.spiral_vase_mode; for (size_t i = 0; i < m_vertices.size(); ++i) { const PathVertex& v = m_vertices[i]; @@ -551,6 +550,13 @@ void ViewerImpl::update_enabled_entities() if (m_vertices[range[1]].is_option() && range[1] < static_cast(m_vertices.size()) - 1) ++range[1]; + if (m_settings.spiral_vase_mode) { + // when spiral vase mode is enabled and only one layer is shown, extend the range by one step + const std::array& layers_range = m_layers.get_view_range(); + if (layers_range[0] > 0 && layers_range[0] == layers_range[1]) + --range[0]; + } + for (uint32_t i = range[0]; i < range[1]; ++i) { const PathVertex& v = m_vertices[i]; @@ -630,7 +636,8 @@ void ViewerImpl::update_colors() const bool color_top_layer_only = m_view_range.get_full()[1] != m_view_range.get_visible()[1]; std::vector colors(m_vertices.size()); for (size_t i = 0; i < m_vertices.size(); i++) { - colors[i] = (color_top_layer_only && m_vertices[i].layer_id < top_layer_id) ? encode_color(Dummy_Color) : encode_color(select_color(m_vertices[i])); + colors[i] = (color_top_layer_only && m_vertices[i].layer_id < top_layer_id && i != m_view_range.get_enabled()[0]) ? + encode_color(Dummy_Color) : encode_color(select_color(m_vertices[i])); } // update gpu buffer for colors @@ -742,11 +749,6 @@ size_t ViewerImpl::get_layer_id_at(float z) const return m_layers.get_layer_id_at(z); } -size_t ViewerImpl::get_extruders_count() const -{ - return m_extruders_count; -} - size_t ViewerImpl::get_used_extruders_count() const { return m_used_extruders_ids.size(); @@ -1141,6 +1143,10 @@ void ViewerImpl::update_view_full_range() } if (shortened) --top_first_it; + + // when spiral vase mode is enabled and only one layer is shown, extend the range by one step + if (m_settings.spiral_vase_mode && layers_range[0] > 0 && layers_range[0] == layers_range[1]) + --top_first_it; m_view_range.set_enabled(std::distance(m_vertices.begin(), top_first_it), full_range[1]); } else diff --git a/src/slic3r/GUI/LibVGCode/src/ViewerImpl.hpp b/src/slic3r/GUI/LibVGCode/src/ViewerImpl.hpp index 8a3e130f19..d3c663b307 100644 --- a/src/slic3r/GUI/LibVGCode/src/ViewerImpl.hpp +++ b/src/slic3r/GUI/LibVGCode/src/ViewerImpl.hpp @@ -90,7 +90,6 @@ public: size_t get_layer_id_at(float z) const; - size_t get_extruders_count() const; size_t get_used_extruders_count() const; const std::vector& get_used_extruders_ids() const; @@ -170,7 +169,6 @@ private: ViewRange m_view_range; ExtrusionRoles m_extrusion_roles; std::array m_travels_time{ 0.0f, 0.0f }; - size_t m_extruders_count{ 0 }; std::vector m_used_extruders_ids; bool m_loading{ false };