diff --git a/src/libslic3r/Technologies.hpp b/src/libslic3r/Technologies.hpp index 3d63f781c..05bb07616 100644 --- a/src/libslic3r/Technologies.hpp +++ b/src/libslic3r/Technologies.hpp @@ -60,3 +60,5 @@ #define ENABLE_MOVE_MIN_THRESHOLD (1 && ENABLE_1_42_0_ALPHA4) // Modified initial default placement of generic subparts #define ENABLE_GENERIC_SUBPARTS_PLACEMENT (1 && ENABLE_1_42_0_ALPHA4) +// Reworked management of bed shape changes +#define ENABLE_REWORKED_BED_SHAPE_CHANGE (1 && ENABLE_1_42_0_ALPHA4) diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index 4e2eae7a6..16f519455 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -3718,7 +3718,11 @@ GLCanvas3D::GLCanvas3D(wxGLCanvas* canvas) , m_dirty(true) , m_initialized(false) , m_use_VBOs(false) +#if ENABLE_REWORKED_BED_SHAPE_CHANGE + , m_requires_zoom_to_bed(false) +#else , m_force_zoom_to_bed_enabled(false) +#endif // ENABLE_REWORKED_BED_SHAPE_CHANGE , m_apply_zoom_to_volumes_filter(false) , m_hover_volume_id(-1) , m_toolbar_action_running(false) @@ -3937,7 +3941,11 @@ void GLCanvas3D::set_bed_shape(const Pointfs& shape) set_bed_axes_length(0.1 * m_bed.get_bounding_box().max_size()); if (new_shape) +#if ENABLE_REWORKED_BED_SHAPE_CHANGE + m_requires_zoom_to_bed = true; +#else zoom_to_bed(); +#endif // ENABLE_REWORKED_BED_SHAPE_CHANGE m_dirty = true; } @@ -4032,10 +4040,12 @@ void GLCanvas3D::enable_toolbar(bool enable) m_toolbar.set_enabled(enable); } +#if !ENABLE_REWORKED_BED_SHAPE_CHANGE void GLCanvas3D::enable_force_zoom_to_bed(bool enable) { m_force_zoom_to_bed_enabled = enable; } +#endif // !ENABLE_REWORKED_BED_SHAPE_CHANGE void GLCanvas3D::enable_dynamic_background(bool enable) { @@ -4116,6 +4126,9 @@ void GLCanvas3D::set_viewport_from_scene(const GLCanvas3D& other) m_camera.set_scene_box(other.m_camera.get_scene_box(), *this); m_camera.set_target(other.m_camera.get_target(), *this); m_camera.zoom = other.m_camera.zoom; +#if ENABLE_REWORKED_BED_SHAPE_CHANGE + m_requires_zoom_to_bed = false; +#endif // ENABLE_REWORKED_BED_SHAPE_CHANGE m_dirty = true; } @@ -4168,8 +4181,18 @@ void GLCanvas3D::render() #endif // ENABLE_USE_UNIQUE_GLCONTEXT return; +#if ENABLE_REWORKED_BED_SHAPE_CHANGE + if (m_requires_zoom_to_bed) + { + zoom_to_bed(); + const Size& cnv_size = get_canvas_size(); + _resize((unsigned int)cnv_size.get_width(), (unsigned int)cnv_size.get_height()); + m_requires_zoom_to_bed = false; + } +#else if (m_force_zoom_to_bed_enabled) _force_zoom_to_bed(); +#endif // ENABLE_REWORKED_BED_SHAPE_CHANGE _camera_tranform(); @@ -5738,11 +5761,13 @@ bool GLCanvas3D::_is_shown_on_screen() const return (m_canvas != nullptr) ? m_canvas->IsShownOnScreen() : false; } +#if !ENABLE_REWORKED_BED_SHAPE_CHANGE void GLCanvas3D::_force_zoom_to_bed() { zoom_to_bed(); m_force_zoom_to_bed_enabled = false; } +#endif // !ENABLE_REWORKED_BED_SHAPE_CHANGE bool GLCanvas3D::_init_toolbar() { @@ -5974,7 +5999,11 @@ void GLCanvas3D::_zoom_to_bounding_box(const BoundingBoxf3& bbox) viewport_changed(); +#if ENABLE_REWORKED_BED_SHAPE_CHANGE + m_dirty = true; +#else _refresh_if_shown_on_screen(); +#endif // ENABLE_REWORKED_BED_SHAPE_CHANGE } } @@ -6076,11 +6105,15 @@ void GLCanvas3D::_refresh_if_shown_on_screen() // Because of performance problems on macOS, where PaintEvents are not delivered // frequently enough, we call render() here directly when we can. +#if ENABLE_REWORKED_BED_SHAPE_CHANGE + render(); +#else // We can't do that when m_force_zoom_to_bed_enabled == true, because then render() // ends up calling back here via _force_zoom_to_bed(), causing a stack overflow. if (m_canvas != nullptr) { m_force_zoom_to_bed_enabled ? m_canvas->Refresh() : render(); } +#endif // ENABLE_REWORKED_BED_SHAPE_CHANGE } } diff --git a/src/slic3r/GUI/GLCanvas3D.hpp b/src/slic3r/GUI/GLCanvas3D.hpp index f1ccdf54b..625c73169 100644 --- a/src/slic3r/GUI/GLCanvas3D.hpp +++ b/src/slic3r/GUI/GLCanvas3D.hpp @@ -829,7 +829,11 @@ private: bool m_dirty; bool m_initialized; bool m_use_VBOs; +#if ENABLE_REWORKED_BED_SHAPE_CHANGE + bool m_requires_zoom_to_bed; +#else bool m_force_zoom_to_bed_enabled; +#endif // ENABLE_REWORKED_BED_SHAPE_CHANGE bool m_apply_zoom_to_volumes_filter; mutable int m_hover_volume_id; bool m_toolbar_action_running; @@ -920,7 +924,9 @@ public: void enable_moving(bool enable); void enable_gizmos(bool enable); void enable_toolbar(bool enable); +#if !ENABLE_REWORKED_BED_SHAPE_CHANGE void enable_force_zoom_to_bed(bool enable); +#endif // !ENABLE_REWORKED_BED_SHAPE_CHANGE void enable_dynamic_background(bool enable); void allow_multisample(bool allow); @@ -1001,7 +1007,9 @@ public: private: bool _is_shown_on_screen() const; +#if !ENABLE_REWORKED_BED_SHAPE_CHANGE void _force_zoom_to_bed(); +#endif // !ENABLE_REWORKED_BED_SHAPE_CHANGE bool _init_toolbar(); diff --git a/src/slic3r/GUI/GUI_Preview.cpp b/src/slic3r/GUI/GUI_Preview.cpp index f791145a2..ad432c273 100644 --- a/src/slic3r/GUI/GUI_Preview.cpp +++ b/src/slic3r/GUI/GUI_Preview.cpp @@ -69,7 +69,9 @@ bool View3D::init(wxWindow* parent, Model* model, DynamicPrintConfig* config, Ba m_canvas->set_config(config); m_canvas->enable_gizmos(true); m_canvas->enable_toolbar(true); +#if !ENABLE_REWORKED_BED_SHAPE_CHANGE m_canvas->enable_force_zoom_to_bed(true); +#endif // !ENABLE_REWORKED_BED_SHAPE_CHANGE #if !ENABLE_IMGUI m_gizmo_widget = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxDefaultSize); @@ -107,7 +109,9 @@ void View3D::set_bed_shape(const Pointfs& shape) if (m_canvas != nullptr) { m_canvas->set_bed_shape(shape); +#if !ENABLE_REWORKED_BED_SHAPE_CHANGE m_canvas->zoom_to_bed(); +#endif // !ENABLE_REWORKED_BED_SHAPE_CHANGE } } diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index d3dad31e9..ad4472bcf 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -1125,9 +1125,11 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame) this->background_process_timer.SetOwner(this->q, 0); this->q->Bind(wxEVT_TIMER, [this](wxTimerEvent &evt) { this->update_restart_background_process(false, false); }); +#if !ENABLE_REWORKED_BED_SHAPE_CHANGE auto *bed_shape = config->opt("bed_shape"); view3D->set_bed_shape(bed_shape->values); preview->set_bed_shape(bed_shape->values); +#endif // !ENABLE_REWORKED_BED_SHAPE_CHANGE update(); @@ -2965,7 +2967,7 @@ void Plater::on_config_change(const DynamicPrintConfig &config) p->config->set_key_value(opt_key, config.option(opt_key)->clone()); if (opt_key == "printer_technology") this->set_printer_technology(config.opt_enum(opt_key)); - else if (opt_key == "bed_shape") { + else if (opt_key == "bed_shape") { if (p->view3D) p->view3D->set_bed_shape(p->config->option(opt_key)->values); if (p->preview) p->preview->set_bed_shape(p->config->option(opt_key)->values); update_scheduled = true; @@ -2990,12 +2992,14 @@ void Plater::on_config_change(const DynamicPrintConfig &config) p->preview->set_number_extruders(p->config->option(opt_key)->values.size()); } else if(opt_key == "max_print_height") { update_scheduled = true; - } else if(opt_key == "printer_model") { + } + else if (opt_key == "printer_model") { // update to force bed selection(for texturing) if (p->view3D) p->view3D->set_bed_shape(p->config->option("bed_shape")->values); if (p->preview) p->preview->set_bed_shape(p->config->option("bed_shape")->values); update_scheduled = true; - } else if (opt_key == "host_type" && this->p->printer_technology == ptSLA) { + } + else if (opt_key == "host_type" && this->p->printer_technology == ptSLA) { p->config->option>(opt_key)->value = htSL1; } }