From 61ecfd3639e065374690c6e0de58e3e730d8bcdc Mon Sep 17 00:00:00 2001 From: wmayer Date: Tue, 2 Nov 2021 12:57:54 +0100 Subject: [PATCH] Gui: [skip ci] expose function to Python to enable/disable context-menu of 3d view --- src/Gui/View3DPy.cpp | 19 +++++++++++++++++++ src/Gui/View3DPy.h | 2 ++ 2 files changed, 21 insertions(+) diff --git a/src/Gui/View3DPy.cpp b/src/Gui/View3DPy.cpp index 2ca90e415f..0576eae5da 100644 --- a/src/Gui/View3DPy.cpp +++ b/src/Gui/View3DPy.cpp @@ -115,6 +115,8 @@ void View3DInventorPy::init_type() add_varargs_method("stopAnimating",&View3DInventorPy::stopAnimating,"stopAnimating()"); add_varargs_method("setAnimationEnabled",&View3DInventorPy::setAnimationEnabled,"setAnimationEnabled()"); add_varargs_method("isAnimationEnabled",&View3DInventorPy::isAnimationEnabled,"isAnimationEnabled()"); + add_varargs_method("setPopupMenuEnabled",&View3DInventorPy::setPopupMenuEnabled,"setPopupMenuEnabled()"); + add_varargs_method("isPopupMenuEnabled",&View3DInventorPy::isPopupMenuEnabled,"isPopupMenuEnabled()"); add_varargs_method("dump",&View3DInventorPy::dump,"dump(filename, [onlyVisible=False])"); add_varargs_method("dumpNode",&View3DInventorPy::dumpNode,"dumpNode(node)"); add_varargs_method("setStereoType",&View3DInventorPy::setStereoType,"setStereoType()"); @@ -953,6 +955,23 @@ Py::Object View3DInventorPy::isAnimationEnabled(const Py::Tuple& args) return Py::Boolean(ok ? true : false); } +Py::Object View3DInventorPy::setPopupMenuEnabled(const Py::Tuple& args) +{ + int ok; + if (!PyArg_ParseTuple(args.ptr(), "i", &ok)) + throw Py::Exception(); + _view->getViewer()->setPopupMenuEnabled(ok!=0); + return Py::None(); +} + +Py::Object View3DInventorPy::isPopupMenuEnabled(const Py::Tuple& args) +{ + if (!PyArg_ParseTuple(args.ptr(), "")) + throw Py::Exception(); + SbBool ok = _view->getViewer()->isPopupMenuEnabled(); + return Py::Boolean(ok ? true : false); +} + Py::Object View3DInventorPy::saveImage(const Py::Tuple& args) { char *cFileName,*cColor="Current",*cComment="$MIBA"; diff --git a/src/Gui/View3DPy.h b/src/Gui/View3DPy.h index 71e2557bad..d84c073c34 100644 --- a/src/Gui/View3DPy.h +++ b/src/Gui/View3DPy.h @@ -87,6 +87,8 @@ public: Py::Object stopAnimating(const Py::Tuple&); Py::Object setAnimationEnabled(const Py::Tuple&); Py::Object isAnimationEnabled(const Py::Tuple&); + Py::Object setPopupMenuEnabled(const Py::Tuple&); + Py::Object isPopupMenuEnabled(const Py::Tuple&); Py::Object dump(const Py::Tuple&); Py::Object dumpNode(const Py::Tuple&); Py::Object setStereoType(const Py::Tuple&);