Sketcher: GeometryFacadePy - testGeometryMode Python interface

This commit is contained in:
Abdullah Tahiri
2020-12-05 05:04:09 +01:00
committed by abdullahtahiriyo
parent cfd5cfd6c7
commit 51eb55081c
2 changed files with 59 additions and 12 deletions

View File

@@ -15,10 +15,20 @@
<Author Licence="LGPL" Name="Abdullah Tahiri" EMail="abdullah.tahiri.yo@gmail.com" />
<UserDocu>Describes a GeometryFacade</UserDocu>
</Documentation>
<Methode Name="testGeometryMode" Const="true">
<Documentation>
<UserDocu>Returns a boolean indicating whether the given bit is set.</UserDocu>
</Documentation>
</Methode>
<Methode Name="setGeometryMode" Const="false">
<Documentation>
<UserDocu>Sets the given bit to true/false.</UserDocu>
</Documentation>
</Methode>
<Attribute Name="Id" ReadOnly="false">
<Documentation>
<UserDocu>
returns the Id of the SketchGeometryExtension.
Sets/returns the Id of the SketchGeometryExtension.
</UserDocu>
</Documentation>
<Parameter Name="Id" Type="Long"/>
@@ -26,7 +36,7 @@
<Attribute Name="InternalType" ReadOnly="false">
<Documentation>
<UserDocu>
returns the Internal Type of the Geometry.
Sets/returns the Internal Alignment Type of the Geometry.
</UserDocu>
</Documentation>
<Parameter Name="InternalType" Type="String"/>
@@ -34,12 +44,17 @@
<Attribute Name="Blocked" ReadOnly="false">
<Documentation>
<UserDocu>
returns whether the geometry is blocked or not.
Sets/returns whether the geometry is blocked or not.
</UserDocu>
</Documentation>
<Parameter Name="Blocked" Type="Boolean"/>
</Attribute>
<Attribute Name="Construction" ReadOnly="false">
<Documentation>
<UserDocu>Sets/retuns this geometry as a construction one, which will not be part of a later built shape.</UserDocu>
</Documentation>
<Parameter Name="Construction" Type="Boolean"/>
</Attribute>
<Methode Name="mirror">
<Documentation>
<UserDocu>Performs the symmetrical transformation of this geometric object</UserDocu>
@@ -105,13 +120,6 @@
<UserDocu>Returns a list with information about the geometry extensions.</UserDocu>
</Documentation>
</Methode>
<Attribute Name="Construction" ReadOnly="false">
<Documentation>
<UserDocu>Defines this geometry as a construction one which
means that it is not part of a later built shape.</UserDocu>
</Documentation>
<Parameter Name="Construction" Type="Boolean"/>
</Attribute>
<Attribute Name="Tag" ReadOnly="true">
<Documentation>
<UserDocu>Gives the tag of the geometry as string.</UserDocu>
@@ -120,7 +128,7 @@ means that it is not part of a later built shape.</UserDocu>
</Attribute>
<Attribute Name="Geometry" ReadOnly="false">
<Documentation>
<UserDocu>Gives the tag of the geometry as string.</UserDocu>
<UserDocu>Returns the underlying geometry object.</UserDocu>
</Documentation>
<Parameter Name="Geometry" Type="Object"/>
</Attribute>

View File

@@ -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)
{