Sketcher: Implement symmetry with respect to a point constraint, aka midpoint constraint

This commit is contained in:
logari81
2012-11-29 22:46:11 +01:00
parent 5e008d8b76
commit a72d95472e
8 changed files with 217 additions and 23 deletions

View File

@@ -51,7 +51,7 @@ int ConstraintPy::PyInit(PyObject* args, PyObject* /*kwd*/)
int SecondIndex= Constraint::GeoUndef;
int SecondPos = none;
int ThirdIndex = Constraint::GeoUndef;
//int ThirdPos = none;
int ThirdPos = none;
double Value = 0;
// Note: In Python 2.x PyArg_ParseTuple prints a warning if a float is given but an integer is expected.
// This means we must use a PyObject and check afterwards if it's a float or integer.
@@ -292,6 +292,21 @@ int ConstraintPy::PyInit(PyObject* args, PyObject* /*kwd*/)
}
}
}
PyErr_Clear();
if (PyArg_ParseTuple(args, "siiiiii", &ConstraintType, &FirstIndex, &FirstPos, &SecondIndex, &SecondPos, &ThirdIndex, &ThirdPos)) {
// ConstraintType, GeoIndex1, PosIndex1, GeoIndex2, PosIndex2, GeoIndex3, PosIndex3
if (strcmp("Symmetric",ConstraintType) == 0 ) {
this->getConstraintPtr()->Type = Symmetric;
this->getConstraintPtr()->First = FirstIndex;
this->getConstraintPtr()->FirstPos = (Sketcher::PointPos) FirstPos;
this->getConstraintPtr()->Second = SecondIndex;
this->getConstraintPtr()->SecondPos = (Sketcher::PointPos) SecondPos;
this->getConstraintPtr()->Third = ThirdIndex;
this->getConstraintPtr()->ThirdPos = (Sketcher::PointPos) ThirdPos;
return 0;
}
}
PyErr_SetString(PyExc_TypeError, "Constraint constructor accepts:\n"
"-- empty parameter list\n"