Toponaming/Part: Transfer in python ElementMapVersion
This commit is contained in:
@@ -1304,6 +1304,24 @@ bool DocumentObject::adjustRelativeLinks(
|
||||
return touched;
|
||||
}
|
||||
|
||||
std::string DocumentObject::getElementMapVersion(const App::Property* _prop, bool restored) const
|
||||
{
|
||||
auto prop = Base::freecad_dynamic_cast<const PropertyComplexGeoData>(_prop);
|
||||
if (!prop) {
|
||||
return std::string();
|
||||
}
|
||||
return prop->getElementMapVersion(restored);
|
||||
}
|
||||
|
||||
bool DocumentObject::checkElementMapVersion(const App::Property* _prop, const char* ver) const
|
||||
{
|
||||
auto prop = Base::freecad_dynamic_cast<const PropertyComplexGeoData>(_prop);
|
||||
if (!prop) {
|
||||
return false;
|
||||
}
|
||||
return prop->checkElementMapVersion(ver);
|
||||
}
|
||||
|
||||
const std::string &DocumentObject::hiddenMarker() {
|
||||
static std::string marker("!hide");
|
||||
return marker;
|
||||
|
||||
@@ -300,6 +300,20 @@ public:
|
||||
bool testIfLinkDAGCompatible(App::PropertyLinkSubList &linksTo) const;
|
||||
bool testIfLinkDAGCompatible(App::PropertyLinkSub &linkTo) const;
|
||||
|
||||
/** Return the element map version of the geometry data stored in the given property
|
||||
*
|
||||
* @param prop: the geometry property to query for element map version
|
||||
* @param restored: whether to query for the restored element map version.
|
||||
* In case of version upgrade, the restored version may
|
||||
* be different from the current version.
|
||||
*
|
||||
* @return Return the element map version string.
|
||||
*/
|
||||
virtual std::string getElementMapVersion(const App::Property *prop, bool restored=false) const;
|
||||
|
||||
/// Return true to signal re-generation of geometry element names
|
||||
virtual bool checkElementMapVersion(const App::Property *prop, const char *ver) const;
|
||||
|
||||
public:
|
||||
/** mustExecute
|
||||
* We call this method to check if the object was modified to
|
||||
|
||||
@@ -225,6 +225,13 @@ Return tuple(obj,newElementName,oldElementName)
|
||||
<UserDocu>adjustRelativeLinks(parent,recursive=True) -- auto correct potential cyclic dependencies</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="getElementMapVersion" Const="true">
|
||||
<Documentation>
|
||||
<UserDocu>
|
||||
getElementMapVersion(property_name): return element map version of a given geometry property
|
||||
</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Attribute Name="OutList" ReadOnly="true">
|
||||
<Documentation>
|
||||
<UserDocu>A list of all objects this object links to.</UserDocu>
|
||||
|
||||
@@ -745,6 +745,22 @@ PyObject* DocumentObjectPy::getPathsByOutList(PyObject *args)
|
||||
}
|
||||
}
|
||||
|
||||
PyObject* DocumentObjectPy::getElementMapVersion(PyObject* args)
|
||||
{
|
||||
const char* name;
|
||||
PyObject* restored = Py_False;
|
||||
if (!PyArg_ParseTuple(args, "s|O", &name, &restored)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Property* prop = getDocumentObjectPtr()->getPropertyByName(name);
|
||||
if (!prop) {
|
||||
throw Py::ValueError("property not found");
|
||||
}
|
||||
return Py::new_reference_to(
|
||||
Py::String(getDocumentObjectPtr()->getElementMapVersion(prop, Base::asBoolean(restored))));
|
||||
}
|
||||
|
||||
PyObject *DocumentObjectPy::getCustomAttributes(const char* ) const
|
||||
{
|
||||
return nullptr;
|
||||
|
||||
@@ -58,6 +58,12 @@ If an object has no such property then None is returned.
|
||||
Unlike to getPropertyNameOfGeometry this function returns the geometry, not its name.</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Attribute Name="ElementMapVersion" ReadOnly="true">
|
||||
<Documentation>
|
||||
<UserDocu>Element map version</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="ElementMapVersion" Type="String" />
|
||||
</Attribute>
|
||||
<CustomAttributes />
|
||||
</PythonExport>
|
||||
</GenerateModel>
|
||||
|
||||
@@ -93,3 +93,8 @@ int GeoFeaturePy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
Py::String GeoFeaturePy::getElementMapVersion() const {
|
||||
return Py::String(getGeoFeaturePtr()->getElementMapVersion(
|
||||
getGeoFeaturePtr()->getPropertyOfGeometry()));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user