From 391eaff6cfe08d45cb9964bb67d6ebdea8c4bbef Mon Sep 17 00:00:00 2001 From: Abdullah Tahiri Date: Wed, 29 Mar 2017 23:31:29 +0200 Subject: [PATCH] Sketcher: Decrease multiplicity command adaptation to unique identifier --- .../Sketcher/Gui/CommandSketcherBSpline.cpp | 68 ++++++++----------- 1 file changed, 29 insertions(+), 39 deletions(-) diff --git a/src/Mod/Sketcher/Gui/CommandSketcherBSpline.cpp b/src/Mod/Sketcher/Gui/CommandSketcherBSpline.cpp index c66ab943a1..6539c5a3f8 100644 --- a/src/Mod/Sketcher/Gui/CommandSketcherBSpline.cpp +++ b/src/Mod/Sketcher/Gui/CommandSketcherBSpline.cpp @@ -696,6 +696,8 @@ void CmdSketcherDecreaseKnotMultiplicity::activated(int iMsg) bool applied = false; + boost::uuids::uuid bsplinetag; + int GeoId; Sketcher::PointPos PosId; getIdsFromName(SubNames[0], Obj, GeoId, PosId); @@ -707,6 +709,8 @@ void CmdSketcherDecreaseKnotMultiplicity::activated(int iMsg) for (std::vector< Sketcher::Constraint * >::const_iterator it= vals.begin(); it != vals.end(); ++it) { if((*it)->Type == Sketcher::InternalAlignment && (*it)->First == GeoId && (*it)->AlignmentType == Sketcher::BSplineKnotPoint) { + bsplinetag = Obj->getGeometry((*it)->Second)->getTag(); + try { Gui::Command::doCommand( Doc,"App.ActiveDocument.%s.modifyBSplineKnotMultiplicity(%d,%d,%d) ", @@ -730,49 +734,35 @@ void CmdSketcherDecreaseKnotMultiplicity::activated(int iMsg) } - // Grab the new GeoId of the knot after possible modifications - bool isnewGeoId = true; - selection = getSelection().getSelectionEx(); - - if (selection.size() != 1) - isnewGeoId = false; - - - const std::vector &SubNames2 = selection[0].getSubNames(); - - if(SubNames.size() == 1) - isnewGeoId = false; - - if(isnewGeoId) { + if(applied) + { + // find new geoid for bspline as GeoId might have changed + const std::vector< Part::Geometry * > &gvals = Obj->getInternalGeometry(); - getIdsFromName(SubNames2[0], Obj, GeoId, PosId); + int ngeoid = 0; + bool ngfound = false; - if(isSimpleVertex(Obj, GeoId, PosId) && applied) { - - const std::vector< Sketcher::Constraint * > &vals = Obj->Constraints.getValues(); - - for (std::vector< Sketcher::Constraint * >::const_iterator it= vals.begin(); it != vals.end(); ++it) { - if((*it)->Type == Sketcher::InternalAlignment && (*it)->First == GeoId && (*it)->AlignmentType == Sketcher::BSplineKnotPoint) - { - try { - Obj->solve(); - - // add internalalignment for new pole - Gui::Command::doCommand(Gui::Command::Doc, - "App.ActiveDocument.%s.exposeInternalGeometry(%d)", - selection[0].getFeatName(), - (*it)->Second); - } - catch (const Base::Exception& e) { - Base::Console().Error("%s\n", e.what()); - getSelection().clearSelection(); - } - - break; // we have already found our knot. - - } + for (std::vector::const_iterator geo = gvals.begin(); geo != gvals.end(); geo++, ngeoid++) { + if ((*geo) && (*geo)->getTag() == bsplinetag) { + ngfound = true; + break; } + } + + if(ngfound) { + try { + // add internalalignment for new pole + Gui::Command::doCommand(Gui::Command::Doc, + "App.ActiveDocument.%s.exposeInternalGeometry(%d)", + selection[0].getFeatName(), + ngeoid); + } + catch (const Base::Exception& e) { + Base::Console().Error("%s\n", e.what()); + getSelection().clearSelection(); + } + } }