Sketcher: Symmetric: Do not copy names of constraints (#17433)

* Sketcher: Symmetric: Do not copy names of constraints

* Sketcher: Symmetric : Fix https://github.com/FreeCAD/FreeCAD/issues/17442
This commit is contained in:
PaddleStroke
2024-10-25 05:58:51 +02:00
committed by GitHub
parent 9ba6bc1b9e
commit 336dda316d

View File

@@ -4757,13 +4757,10 @@ int SketchObject::addSymmetric(const std::vector<int>& geoIdList, int refGeoId,
Base::StateLocker lock(managedoperation, true);
const std::vector<Part::Geometry*>& geovals = getInternalGeometry();
std::vector<Part::Geometry*> newgeoVals(geovals);
const std::vector<Constraint*>& constrvals = this->Constraints.getValues();
std::vector<Constraint*> newconstrVals(constrvals);
newgeoVals.reserve(geovals.size() + geoIdList.size());
std::map<int, int> geoIdMap;
std::map<int, bool> isStartEndInverted;
@@ -4783,15 +4780,10 @@ int SketchObject::addSymmetric(const std::vector<int>& geoIdList, int refGeoId,
}
}
// add the geometry
std::vector<Part::Geometry*> symmetricVals = getSymmetric(geoIdList, geoIdMap, isStartEndInverted, refGeoId, refPosId);
newgeoVals.insert(newgeoVals.end(), symmetricVals.begin(), symmetricVals.end());
std::vector<Part::Geometry*> symgeos = getSymmetric(geoIdList, geoIdMap, isStartEndInverted, refGeoId, refPosId);
// Block acceptGeometry in OnChanged to avoid unnecessary checks and updates
{
Base::StateLocker lock(internaltransaction, true);
Geometry.setValues(std::move(newgeoVals));
addGeometry(symgeos);
for (auto* constr : constrvals) {
// we look in the map, because we might have skipped internal alignment geometry
@@ -4812,6 +4804,7 @@ int SketchObject::addSymmetric(const std::vector<int>& geoIdList, int refGeoId,
if (constr->Type != Sketcher::DistanceX
&& constr->Type != Sketcher::DistanceY) {
Constraint* constNew = constr->copy();
constNew->Name = ""; // Make sure we don't have 2 constraint with same name.
constNew->First = fit->second;
newconstrVals.push_back(constNew);
}
@@ -4824,6 +4817,7 @@ int SketchObject::addSymmetric(const std::vector<int>& geoIdList, int refGeoId,
// diameter, weight,...
Constraint* constNew = constr->copy();
constNew->Name = "";
constNew->First = fit->second;
newconstrVals.push_back(constNew);
}
@@ -4844,7 +4838,7 @@ int SketchObject::addSymmetric(const std::vector<int>& geoIdList, int refGeoId,
|| constr->Type == Sketcher::PointOnObject
|| constr->Type == Sketcher::InternalAlignment) {
Constraint* constNew = constr->copy();
constNew->Name = "";
constNew->First = fit->second;
constNew->Second = sit->second;
if (isStartEndInverted[constr->First]) {
@@ -4876,6 +4870,7 @@ int SketchObject::addSymmetric(const std::vector<int>& geoIdList, int refGeoId,
if (tit != geoIdMap.end()) {// Third is also in the list
Constraint* constNew = constr->copy();
constNew->Name = "";
constNew->First = fit->second;
constNew->Second = sit->second;
constNew->Third = tit->second;