diff --git a/src/Mod/Sketcher/App/Constraint.cpp b/src/Mod/Sketcher/App/Constraint.cpp index 1fd90f435..35e78685e 100644 --- a/src/Mod/Sketcher/App/Constraint.cpp +++ b/src/Mod/Sketcher/App/Constraint.cpp @@ -97,6 +97,26 @@ Constraint *Constraint::clone(void) const return new Constraint(*this); } +Constraint *Constraint::copy(void) const +{ + Constraint *temp = new Constraint(); + temp->Value = this->Value; + temp->Type = this->Type; + temp->AlignmentType = this->AlignmentType; + temp->Name = this->Name; + temp->First = this->First; + temp->FirstPos = this->FirstPos; + temp->Second = this->Second; + temp->SecondPos = this->SecondPos; + temp->Third = this->Third; + temp->ThirdPos = this->ThirdPos; + temp->LabelDistance = this->LabelDistance; + temp->LabelPosition = this->LabelPosition; + temp->isDriving = this->isDriving; + // Do not copy tag, otherwise it is considered a clone, and a "rename" by the expression engine. + return temp; +} + PyObject *Constraint::getPyObject(void) { return new ConstraintPy(new Constraint(*this)); diff --git a/src/Mod/Sketcher/App/Constraint.h b/src/Mod/Sketcher/App/Constraint.h index 11102e7f8..0a4bb5efa 100644 --- a/src/Mod/Sketcher/App/Constraint.h +++ b/src/Mod/Sketcher/App/Constraint.h @@ -71,7 +71,8 @@ public: Constraint(); Constraint(const Constraint&); virtual ~Constraint(); - virtual Constraint *clone(void) const; + virtual Constraint *clone(void) const; // does copy the tag, it will be treated as a rename by the expression engine. + virtual Constraint *copy(void) const; // does not copy the tag, but generates a new one static const int GeoUndef; diff --git a/src/Mod/Sketcher/App/SketchObject.cpp b/src/Mod/Sketcher/App/SketchObject.cpp index 1825413a0..9fb5b3090 100644 --- a/src/Mod/Sketcher/App/SketchObject.cpp +++ b/src/Mod/Sketcher/App/SketchObject.cpp @@ -49,7 +49,7 @@ #include #include -#include +#include #include #include #include @@ -1951,7 +1951,7 @@ int SketchObject::addSymmetric(const std::vector &geoIdList, int refGeoId, if( (*it)->Type != Sketcher::DistanceX && (*it)->Type != Sketcher::DistanceY) { - Constraint *constNew = (*it)->clone(); + Constraint *constNew = (*it)->copy(); constNew->First = geoIdMap[(*it)->First]; newconstrVals.push_back(constNew); @@ -1972,7 +1972,7 @@ int SketchObject::addSymmetric(const std::vector &geoIdList, int refGeoId, (*it)->Type == Sketcher::Equal || (*it)->Type == Sketcher::Radius || (*it)->Type == Sketcher::PointOnObject ){ - Constraint *constNew = (*it)->clone(); + Constraint *constNew = (*it)->copy(); constNew->First = geoIdMap[(*it)->First]; constNew->Second = geoIdMap[(*it)->Second]; @@ -1999,7 +1999,7 @@ int SketchObject::addSymmetric(const std::vector &geoIdList, int refGeoId, std::vector::const_iterator tit=std::find(geoIdList.begin(), geoIdList.end(), (*it)->Third); if(tit != geoIdList.end()) { // Third is also in the list - Constraint *constNew = (*it)->clone(); + Constraint *constNew = (*it)->copy(); constNew->First = geoIdMap[(*it)->First]; constNew->Second = geoIdMap[(*it)->Second]; constNew->Third = geoIdMap[(*it)->Third]; @@ -2182,20 +2182,20 @@ int SketchObject::addCopy(const std::vector &geoIdList, const Base::Vector3 (*it)->Type == Sketcher::Distance || (*it)->Type == Sketcher::Radius ) && clone ) { // Distances on a single Element are mapped to equality constraints in clone mode - Constraint *constNew = (*it)->clone(); + Constraint *constNew = (*it)->copy(); constNew->Type = Sketcher::Equal; constNew->Second = geoIdMap[(*it)->First]; // first is already (*it->First) newconstrVals.push_back(constNew); } else if ((*it)->Type == Sketcher::Angle && clone){ // Angles on a single Element are mapped to parallel constraints in clone mode - Constraint *constNew = (*it)->clone(); + Constraint *constNew = (*it)->copy(); constNew->Type = Sketcher::Parallel; constNew->Second = geoIdMap[(*it)->First]; // first is already (*it->First) newconstrVals.push_back(constNew); } else { - Constraint *constNew = (*it)->clone(); + Constraint *constNew = (*it)->copy(); constNew->First = geoIdMap[(*it)->First]; newconstrVals.push_back(constNew); } @@ -2211,7 +2211,7 @@ int SketchObject::addCopy(const std::vector &geoIdList, const Base::Vector3 (*it)->Type == Sketcher::DistanceY || (*it)->Type == Sketcher::Distance) && ((*it)->First == (*it)->Second) && clone ) { // Distances on a two Elements, which must be points of the same line are mapped to equality constraints in clone mode - Constraint *constNew = (*it)->clone(); + Constraint *constNew = (*it)->copy(); constNew->Type = Sketcher::Equal; constNew->FirstPos = Sketcher::none; constNew->Second = geoIdMap[(*it)->First]; // first is already (*it->First) @@ -2219,7 +2219,7 @@ int SketchObject::addCopy(const std::vector &geoIdList, const Base::Vector3 newconstrVals.push_back(constNew); } else { - Constraint *constNew = (*it)->clone(); + Constraint *constNew = (*it)->copy(); constNew->First = geoIdMap[(*it)->First]; constNew->Second = geoIdMap[(*it)->Second]; newconstrVals.push_back(constNew); @@ -2229,7 +2229,7 @@ int SketchObject::addCopy(const std::vector &geoIdList, const Base::Vector3 std::vector::const_iterator tit=std::find(geoIdList.begin(), geoIdList.end(), (*it)->Third); if(tit != geoIdList.end()) { // Third is also in the list - Constraint *constNew = (*it)->clone(); + Constraint *constNew = (*it)->copy(); constNew->First = geoIdMap[(*it)->First]; constNew->Second = geoIdMap[(*it)->Second]; constNew->Third = geoIdMap[(*it)->Third];