MCPcopy Create free account
hub / github.com/FreeCAD/FreeCAD / addQGObjToView

Method addQGObjToView

src/Mod/TechDraw/Gui/AppTechDrawGuiPy.cpp:284–322  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 8

getQViewMethod · 0.80
loadGuiModuleMethod · 0.80
toQGraphicsObjectMethod · 0.80
addArbitraryItemMethod · 0.80
ExceptionClass · 0.50
ptrMethod · 0.45
getViewProviderMethod · 0.45
setPyExceptionMethod · 0.45

Tested by

no test coverage detected