From becf03c92ddff5ff8fa1efdc9ede5884f78b2461 Mon Sep 17 00:00:00 2001 From: wmayer Date: Mon, 1 Apr 2024 14:56:19 +0200 Subject: [PATCH] Base: expose a method to copy a parameter group to Python --- src/Base/ParameterPy.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/Base/ParameterPy.cpp b/src/Base/ParameterPy.cpp index 6b7a9d01cd..7149d9ace4 100644 --- a/src/Base/ParameterPy.cpp +++ b/src/Base/ParameterPy.cpp @@ -118,6 +118,7 @@ public: Py::Object remGroup(const Py::Tuple&); Py::Object hasGroup(const Py::Tuple&); Py::Object renameGroup(const Py::Tuple&); + Py::Object copyTo(const Py::Tuple&); Py::Object getManager(const Py::Tuple&); Py::Object getParent(const Py::Tuple&); @@ -193,6 +194,7 @@ void ParameterGrpPy::init_type() add_varargs_method("RemGroup", &ParameterGrpPy::remGroup, "RemGroup(str)"); add_varargs_method("HasGroup", &ParameterGrpPy::hasGroup, "HasGroup(str)"); add_varargs_method("RenameGroup", &ParameterGrpPy::renameGroup, "RenameGroup(str, str)"); + add_varargs_method("CopyTo", &ParameterGrpPy::copyTo, "copyTo(ParameterGrp)"); add_varargs_method("Manager", &ParameterGrpPy::getManager, "Manager()"); add_varargs_method("Parent", &ParameterGrpPy::getParent, "Parent()"); @@ -702,6 +704,18 @@ Py::Object ParameterGrpPy::renameGroup(const Py::Tuple& args) return Py::Boolean(_cParamGrp->RenameGrp(oldname, newname)); // NOLINT } +Py::Object ParameterGrpPy::copyTo(const Py::Tuple& args) +{ + PyObject* pygrp {}; + if (!PyArg_ParseTuple(args.ptr(), "O!", ParameterGrpPy::type_object(), &pygrp)) { + throw Py::Exception(); + } + + auto grp = static_cast(pygrp); // NOLINT + _cParamGrp->copyTo(grp->_cParamGrp); + return Py::None(); +} + Py::Object ParameterGrpPy::attach(const Py::Tuple& args) { PyObject* obj = nullptr;