From 170fe23b46b74b051b54092efe498f5ba1230845 Mon Sep 17 00:00:00 2001 From: Vojtech Bubnik Date: Fri, 9 Oct 2020 12:25:57 +0200 Subject: [PATCH] Fixing Undo / Redo issues after copy / paste due to not updating ObjectIDs of support painting / seam painting / layer height profile. --- src/libslic3r/Model.cpp | 9 +++++++++ src/libslic3r/Model.hpp | 8 +++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/libslic3r/Model.cpp b/src/libslic3r/Model.cpp index a4541eeec..97327daa3 100644 --- a/src/libslic3r/Model.cpp +++ b/src/libslic3r/Model.cpp @@ -608,6 +608,7 @@ void ModelObject::assign_new_unique_ids_recursive() model_volume->assign_new_unique_ids_recursive(); for (ModelInstance *model_instance : this->instances) model_instance->assign_new_unique_ids_recursive(); + this->layer_height_profile.set_new_unique_id(); } // Clone this ModelObject including its volumes and instances, keep the IDs of the copies equal to the original. @@ -1727,6 +1728,14 @@ void ModelObject::scale_to_fit(const Vec3d &size) */ } +void ModelVolume::assign_new_unique_ids_recursive() +{ + ObjectBase::set_new_unique_id(); + config.set_new_unique_id(); + m_supported_facets.set_new_unique_id(); + m_seam_facets.set_new_unique_id(); +} + void ModelVolume::rotate(double angle, Axis axis) { switch (axis) diff --git a/src/libslic3r/Model.hpp b/src/libslic3r/Model.hpp index 003c4ed0f..3d9d14a16 100644 --- a/src/libslic3r/Model.hpp +++ b/src/libslic3r/Model.hpp @@ -191,6 +191,9 @@ public: private: std::vector m_data; + + // to access set_new_unique_id() when copy / pasting an object + friend class ModelObject; }; // A printable object, possibly having multiple print volumes (each with its own set of parameters and materials), @@ -446,6 +449,9 @@ private: } std::map> m_data; + + // To access set_new_unique_id() when copy / pasting a ModelVolume. + friend class ModelVolume; }; // An object STL, or a modifier volume, over which a different set of parameters shall be applied. @@ -579,7 +585,7 @@ protected: // Copies IDs of both the ModelVolume and its config. explicit ModelVolume(const ModelVolume &rhs) = default; void set_model_object(ModelObject *model_object) { object = model_object; } - void assign_new_unique_ids_recursive() override { ObjectBase::set_new_unique_id(); config.set_new_unique_id(); } + void assign_new_unique_ids_recursive() override; void transform_this_mesh(const Transform3d& t, bool fix_left_handed); void transform_this_mesh(const Matrix3d& m, bool fix_left_handed);