+ fixes #0001874: Scripted constraints not evaluated correctly

This commit is contained in:
wmayer 2014-12-23 15:32:03 +01:00
parent c918ef7e40
commit 3fa8a1ed2b
7 changed files with 25 additions and 4 deletions

View File

@ -306,6 +306,11 @@ bool Part2DObject::seekTrimPoints(const std::vector<Geometry *> &geomlist,
return true;
}
void Part2DObject::acceptGeometry()
{
// implemented in sub-classes
}
// Python Drawing feature ---------------------------------------------------------
namespace App {

View File

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

View File

@ -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<Part2DObject*>(this->getContainer());
if (PyList_Check(value)) {
Py_ssize_t nSize = PyList_Size(value);
std::vector<Geometry*> 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<GeometryPy*>(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);

View File

@ -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;

View File

@ -34,8 +34,6 @@
namespace Part
{
class Property;
/** The part shape property class.
* @author Werner Mayer
*/

View File

@ -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<Part::Geometry *> &geoList)
{
const std::vector< Part::Geometry * > &vals = getInternalGeometry();

View File

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