diff --git a/src/libslic3r/Technologies.hpp b/src/libslic3r/Technologies.hpp index 755ca5ffa..20f18cdee 100644 --- a/src/libslic3r/Technologies.hpp +++ b/src/libslic3r/Technologies.hpp @@ -58,5 +58,7 @@ // Printbed textures generated from svg files #define ENABLE_TEXTURES_FROM_SVG (1 && ENABLE_1_42_0_ALPHA7) +// Do not regenerate GLVolumes for gcode preview if not needed +#define ENABLE_NO_GCODE_TOOLPATHS_REGENERATION (1 && ENABLE_1_42_0_ALPHA7) #endif // _technologies_h_ diff --git a/src/slic3r/GUI/GUI_Preview.cpp b/src/slic3r/GUI/GUI_Preview.cpp index 549dbd7e6..f9f507571 100644 --- a/src/slic3r/GUI/GUI_Preview.cpp +++ b/src/slic3r/GUI/GUI_Preview.cpp @@ -418,11 +418,22 @@ void Preview::load_print() load_print_as_sla(); } +#if ENABLE_NO_GCODE_TOOLPATHS_REGENERATION +void Preview::reload_print(bool force, bool keep_volumes) +#else void Preview::reload_print(bool force) +#endif // ENABLE_NO_GCODE_TOOLPATHS_REGENERATION { - m_canvas->reset_volumes(); - m_canvas->reset_legend_texture(); - m_loaded = false; +#if ENABLE_NO_GCODE_TOOLPATHS_REGENERATION + if (!keep_volumes) + { +#endif // ENABLE_NO_GCODE_TOOLPATHS_REGENERATION + m_canvas->reset_volumes(); + m_canvas->reset_legend_texture(); + m_loaded = false; +#if ENABLE_NO_GCODE_TOOLPATHS_REGENERATION + } +#endif // ENABLE_NO_GCODE_TOOLPATHS_REGENERATION if (!IsShown() && !force) return; diff --git a/src/slic3r/GUI/GUI_Preview.hpp b/src/slic3r/GUI/GUI_Preview.hpp index 6cd67013c..124be934d 100644 --- a/src/slic3r/GUI/GUI_Preview.hpp +++ b/src/slic3r/GUI/GUI_Preview.hpp @@ -129,7 +129,11 @@ public: void set_drop_target(wxDropTarget* target); void load_print(); +#if ENABLE_NO_GCODE_TOOLPATHS_REGENERATION + void reload_print(bool force = false, bool keep_volumes = false); +#else void reload_print(bool force = false); +#endif // ENABLE_NO_GCODE_TOOLPATHS_REGENERATION void refresh_print(); private: diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 08698998f..6d62e9d84 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -1997,6 +1997,11 @@ void Plater::priv::schedule_background_process() this->background_process_timer.Start(500, wxTIMER_ONE_SHOT); // Notify the Canvas3D that something has changed, so it may invalidate some of the layer editing stuff. this->view3D->get_canvas3d()->set_config(this->config); +#if ENABLE_NO_GCODE_TOOLPATHS_REGENERATION + // Reset gcode preview + this->preview->get_canvas3d()->reset_volumes(); + this->preview->get_canvas3d()->reset_legend_texture(); +#endif // ENABLE_NO_GCODE_TOOLPATHS_REGENERATION } void Plater::priv::update_print_volume_state() @@ -2261,7 +2266,12 @@ void Plater::priv::set_current_panel(wxPanel* panel) else if (current_panel == preview) { this->q->reslice(); +#if ENABLE_NO_GCODE_TOOLPATHS_REGENERATION + // keeps current gcode preview, if any + preview->reload_print(false, true); +#else preview->reload_print(); +#endif // ENABLE_NO_GCODE_TOOLPATHS_REGENERATION preview->set_canvas_as_dirty(); view_toolbar.select_item("Preview"); }