Sketcher: Make PointPos modifiable from Python
This commit is contained in:
committed by
abdullahtahiriyo
parent
875197f4a1
commit
e104304a98
@@ -1,13 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<GenerateModel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="generateMetaModel_Module.xsd">
|
||||
<PythonExport
|
||||
Father="PersistencePy"
|
||||
Name="ConstraintPy"
|
||||
Twin="Constraint"
|
||||
TwinPointer="Constraint"
|
||||
Include="Mod/Sketcher/App/Constraint.h"
|
||||
Namespace="Sketcher"
|
||||
FatherInclude="Base/PersistencePy.h"
|
||||
<PythonExport
|
||||
Father="PersistencePy"
|
||||
Name="ConstraintPy"
|
||||
Twin="Constraint"
|
||||
TwinPointer="Constraint"
|
||||
Include="Mod/Sketcher/App/Constraint.h"
|
||||
Namespace="Sketcher"
|
||||
FatherInclude="Base/PersistencePy.h"
|
||||
FatherNamespace="Base"
|
||||
Constructor="true"
|
||||
Delete="true">
|
||||
@@ -28,7 +28,7 @@
|
||||
</Documentation>
|
||||
<Parameter Name="First" Type="Long"/>
|
||||
</Attribute>
|
||||
<Attribute Name="FirstPos" ReadOnly="true">
|
||||
<Attribute Name="FirstPos" ReadOnly="false">
|
||||
<Documentation>
|
||||
<UserDocu>Position of first geometry index the Constraint refers to</UserDocu>
|
||||
</Documentation>
|
||||
@@ -40,7 +40,7 @@
|
||||
</Documentation>
|
||||
<Parameter Name="Second" Type="Long"/>
|
||||
</Attribute>
|
||||
<Attribute Name="SecondPos" ReadOnly="true">
|
||||
<Attribute Name="SecondPos" ReadOnly="false">
|
||||
<Documentation>
|
||||
<UserDocu>Position of second geometry index the Constraint refers to</UserDocu>
|
||||
</Documentation>
|
||||
@@ -52,7 +52,7 @@
|
||||
</Documentation>
|
||||
<Parameter Name="Second" Type="Long"/>
|
||||
</Attribute>
|
||||
<Attribute Name="ThirdPos" ReadOnly="true">
|
||||
<Attribute Name="ThirdPos" ReadOnly="false">
|
||||
<Documentation>
|
||||
<UserDocu>Position of third geometry index the Constraint refers to</UserDocu>
|
||||
</Documentation>
|
||||
|
||||
@@ -31,7 +31,7 @@ using namespace Sketcher;
|
||||
|
||||
PyObject *ConstraintPy::PyMake(struct _typeobject *, PyObject *, PyObject *) // Python wrapper
|
||||
{
|
||||
// create a new instance of ConstraintPy and the Twin object
|
||||
// create a new instance of ConstraintPy and the Twin object
|
||||
return new ConstraintPy(new Constraint);
|
||||
}
|
||||
|
||||
@@ -108,18 +108,18 @@ int ConstraintPy::PyInit(PyObject* args, PyObject* /*kwd*/)
|
||||
}
|
||||
else if (strstr(ConstraintType,"InternalAlignment") != NULL) {
|
||||
this->getConstraintPtr()->Type = InternalAlignment;
|
||||
|
||||
|
||||
valid = true;
|
||||
if(strstr(ConstraintType,"EllipseMajorDiameter") != NULL)
|
||||
this->getConstraintPtr()->AlignmentType=EllipseMajorDiameter;
|
||||
else if(strstr(ConstraintType,"EllipseMinorDiameter") != NULL)
|
||||
this->getConstraintPtr()->AlignmentType=EllipseMinorDiameter;
|
||||
this->getConstraintPtr()->AlignmentType=EllipseMinorDiameter;
|
||||
else {
|
||||
this->getConstraintPtr()->AlignmentType=Undef;
|
||||
valid = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (valid) {
|
||||
this->getConstraintPtr()->First = FirstIndex;
|
||||
this->getConstraintPtr()->Second = SecondIndex;
|
||||
@@ -200,11 +200,11 @@ int ConstraintPy::PyInit(PyObject* args, PyObject* /*kwd*/)
|
||||
}
|
||||
else if (strstr(ConstraintType,"InternalAlignment") != NULL) {
|
||||
this->getConstraintPtr()->Type = InternalAlignment;
|
||||
|
||||
|
||||
valid = true;
|
||||
|
||||
|
||||
if(strstr(ConstraintType,"EllipseFocus1") != NULL)
|
||||
this->getConstraintPtr()->AlignmentType=EllipseFocus1;
|
||||
this->getConstraintPtr()->AlignmentType=EllipseFocus1;
|
||||
else if(strstr(ConstraintType,"EllipseFocus2") != NULL)
|
||||
this->getConstraintPtr()->AlignmentType=EllipseFocus2;
|
||||
else {
|
||||
@@ -324,13 +324,13 @@ int ConstraintPy::PyInit(PyObject* args, PyObject* /*kwd*/)
|
||||
valid = true;
|
||||
|
||||
if(strstr(ConstraintType,"BSplineControlPoint") != NULL) {
|
||||
this->getConstraintPtr()->AlignmentType=BSplineControlPoint;
|
||||
this->getConstraintPtr()->AlignmentType=BSplineControlPoint;
|
||||
}
|
||||
else {
|
||||
this->getConstraintPtr()->AlignmentType=Undef;
|
||||
valid = false;
|
||||
}
|
||||
|
||||
|
||||
if (valid) {
|
||||
this->getConstraintPtr()->First = intArg1;
|
||||
this->getConstraintPtr()->FirstPos = (Sketcher::PointPos) intArg2;
|
||||
@@ -338,7 +338,7 @@ int ConstraintPy::PyInit(PyObject* args, PyObject* /*kwd*/)
|
||||
this->getConstraintPtr()->InternalAlignmentIndex = intArg4;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
if (valid) {
|
||||
this->getConstraintPtr()->First = intArg1;
|
||||
@@ -521,7 +521,7 @@ std::string ConstraintPy::representation(void) const
|
||||
break;
|
||||
case Symmetric : result << "'Symmetric'>"; break;
|
||||
case SnellsLaw : result << "'SnellsLaw'>"; break;
|
||||
case InternalAlignment :
|
||||
case InternalAlignment :
|
||||
switch(this->getConstraintPtr()->AlignmentType) {
|
||||
case Undef : result << "'InternalAlignment:Undef'>";break;
|
||||
case EllipseMajorDiameter : result << "'InternalAlignment:EllipseMajorDiameter'>";break;
|
||||
@@ -583,6 +583,25 @@ Py::Long ConstraintPy::getFirstPos(void) const
|
||||
return Py::Long(static_cast<int>(this->getConstraintPtr()->FirstPos));
|
||||
}
|
||||
|
||||
void ConstraintPy::setFirstPos(Py::Long arg)
|
||||
{
|
||||
#if PY_MAJOR_VERSION < 3
|
||||
int pos = Py::Int(arg);
|
||||
#else
|
||||
int pos = arg;
|
||||
#endif
|
||||
|
||||
if(pos>=Sketcher::none && pos<=Sketcher::mid) {
|
||||
this->getConstraintPtr()->FirstPos = (Sketcher::PointPos)pos;
|
||||
}
|
||||
else {
|
||||
std::stringstream str;
|
||||
str << "Invalid PointPos parameter: " << arg << std::endl;
|
||||
|
||||
PyErr_SetString(PyExc_TypeError, str.str().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
Py::Long ConstraintPy::getSecond(void) const
|
||||
{
|
||||
return Py::Long(this->getConstraintPtr()->Second);
|
||||
@@ -602,6 +621,25 @@ Py::Long ConstraintPy::getSecondPos(void) const
|
||||
return Py::Long(static_cast<int>(this->getConstraintPtr()->SecondPos));
|
||||
}
|
||||
|
||||
void ConstraintPy::setSecondPos(Py::Long arg)
|
||||
{
|
||||
#if PY_MAJOR_VERSION < 3
|
||||
int pos = Py::Int(arg);
|
||||
#else
|
||||
int pos = arg;
|
||||
#endif
|
||||
|
||||
if(pos>=Sketcher::none && pos<=Sketcher::mid) {
|
||||
this->getConstraintPtr()->SecondPos = (Sketcher::PointPos)pos;
|
||||
}
|
||||
else {
|
||||
std::stringstream str;
|
||||
str << "Invalid PointPos parameter: " << arg << std::endl;
|
||||
|
||||
PyErr_SetString(PyExc_TypeError, str.str().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
Py::Long ConstraintPy::getThird(void) const
|
||||
{
|
||||
return Py::Long(this->getConstraintPtr()->Third);
|
||||
@@ -621,6 +659,25 @@ Py::Long ConstraintPy::getThirdPos(void) const
|
||||
return Py::Long(static_cast<int>(this->getConstraintPtr()->ThirdPos));
|
||||
}
|
||||
|
||||
void ConstraintPy::setThirdPos(Py::Long arg)
|
||||
{
|
||||
#if PY_MAJOR_VERSION < 3
|
||||
int pos = Py::Int(arg);
|
||||
#else
|
||||
int pos = arg;
|
||||
#endif
|
||||
|
||||
if(pos>=Sketcher::none && pos<=Sketcher::mid) {
|
||||
this->getConstraintPtr()->ThirdPos = (Sketcher::PointPos)pos;
|
||||
}
|
||||
else {
|
||||
std::stringstream str;
|
||||
str << "Invalid PointPos parameter: " << arg << std::endl;
|
||||
|
||||
PyErr_SetString(PyExc_TypeError, str.str().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
Py::String ConstraintPy::getName(void) const
|
||||
{
|
||||
return Py::String(this->getConstraintPtr()->Name);
|
||||
@@ -653,5 +710,5 @@ PyObject *ConstraintPy::getCustomAttributes(const char* /*attr*/) const
|
||||
|
||||
int ConstraintPy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/)
|
||||
{
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user