From bf7b5542356966e69259a7ce8a91a1c4a8d091ea Mon Sep 17 00:00:00 2001 From: enricoturri1966 Date: Fri, 16 Jul 2021 12:30:47 +0200 Subject: [PATCH] Disable reload from disk for built-in objects --- src/libslic3r/Model.cpp | 4 ++-- src/libslic3r/Model.hpp | 7 ++++--- src/slic3r/GUI/GUI_ObjectList.cpp | 1 + src/slic3r/GUI/Plater.cpp | 15 ++++++--------- 4 files changed, 13 insertions(+), 14 deletions(-) diff --git a/src/libslic3r/Model.cpp b/src/libslic3r/Model.cpp index 3c8621bdc..306f80394 100644 --- a/src/libslic3r/Model.cpp +++ b/src/libslic3r/Model.cpp @@ -1070,8 +1070,7 @@ void ModelObject::convert_units(ModelObjectPtrs& new_objects, ConversionType con new_object->input_file.clear(); int vol_idx = 0; - for (ModelVolume* volume : volumes) - { + for (ModelVolume* volume : volumes) { if (!volume->mesh().empty()) { TriangleMesh mesh(volume->mesh()); mesh.require_shared_vertices(); @@ -1089,6 +1088,7 @@ void ModelObject::convert_units(ModelObjectPtrs& new_objects, ConversionType con vol->source.volume_idx = vol_idx; vol->source.is_converted_from_inches = volume->source.is_converted_from_inches; vol->source.is_converted_from_meters = volume->source.is_converted_from_meters; + vol->source.is_from_builtin_objects = volume->source.is_from_builtin_objects; vol->supported_facets.assign(volume->supported_facets); vol->seam_facets.assign(volume->seam_facets); diff --git a/src/libslic3r/Model.hpp b/src/libslic3r/Model.hpp index 6d0a542c2..5e7e4c03d 100644 --- a/src/libslic3r/Model.hpp +++ b/src/libslic3r/Model.hpp @@ -596,13 +596,14 @@ public: int volume_idx{ -1 }; Vec3d mesh_offset{ Vec3d::Zero() }; Geometry::Transformation transform; - bool is_converted_from_inches = false; - bool is_converted_from_meters = false; + bool is_converted_from_inches{ false }; + bool is_converted_from_meters{ false }; + bool is_from_builtin_objects{ false }; template void serialize(Archive& ar) { //FIXME Vojtech: Serialize / deserialize only if the Source is set. // likely testing input_file or object_idx would be sufficient. - ar(input_file, object_idx, volume_idx, mesh_offset, transform, is_converted_from_inches, is_converted_from_meters); + ar(input_file, object_idx, volume_idx, mesh_offset, transform, is_converted_from_inches, is_converted_from_meters, is_from_builtin_objects); } }; Source source; diff --git a/src/slic3r/GUI/GUI_ObjectList.cpp b/src/slic3r/GUI/GUI_ObjectList.cpp index 37232e55c..9e2149a0e 100644 --- a/src/slic3r/GUI/GUI_ObjectList.cpp +++ b/src/slic3r/GUI/GUI_ObjectList.cpp @@ -1637,6 +1637,7 @@ void ObjectList::load_generic_subobject(const std::string& type_name, const Mode new_volume->name = into_u8(name); // set a default extruder value, since user can't add it manually new_volume->config.set_key_value("extruder", new ConfigOptionInt(0)); + new_volume->source.is_from_builtin_objects = true; select_item([this, obj_idx, new_volume]() { wxDataViewItem sel_item; diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index eb727bebe..75c7cc7fe 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -3350,7 +3350,7 @@ void Plater::priv::reload_from_disk() else missing_input_paths.push_back(volume->source.input_file); } - else if (!object->input_file.empty() && volume->is_model_part() && !volume->name.empty()) + else if (!object->input_file.empty() && volume->is_model_part() && !volume->name.empty() && !volume->source.is_from_builtin_objects) missing_input_paths.push_back(volume->name); } @@ -4323,14 +4323,12 @@ bool Plater::priv::can_reload_from_disk() const // collects selected ModelVolumes const std::set& selected_volumes_idxs = selection.get_volume_idxs(); - for (unsigned int idx : selected_volumes_idxs) - { + for (unsigned int idx : selected_volumes_idxs) { const GLVolume* v = selection.get_volume(idx); int v_idx = v->volume_idx(); - if (v_idx >= 0) - { + if (v_idx >= 0) { int o_idx = v->object_idx(); - if ((0 <= o_idx) && (o_idx < (int)model.objects.size())) + if (0 <= o_idx && o_idx < (int)model.objects.size()) selected_volumes.push_back({ o_idx, v_idx }); } } @@ -4339,13 +4337,12 @@ bool Plater::priv::can_reload_from_disk() const // collects paths of files to load std::vector paths; - for (const SelectedVolume& v : selected_volumes) - { + for (const SelectedVolume& v : selected_volumes) { const ModelObject* object = model.objects[v.object_idx]; const ModelVolume* volume = object->volumes[v.volume_idx]; if (!volume->source.input_file.empty()) paths.push_back(volume->source.input_file); - else if (!object->input_file.empty() && !volume->name.empty()) + else if (!object->input_file.empty() && !volume->name.empty() && !volume->source.is_from_builtin_objects) paths.push_back(volume->name); } std::sort(paths.begin(), paths.end());