diff --git a/src/App/Part.cpp b/src/App/Part.cpp index c56bee1c84..3468ee3652 100644 --- a/src/App/Part.cpp +++ b/src/App/Part.cpp @@ -46,7 +46,7 @@ PROPERTY_SOURCE_WITH_EXTENSIONS(App::Part, App::GeoFeature) Part::Part(void) { ADD_PROPERTY(Type,("")); - ADD_PROPERTY_TYPE(Material, (), 0, App::Prop_None, "Map with material properties"); + ADD_PROPERTY_TYPE(Material, (0), 0, App::Prop_None, "The Material for this Part"); ADD_PROPERTY_TYPE(Meta, (), 0, App::Prop_None, "Map with additional meta information"); // create the uuid for the document @@ -109,6 +109,21 @@ PyObject *Part::getPyObject() return Py::new_reference_to(PythonObject); } +void Part::handleChangedPropertyType(Base::XMLReader &reader, const char *TypeName, App::Property *prop) +{ + // Migrate Material from App::PropertyMap to App::PropertyLink + if (!strcmp(TypeName, "App::PropertyMap")) { + App::PropertyMap oldvalue; + oldvalue.Restore(reader); + if (oldvalue.getSize()) { + auto oldprop = static_cast(addDynamicProperty("App::PropertyMap", "Material_old", "Base")); + oldprop->setValues(oldvalue.getValues()); + } + } else { + App::GeoFeature::handleChangedPropertyType(reader, TypeName, prop); + } +} + // Python feature --------------------------------------------------------- // Not quite sure yet making Part derivable in Python is good Idea! diff --git a/src/App/Part.h b/src/App/Part.h index 8c7667fbd0..a38ab5ec8f 100644 --- a/src/App/Part.h +++ b/src/App/Part.h @@ -53,7 +53,7 @@ public: /// unique identifier of the Item App::PropertyUUID Uid; /// material descriptions - App::PropertyMap Material; + App::PropertyLink Material; /// Meta descriptions App::PropertyMap Meta; @@ -84,6 +84,9 @@ public: return "Gui::ViewProviderPart"; } + + virtual void handleChangedPropertyType(Base::XMLReader &reader, const char *TypeName, App::Property *prop) override; + /** * Returns the part which contains this object. * In case this object does not belong to any Part, 0 is returned.