diff --git a/Gui/NatronGui/guiapp_wrapper.cpp b/Gui/NatronGui/guiapp_wrapper.cpp index 9558fa6bd4..d4a557e3bf 100644 --- a/Gui/NatronGui/guiapp_wrapper.cpp +++ b/Gui/NatronGui/guiapp_wrapper.cpp @@ -1217,6 +1217,77 @@ static PyObject* Sbk_GuiAppFunc_selectAllNodes(PyObject* self, PyObject* args, P return 0; } +static PyObject* Sbk_GuiAppFunc_copySelectedNodes(PyObject* self, PyObject* args, PyObject* kwds) +{ + ::GuiApp* cppSelf = 0; + SBK_UNUSED(cppSelf) + if (!Shiboken::Object::isValid(self)) + return 0; + cppSelf = ((::GuiApp*)Shiboken::Conversions::cppPointer(SbkNatronGuiTypes[SBK_GUIAPP_IDX], (SbkObject*)self)); + int overloadId = -1; + PythonToCppFunc pythonToCpp[] = { 0 }; + SBK_UNUSED(pythonToCpp) + int numNamedArgs = (kwds ? PyDict_Size(kwds) : 0); + int numArgs = PyTuple_GET_SIZE(args); + PyObject* pyArgs[] = {0}; + + // invalid argument lengths + if (numArgs + numNamedArgs > 1) { + PyErr_SetString(PyExc_TypeError, "NatronGui.GuiApp.copySelectedNodes(): too many arguments"); + return 0; + } + + if (!PyArg_ParseTuple(args, "|O:copySelectedNodes", &(pyArgs[0]))) + return 0; + + + // Overloaded function decisor + // 0: copySelectedNodes(Group*) + if (numArgs == 0) { + overloadId = 0; // copySelectedNodes(Group*) + } else if ((pythonToCpp[0] = Shiboken::Conversions::isPythonToCppPointerConvertible((SbkObjectType*)SbkNatronEngineTypes[SBK_GROUP_IDX], (pyArgs[0])))) { + overloadId = 0; // copySelectedNodes(Group*) + } + + // Function signature not found. + if (overloadId == -1) goto Sbk_GuiAppFunc_copySelectedNodes_TypeError; + + // Call function/method + { + if (kwds) { + PyObject* value = PyDict_GetItemString(kwds, "group"); + if (value && pyArgs[0]) { + PyErr_SetString(PyExc_TypeError, "NatronGui.GuiApp.copySelectedNodes(): got multiple values for keyword argument 'group'."); + return 0; + } else if (value) { + pyArgs[0] = value; + if (!(pythonToCpp[0] = Shiboken::Conversions::isPythonToCppPointerConvertible((SbkObjectType*)SbkNatronEngineTypes[SBK_GROUP_IDX], (pyArgs[0])))) + goto Sbk_GuiAppFunc_copySelectedNodes_TypeError; + } + } + if (!Shiboken::Object::isValid(pyArgs[0])) + return 0; + ::Group* cppArg0 = 0; + if (pythonToCpp[0]) pythonToCpp[0](pyArgs[0], &cppArg0); + + if (!PyErr_Occurred()) { + // copySelectedNodes(Group*) + cppSelf->copySelectedNodes(cppArg0); + } + } + + if (PyErr_Occurred()) { + return 0; + } + Py_RETURN_NONE; + + Sbk_GuiAppFunc_copySelectedNodes_TypeError: + const char* overloads[] = {"NatronEngine.Group = None", 0}; + Shiboken::setErrorAboutWrongArguments(args, "NatronGui.GuiApp.copySelectedNodes", overloads); + return 0; +} + + static PyObject* Sbk_GuiAppFunc_selectNode(PyObject* self, PyObject* args) { ::GuiApp* cppSelf = 0; @@ -1380,6 +1451,7 @@ static PyMethodDef Sbk_GuiApp_methods[] = { {"saveFilenameDialog", (PyCFunction)Sbk_GuiAppFunc_saveFilenameDialog, METH_VARARGS|METH_KEYWORDS}, {"saveSequenceDialog", (PyCFunction)Sbk_GuiAppFunc_saveSequenceDialog, METH_VARARGS|METH_KEYWORDS}, {"selectAllNodes", (PyCFunction)Sbk_GuiAppFunc_selectAllNodes, METH_VARARGS|METH_KEYWORDS}, + {"copySelectedNodes", (PyCFunction)Sbk_GuiAppFunc_copySelectedNodes, METH_VARARGS|METH_KEYWORDS}, {"selectNode", (PyCFunction)Sbk_GuiAppFunc_selectNode, METH_VARARGS}, {"setSelection", (PyCFunction)Sbk_GuiAppFunc_setSelection, METH_O}, {"unregisterPythonPanel", (PyCFunction)Sbk_GuiAppFunc_unregisterPythonPanel, METH_O}, diff --git a/Gui/PyGuiApp.cpp b/Gui/PyGuiApp.cpp index d3bb161147..e4128f8019 100644 --- a/Gui/PyGuiApp.cpp +++ b/Gui/PyGuiApp.cpp @@ -424,6 +424,35 @@ GuiApp::selectAllNodes(Group* group) graph->selectAllNodes(false); } + +void +GuiApp::copySelectedNodes(Group* group) +{ + if ( appPTR->isBackground() ) { + return; + } + NodeGraph* graph = 0; + NodeCollectionPtr collection; + NodeGroup* isGroup = 0; + if (group) { + collection = group->getInternalCollection(); + if (collection) { + isGroup = dynamic_cast( collection.get() ); + if (isGroup) { + graph = dynamic_cast( isGroup->getNodeGraph() ); + } + } + } + if (!graph) { + graph = getInternalGuiApp()->getGui()->getNodeGraph(); + } + assert(graph); + if (!graph) { + throw std::logic_error("invalid ggraph"); + } + graph->copySelectedNodes(); +} + void GuiApp::deselectNode(Effect* effect) { @@ -449,7 +478,7 @@ GuiApp::deselectNode(Effect* effect) } assert(graph); if (!graph) { - throw std::logic_error(""); + throw std::logic_error("invalid graph"); } graph->deselectNode(nodeUi); } diff --git a/Gui/PyGuiApp.h b/Gui/PyGuiApp.h index 0497c88734..8da78d1743 100644 --- a/Gui/PyGuiApp.h +++ b/Gui/PyGuiApp.h @@ -155,6 +155,7 @@ class GuiApp void selectNode(Effect* effect, bool clearPreviousSelection); void setSelection(const std::list& nodes); void selectAllNodes(Group* group = 0); + void copySelectedNodes(Group* group = 0); void deselectNode(Effect* effect); void clearSelection(Group* group = 0);