diff --git a/src/Mod/Sketcher/Gui/CommandSketcherTools.cpp b/src/Mod/Sketcher/Gui/CommandSketcherTools.cpp index 261dcb6583..ccf7d7b403 100644 --- a/src/Mod/Sketcher/Gui/CommandSketcherTools.cpp +++ b/src/Mod/Sketcher/Gui/CommandSketcherTools.cpp @@ -63,205 +63,6 @@ using namespace Sketcher; // ================================================================================ -// Close Shape Command -DEF_STD_CMD_A(CmdSketcherCloseShape) - -CmdSketcherCloseShape::CmdSketcherCloseShape() - :Command("Sketcher_CloseShape") -{ - sAppModule = "Sketcher"; - sGroup = "Sketcher"; - sMenuText = QT_TR_NOOP("Close shape"); - sToolTipText = QT_TR_NOOP("Produce a closed shape by tying the end point " - "of one element with the next element's starting point"); - sWhatsThis = "Sketcher_CloseShape"; - sStatusTip = sToolTipText; - sPixmap = "Sketcher_CloseShape"; - sAccel = "Z, W"; - eType = ForEdit; -} - -void CmdSketcherCloseShape::activated(int iMsg) -{ - Q_UNUSED(iMsg); - - // Cancel any in-progress operation - Gui::Document* doc = Gui::Application::Instance->activeDocument(); - SketcherGui::ReleaseHandler(doc); - - // get the selection - std::vector selection; - selection = getSelection().getSelectionEx(nullptr, 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"), - QObject::tr("Select at least two edges from the sketch.")); - return; - } - - // get the needed lists and objects - const std::vector &SubNames = selection[0].getSubNames(); - if (SubNames.size() < 2) { - QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"), - QObject::tr("Select at least two edges from the sketch.")); - return; - } - - Sketcher::SketchObject* Obj = static_cast(selection[0].getObject()); - - int GeoIdFirst = -1; - int GeoIdLast = -1; - - // undo command open - openCommand(QT_TRANSLATE_NOOP("Command", "Add coincident constraint")); - // go through the selected subelements - for (size_t i=0; i < (SubNames.size() - 1); i++) { - // only handle edges - if (SubNames[i].size() > 4 && SubNames[i].substr(0,4) == "Edge" && - SubNames[i+1].size() > 4 && SubNames[i+1].substr(0,4) == "Edge") { - - int GeoId1 = std::atoi(SubNames[i].substr(4,4000).c_str()) - 1; - int GeoId2 = std::atoi(SubNames[i+1].substr(4,4000).c_str()) - 1; - - if (GeoIdFirst == -1) - GeoIdFirst = GeoId1; - - GeoIdLast = GeoId2; - - const Part::Geometry *geo1 = Obj->getGeometry(GeoId1); - const Part::Geometry *geo2 = Obj->getGeometry(GeoId2); - if ((geo1->getTypeId() != Part::GeomLineSegment::getClassTypeId() && - geo1->getTypeId() != Part::GeomArcOfCircle::getClassTypeId()) || - (geo2->getTypeId() != Part::GeomLineSegment::getClassTypeId() && - geo2->getTypeId() != Part::GeomArcOfCircle::getClassTypeId())) { - QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Impossible constraint"), - QObject::tr("One selected edge is not connectable")); - abortCommand(); - return; - } - - // Check for the special case of closing a shape with two lines to avoid overlap - if (SubNames.size() == 2 && - geo1->getTypeId() == Part::GeomLineSegment::getClassTypeId() && - geo2->getTypeId() == Part::GeomLineSegment::getClassTypeId() ) { - QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"), - QObject::tr("Closing a shape formed by exactly two lines makes no sense.")); - abortCommand(); - return; - } - - Gui::cmdAppObjectArgs(selection[0].getObject(), - "addConstraint(Sketcher.Constraint('Coincident', %d, %d, %d, %d)) ", - GeoId1, static_cast(Sketcher::PointPos::end), GeoId2, static_cast(Sketcher::PointPos::start)); - } - } - - // Close Last Edge with First Edge - Gui::cmdAppObjectArgs(selection[0].getObject(), - "addConstraint(Sketcher.Constraint('Coincident', %d, %d, %d, %d)) ", - GeoIdLast, static_cast(Sketcher::PointPos::end), GeoIdFirst, static_cast(Sketcher::PointPos::start)); - - // finish the transaction and update, and clear the selection (convenience) - commitCommand(); - tryAutoRecompute(Obj); - getSelection().clearSelection(); -} - -bool CmdSketcherCloseShape::isActive(void) -{ - return isCommandActive(getActiveGuiDocument(), true); -} - -// ================================================================================ - -// Connect Edges Command -DEF_STD_CMD_A(CmdSketcherConnect) - -CmdSketcherConnect::CmdSketcherConnect() - :Command("Sketcher_ConnectLines") -{ - sAppModule = "Sketcher"; - sGroup = "Sketcher"; - sMenuText = QT_TR_NOOP("Connect edges"); - sToolTipText = QT_TR_NOOP("Tie the end point of the element with next element's starting point"); - sWhatsThis = "Sketcher_ConnectLines"; - sStatusTip = sToolTipText; - sPixmap = "Sketcher_ConnectLines"; - sAccel = "Z, J"; - eType = ForEdit; -} - -void CmdSketcherConnect::activated(int iMsg) -{ - Q_UNUSED(iMsg); - - // Cancel any in-progress operation - Gui::Document* doc = Gui::Application::Instance->activeDocument(); - SketcherGui::ReleaseHandler(doc); - - // get the selection - std::vector selection; - selection = getSelection().getSelectionEx(nullptr, 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"), - QObject::tr("Select at least two edges from the sketch.")); - return; - } - - // get the needed lists and objects - const std::vector &SubNames = selection[0].getSubNames(); - if (SubNames.size() < 2) { - QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"), - QObject::tr("Select at least two edges from the sketch.")); - return; - } - Sketcher::SketchObject* Obj = static_cast(selection[0].getObject()); - - // undo command open - openCommand(QT_TRANSLATE_NOOP("Command", "Add coincident constraint")); - - // go through the selected subelements - for (unsigned int i=0; i<(SubNames.size()-1); i++ ) { - // only handle edges - if (SubNames[i].size() > 4 && SubNames[i].substr(0,4) == "Edge" && - SubNames[i+1].size() > 4 && SubNames[i+1].substr(0,4) == "Edge") { - - int GeoId1 = std::atoi(SubNames[i].substr(4,4000).c_str()) - 1; - int GeoId2 = std::atoi(SubNames[i+1].substr(4,4000).c_str()) - 1; - - const Part::Geometry *geo1 = Obj->getGeometry(GeoId1); - const Part::Geometry *geo2 = Obj->getGeometry(GeoId2); - if ((geo1->getTypeId() != Part::GeomLineSegment::getClassTypeId() && - geo1->getTypeId() != Part::GeomArcOfCircle::getClassTypeId()) || - (geo2->getTypeId() != Part::GeomLineSegment::getClassTypeId() && - geo2->getTypeId() != Part::GeomArcOfCircle::getClassTypeId())) { - QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Impossible constraint"), - QObject::tr("One selected edge is not connectable")); - abortCommand(); - return; - } - - Gui::cmdAppObjectArgs(selection[0].getObject(),"addConstraint(Sketcher.Constraint('Coincident',%d,%d,%d,%d)) ", - GeoId1,static_cast(Sketcher::PointPos::end),GeoId2,static_cast(Sketcher::PointPos::start)); - } - } - - // finish the transaction and update, and clear the selection (convenience) - commitCommand(); - tryAutoRecompute(Obj); - getSelection().clearSelection(); -} - -bool CmdSketcherConnect::isActive(void) -{ - return isCommandActive(getActiveGuiDocument(), true); -} - -// ================================================================================ - // Select Constraints of selected elements DEF_STD_CMD_A(CmdSketcherSelectConstraints) @@ -2348,8 +2149,6 @@ void CreateSketcherCommandsConstraintAccel(void) { Gui::CommandManager &rcCmdMgr = Gui::Application::Instance->commandManager(); - rcCmdMgr.addCommand(new CmdSketcherCloseShape()); - rcCmdMgr.addCommand(new CmdSketcherConnect()); rcCmdMgr.addCommand(new CmdSketcherSelectConstraints()); rcCmdMgr.addCommand(new CmdSketcherSelectOrigin()); rcCmdMgr.addCommand(new CmdSketcherSelectVerticalAxis()); diff --git a/src/Mod/Sketcher/Gui/Resources/Sketcher.qrc b/src/Mod/Sketcher/Gui/Resources/Sketcher.qrc index d54c2bfb63..c4063a78a9 100644 --- a/src/Mod/Sketcher/Gui/Resources/Sketcher.qrc +++ b/src/Mod/Sketcher/Gui/Resources/Sketcher.qrc @@ -222,8 +222,6 @@ icons/tools/Sketcher_Clone.svg - icons/tools/Sketcher_CloseShape.svg - icons/tools/Sketcher_ConnectLines.svg icons/tools/Sketcher_Copy.svg icons/tools/Sketcher_DeleteConstraints.svg icons/tools/Sketcher_DeleteGeometry.svg diff --git a/src/Mod/Sketcher/Gui/Resources/icons/tools/Sketcher_CloseShape.svg b/src/Mod/Sketcher/Gui/Resources/icons/tools/Sketcher_CloseShape.svg deleted file mode 100644 index a0d011eb00..0000000000 --- a/src/Mod/Sketcher/Gui/Resources/icons/tools/Sketcher_CloseShape.svg +++ /dev/null @@ -1,121 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - [wmayer] - - - 2014-08-04 - http://www.freecadweb.org/wiki/index.php?title=Artwork - - - FreeCAD - - - FreeCAD/src/Mod/Sketcher/Gui/Resources/icons/Sketcher_CloseShape.svg - - - FreeCAD LGPL2+ - - - https://www.gnu.org/copyleft/lesser.html - - - [agryson] Alexander Gryson - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Mod/Sketcher/Gui/Resources/icons/tools/Sketcher_ConnectLines.svg b/src/Mod/Sketcher/Gui/Resources/icons/tools/Sketcher_ConnectLines.svg deleted file mode 100644 index a990cbddfd..0000000000 --- a/src/Mod/Sketcher/Gui/Resources/icons/tools/Sketcher_ConnectLines.svg +++ /dev/null @@ -1,109 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - [wmayer] - - - 2014-08-04 - http://www.freecadweb.org/wiki/index.php?title=Artwork - - - FreeCAD - - - FreeCAD/src/Mod/Sketcher/Gui/Resources/icons/Sketcher_ConnectLines.svg - - - FreeCAD LGPL2+ - - - https://www.gnu.org/copyleft/lesser.html - - - [agryson] Alexander Gryson - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Mod/Sketcher/Gui/Workbench.cpp b/src/Mod/Sketcher/Gui/Workbench.cpp index f32ec401f1..37ac84f1e4 100644 --- a/src/Mod/Sketcher/Gui/Workbench.cpp +++ b/src/Mod/Sketcher/Gui/Workbench.cpp @@ -358,8 +358,6 @@ template <> inline void SketcherAddWorkbenchTools(Gui::MenuItem& consaccel) { consaccel << "Sketcher_SelectElementsWithDoFs" - << "Sketcher_CloseShape" - << "Sketcher_ConnectLines" << "Sketcher_SelectConstraints" << "Sketcher_SelectElementsAssociatedWithConstraints" << "Sketcher_SelectRedundantConstraints" @@ -385,8 +383,6 @@ template <> inline void SketcherAddWorkbenchTools(Gui::ToolBarItem& consaccel) { consaccel << "Sketcher_SelectElementsWithDoFs" - << "Sketcher_CloseShape" - << "Sketcher_ConnectLines" << "Sketcher_SelectConstraints" << "Sketcher_SelectElementsAssociatedWithConstraints" << "Sketcher_SelectRedundantConstraints"