From fbd7d143151b5115771b4fd6ab37b15fd6d762f9 Mon Sep 17 00:00:00 2001 From: enricoturri1966 Date: Tue, 15 Aug 2023 11:08:45 +0200 Subject: [PATCH] Fixed wipe tower shell visibility for preview --- src/slic3r/GUI/GCodeViewer.cpp | 43 +++++++++++++++++++++------------- src/slic3r/GUI/GCodeViewer.hpp | 1 + 2 files changed, 28 insertions(+), 16 deletions(-) diff --git a/src/slic3r/GUI/GCodeViewer.cpp b/src/slic3r/GUI/GCodeViewer.cpp index 12567c5c74..cb0775c626 100644 --- a/src/slic3r/GUI/GCodeViewer.cpp +++ b/src/slic3r/GUI/GCodeViewer.cpp @@ -739,6 +739,7 @@ void GCodeViewer::load(const GCodeProcessorResult& gcode_result, const Print& pr m_max_print_height = gcode_result.max_print_height; load_toolpaths(gcode_result); + load_wipetower_shell(print); if (m_layers.empty()) return; @@ -2254,22 +2255,6 @@ void GCodeViewer::load_shells(const Print& print) ++object_id; } - if (wxGetApp().preset_bundle->printers.get_edited_preset().printer_technology() == ptFFF) { - // adds wipe tower's volume - const double max_z = print.objects()[0]->model_object()->get_model()->max_z(); - const PrintConfig& config = print.config(); - const size_t extruders_count = config.nozzle_diameter.size(); - if (extruders_count > 1 && config.wipe_tower && !config.complete_objects) { - const WipeTowerData& wipe_tower_data = print.wipe_tower_data(extruders_count); - const float depth = wipe_tower_data.depth; - const std::vector> z_and_depth_pairs = print.wipe_tower_data(extruders_count).z_and_depth_pairs; - const float brim_width = wipe_tower_data.brim_width; - if (depth != 0.) - m_shells.volumes.load_wipe_tower_preview(config.wipe_tower_x, config.wipe_tower_y, config.wipe_tower_width, depth, z_and_depth_pairs, max_z, config.wipe_tower_cone_angle, config.wipe_tower_rotation_angle, - !print.is_step_done(psWipeTower), brim_width); - } - } - // remove modifiers while (true) { GLVolumePtrs::iterator it = std::find_if(m_shells.volumes.volumes.begin(), m_shells.volumes.volumes.end(), [](GLVolume* volume) { return volume->is_modifier; }); @@ -2296,6 +2281,32 @@ void GCodeViewer::load_shells(const Print& print) m_max_bounding_box.reset(); } +void GCodeViewer::load_wipetower_shell(const Print& print) +{ + if (wxGetApp().preset_bundle->printers.get_edited_preset().printer_technology() == ptFFF && print.is_step_done(psWipeTower)) { + // adds wipe tower's volume + const double max_z = print.objects()[0]->model_object()->get_model()->max_z(); + const PrintConfig& config = print.config(); + const size_t extruders_count = config.nozzle_diameter.size(); + if (extruders_count > 1 && config.wipe_tower && !config.complete_objects) { + const WipeTowerData& wipe_tower_data = print.wipe_tower_data(extruders_count); + const float depth = wipe_tower_data.depth; + const std::vector> z_and_depth_pairs = print.wipe_tower_data(extruders_count).z_and_depth_pairs; + const float brim_width = wipe_tower_data.brim_width; + if (depth != 0.) { + m_shells.volumes.load_wipe_tower_preview(config.wipe_tower_x, config.wipe_tower_y, config.wipe_tower_width, depth, z_and_depth_pairs, + max_z, config.wipe_tower_cone_angle, config.wipe_tower_rotation_angle, false, brim_width); + GLVolume* volume = m_shells.volumes.volumes.back(); + volume->color.a(0.25f); + volume->force_native_color = true; + volume->set_render_color(true); + m_shells_bounding_box.merge(volume->transformed_bounding_box()); + m_max_bounding_box.reset(); + } + } + } +} + void GCodeViewer::refresh_render_paths(bool keep_sequential_current_first, bool keep_sequential_current_last) const { #if ENABLE_GCODE_VIEWER_STATISTICS diff --git a/src/slic3r/GUI/GCodeViewer.hpp b/src/slic3r/GUI/GCodeViewer.hpp index 50c27e5fa4..aa021089d1 100644 --- a/src/slic3r/GUI/GCodeViewer.hpp +++ b/src/slic3r/GUI/GCodeViewer.hpp @@ -867,6 +867,7 @@ public: private: void load_toolpaths(const GCodeProcessorResult& gcode_result); + void load_wipetower_shell(const Print& print); void render_toolpaths(); void render_shells(); void render_legend(float& legend_height);