From cb786fcbcd76cc1df98463afdaec546bc387012b Mon Sep 17 00:00:00 2001 From: wmayer Date: Thu, 5 Oct 2023 16:27:35 +0200 Subject: [PATCH] Gui: expose functions to Python to add and remove a manipulator --- src/Gui/Application.h | 3 +++ src/Gui/ApplicationPy.cpp | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/src/Gui/Application.h b/src/Gui/Application.h index f1c6916438..e9462b15c1 100644 --- a/src/Gui/Application.h +++ b/src/Gui/Application.h @@ -348,6 +348,9 @@ public: static PyObject* sAddDocObserver (PyObject *self,PyObject *args); static PyObject* sRemoveDocObserver (PyObject *self,PyObject *args); + static PyObject* sAddWbManipulator (PyObject *self,PyObject *args); + static PyObject* sRemoveWbManipulator (PyObject *self,PyObject *args); + static PyObject* sListUserEditModes (PyObject *self,PyObject *args); static PyObject* sGetUserEditMode (PyObject *self,PyObject *args); static PyObject* sSetUserEditMode (PyObject *self,PyObject *args); diff --git a/src/Gui/ApplicationPy.cpp b/src/Gui/ApplicationPy.cpp index d41fe6f25f..1b9c4cc54b 100644 --- a/src/Gui/ApplicationPy.cpp +++ b/src/Gui/ApplicationPy.cpp @@ -66,6 +66,7 @@ #include "WidgetFactory.h" #include "Workbench.h" #include "WorkbenchManager.h" +#include "WorkbenchManipulatorPython.h" #include "Inventor/MarkerBitmaps.h" #include "Language/Translator.h" @@ -357,6 +358,18 @@ PyMethodDef Application::Methods[] = { "Remove an added document observer.\n" "\n" "obj : object"}, + {"addWorkbenchManipulator", (PyCFunction) Application::sAddWbManipulator, METH_VARARGS, + "addWorkbenchManipulator(obj) -> None\n" + "\n" + "Add a workbench manipulator to modify a workbench when it is activated.\n" + "\n" + "obj : object"}, + {"removeWorkbenchManipulator", (PyCFunction) Application::sRemoveWbManipulator, METH_VARARGS, + "removeWorkbenchManipulator(obj) -> None\n" + "\n" + "Remove an added workbench manipulator.\n" + "\n" + "obj : object"}, {"listUserEditModes", (PyCFunction) Application::sListUserEditModes, METH_VARARGS, "listUserEditModes() -> list\n" "\n" @@ -1533,6 +1546,32 @@ PyObject* Application::sRemoveDocObserver(PyObject * /*self*/, PyObject *args) PY_CATCH; } +PyObject* Application::sAddWbManipulator(PyObject * /*self*/, PyObject *args) +{ + PyObject* o; + if (!PyArg_ParseTuple(args, "O",&o)) + return nullptr; + + PY_TRY { + WorkbenchManipulatorPython::installManipulator(Py::Object(o)); + Py_Return; + } + PY_CATCH; +} + +PyObject* Application::sRemoveWbManipulator(PyObject * /*self*/, PyObject *args) +{ + PyObject* o; + if (!PyArg_ParseTuple(args, "O",&o)) + return nullptr; + + PY_TRY { + WorkbenchManipulatorPython::removeManipulator(Py::Object(o)); + Py_Return; + } + PY_CATCH; +} + PyObject* Application::sCoinRemoveAllChildren(PyObject * /*self*/, PyObject *args) { PyObject *pynode;