From b0ec0931cb60c60115ed68ec720bdf0a61cf5049 Mon Sep 17 00:00:00 2001 From: Yorik van Havre Date: Mon, 13 Feb 2012 20:11:14 -0200 Subject: [PATCH] Added Std_Edit FreeCAD command That command (located in the Edit menu) toggles (enters or leaves) the Edit mode of a selected object. --- src/Gui/CommandDoc.cpp | 43 +++++++++++ src/Gui/Icons/edit-edit.svg | 149 ++++++++++++++++++++++++++++++++++++ src/Gui/Icons/resource.qrc | 1 + src/Gui/Workbench.cpp | 2 +- 4 files changed, 194 insertions(+), 1 deletion(-) create mode 100644 src/Gui/Icons/edit-edit.svg diff --git a/src/Gui/CommandDoc.cpp b/src/Gui/CommandDoc.cpp index 8e1e79cfb..8bbe611c0 100644 --- a/src/Gui/CommandDoc.cpp +++ b/src/Gui/CommandDoc.cpp @@ -52,6 +52,8 @@ #include "Placement.h" #include "WaitCursor.h" #include "ViewProvider.h" +#include +#include #include "MergeDocuments.h" using namespace Gui; @@ -1022,6 +1024,46 @@ bool StdCmdPlacement::isActive(void) return (Gui::Control().activeDialog()==0); } +//=========================================================================== +// Std_Edit +//=========================================================================== +DEF_STD_CMD_A(StdCmdEdit); + +StdCmdEdit::StdCmdEdit() + :Command("Std_Edit") +{ + sGroup = QT_TR_NOOP("Edit"); + sMenuText = QT_TR_NOOP("Toggle &Editmode"); + sToolTipText = QT_TR_NOOP("Toggles the selected object's edit mode"); + sWhatsThis = "Std_Edit"; + sStatusTip = QT_TR_NOOP("Enters or leaves the selected object's edit mode"); +#if QT_VERSION >= 0x040200 + sPixmap = "edit-edit"; +#endif + eType = ForEdit; +} + +void StdCmdEdit::activated(int iMsg) +{ + Gui::MDIView* view = Gui::getMainWindow()->activeWindow(); + if (view && view->isDerivedFrom(Gui::View3DInventor::getClassTypeId())) { + Gui::View3DInventorViewer* viewer = static_cast(view)->getViewer(); + if (viewer->isEditingViewProvider()) { + doCommand(Command::Gui,"Gui.activeDocument().resetEdit()"); + } else { + if (Selection().getCompleteSelection().size() > 0) { + SelectionSingleton::SelObj obj = Selection().getCompleteSelection()[0]; + doCommand(Command::Gui,"Gui.activeDocument().setEdit(\"%s\",0)",obj.FeatName); + } + } + } +} + +bool StdCmdEdit::isActive(void) +{ + return (Selection().getCompleteSelection().size() > 0) || (Gui::Control().activeDialog() != 0); +} + namespace Gui { @@ -1054,6 +1096,7 @@ void CreateDocCommands(void) rcCmdMgr.addCommand(new StdCmdRefresh()); rcCmdMgr.addCommand(new StdCmdTransform()); rcCmdMgr.addCommand(new StdCmdPlacement()); + rcCmdMgr.addCommand(new StdCmdEdit()); } } // namespace Gui diff --git a/src/Gui/Icons/edit-edit.svg b/src/Gui/Icons/edit-edit.svg new file mode 100644 index 000000000..d63fb7ce7 --- /dev/null +++ b/src/Gui/Icons/edit-edit.svg @@ -0,0 +1,149 @@ + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + diff --git a/src/Gui/Icons/resource.qrc b/src/Gui/Icons/resource.qrc index 78a314d16..82548cd39 100644 --- a/src/Gui/Icons/resource.qrc +++ b/src/Gui/Icons/resource.qrc @@ -45,6 +45,7 @@ edit-select-all.svg edit-redo.svg edit-undo.svg + edit-edit.svg help-browser.svg preferences-system.svg window-new.svg diff --git a/src/Gui/Workbench.cpp b/src/Gui/Workbench.cpp index b3e1115d0..749278fb0 100644 --- a/src/Gui/Workbench.cpp +++ b/src/Gui/Workbench.cpp @@ -440,7 +440,7 @@ MenuItem* StdWorkbench::setupMenuBar() const *edit << "Std_Undo" << "Std_Redo" << "Separator" << "Std_Cut" << "Std_Copy" << "Std_Paste" << "Std_DuplicateSelection" << "Separator" << "Std_Refresh" << "Std_SelectAll" << "Std_Delete" << "Std_Placement" - << "Separator" << "Std_DlgPreferences"; + << "Std_Edit" << "Separator" << "Std_DlgPreferences"; // Standard views MenuItem* stdviews = new MenuItem;