Gui: implemented isShow() for python viewproviders

This commit is contained in:
Yorik van Havre
2017-04-28 15:03:47 -03:00
parent 779c8a4e43
commit 77f652ea2f
2 changed files with 36 additions and 0 deletions

View File

@@ -1005,6 +1005,34 @@ ViewProviderPythonFeatureImp::dropObject(App::DocumentObject* obj)
return Rejected;
}
bool ViewProviderPythonFeatureImp::isShow() const
{
// Run the onChanged method of the proxy object.
Base::PyGILStateLocker lock;
try {
App::Property* proxy = object->getPropertyByName("Proxy");
if (proxy && proxy->getTypeId() == App::PropertyPythonObject::getClassTypeId()) {
Py::Object vp = static_cast<App::PropertyPythonObject*>(proxy)->getValue();
if (vp.hasAttr(std::string("isShow"))) {
Py::Callable method(vp.getAttr(std::string("isShow")));
Py::Tuple args;
Py::Boolean ok(method.apply(args));
return static_cast<bool>(ok) ? true : false;
}
else {
return false;
}
}
}
catch (Py::Exception&) {
Base::PyException e; // extract the Python error text
e.ReportException();
}
return false;
}
// ---------------------------------------------------------
namespace Gui {