diff --git a/src/Mod/PartDesign/Gui/Command.cpp b/src/Mod/PartDesign/Gui/Command.cpp index 6c03b3c232..3bf2379f77 100644 --- a/src/Mod/PartDesign/Gui/Command.cpp +++ b/src/Mod/PartDesign/Gui/Command.cpp @@ -298,6 +298,49 @@ bool CmdPartDesignShapeBinder::isActive(void) return hasActiveDocument (); } +//=========================================================================== +// PartDesign_Clone +//=========================================================================== + +DEF_STD_CMD_A(CmdPartDesignClone) + +CmdPartDesignClone::CmdPartDesignClone() + :Command("PartDesign_Clone") +{ + sAppModule = "PartDesign"; + sGroup = QT_TR_NOOP("PartDesign"); + sMenuText = QT_TR_NOOP("Create a clone"); + sToolTipText = QT_TR_NOOP("Create a new clone"); + sWhatsThis = "PartDesign_Clone"; + sStatusTip = sToolTipText; + sPixmap = "PartDesign_Clone"; +} + +void CmdPartDesignClone::activated(int iMsg) +{ + Q_UNUSED(iMsg); + std::string FeatName = getUniqueObjectName("Clone"); + std::vector objs = getSelection().getObjectsOfType + (Part::Feature::getClassTypeId()); + if (objs.size() == 1) { + openCommand("Create Clone"); + doCommand(Command::Doc,"App.ActiveDocument.addObject('PartDesign::FeatureBase','%s')", + FeatName.c_str()); + doCommand(Command::Doc,"App.ActiveDocument.ActiveObject.BaseFeature = App.ActiveDocument.%s", + objs.front()->getNameInDocument()); + doCommand(Command::Doc,"App.ActiveDocument.ActiveObject.Placement = App.ActiveDocument.%s.Placement", + objs.front()->getNameInDocument()); + doCommand(Command::Doc,"App.ActiveDocument.ActiveObject.setEditorMode('Placement',0)"); + commitCommand(); + updateActive(); + } +} + +bool CmdPartDesignClone::isActive(void) +{ + return getSelection().countObjectsOfType(Part::Feature::getClassTypeId()) == 1; +} + //=========================================================================== // PartDesign_Sketch //=========================================================================== @@ -2158,6 +2201,7 @@ void CreatePartDesignCommands(void) Gui::CommandManager &rcCmdMgr = Gui::Application::Instance->commandManager(); rcCmdMgr.addCommand(new CmdPartDesignShapeBinder()); + rcCmdMgr.addCommand(new CmdPartDesignClone()); rcCmdMgr.addCommand(new CmdPartDesignPlane()); rcCmdMgr.addCommand(new CmdPartDesignLine()); rcCmdMgr.addCommand(new CmdPartDesignPoint()); diff --git a/src/Mod/PartDesign/Gui/Resources/PartDesign.qrc b/src/Mod/PartDesign/Gui/Resources/PartDesign.qrc index 7630713cce..ea41c732b9 100644 --- a/src/Mod/PartDesign/Gui/Resources/PartDesign.qrc +++ b/src/Mod/PartDesign/Gui/Resources/PartDesign.qrc @@ -17,6 +17,7 @@ icons/PartDesign_Body.svg icons/PartDesign_Boolean.svg icons/PartDesign_ShapeBinder.svg + icons/PartDesign_Clone.svg icons/PartDesign_Plane.svg icons/PartDesign_Line.svg icons/PartDesign_Point.svg diff --git a/src/Mod/PartDesign/Gui/Resources/icons/PartDesign_Clone.svg b/src/Mod/PartDesign/Gui/Resources/icons/PartDesign_Clone.svg new file mode 100644 index 0000000000..e7afe2896e --- /dev/null +++ b/src/Mod/PartDesign/Gui/Resources/icons/PartDesign_Clone.svg @@ -0,0 +1,250 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + Fri May 4 19:21:54 2012 -0300 + + + [Yorik van Havre] + + + + + FreeCAD LGPL2+ + + + + + FreeCAD + + + FreeCAD/src/Mod/Draft/Resources/icons/Draft_Clone.svg + http://www.freecadweb.org/wiki/index.php?title=Artwork + + + [agryson] Alexander Gryson + + + + + stormtrooper + clone + helmet + + + A clone stormtrooper helmet similar in style to a popuar scifi universe based on wars in the stars + + + + diff --git a/src/Mod/PartDesign/Gui/Workbench.cpp b/src/Mod/PartDesign/Gui/Workbench.cpp index 3ab2966d93..380a566fab 100644 --- a/src/Mod/PartDesign/Gui/Workbench.cpp +++ b/src/Mod/PartDesign/Gui/Workbench.cpp @@ -447,11 +447,12 @@ Gui::MenuItem* Workbench::setupMenuBar() const << "PartDesign_Line" << "PartDesign_Plane" << "PartDesign_ShapeBinder" + << "PartDesign_Clone" << "Separator" - << "PartDesign_Pad" - << "PartDesign_Revolution" + << "PartDesign_Pad" + << "PartDesign_Revolution" << "PartDesign_AdditiveLoft" - << "PartDesign_AdditivePipe" + << "PartDesign_AdditivePipe" << "PartDesign_CompPrimitiveAdditive" << "Separator" << "PartDesign_Pocket" @@ -510,14 +511,15 @@ Gui::ToolBarItem* Workbench::setupToolBars() const << "PartDesign_Point" << "PartDesign_Line" << "PartDesign_Plane" - << "PartDesign_ShapeBinder"; - + << "PartDesign_ShapeBinder" + << "PartDesign_Clone"; + part = new Gui::ToolBarItem(root); part->setCommand("Part Design Modeling"); - *part << "PartDesign_Pad" - << "PartDesign_Revolution" + *part << "PartDesign_Pad" + << "PartDesign_Revolution" << "PartDesign_AdditiveLoft" - << "PartDesign_AdditivePipe" + << "PartDesign_AdditivePipe" << "PartDesign_CompPrimitiveAdditive" << "Separator" << "PartDesign_Pocket"