Set App::Part Material property type to App::PropertyLink

App::Part Material property type is currently App::PropertyMap, but to
be consistent with other domains using materials (like Arch, especially), it
should rather be App::PropertyLink, in order to link to a Material
card.
This commit is contained in:
howetuft
2021-02-21 17:53:37 +01:00
committed by Uwe
parent f9d69a1464
commit 8e87eca83c
2 changed files with 20 additions and 2 deletions

View File

@@ -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<App::PropertyMap*>(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!