| |
|
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| |
|
| | #include <QMessageBox>
|
| |
|
| |
|
| | #include <Gui/Application.h>
|
| | #include <Gui/Command.h>
|
| | #include <Gui/Document.h>
|
| | #include <Gui/MainWindow.h>
|
| | #include <Gui/Selection/Selection.h>
|
| | #include <Mod/Robot/App/RobotObject.h>
|
| |
|
| | #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<App::DocumentObject*> robots = getSelection().getObjectsOfType(
|
| | Robot::RobotObject::getClassTypeId()
|
| | );
|
| | std::vector<App::DocumentObject*> shapes = getSelection().getObjectsOfType(
|
| | Base::Type::fromName("Part::Feature")
|
| | );
|
| | std::vector<App::DocumentObject*> 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()
|
| | );
|
| |
|
| | updateActive();
|
| | commitCommand();
|
| | }
|
| |
|
| | bool CmdRobotAddToolShape::isActive()
|
| | {
|
| |
|
| | return hasActiveDocument();
|
| | }
|
| |
|
| | void CreateRobotCommandsInsertRobots()
|
| | {
|
| | Gui::CommandManager& command_manager = Gui::Application::Instance->commandManager();
|
| |
|
| | command_manager.addCommand(new CmdRobotAddToolShape());
|
| | }
|
| |
|