diff --git a/src/Mod/Sketcher/App/Constraint.cpp b/src/Mod/Sketcher/App/Constraint.cpp index 1f846b7402..cd32c1e98f 100644 --- a/src/Mod/Sketcher/App/Constraint.cpp +++ b/src/Mod/Sketcher/App/Constraint.cpp @@ -56,7 +56,8 @@ Constraint::Constraint() ThirdPos(none), LabelDistance(10.f), LabelPosition(0.f), - isDriving(true) + isDriving(true), + InternalAlignmentIndex(-1) { // Initialize a random number generator, to avoid Valgrind false positives. static boost::mt19937 ran; @@ -85,7 +86,8 @@ Constraint::Constraint(const Constraint& from) LabelDistance(from.LabelDistance), LabelPosition(from.LabelPosition), isDriving(from.isDriving), - tag(from.tag) + tag(from.tag), + InternalAlignmentIndex(from.InternalAlignmentIndex) { } @@ -114,6 +116,7 @@ Constraint *Constraint::copy(void) const temp->LabelDistance = this->LabelDistance; temp->LabelPosition = this->LabelPosition; temp->isDriving = this->isDriving; + temp->InternalAlignmentIndex = this->InternalAlignmentIndex; // Do not copy tag, otherwise it is considered a clone, and a "rename" by the expression engine. return temp; } @@ -172,22 +175,24 @@ unsigned int Constraint::getMemSize (void) const void Constraint::Save (Writer &writer) const { writer.Stream() << writer.ind() << "Type==InternalAlignment) writer.Stream() - << "InternalAlignmentType=\"" << (int)AlignmentType << "\" "; + << "InternalAlignmentType=\"" << (int)AlignmentType << "\" " + << "InternalAlignmentIndex=\"" << InternalAlignmentIndex << "\" "; writer.Stream() - << "Value=\"" << Value << "\" " - << "First=\"" << First << "\" " - << "FirstPos=\"" << (int) FirstPos << "\" " - << "Second=\"" << Second << "\" " - << "SecondPos=\"" << (int) SecondPos << "\" " - << "Third=\"" << Third << "\" " - << "ThirdPos=\"" << (int) ThirdPos << "\" " - << "LabelDistance=\"" << LabelDistance << "\" " - << "LabelPosition=\"" << LabelPosition << "\" " - << "IsDriving=\"" << (int)isDriving << "\" />" + << "Value=\"" << Value << "\" " + << "First=\"" << First << "\" " + << "FirstPos=\"" << (int) FirstPos << "\" " + << "Second=\"" << Second << "\" " + << "SecondPos=\"" << (int) SecondPos << "\" " + << "Third=\"" << Third << "\" " + << "ThirdPos=\"" << (int) ThirdPos << "\" " + << "LabelDistance=\"" << LabelDistance << "\" " + << "LabelPosition=\"" << LabelPosition << "\" " + << "IsDriving=\"" << (int)isDriving << "\" />" + << std::endl; } @@ -202,10 +207,15 @@ void Constraint::Restore(XMLReader &reader) Second = reader.getAttributeAsInteger("Second"); SecondPos = (PointPos) reader.getAttributeAsInteger("SecondPos"); - if(this->Type==InternalAlignment) + if(this->Type==InternalAlignment) { AlignmentType = (InternalAlignmentType) reader.getAttributeAsInteger("InternalAlignmentType"); - else + + if (reader.hasAttribute("InternalAlignmentIndex")) + InternalAlignmentIndex = reader.getAttributeAsInteger("InternalAlignmentIndex"); + } + else { AlignmentType = Undef; + } // read the third geo group if present if (reader.hasAttribute("Third")) { diff --git a/src/Mod/Sketcher/App/Constraint.h b/src/Mod/Sketcher/App/Constraint.h index bc897198fc..e46691d073 100644 --- a/src/Mod/Sketcher/App/Constraint.h +++ b/src/Mod/Sketcher/App/Constraint.h @@ -111,11 +111,12 @@ public: PointPos FirstPos; int Second; PointPos SecondPos; - int Third; // Note: for InternalAlignment Type this index indexes equal internal geometry elements (e.g. index of pole in a bspline), thirdpos remains unused. It is not a GeoId. + int Third; PointPos ThirdPos; float LabelDistance; float LabelPosition; bool isDriving; + int InternalAlignmentIndex; // Note: for InternalAlignment Type this index indexes equal internal geometry elements (e.g. index of pole in a bspline). It is not a GeoId!! protected: boost::uuids::uuid tag; diff --git a/src/Mod/Sketcher/App/Sketch.cpp b/src/Mod/Sketcher/App/Sketch.cpp index c48db28ccd..6aad91d611 100644 --- a/src/Mod/Sketcher/App/Sketch.cpp +++ b/src/Mod/Sketcher/App/Sketch.cpp @@ -1198,7 +1198,7 @@ int Sketch::addConstraint(const Constraint *constraint) rtn = addInternalAlignmentParabolaFocus(constraint->First,constraint->Second); break; case BSplineControlPoint: - rtn = addInternalAlignmentBSplineControlPoint(constraint->First,constraint->Second, constraint->Third); + rtn = addInternalAlignmentBSplineControlPoint(constraint->First,constraint->Second, constraint->InternalAlignmentIndex); default: break; } diff --git a/src/Mod/Sketcher/App/SketchObject.cpp b/src/Mod/Sketcher/App/SketchObject.cpp index f5660eb67a..149330cae6 100644 --- a/src/Mod/Sketcher/App/SketchObject.cpp +++ b/src/Mod/Sketcher/App/SketchObject.cpp @@ -3326,8 +3326,8 @@ int SketchObject::ExposeInternalGeometry(int GeoId) { switch((*it)->AlignmentType){ case Sketcher::BSplineControlPoint: - controlpoints[(*it)->Third] = true; - controlpointgeoids[(*it)->Third] = (*it)->First; + controlpoints[(*it)->InternalAlignmentIndex] = true; + controlpointgeoids[(*it)->InternalAlignmentIndex] = (*it)->First; break; default: return -1; @@ -3373,7 +3373,7 @@ int SketchObject::ExposeInternalGeometry(int GeoId) newConstr->First = currentgeoid+incrgeo+1; newConstr->FirstPos = Sketcher::mid; newConstr->Second = GeoId; - newConstr->Third = index; + newConstr->InternalAlignmentIndex = index; icon.push_back(newConstr);