From 8dd191d9459e1d2ce8f37ef9cf55ffa315c90a29 Mon Sep 17 00:00:00 2001 From: Abdullah Tahiri Date: Sat, 5 Dec 2020 05:04:09 +0100 Subject: [PATCH] Sketcher: GeometryFacadePy - testGeometryMode Python interface --- src/Mod/Sketcher/App/GeometryFacadePy.xml | 32 ++++++++++------ src/Mod/Sketcher/App/GeometryFacadePyImp.cpp | 39 ++++++++++++++++++++ 2 files changed, 59 insertions(+), 12 deletions(-) diff --git a/src/Mod/Sketcher/App/GeometryFacadePy.xml b/src/Mod/Sketcher/App/GeometryFacadePy.xml index db4febce4a..ca0d84b9a2 100644 --- a/src/Mod/Sketcher/App/GeometryFacadePy.xml +++ b/src/Mod/Sketcher/App/GeometryFacadePy.xml @@ -15,10 +15,20 @@ Describes a GeometryFacade + + + Returns a boolean indicating whether the given bit is set. + + + + + Sets the given bit to true/false. + + - returns the Id of the SketchGeometryExtension. + Sets/returns the Id of the SketchGeometryExtension. @@ -26,7 +36,7 @@ - returns the Internal Type of the Geometry. + Sets/returns the Internal Alignment Type of the Geometry. @@ -34,12 +44,17 @@ - returns whether the geometry is blocked or not. + Sets/returns whether the geometry is blocked or not. - + + + Sets/retuns this geometry as a construction one, which will not be part of a later built shape. + + + Performs the symmetrical transformation of this geometric object @@ -105,13 +120,6 @@ Returns a list with information about the geometry extensions. - - - Defines this geometry as a construction one which -means that it is not part of a later built shape. - - - Gives the tag of the geometry as string. @@ -120,7 +128,7 @@ means that it is not part of a later built shape. - Gives the tag of the geometry as string. + Returns the underlying geometry object. diff --git a/src/Mod/Sketcher/App/GeometryFacadePyImp.cpp b/src/Mod/Sketcher/App/GeometryFacadePyImp.cpp index cc9bf97dff..1c5d4f8a16 100644 --- a/src/Mod/Sketcher/App/GeometryFacadePyImp.cpp +++ b/src/Mod/Sketcher/App/GeometryFacadePyImp.cpp @@ -127,6 +127,45 @@ void GeometryFacadePy::setBlocked(Py::Boolean arg) getGeometryFacadePtr()->setBlocked(arg); } +PyObject* GeometryFacadePy::testGeometryMode(PyObject *args) +{ + char* flag; + if (PyArg_ParseTuple(args, "s",&flag)) { + + GeometryMode::GeometryMode mode; + + if(SketchGeometryExtension::getGeometryModeFromName(flag, mode)) + return new_reference_to(Py::Boolean(getGeometryFacadePtr()->testGeometryMode(mode))); + + PyErr_SetString(PyExc_TypeError, "Flag string does not exist."); + return NULL; + } + + PyErr_SetString(PyExc_TypeError, "No flag string provided."); + return NULL; +} + +PyObject* GeometryFacadePy::setGeometryMode(PyObject *args) +{ + char * flag; + PyObject * bflag = Py_True; + if (PyArg_ParseTuple(args, "s|O!", &flag, &PyBool_Type, &bflag)) { + + GeometryMode::GeometryMode mode; + + if(SketchGeometryExtension::getGeometryModeFromName(flag, mode)) { + getGeometryFacadePtr()->setGeometryMode(mode, PyObject_IsTrue(bflag) ? true : false); + Py_Return; + } + + PyErr_SetString(PyExc_TypeError, "Flag string does not exist."); + return NULL; + } + + PyErr_SetString(PyExc_TypeError, "No flag string provided."); + Py_Return; +} + PyObject* GeometryFacadePy::mirror(PyObject *args) {