// SPDX-License-Identifier: LGPL-2.1-or-later /*************************************************************************** * Copyright (c) 2008 Jürgen Riegel * * * * This file is part of the FreeCAD CAx development system. * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Library General Public * * License as published by the Free Software Foundation; either * * version 2 of the License, or (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Library General Public License for more details. * * * * You should have received a copy of the GNU Library General Public * * License along with this library; see the file COPYING.LIB. If not, * * write to the Free Software Foundation, Inc., 59 Temple Place, * * Suite 330, Boston, MA 02111-1307, USA * * * ***************************************************************************/ #include #include #include #include #include #include #include #include "TrajectorySimulate.h" using namespace std; DEF_STD_CMD_A(CmdRobotAddToolShape) CmdRobotAddToolShape::CmdRobotAddToolShape() : Command("Robot_AddToolShape") { sAppModule = "Robot"; sGroup = QT_TR_NOOP("Robot"); sMenuText = QT_TR_NOOP("Tool"); sToolTipText = QT_TR_NOOP("Adds a tool shape to the robot"); sWhatsThis = "Robot_AddToolShape"; sStatusTip = sToolTipText; sPixmap = "Robot_CreateRobot"; } void CmdRobotAddToolShape::activated(int) { std::vector robots = getSelection().getObjectsOfType( Robot::RobotObject::getClassTypeId() ); std::vector shapes = getSelection().getObjectsOfType( Base::Type::fromName("Part::Feature") ); std::vector VRMLs = getSelection().getObjectsOfType( Base::Type::fromName("App::VRMLObject") ); if (robots.size() != 1 || (shapes.size() != 1 && VRMLs.size() != 1)) { QMessageBox::warning( Gui::getMainWindow(), QObject::tr("Wrong selection"), QObject::tr("Select one robot and one shape or VRML object.") ); return; } std::string RoboName = robots.front()->getNameInDocument(); std::string ShapeName; if (shapes.size() == 1) { ShapeName = shapes.front()->getNameInDocument(); } else { ShapeName = VRMLs.front()->getNameInDocument(); } openCommand("Add tool to robot"); doCommand( Doc, "App.activeDocument().%s.ToolShape = App.activeDocument().%s", RoboName.c_str(), ShapeName.c_str() ); // doCommand(Gui,"Gui.activeDocument().hide(\"%s\")",ShapeName.c_str()); updateActive(); commitCommand(); } bool CmdRobotAddToolShape::isActive() { // return false; // not yet implemented and thus not active return hasActiveDocument(); } void CreateRobotCommandsInsertRobots() { Gui::CommandManager& command_manager = Gui::Application::Instance->commandManager(); command_manager.addCommand(new CmdRobotAddToolShape()); }