+ Selection handling of Python view providers

This commit is contained in:
wmayer 2013-10-26 19:52:22 +02:00
parent 3a0037ff8d
commit 6d8f51f92a

View File

@ -337,22 +337,15 @@ std::string ViewProviderPythonFeatureImp::getElement(const SoDetail *det) const
Py::Object vp = static_cast<App::PropertyPythonObject*>(proxy)->getValue();
if (vp.hasAttr(std::string("getElement"))) {
PyObject* pivy = 0;
pivy = Base::Interpreter().createSWIGPointerObj("pivy.coin", "SoDetail *", (void*)det, 1);
if (vp.hasAttr("__object__")) {
Py::Callable method(vp.getAttr(std::string("getElement")));
Py::Tuple args(1);
args.setItem(0, Py::Object(pivy, true));
Py::String name(method.apply(args));
return (std::string)name;
}
else {
Py::Callable method(vp.getAttr(std::string("getElement")));
Py::Tuple args(2);
args.setItem(0, Py::Object(object->getPyObject(), true));
args.setItem(1, Py::Object(pivy, true));
Py::String name(method.apply(args));
return (std::string)name;
}
// Note: As there is no ref'counting mechanism for the SoDetail class we must
// pass '0' as the last parameter so that the Python object does not 'own'
// the detail object.
pivy = Base::Interpreter().createSWIGPointerObj("pivy.coin", "SoDetail *", (void*)det, 0);
Py::Callable method(vp.getAttr(std::string("getElement")));
Py::Tuple args(1);
args.setItem(0, Py::Object(pivy, true));
Py::String name(method.apply(args));
return (std::string)name;
}
}
}
@ -376,25 +369,13 @@ SoDetail* ViewProviderPythonFeatureImp::getDetail(const char* name) const
if (proxy && proxy->getTypeId() == App::PropertyPythonObject::getClassTypeId()) {
Py::Object vp = static_cast<App::PropertyPythonObject*>(proxy)->getValue();
if (vp.hasAttr(std::string("getDetail"))) {
if (vp.hasAttr("__object__")) {
Py::Callable method(vp.getAttr(std::string("getDetail")));
Py::Tuple args(1);
args.setItem(0, Py::String(name));
Py::Object det(method.apply(args));
void* ptr = 0;
Base::Interpreter().convertSWIGPointerObj("pivy.coin", "SoNode *", det.ptr(), &ptr, 0);
return reinterpret_cast<SoDetail*>(ptr);
}
else {
Py::Callable method(vp.getAttr(std::string("getDetail")));
Py::Tuple args(2);
args.setItem(0, Py::Object(object->getPyObject(), true));
args.setItem(1, Py::String(name));
Py::Object det(method.apply(args));
void* ptr = 0;
Base::Interpreter().convertSWIGPointerObj("pivy.coin", "SoNode *", det.ptr(), &ptr, 0);
return reinterpret_cast<SoDetail*>(ptr);
}
Py::Callable method(vp.getAttr(std::string("getDetail")));
Py::Tuple args(1);
args.setItem(0, Py::String(name));
Py::Object det(method.apply(args));
void* ptr = 0;
Base::Interpreter().convertSWIGPointerObj("pivy.coin", "SoDetail *", det.ptr(), &ptr, 0);
return reinterpret_cast<SoDetail*>(ptr);
}
}
}