diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index 85d7c547b7..7761b46b3b 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -1123,6 +1123,7 @@ GLCanvas3D::GLCanvas3D(wxGLCanvas* canvas, Bed3D& bed, Camera& camera, GLToolbar , m_retina_helper(nullptr) #endif , m_in_render(false) + , m_render_enabled(true) , m_bed(bed) , m_camera(camera) , m_view_toolbar(view_toolbar) @@ -1509,7 +1510,7 @@ void GLCanvas3D::update_volumes_colors_by_extruder() void GLCanvas3D::render() { - if (m_in_render) + if (!m_render_enabled || m_in_render) { // if called recursively, return m_dirty = true; diff --git a/src/slic3r/GUI/GLCanvas3D.hpp b/src/slic3r/GUI/GLCanvas3D.hpp index bc4b44f7c3..202d3ef776 100644 --- a/src/slic3r/GUI/GLCanvas3D.hpp +++ b/src/slic3r/GUI/GLCanvas3D.hpp @@ -403,6 +403,7 @@ private: std::unique_ptr m_retina_helper; #endif bool m_in_render; + bool m_render_enabled; LegendTexture m_legend_texture; WarningTexture m_warning_texture; wxTimer m_timer; @@ -532,6 +533,9 @@ public: void enable_dynamic_background(bool enable); void allow_multisample(bool allow); + void enable_render(bool enable) { m_render_enabled = enable; } + bool is_render_enabled() const { return m_render_enabled; } + void zoom_to_bed(); void zoom_to_volumes(); void zoom_to_selection(); diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 141b33d01e..838e79e3d3 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -3080,18 +3080,28 @@ void Plater::priv::reload_from_disk() { Plater::TakeSnapshot snapshot(q, _(L("Reload from Disk"))); - const auto &selection = get_selection(); + auto& selection = get_selection(); const auto obj_orig_idx = selection.get_object_idx(); if (selection.is_wipe_tower() || obj_orig_idx == -1) { return; } + int instance_idx = selection.get_instance_idx(); auto *object_orig = model.objects[obj_orig_idx]; std::vector input_paths(1, object_orig->input_file); + // disable render to avoid to show intermediate states + view3D->get_canvas3d()->enable_render(false); + const auto new_idxs = load_files(input_paths, true, false); + if (new_idxs.empty()) + { + // error while loading + view3D->get_canvas3d()->enable_render(true); + return; + } for (const auto idx : new_idxs) { ModelObject *object = model.objects[idx]; - + object->config.apply(object_orig->config); object->clear_instances(); for (const ModelInstance *instance : object_orig->instances) { object->add_instance(*instance); @@ -3103,10 +3113,26 @@ void Plater::priv::reload_from_disk() } } + if (object_orig->instances.size() > 1) + sidebar->obj_list()->increase_object_instances(idx, object_orig->instances.size()); + // XXX: Restore more: layer_height_ranges, layer_height_profile (?) } remove(obj_orig_idx); + + // re-enable render + view3D->get_canvas3d()->enable_render(true); + + // the previous call to remove() clears the selection + // select newly added objects + selection.clear(); + for (const auto idx : new_idxs) + { + selection.add_instance((unsigned int)idx - 1, instance_idx, false); + } + + wxGetApp().obj_list()->update_and_show_object_settings_item(); } void Plater::priv::fix_through_netfabb(const int obj_idx, const int vol_idx/* = -1*/)