From 3fa8a1ed2b859b7a6b74cdf89e7704042924268c Mon Sep 17 00:00:00 2001 From: wmayer Date: Tue, 23 Dec 2014 15:32:03 +0100 Subject: [PATCH] + fixes #0001874: Scripted constraints not evaluated correctly --- src/Mod/Part/App/Part2DObject.cpp | 5 +++++ src/Mod/Part/App/Part2DObject.h | 2 ++ src/Mod/Part/App/PropertyGeometryList.cpp | 10 +++++++++- src/Mod/Part/App/PropertyGeometryList.h | 2 +- src/Mod/Part/App/PropertyTopoShape.h | 2 -- src/Mod/Sketcher/App/SketchObject.cpp | 6 ++++++ src/Mod/Sketcher/App/SketchObject.h | 2 ++ 7 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/Mod/Part/App/Part2DObject.cpp b/src/Mod/Part/App/Part2DObject.cpp index c4e55e696..9d34a71d6 100644 --- a/src/Mod/Part/App/Part2DObject.cpp +++ b/src/Mod/Part/App/Part2DObject.cpp @@ -306,6 +306,11 @@ bool Part2DObject::seekTrimPoints(const std::vector &geomlist, return true; } +void Part2DObject::acceptGeometry() +{ + // implemented in sub-classes +} + // Python Drawing feature --------------------------------------------------------- namespace App { diff --git a/src/Mod/Part/App/Part2DObject.h b/src/Mod/Part/App/Part2DObject.h index bb4e879d7..be4892fd8 100644 --- a/src/Mod/Part/App/Part2DObject.h +++ b/src/Mod/Part/App/Part2DObject.h @@ -77,6 +77,8 @@ public: virtual int getAxisCount(void) const; /// retrieves an axis iterating through the construction lines of the sketch (indices start at 0) virtual Base::Axis getAxis(int axId) const; + /// verify and accept the assigned geometry + virtual void acceptGeometry(); /** calculate the points where a curve with index GeoId should be trimmed * with respect to the rest of the curves contained in the list geomlist diff --git a/src/Mod/Part/App/PropertyGeometryList.cpp b/src/Mod/Part/App/PropertyGeometryList.cpp index bf0583276..1a1bddcbe 100644 --- a/src/Mod/Part/App/PropertyGeometryList.cpp +++ b/src/Mod/Part/App/PropertyGeometryList.cpp @@ -37,6 +37,7 @@ #include "GeometryPy.h" #include "PropertyGeometryList.h" +#include "Part2DObject.h" using namespace App; using namespace Base; @@ -113,6 +114,9 @@ PyObject *PropertyGeometryList::getPyObject(void) void PropertyGeometryList::setPyObject(PyObject *value) { + // check container of this property to notify about changes + Part2DObject* part2d = dynamic_cast(this->getContainer()); + if (PyList_Check(value)) { Py_ssize_t nSize = PyList_Size(value); std::vector values; @@ -130,10 +134,14 @@ void PropertyGeometryList::setPyObject(PyObject *value) } setValues(values); + if (part2d) + part2d->acceptGeometry(); } else if (PyObject_TypeCheck(value, &(GeometryPy::Type))) { GeometryPy *pcObject = static_cast(value); setValue(pcObject->getGeometryPtr()); + if (part2d) + part2d->acceptGeometry(); } else { std::string error = std::string("type must be 'Geometry' or list of 'Geometry', not "); @@ -182,7 +190,7 @@ void PropertyGeometryList::Restore(Base::XMLReader &reader) setValues(values); } -Property *PropertyGeometryList::Copy(void) const +App::Property *PropertyGeometryList::Copy(void) const { PropertyGeometryList *p = new PropertyGeometryList(); p->setValues(_lValueList); diff --git a/src/Mod/Part/App/PropertyGeometryList.h b/src/Mod/Part/App/PropertyGeometryList.h index f8e97ac28..135430ad6 100644 --- a/src/Mod/Part/App/PropertyGeometryList.h +++ b/src/Mod/Part/App/PropertyGeometryList.h @@ -80,7 +80,7 @@ public: virtual void Save(Base::Writer &writer) const; virtual void Restore(Base::XMLReader &reader); - virtual Property *Copy(void) const; + virtual App::Property *Copy(void) const; virtual void Paste(const App::Property &from); virtual unsigned int getMemSize(void) const; diff --git a/src/Mod/Part/App/PropertyTopoShape.h b/src/Mod/Part/App/PropertyTopoShape.h index a75c85ccd..f939c5953 100644 --- a/src/Mod/Part/App/PropertyTopoShape.h +++ b/src/Mod/Part/App/PropertyTopoShape.h @@ -34,8 +34,6 @@ namespace Part { -class Property; - /** The part shape property class. * @author Werner Mayer */ diff --git a/src/Mod/Sketcher/App/SketchObject.cpp b/src/Mod/Sketcher/App/SketchObject.cpp index 4c8f75d3a..7173a5c04 100644 --- a/src/Mod/Sketcher/App/SketchObject.cpp +++ b/src/Mod/Sketcher/App/SketchObject.cpp @@ -321,6 +321,12 @@ Base::Axis SketchObject::getAxis(int axId) const return Base::Axis(); } +void SketchObject::acceptGeometry() +{ + Constraints.acceptGeometry(getCompleteGeometry()); + rebuildVertexIndex(); +} + int SketchObject::addGeometry(const std::vector &geoList) { const std::vector< Part::Geometry * > &vals = getInternalGeometry(); diff --git a/src/Mod/Sketcher/App/SketchObject.h b/src/Mod/Sketcher/App/SketchObject.h index 887d56008..37c6cc2ae 100644 --- a/src/Mod/Sketcher/App/SketchObject.h +++ b/src/Mod/Sketcher/App/SketchObject.h @@ -162,6 +162,8 @@ public: virtual int getAxisCount(void) const; /// retrieves an axis iterating through the construction lines of the sketch (indices start at 0) virtual Base::Axis getAxis(int axId) const; + /// verify and accept the assigned geometry + virtual void acceptGeometry(); protected: /// get called by the container when a property has changed