+ expose onDocumentRestored to Python feature classes
This commit is contained in:
parent
53024a6140
commit
061c67cbf8
|
@ -161,6 +161,12 @@ protected:
|
||||||
virtual void onChanged(const Property* prop) {
|
virtual void onChanged(const Property* prop) {
|
||||||
FeatureT::onChanged(prop);
|
FeatureT::onChanged(prop);
|
||||||
}
|
}
|
||||||
|
virtual void onDocumentRestored() {
|
||||||
|
FeatureT::onDocumentRestored();
|
||||||
|
}
|
||||||
|
virtual void onSettingDocument() {
|
||||||
|
FeatureT::onSettingDocument();
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DynamicProperty* props;
|
DynamicProperty* props;
|
||||||
|
|
|
@ -154,6 +154,35 @@ void FeaturePythonImp::onChanged(const Property* prop)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FeaturePythonImp::onDocumentRestored()
|
||||||
|
{
|
||||||
|
// Run the execute method of the proxy object.
|
||||||
|
Base::PyGILStateLocker lock;
|
||||||
|
try {
|
||||||
|
Property* proxy = object->getPropertyByName("Proxy");
|
||||||
|
if (proxy && proxy->getTypeId() == PropertyPythonObject::getClassTypeId()) {
|
||||||
|
Py::Object feature = static_cast<PropertyPythonObject*>(proxy)->getValue();
|
||||||
|
if (feature.hasAttr(std::string("onDocumentRestored"))) {
|
||||||
|
if (feature.hasAttr("__object__")) {
|
||||||
|
Py::Callable method(feature.getAttr(std::string("onDocumentRestored")));
|
||||||
|
Py::Tuple args;
|
||||||
|
method.apply(args);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Py::Callable method(feature.getAttr(std::string("onDocumentRestored")));
|
||||||
|
Py::Tuple args(1);
|
||||||
|
args.setItem(0, Py::Object(object->getPyObject(), true));
|
||||||
|
method.apply(args);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Py::Exception&) {
|
||||||
|
Base::PyException e; // extract the Python error text
|
||||||
|
e.ReportException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
PyObject *FeaturePythonImp::getPyObject(void)
|
PyObject *FeaturePythonImp::getPyObject(void)
|
||||||
{
|
{
|
||||||
// ref counter is set to 1
|
// ref counter is set to 1
|
||||||
|
|
|
@ -47,6 +47,7 @@ public:
|
||||||
bool execute();
|
bool execute();
|
||||||
void onBeforeChange(const Property* prop);
|
void onBeforeChange(const Property* prop);
|
||||||
void onChanged(const Property* prop);
|
void onChanged(const Property* prop);
|
||||||
|
void onDocumentRestored();
|
||||||
PyObject *getPyObject(void);
|
PyObject *getPyObject(void);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -200,6 +201,10 @@ protected:
|
||||||
imp->onChanged(prop);
|
imp->onChanged(prop);
|
||||||
FeatureT::onChanged(prop);
|
FeatureT::onChanged(prop);
|
||||||
}
|
}
|
||||||
|
virtual void onDocumentRestored() {
|
||||||
|
imp->onDocumentRestored();
|
||||||
|
FeatureT::onDocumentRestored();
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
FeaturePythonImp* imp;
|
FeaturePythonImp* imp;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user