Sketcher: Fixed regression in fix for issue #3245.
This commit is contained in:
@@ -185,18 +185,16 @@ void PropertyConstraintList::applyValues(const std::vector<Constraint*>& lValue)
|
||||
std::vector<Constraint*> oldVals(_lValueList);
|
||||
std::map<App::ObjectIdentifier, App::ObjectIdentifier> renamed;
|
||||
std::set<App::ObjectIdentifier> removed;
|
||||
std::set<App::ObjectIdentifier> newRenamedPaths;
|
||||
|
||||
|
||||
/* Check for renames */
|
||||
for (unsigned int i = 0; i < lValue.size(); i++) {
|
||||
boost::unordered_map<boost::uuids::uuid, std::size_t>::const_iterator j = valueMap.find(lValue[i]->tag);
|
||||
|
||||
if (j != valueMap.end() && (i != j->second || _lValueList[j->second]->Name != lValue[i]->Name) ) {
|
||||
App::ObjectIdentifier oid(makePath(i, lValue[i]));
|
||||
renamed[makePath(j->second, _lValueList[j->second] )] = oid;
|
||||
|
||||
/* Keep track of new paths */
|
||||
newRenamedPaths.insert(oid);
|
||||
App::ObjectIdentifier old_oid(makePath(j->second, _lValueList[j->second] ));
|
||||
App::ObjectIdentifier new_oid(makePath(i, lValue[i]));
|
||||
|
||||
renamed[old_oid] = new_oid;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -205,24 +203,24 @@ void PropertyConstraintList::applyValues(const std::vector<Constraint*>& lValue)
|
||||
for (std::size_t i = 0; i < lValue.size(); i++)
|
||||
valueMap[lValue[i]->tag] = i;
|
||||
|
||||
/* Signal renames */
|
||||
if (renamed.size() > 0)
|
||||
signalConstraintsRenamed(renamed);
|
||||
|
||||
/* Collect info about removed elements */
|
||||
for (std::size_t i = 0; i < oldVals.size(); i++) {
|
||||
boost::unordered_map<boost::uuids::uuid, std::size_t>::const_iterator j = valueMap.find(oldVals[i]->tag);
|
||||
App::ObjectIdentifier oid(makePath(i, oldVals[i]));
|
||||
|
||||
/* If not found in new values or a renamed expression takes its place, place it in the set to be removed */
|
||||
if (j == valueMap.end() && newRenamedPaths.find(oid) == newRenamedPaths.end())
|
||||
/* If not found in new values, place it in the set to be removed */
|
||||
if (j == valueMap.end())
|
||||
removed.insert(oid);
|
||||
}
|
||||
|
||||
/* Signal removes */
|
||||
/* Signal removes first, in case renamed values below have the same names as some of the removed ones. */
|
||||
if (removed.size() > 0)
|
||||
signalConstraintsRemoved(removed);
|
||||
|
||||
/* Signal renames */
|
||||
if (renamed.size() > 0)
|
||||
signalConstraintsRenamed(renamed);
|
||||
|
||||
/* Resize array to new size */
|
||||
_lValueList.resize(lValue.size());
|
||||
|
||||
|
||||
@@ -180,6 +180,36 @@ class SketcherSolverTestCases(unittest.TestCase):
|
||||
self.failUnless(values['Constraints[4]'] == u'60')
|
||||
self.failUnless(values['Constraints[5]'] == u'65')
|
||||
FreeCAD.closeDocument("Issue3245")
|
||||
|
||||
def testIssue3245_2(self):
|
||||
self.Doc2 = FreeCAD.newDocument("Issue3245")
|
||||
ActiveSketch = self.Doc2.addObject('Sketcher::SketchObject','Sketch')
|
||||
ActiveSketch.Placement = App.Placement(App.Vector(0.000000,0.000000,0.000000),App.Rotation(0.000000,0.000000,0.000000,1.000000))
|
||||
ActiveSketch.MapMode = "Deactivated"
|
||||
geoList = []
|
||||
geoList.append(Part.LineSegment(App.Vector(-23.574591,42.399727,0),App.Vector(81.949776,42.399727,0)))
|
||||
geoList.append(Part.LineSegment(App.Vector(81.949776,42.399727,0),App.Vector(81.949776,-19.256901,0)))
|
||||
geoList.append(Part.LineSegment(App.Vector(81.949776,-19.256901,0),App.Vector(-23.574591,-19.256901,0)))
|
||||
geoList.append(Part.LineSegment(App.Vector(-23.574591,-19.256901,0),App.Vector(-23.574591,42.399727,0)))
|
||||
ActiveSketch.addGeometry(geoList,False)
|
||||
conList = []
|
||||
conList.append(Sketcher.Constraint('Coincident',0,2,1,1))
|
||||
conList.append(Sketcher.Constraint('Coincident',1,2,2,1))
|
||||
conList.append(Sketcher.Constraint('Coincident',2,2,3,1))
|
||||
conList.append(Sketcher.Constraint('Coincident',3,2,0,1))
|
||||
conList.append(Sketcher.Constraint('Horizontal',0))
|
||||
conList.append(Sketcher.Constraint('Horizontal',2))
|
||||
conList.append(Sketcher.Constraint('Vertical',1))
|
||||
conList.append(Sketcher.Constraint('Vertical',3))
|
||||
ActiveSketch.addConstraint(conList)
|
||||
ActiveSketch.addConstraint(Sketcher.Constraint('DistanceX',0,1,0,2,105.524367))
|
||||
ActiveSketch.setExpression('Constraints[8]', u'10 + 10')
|
||||
ActiveSketch.addConstraint(Sketcher.Constraint('DistanceY',3,1,3,2,61.656628))
|
||||
ActiveSketch.setDatum(9,App.Units.Quantity('5.000000 mm'))
|
||||
ActiveSketch.delConstraint(8)
|
||||
values = d = {key: value for (key, value) in self.Doc2.Sketch.ExpressionEngine}
|
||||
self.Doc2.recompute()
|
||||
self.failUnless(len(values) == 0)
|
||||
|
||||
def tearDown(self):
|
||||
#closing doc
|
||||
|
||||
Reference in New Issue
Block a user