From 5b85233a584275352bde07de58630bfc7cd6a8d3 Mon Sep 17 00:00:00 2001 From: wmayer Date: Wed, 3 Oct 2018 16:31:58 +0200 Subject: [PATCH] remove useless methods startEditing/finishEditing/isEditing from Python wrapper of view provider add attribute to access document from view provider --- src/Gui/ViewProviderDocumentObjectPy.xml | 6 +++++ src/Gui/ViewProviderDocumentObjectPyImp.cpp | 9 ++++++- src/Gui/ViewProviderPy.xml | 15 ------------ src/Gui/ViewProviderPyImp.cpp | 27 --------------------- 4 files changed, 14 insertions(+), 43 deletions(-) diff --git a/src/Gui/ViewProviderDocumentObjectPy.xml b/src/Gui/ViewProviderDocumentObjectPy.xml index 6be8f4ed26..5901cddf18 100644 --- a/src/Gui/ViewProviderDocumentObjectPy.xml +++ b/src/Gui/ViewProviderDocumentObjectPy.xml @@ -24,5 +24,11 @@ + + + Return the document the view provider is part of + + + diff --git a/src/Gui/ViewProviderDocumentObjectPyImp.cpp b/src/Gui/ViewProviderDocumentObjectPyImp.cpp index 4bdddb291e..603b19997a 100644 --- a/src/Gui/ViewProviderDocumentObjectPyImp.cpp +++ b/src/Gui/ViewProviderDocumentObjectPyImp.cpp @@ -27,7 +27,8 @@ # include #endif -#include "Gui/ViewProviderDocumentObject.h" +#include +#include #include // inclusion of the generated files (generated out of ViewProviderDocumentObjectPy.xml) @@ -61,6 +62,12 @@ Py::Object ViewProviderDocumentObjectPy::getObject(void) const return Py::Object(obj->getPyObject(), true); // do not inc'ref twice } +Py::Object ViewProviderDocumentObjectPy::getDocument(void) const +{ + Document* doc = getViewProviderDocumentObjectPtr()->getDocument(); + return Py::asObject(doc->getPyObject()); // do not inc'ref twice +} + PyObject *ViewProviderDocumentObjectPy::getCustomAttributes(const char* /*attr*/) const { return 0; diff --git a/src/Gui/ViewProviderPy.xml b/src/Gui/ViewProviderPy.xml index 84147f9e64..1da524c702 100644 --- a/src/Gui/ViewProviderPy.xml +++ b/src/Gui/ViewProviderPy.xml @@ -65,21 +65,6 @@ Return a string representation of the Inventor node - - - Start the editing mode (default=0) - - - - - Finish editing mode - - - - - Returns True if the view provider is in editing mode, False otherwise - - Set a transformation on the Inventor node diff --git a/src/Gui/ViewProviderPyImp.cpp b/src/Gui/ViewProviderPyImp.cpp index 90a59b6372..009b5db440 100644 --- a/src/Gui/ViewProviderPyImp.cpp +++ b/src/Gui/ViewProviderPyImp.cpp @@ -203,33 +203,6 @@ PyObject* ViewProviderPy::toString(PyObject *args) } PY_CATCH; } -PyObject* ViewProviderPy::startEditing(PyObject *args) -{ - int mode=0; - if (!PyArg_ParseTuple(args, "|i", &mode)) // convert args: Python->C - return NULL; // NULL triggers exception - bool edit = getViewProviderPtr()->startEditing(mode); - Py::Boolean ok(edit); - return Py::new_reference_to(ok); -} - -PyObject* ViewProviderPy::finishEditing(PyObject *args) -{ - if (!PyArg_ParseTuple(args, "")) // convert args: Python->C - return NULL; // NULL triggers exception - getViewProviderPtr()->finishEditing(); - Py_Return; -} - -PyObject* ViewProviderPy::isEditing(PyObject *args) -{ - if (!PyArg_ParseTuple(args, "")) // convert args: Python->C - return NULL; // NULL triggers exception - bool edit = getViewProviderPtr()->isEditing(); - Py::Boolean ok(edit); - return Py::new_reference_to(ok); -} - PyObject* ViewProviderPy::setTransformation(PyObject *args) { PyObject* p;