Skip to content

Commit

Permalink
Fix missing update of preview:
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
lukasmatena committed Dec 13, 2024
1 parent 77bb494 commit 817df53
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/libslic3r/MultipleBeds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions src/libslic3r/MultipleBeds.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion src/slic3r/GUI/GCodeViewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand All @@ -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();
Expand Down
1 change: 1 addition & 0 deletions src/slic3r/GUI/GLCanvas3D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down

0 comments on commit 817df53

Please sign in to comment.