| 282 | } |
| 283 | |
| 284 | Py::Object addQGObjToView(const Py::Tuple& args) |
| 285 | { |
| 286 | PyObject *viewPy = nullptr; |
| 287 | PyObject *qgiPy = nullptr; |
| 288 | if (!PyArg_ParseTuple(args.ptr(), "O!O", &(TechDraw::DrawViewPy::Type), &viewPy, &qgiPy)) { |
| 289 | throw Py::TypeError("expected (view, item)"); |
| 290 | } |
| 291 | |
| 292 | try { |
| 293 | App::DocumentObject* obj = nullptr; |
| 294 | Gui::ViewProvider* vp = nullptr; |
| 295 | QGIView* qgiv = nullptr; |
| 296 | obj = static_cast<App::DocumentObjectPy*>(viewPy)->getDocumentObjectPtr(); |
| 297 | vp = Gui::Application::Instance->getViewProvider(obj); |
| 298 | if (vp) { |
| 299 | TechDrawGui::ViewProviderDrawingView* vpdv = |
| 300 | dynamic_cast<TechDrawGui::ViewProviderDrawingView*>(vp); |
| 301 | if (vpdv) { |
| 302 | qgiv = vpdv->getQView(); |
| 303 | if (qgiv) { |
| 304 | Gui::PythonWrapper wrap; |
| 305 | if (!wrap.loadGuiModule()) { |
| 306 | throw Py::RuntimeError("Failed to load Python wrapper for Qt::Gui"); |
| 307 | } |
| 308 | QGraphicsObject* item = wrap.toQGraphicsObject(args[1]); |
| 309 | if (item) { |
| 310 | qgiv->addArbitraryItem(item); |
| 311 | } |
| 312 | } |
| 313 | } |
| 314 | } |
| 315 | } |
| 316 | catch (Base::Exception &e) { |
| 317 | e.setPyException(); |
| 318 | throw Py::Exception(); |
| 319 | } |
| 320 | |
| 321 | return Py::None(); |
| 322 | } |
| 323 | |
| 324 | |
| 325 | //adds a free graphics item to a Page's scene |
nothing calls this directly
no test coverage detected