Merge branch 'master' into translation-fix

This commit is contained in:
Jonathan Wiedemann 2016-05-18 18:21:33 +02:00
commit 149a5a19db
10 changed files with 140 additions and 29 deletions

View File

@ -9,7 +9,8 @@
FatherInclude="Base/PyObjectBase.h"
Namespace="Base"
Constructor="true"
Delete="true"
Delete="true"
RichCompare="true"
FatherNamespace="Base">
<Documentation>
<Author Licence="LGPL" Name="Juergen Riegel" EMail="FreeCAD@juergen-riegel.net" />
@ -75,7 +76,7 @@ Placement(Base, Axis, Angle) -- define position and rotation
</UserDocu>
</Documentation>
</Methode>
<Methode Name="isNull" Const="true">
<Methode Name="isNull" Const="true">
<Documentation>
<UserDocu>
isNull() -> Bool
@ -83,7 +84,7 @@ Placement(Base, Axis, Angle) -- define position and rotation
</UserDocu>
</Documentation>
</Methode>
<Attribute Name="Base" ReadOnly="false">
<Attribute Name="Base" ReadOnly="false">
<Documentation>
<UserDocu>Vector to the Base Position of the Placement</UserDocu>
</Documentation>

View File

@ -118,6 +118,37 @@ int PlacementPy::PyInit(PyObject* args, PyObject* /*kwd*/)
return -1;
}
PyObject* PlacementPy::richCompare(PyObject *v, PyObject *w, int op)
{
if (PyObject_TypeCheck(v, &(PlacementPy::Type)) &&
PyObject_TypeCheck(w, &(PlacementPy::Type))) {
Base::Placement p1 = *static_cast<PlacementPy*>(v)->getPlacementPtr();
Base::Placement p2 = *static_cast<PlacementPy*>(w)->getPlacementPtr();
PyObject *res=0;
if (op != Py_EQ && op != Py_NE) {
PyErr_SetString(PyExc_TypeError,
"no ordering relation is defined for Placement");
return 0;
}
else if (op == Py_EQ) {
res = (p1 == p2) ? Py_True : Py_False;
Py_INCREF(res);
return res;
}
else {
res = (p1 != p2) ? Py_True : Py_False;
Py_INCREF(res);
return res;
}
}
else {
// This always returns False
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
}
}
PyObject* PlacementPy::move(PyObject * args)
{
PyObject *vec;

View File

@ -294,10 +294,12 @@ Rotation Rotation::operator*(const Rotation & q) const
bool Rotation::operator==(const Rotation & q) const
{
bool equal = true;
for (int i=0; i<4;i++)
equal &= (fabs(this->quat[i] - q.quat[i]) < 0.005 );
return equal;
if (this->quat[0] == q.quat[0] &&
this->quat[1] == q.quat[1] &&
this->quat[2] == q.quat[2] &&
this->quat[3] == q.quat[3])
return true;
return false;
}
bool Rotation::operator!=(const Rotation & q) const
@ -305,6 +307,16 @@ bool Rotation::operator!=(const Rotation & q) const
return !(*this == q);
}
bool Rotation::isSame(const Rotation& q) const
{
if ((this->quat[0] == q.quat[0] || this->quat[0] == -q.quat[0]) &&
(this->quat[1] == q.quat[1] || this->quat[1] == -q.quat[1]) &&
(this->quat[2] == q.quat[2] || this->quat[2] == -q.quat[2]) &&
(this->quat[3] == q.quat[3] || this->quat[3] == -q.quat[3]))
return true;
return false;
}
void Rotation::multVec(const Vector3d & src, Vector3d & dst) const
{
double x = this->quat[0];

View File

@ -79,6 +79,7 @@ public:
void multVec(const Vector3d & src, Vector3d & dst) const;
void scaleAngle(const double scaleFactor);
bool isSame(const Rotation&) const;
//@}
static Rotation slerp(const Rotation & rot0, const Rotation & rot1, double t);

View File

@ -10,6 +10,7 @@
Namespace="Base"
Constructor="true"
Delete="true"
RichCompare="true"
FatherNamespace="Base">
<Documentation>
<Author Licence="LGPL" Name="Juergen Riegel" EMail="FreeCAD@juergen-riegel.net" />
@ -29,12 +30,28 @@
<Methode Name="invert">
<Documentation>
<UserDocu>
move(Vector)
Move the matrix along the vector
invert() -> None
Sets the rotation to its inverse
</UserDocu>
</Documentation>
</Methode>
<Methode Name="multiply" Const="true">
<Methode Name="inverted">
<Documentation>
<UserDocu>
inverted() -> Rotation
Returns the inverse of the rotation
</UserDocu>
</Documentation>
</Methode>
<Methode Name="isSame">
<Documentation>
<UserDocu>
isSame(Rotation)
Checks if the two quaternions perform the same rotation
</UserDocu>
</Documentation>
</Methode>
<Methode Name="multiply" Const="true">
<Documentation>
<UserDocu>
multiply(Rotation)
@ -59,7 +76,7 @@
</UserDocu>
</Documentation>
</Methode>
<Methode Name="isNull" Const="true">
<Methode Name="isNull" Const="true">
<Documentation>
<UserDocu>
isNull() -> Bool
@ -67,7 +84,7 @@
</UserDocu>
</Documentation>
</Methode>
<Attribute Name="Q" ReadOnly="false">
<Attribute Name="Q" ReadOnly="false">
<Documentation>
<UserDocu>The rotation elements (as quaternion)</UserDocu>
</Documentation>

View File

@ -77,14 +77,14 @@ int RotationPy::PyInit(PyObject* args, PyObject* /*kwd*/)
PyErr_Clear();
double angle;
if (PyArg_ParseTuple(args, "O!d", &(Base::VectorPy::Type), &o, &angle)) {
// NOTE: The last parameter defines the rotation angle in degree.
// NOTE: The last parameter defines the rotation angle in degree.
getRotationPtr()->setValue(static_cast<Base::VectorPy*>(o)->value(), Base::toRadians<double>(angle));
return 0;
}
PyErr_Clear();
if (PyArg_ParseTuple(args, "O!d", &(Base::MatrixPy::Type), &o, &angle)) {
// NOTE: The last parameter defines the rotation angle in degree.
// NOTE: The last parameter defines the rotation angle in degree.
getRotationPtr()->setValue(static_cast<Base::MatrixPy*>(o)->value());
return 0;
}
@ -164,6 +164,37 @@ int RotationPy::PyInit(PyObject* args, PyObject* /*kwd*/)
return -1;
}
PyObject* RotationPy::richCompare(PyObject *v, PyObject *w, int op)
{
if (PyObject_TypeCheck(v, &(RotationPy::Type)) &&
PyObject_TypeCheck(w, &(RotationPy::Type))) {
Base::Rotation r1 = *static_cast<RotationPy*>(v)->getRotationPtr();
Base::Rotation r2 = *static_cast<RotationPy*>(w)->getRotationPtr();
PyObject *res=0;
if (op != Py_EQ && op != Py_NE) {
PyErr_SetString(PyExc_TypeError,
"no ordering relation is defined for Rotation");
return 0;
}
else if (op == Py_EQ) {
res = (r1 == r2) ? Py_True : Py_False;
Py_INCREF(res);
return res;
}
else {
res = (r1 != r2) ? Py_True : Py_False;
Py_INCREF(res);
return res;
}
}
else {
// This always returns False
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
}
}
PyObject* RotationPy::invert(PyObject * args)
{
if (!PyArg_ParseTuple(args, ""))
@ -172,6 +203,14 @@ PyObject* RotationPy::invert(PyObject * args)
Py_Return;
}
PyObject* RotationPy::inverted(PyObject * args)
{
if (!PyArg_ParseTuple(args, ""))
return 0;
Rotation mult = this->getRotationPtr()->inverse();
return new RotationPy(new Rotation(mult));
}
PyObject* RotationPy::multiply(PyObject * args)
{
PyObject *rot;
@ -205,16 +244,26 @@ PyObject* RotationPy::toEuler(PyObject * args)
return Py::new_reference_to(tuple);
}
PyObject* RotationPy::isNull(PyObject *args)
{
if (!PyArg_ParseTuple(args, ""))
return NULL;
Base::Rotation rot = * getRotationPtr();
Base::Rotation nullrot(0,0,0,1);
Base::Rotation nullrotinv(0,0,0,-1);
bool null = (rot == nullrot) | (rot == nullrotinv);
return Py_BuildValue("O", (null ? Py_True : Py_False));
}
PyObject* RotationPy::isSame(PyObject *args)
{
PyObject *rot;
if (!PyArg_ParseTuple(args, "O!", &(RotationPy::Type), &rot))
return NULL;
Base::Rotation rot1 = * getRotationPtr();
Base::Rotation rot2 = * static_cast<RotationPy*>(rot)->getRotationPtr();
bool same = rot1.isSame(rot2);
return Py_BuildValue("O", (same ? Py_True : Py_False));
}
PyObject* RotationPy::isNull(PyObject *args)
{
if (!PyArg_ParseTuple(args, ""))
return NULL;
Base::Rotation rot = * getRotationPtr();
Base::Rotation nullrot(0,0,0,1);
bool null = rot.isSame(nullrot);
return Py_BuildValue("O", (null ? Py_True : Py_False));
}
Py::Tuple RotationPy::getQ(void) const
{

View File

@ -3208,7 +3208,7 @@ class ToggleConstructionMode():
def GetResources(self):
return {'Pixmap' : 'Draft_Construction',
'MenuText': QtCore.QT_TRANSLATE_NOOP("Draft_ToggleConstructionMode", "Toggle construcion Mode"),
'MenuText': QtCore.QT_TRANSLATE_NOOP("Draft_ToggleConstructionMode", "Toggle Construction Mode"),
'Accel' : "C, M",
'ToolTip': QtCore.QT_TRANSLATE_NOOP("Draft_ToggleConstructionMode", "Toggles the Construction Mode for next objects.")}

View File

@ -562,13 +562,13 @@ int Sketch::addEllipse(const Part::GeomEllipse &elip, bool fixed)
return Geoms.size()-1;
}
std::vector<Part::Geometry *> Sketch::extractGeometry(bool withConstrucionElements,
std::vector<Part::Geometry *> Sketch::extractGeometry(bool withConstructionElements,
bool withExternalElements) const
{
std::vector<Part::Geometry *> temp;
temp.reserve(Geoms.size());
for (std::vector<GeoDef>::const_iterator it=Geoms.begin(); it != Geoms.end(); ++it)
if ((!it->external || withExternalElements) && (!it->geo->Construction || withConstrucionElements))
if ((!it->external || withExternalElements) && (!it->geo->Construction || withConstructionElements))
temp.push_back(it->geo->clone());
return temp;

View File

@ -77,7 +77,7 @@ public:
/// add unspecified geometry
int addGeometry(const std::vector<Part::Geometry *> &geo, bool fixed=false);
/// returns the actual geometry
std::vector<Part::Geometry *> extractGeometry(bool withConstrucionElements=true,
std::vector<Part::Geometry *> extractGeometry(bool withConstructionElements=true,
bool withExternalElements=false) const;
/// get the geometry as python objects
Py::Tuple getPyGeometry(void) const;

View File

@ -30,7 +30,7 @@
</Methode>
<Methode Name="toggleConstruction">
<Documentation>
<UserDocu>switch a geometry to a construcion line</UserDocu>
<UserDocu>switch a geometry to a construction line</UserDocu>
</Documentation>
</Methode>
<Methode Name="setConstruction">