From abcaef8601937f8934a4235e78800b190696f0f2 Mon Sep 17 00:00:00 2001 From: wmayer Date: Thu, 1 Oct 2020 13:54:12 +0200 Subject: [PATCH] Gui: [skip ci] add method to access the Inventor viewer as QGraphicsView --- src/Gui/View3DPy.cpp | 13 +++++++++++++ src/Gui/View3DPy.h | 1 + 2 files changed, 14 insertions(+) diff --git a/src/Gui/View3DPy.cpp b/src/Gui/View3DPy.cpp index 37365af2eb..1c7f1d987d 100644 --- a/src/Gui/View3DPy.cpp +++ b/src/Gui/View3DPy.cpp @@ -51,6 +51,7 @@ #include "View3DInventorViewer.h" #include "View3DViewerPy.h" #include "ActiveObjectList.h" +#include "WidgetFactory.h" #include @@ -203,6 +204,8 @@ void View3DInventorPy::init_type() "pla: clipping plane placement"); add_varargs_method("hasClippingPlane",&View3DInventorPy::hasClippingPlane, "hasClippingPlane(): check whether this clipping plane is active"); + add_varargs_method("graphicsView",&View3DInventorPy::graphicsView, + "graphicsView(): Access this view as QGraphicsView"); } View3DInventorPy::View3DInventorPy(View3DInventor *vi) @@ -2597,3 +2600,13 @@ Py::Object View3DInventorPy::hasClippingPlane(const Py::Tuple& args) throw Py::Exception(); return Py::Boolean(_view->getViewer()->hasClippingPlane()); } + +Py::Object View3DInventorPy::graphicsView(const Py::Tuple& args) +{ + if (!PyArg_ParseTuple(args.ptr(), "")) + throw Py::Exception(); + + PythonWrapper wrap; + wrap.loadWidgetsModule(); + return wrap.fromQWidget(_view->getViewer(), "QGraphicsView"); +} diff --git a/src/Gui/View3DPy.h b/src/Gui/View3DPy.h index f93abf71c3..71e2557bad 100644 --- a/src/Gui/View3DPy.h +++ b/src/Gui/View3DPy.h @@ -132,6 +132,7 @@ public: Py::Object setName(const Py::Tuple&); Py::Object toggleClippingPlane(const Py::Tuple& args, const Py::Dict &); Py::Object hasClippingPlane(const Py::Tuple& args); + Py::Object graphicsView(const Py::Tuple& args); View3DInventor* getView3DIventorPtr() {return _view;}