Sketcher: bugfix: disallow opening when geometry types changed

This commit is contained in:
DeepSOIC 2015-03-13 04:46:33 +03:00 committed by wmayer
parent 3e6eb430fa
commit 89d0a7a176
3 changed files with 35 additions and 9 deletions

View File

@ -232,24 +232,41 @@ void PropertyConstraintList::applyValidGeometryKeys(const std::vector<unsigned i
void PropertyConstraintList::checkGeometry(const std::vector<Part::Geometry *> &GeoList)
{
if (validGeometryKeys.size() != GeoList.size()) {
if (!scanGeometry(GeoList)) {
invalidGeometry = true;
return;
}
//if we made it here, geometry is OK
if (invalidGeometry) {
//geometry was bad, but now it became OK.
invalidGeometry = false;
touch();
}
}
/*!
* \brief PropertyConstraintList::scanGeometry tests if the supplied geometry
* is the same (all elements are of the same type as they used to be).
* \param GeoList - new geometry list to be checked
* \return false, if the types have changed.
*/
bool PropertyConstraintList::scanGeometry(const std::vector<Part::Geometry *> &GeoList) const
{
if (validGeometryKeys.size() != GeoList.size()) {
return false;
}
unsigned int i=0;
for (std::vector< Part::Geometry * >::const_iterator it=GeoList.begin();
it != GeoList.end(); ++it, i++) {
if (validGeometryKeys[i] != (*it)->getTypeId().getKey()) {
invalidGeometry = true;
return;
return false;
}
}
if (invalidGeometry) {
invalidGeometry = false;
touch();
}
return true;
}
std::vector<Constraint *> PropertyConstraintList::_emptyValueList(0);

View File

@ -79,6 +79,9 @@ public:
const std::vector<Constraint*> &getValues(void) const {
return invalidGeometry ? _emptyValueList : _lValueList;
}
const std::vector<Constraint*> &getValuesForce(void) const {//to suppress check for invalid geometry, to be used for sketch repairing.
return _lValueList;
}
virtual PyObject *getPyObject(void);
virtual void setPyObject(PyObject *);
@ -93,6 +96,8 @@ public:
void acceptGeometry(const std::vector<Part::Geometry *> &GeoList);
void checkGeometry(const std::vector<Part::Geometry *> &GeoList);
bool scanGeometry(const std::vector<Part::Geometry *> &GeoList) const;
bool isGeometryInvalid(){return invalidGeometry;}
private:
std::vector<Constraint *> _lValueList;

View File

@ -1756,7 +1756,7 @@ int SketchObject::delExternal(int ExtGeoId)
int SketchObject::delConstraintsToExternal()
{
const std::vector< Constraint * > &constraints = Constraints.getValues();
const std::vector< Constraint * > &constraints = Constraints.getValuesForce();
std::vector< Constraint * > newConstraints(0);
int GeoId = -3, NullId = -2000;
for (std::vector<Constraint *>::const_iterator it = constraints.begin();
@ -2270,7 +2270,7 @@ bool SketchObject::evaluateConstraints() const
int extGeoCount = getExternalGeometryCount();
std::vector<Part::Geometry *> geometry = getCompleteGeometry();
const std::vector<Sketcher::Constraint *>& constraints = Constraints.getValues();
const std::vector<Sketcher::Constraint *>& constraints = Constraints.getValuesForce();
if (static_cast<int>(geometry.size()) != extGeoCount + intGeoCount)
return false;
if (geometry.size() < 2)
@ -2282,6 +2282,10 @@ bool SketchObject::evaluateConstraints() const
return false;
}
if(constraints.size()>0){
if (!Constraints.scanGeometry(geometry)) return false;
}
return true;
}