diff --git a/src/Mod/Sketcher/Gui/CommandAlterGeometry.cpp b/src/Mod/Sketcher/Gui/CommandAlterGeometry.cpp index 56cb3a696c..7c8ef120b4 100644 --- a/src/Mod/Sketcher/Gui/CommandAlterGeometry.cpp +++ b/src/Mod/Sketcher/Gui/CommandAlterGeometry.cpp @@ -113,9 +113,10 @@ void CmdSketcherToggleConstruction::activated(int iMsg) else // there was a selection, so operate in toggle mode. { // get the selection - std::vector selection = getSelection().getSelectionEx(); - - Sketcher::SketchObject* Obj = static_cast(selection[0].getObject()); + std::vector selection; + selection = getSelection().getSelectionEx(0, Sketcher::SketchObject::getClassTypeId()); + + Sketcher::SketchObject* Obj = static_cast(selection[0].getObject()); // only one sketch with its subelements are allowed to be selected if (selection.size() != 1) { diff --git a/src/Mod/Sketcher/Gui/CommandSketcherBSpline.cpp b/src/Mod/Sketcher/Gui/CommandSketcherBSpline.cpp index 763d9905ce..d2c7d7de76 100644 --- a/src/Mod/Sketcher/Gui/CommandSketcherBSpline.cpp +++ b/src/Mod/Sketcher/Gui/CommandSketcherBSpline.cpp @@ -360,7 +360,8 @@ void CmdSketcherConvertToNURB::activated(int iMsg) Q_UNUSED(iMsg); // get the selection - std::vector selection = getSelection().getSelectionEx(); + std::vector selection; + selection = getSelection().getSelectionEx(0, Sketcher::SketchObject::getClassTypeId()); // only one sketch with its subelements are allowed to be selected if (selection.size() != 1) { @@ -440,7 +441,8 @@ void CmdSketcherIncreaseDegree::activated(int iMsg) Q_UNUSED(iMsg); // get the selection - std::vector selection = getSelection().getSelectionEx(); + std::vector selection; + selection = getSelection().getSelectionEx(0, Sketcher::SketchObject::getClassTypeId()); // only one sketch with its subelements are allowed to be selected if (selection.size() != 1) { @@ -525,8 +527,9 @@ void CmdSketcherIncreaseKnotMultiplicity::activated(int iMsg) #endif // get the selection - std::vector selection = getSelection().getSelectionEx(); - + std::vector selection; + selection = getSelection().getSelectionEx(0, Sketcher::SketchObject::getClassTypeId()); + // only one sketch with its subelements are allowed to be selected if (selection.size() != 1) { return; @@ -685,8 +688,9 @@ void CmdSketcherDecreaseKnotMultiplicity::activated(int iMsg) #endif // get the selection - std::vector selection = getSelection().getSelectionEx(); - + std::vector selection; + selection = getSelection().getSelectionEx(0, Sketcher::SketchObject::getClassTypeId()); + // only one sketch with its subelements are allowed to be selected if (selection.size() != 1) { return; diff --git a/src/Mod/Sketcher/Gui/CommandSketcherTools.cpp b/src/Mod/Sketcher/Gui/CommandSketcherTools.cpp index e2694536ec..c5682bbebc 100644 --- a/src/Mod/Sketcher/Gui/CommandSketcherTools.cpp +++ b/src/Mod/Sketcher/Gui/CommandSketcherTools.cpp @@ -109,7 +109,8 @@ void CmdSketcherCloseShape::activated(int iMsg) { Q_UNUSED(iMsg); // get the selection - std::vector selection = getSelection().getSelectionEx(); + std::vector selection; + selection = getSelection().getSelectionEx(0, Sketcher::SketchObject::getClassTypeId()); // only one sketch with its subelements are allowed to be selected if (selection.size() != 1) { @@ -216,7 +217,8 @@ void CmdSketcherConnect::activated(int iMsg) { Q_UNUSED(iMsg); // get the selection - std::vector selection = getSelection().getSelectionEx(); + std::vector selection; + selection = getSelection().getSelectionEx(0, Sketcher::SketchObject::getClassTypeId()); // only one sketch with its subelements are allowed to be selected if (selection.size() != 1) { @@ -299,7 +301,8 @@ void CmdSketcherSelectConstraints::activated(int iMsg) { Q_UNUSED(iMsg); // get the selection - std::vector selection = getSelection().getSelectionEx(); + std::vector selection; + selection = getSelection().getSelectionEx(0, Sketcher::SketchObject::getClassTypeId()); // only one sketch with its subelements are allowed to be selected if (selection.size() != 1) { @@ -830,7 +833,8 @@ void CmdSketcherRestoreInternalAlignmentGeometry::activated(int iMsg) { Q_UNUSED(iMsg); // get the selection - std::vector selection = getSelection().getSelectionEx(); + std::vector selection; + selection = getSelection().getSelectionEx(0, Sketcher::SketchObject::getClassTypeId()); // only one sketch with its subelements are allowed to be selected if (selection.size() != 1) { @@ -928,7 +932,8 @@ void CmdSketcherSymmetry::activated(int iMsg) { Q_UNUSED(iMsg); // get the selection - std::vector selection = getSelection().getSelectionEx(); + std::vector selection; + selection = getSelection().getSelectionEx(0, Sketcher::SketchObject::getClassTypeId()); // only one sketch with its subelements are allowed to be selected if (selection.size() != 1) { @@ -1823,8 +1828,9 @@ void CmdSketcherRectangularArray::activated(int iMsg) { Q_UNUSED(iMsg); // get the selection - std::vector selection = getSelection().getSelectionEx(); - + std::vector selection; + selection = getSelection().getSelectionEx(0, Sketcher::SketchObject::getClassTypeId()); + // only one sketch with its subelements are allowed to be selected if (selection.size() != 1) { QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"), diff --git a/src/Mod/Sketcher/Gui/CommandSketcherVirtualSpace.cpp b/src/Mod/Sketcher/Gui/CommandSketcherVirtualSpace.cpp index 822f7c9cc5..b21d18451d 100644 --- a/src/Mod/Sketcher/Gui/CommandSketcherVirtualSpace.cpp +++ b/src/Mod/Sketcher/Gui/CommandSketcherVirtualSpace.cpp @@ -108,22 +108,22 @@ void CmdSketcherSwitchVirtualSpace::activated(int iMsg) { Q_UNUSED(iMsg); bool modeChange=true; - + std::vector selection; - + if (Gui::Selection().countObjectsOfType(Sketcher::SketchObject::getClassTypeId()) > 0){ // Now we check whether we have a constraint selected or not. - + // get the selection selection = getSelection().getSelectionEx(); - + // only one sketch with its subelements are allowed to be selected - if (selection.size() != 1) { + if (selection.size() != 1 || !selection[0].isObjectTypeOf(Sketcher::SketchObject::getClassTypeId())) { QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"), QObject::tr("Select constraint(s) from the sketch.")); return; } - + // get the needed lists and objects const std::vector &SubNames = selection[0].getSubNames(); if (SubNames.empty()) { @@ -131,7 +131,7 @@ void CmdSketcherSwitchVirtualSpace::activated(int iMsg) QObject::tr("Select constraint(s) from the sketch.")); return; } - + for (std::vector::const_iterator it=SubNames.begin();it!=SubNames.end();++it){ // see if we have constraints, if we do it is not a mode change, but a toggle. if (it->size() > 10 && it->substr(0,10) == "Constraint")