From 622228d59e58631f6282b44b467aa35192e65d10 Mon Sep 17 00:00:00 2001 From: wmayer Date: Sat, 12 Oct 2013 15:16:46 +0200 Subject: [PATCH] 0001258: Constraint application to all selected objects at once --- src/Mod/Sketcher/Gui/CommandConstraints.cpp | 33 +++++++++++++-------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/src/Mod/Sketcher/Gui/CommandConstraints.cpp b/src/Mod/Sketcher/Gui/CommandConstraints.cpp index 086ae112e..bc3fd208a 100644 --- a/src/Mod/Sketcher/Gui/CommandConstraints.cpp +++ b/src/Mod/Sketcher/Gui/CommandConstraints.cpp @@ -520,28 +520,35 @@ void CmdSketcherConstrainCoincident::activated(int iMsg) const std::vector &SubNames = selection[0].getSubNames(); Sketcher::SketchObject* Obj = dynamic_cast(selection[0].getObject()); - if (SubNames.size() != 2) { + if (SubNames.size() < 2) { QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"), - QObject::tr("Select exactly two vertexes from the sketch.")); + QObject::tr("Select two or more vertexes from the sketch.")); return; } + for (std::vector::const_iterator it = SubNames.begin(); it != SubNames.end(); ++it) { + int GeoId; + Sketcher::PointPos PosId; + getIdsFromName(*it, Obj, GeoId, PosId); + if (isEdge(GeoId,PosId)) { + QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"), + QObject::tr("Select two or more vertexes from the sketch.")); + return; + } + } + int GeoId1, GeoId2; Sketcher::PointPos PosId1, PosId2; getIdsFromName(SubNames[0], Obj, GeoId1, PosId1); - getIdsFromName(SubNames[1], Obj, GeoId2, PosId2); - - if (isEdge(GeoId1,PosId1) || isEdge(GeoId2,PosId2)) { - QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"), - QObject::tr("Select exactly two vertexes from the sketch.")); - return; - } // undo command open openCommand("add coincident constraint"); - Gui::Command::doCommand( - Doc,"App.ActiveDocument.%s.addConstraint(Sketcher.Constraint('Coincident',%d,%d,%d,%d)) ", - selection[0].getFeatName(),GeoId1,PosId1,GeoId2,PosId2); + for (std::size_t i=1; i