Fix missing update of preview:

The problem was that when one print preview was loaded, second print was in progress and someone switched
to the first bed in 3D view and then switched to preview, the preview was not updated. GCodeViewer remembers
last preview it loaded, so it thought that no action is needed.
For now, let's just place this ugly patch to make sure that no other functionality is broken.
This commit is contained in:
Lukas Matena 2024-12-13 10:16:24 +01:00
parent 77bb4945f2
commit 817df53480
4 changed files with 5 additions and 1 deletions

View File

@ -12,6 +12,7 @@ namespace Slic3r {
MultipleBeds s_multiple_beds;
bool s_reload_preview_after_switching_beds = false;
bool s_beds_just_switched = false;
bool s_beds_switched_since_last_gcode_load = false;
bool is_sliceable(const PrintStatus status) {
if (status == PrintStatus::empty) {

View File

@ -17,6 +17,7 @@ class Print;
extern bool s_reload_preview_after_switching_beds;
extern bool s_beds_just_switched;
extern bool s_beds_switched_since_last_gcode_load;
namespace BedsGrid {
using GridCoords = Vec2crd;

View File

@ -870,7 +870,7 @@ void GCodeViewer::load_as_gcode(const GCodeProcessorResult& gcode_result, const
m_viewer.toggle_top_layer_only_view_range();
// avoid processing if called with the same gcode_result
if (m_last_result_id == gcode_result.id && wxGetApp().is_editor() && ! s_reload_preview_after_switching_beds) {
if (m_last_result_id == gcode_result.id && ! s_beds_switched_since_last_gcode_load && wxGetApp().is_editor() && ! s_reload_preview_after_switching_beds) {
// collect tool colors
libvgcode::Palette tools_colors;
tools_colors.reserve(str_tool_colors.size());
@ -890,6 +890,7 @@ void GCodeViewer::load_as_gcode(const GCodeProcessorResult& gcode_result, const
}
m_last_result_id = gcode_result.id;
s_beds_switched_since_last_gcode_load = false;
// release gpu memory, if used
reset();

View File

@ -135,6 +135,7 @@ void GLCanvas3D::select_bed(int i, bool triggered_by_user)
wxYield();
s_multiple_beds.set_active_bed(i);
s_beds_just_switched = true;
s_beds_switched_since_last_gcode_load = true;
if (wxGetApp().plater()->is_preview_shown()) {
s_reload_preview_after_switching_beds = true;
wxPostEvent(wxGetApp().plater(), SimpleEvent(EVT_GLVIEWTOOLBAR_PREVIEW));