00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include "PreCompiled.h"
00025 #ifndef _PreComp_
00026 # include <QMessageBox>
00027 #endif
00028
00029 #include <App/Application.h>
00030 #include <Gui/Application.h>
00031 #include <Gui/Command.h>
00032 #include <Gui/MainWindow.h>
00033 #include <Gui/FileDialog.h>
00034 #include <Gui/Selection.h>
00035 #include <Gui/Document.h>
00036
00037 #include <Mod/Robot/App/RobotObject.h>
00038 #include <Mod/Robot/App/TrajectoryObject.h>
00039
00040
00041 #include "TrajectorySimulate.h"
00042
00043 using namespace std;
00044
00045 DEF_STD_CMD_A(CmdRobotInsertKukaIR500);
00046
00047 CmdRobotInsertKukaIR500::CmdRobotInsertKukaIR500()
00048 :Command("Robot_InsertKukaIR500")
00049 {
00050 sAppModule = "Robot";
00051 sGroup = QT_TR_NOOP("Robot");
00052 sMenuText = QT_TR_NOOP("Kuka IR500");
00053 sToolTipText = QT_TR_NOOP("Insert a Kuka IR500 into the document.");
00054 sWhatsThis = sToolTipText;
00055 sStatusTip = sToolTipText;
00056 sPixmap = "Robot_CreateRobot";
00057 }
00058
00059
00060 void CmdRobotInsertKukaIR500::activated(int iMsg)
00061 {
00062 std::string FeatName = getUniqueObjectName("Robot");
00063 std::string RobotPath = "Mod/Robot/Lib/Kuka/kr500_1.wrl";
00064 std::string KinematicPath = "Mod/Robot/Lib/Kuka/kr500_1.csv";
00065
00066 openCommand("Place robot");
00067 doCommand(Doc,"App.activeDocument().addObject(\"Robot::RobotObject\",\"%s\")",FeatName.c_str());
00068 doCommand(Doc,"App.activeDocument().%s.RobotVrmlFile = App.getResourceDir()+\"%s\"",FeatName.c_str(),RobotPath.c_str());
00069 doCommand(Doc,"App.activeDocument().%s.RobotKinematicFile = App.getResourceDir()+\"%s\"",FeatName.c_str(),KinematicPath.c_str());
00070 doCommand(Doc,"App.activeDocument().%s.Axis2 = -90",FeatName.c_str());
00071 doCommand(Doc,"App.activeDocument().%s.Axis3 = 90",FeatName.c_str());
00072 doCommand(Doc,"App.activeDocument().%s.Axis5 = 45",FeatName.c_str());
00073 doCommand(Doc,"App.activeDocument().%s.Home = [0.0,-90.0,90.0,0.0,45.0,0.0]",FeatName.c_str());
00074 updateActive();
00075 commitCommand();
00076
00077 }
00078
00079 bool CmdRobotInsertKukaIR500::isActive(void)
00080 {
00081 return hasActiveDocument();
00082 }
00083
00084
00085
00086
00087 DEF_STD_CMD_A(CmdRobotInsertKukaIR16);
00088
00089 CmdRobotInsertKukaIR16::CmdRobotInsertKukaIR16()
00090 :Command("Robot_InsertKukaIR16")
00091 {
00092 sAppModule = "Robot";
00093 sGroup = QT_TR_NOOP("Robot");
00094 sMenuText = QT_TR_NOOP("Kuka IR16");
00095 sToolTipText = QT_TR_NOOP("Insert a Kuka IR16 into the document.");
00096 sWhatsThis = sToolTipText;
00097 sStatusTip = sToolTipText;
00098 sPixmap = "Robot_CreateRobot";
00099 }
00100
00101
00102 void CmdRobotInsertKukaIR16::activated(int iMsg)
00103 {
00104 std::string FeatName = getUniqueObjectName("Robot");
00105 std::string RobotPath = "Mod/Robot/Lib/Kuka/kr16.wrl";
00106 std::string KinematicPath = "Mod/Robot/Lib/Kuka/kr_16.csv";
00107
00108 openCommand("Place robot");
00109 doCommand(Doc,"App.activeDocument().addObject(\"Robot::RobotObject\",\"%s\")",FeatName.c_str());
00110 doCommand(Doc,"App.activeDocument().%s.RobotVrmlFile = App.getResourceDir()+\"%s\"",FeatName.c_str(),RobotPath.c_str());
00111 doCommand(Doc,"App.activeDocument().%s.RobotKinematicFile = App.getResourceDir()+\"%s\"",FeatName.c_str(),KinematicPath.c_str());
00112 doCommand(Doc,"App.activeDocument().%s.Axis2 = -90",FeatName.c_str());
00113 doCommand(Doc,"App.activeDocument().%s.Axis3 = 90",FeatName.c_str());
00114 doCommand(Doc,"App.activeDocument().%s.Axis5 = 45",FeatName.c_str());
00115 updateActive();
00116 commitCommand();
00117
00118 }
00119
00120 bool CmdRobotInsertKukaIR16::isActive(void)
00121 {
00122 return hasActiveDocument();
00123 }
00124
00125
00126
00127
00128 DEF_STD_CMD_A(CmdRobotInsertKukaIR210);
00129
00130 CmdRobotInsertKukaIR210::CmdRobotInsertKukaIR210()
00131 :Command("Robot_InsertKukaIR210")
00132 {
00133 sAppModule = "Robot";
00134 sGroup = QT_TR_NOOP("Robot");
00135 sMenuText = QT_TR_NOOP("Kuka IR210");
00136 sToolTipText = QT_TR_NOOP("Insert a Kuka IR210 into the document.");
00137 sWhatsThis = sToolTipText;
00138 sStatusTip = sToolTipText;
00139 sPixmap = "Robot_CreateRobot";
00140 }
00141
00142
00143 void CmdRobotInsertKukaIR210::activated(int iMsg)
00144 {
00145 std::string FeatName = getUniqueObjectName("Robot");
00146 std::string RobotPath = "Mod/Robot/Lib/Kuka/kr210.WRL";
00147 std::string KinematicPath = "Mod/Robot/Lib/Kuka/kr_210_2.csv";
00148
00149 openCommand("Place robot");
00150 doCommand(Doc,"App.activeDocument().addObject(\"Robot::RobotObject\",\"%s\")",FeatName.c_str());
00151 doCommand(Doc,"App.activeDocument().%s.RobotVrmlFile = App.getResourceDir()+\"%s\"",FeatName.c_str(),RobotPath.c_str());
00152 doCommand(Doc,"App.activeDocument().%s.RobotKinematicFile = App.getResourceDir()+\"%s\"",FeatName.c_str(),KinematicPath.c_str());
00153 doCommand(Doc,"App.activeDocument().%s.Axis2 = -90",FeatName.c_str());
00154 doCommand(Doc,"App.activeDocument().%s.Axis3 = 90",FeatName.c_str());
00155 doCommand(Doc,"App.activeDocument().%s.Axis5 = 45",FeatName.c_str());
00156 updateActive();
00157 commitCommand();
00158
00159 }
00160
00161 bool CmdRobotInsertKukaIR210::isActive(void)
00162 {
00163 return hasActiveDocument();
00164 }
00165
00166
00167
00168 DEF_STD_CMD_A(CmdRobotInsertKukaIR125);
00169
00170 CmdRobotInsertKukaIR125::CmdRobotInsertKukaIR125()
00171 :Command("Robot_InsertKukaIR125")
00172 {
00173 sAppModule = "Robot";
00174 sGroup = QT_TR_NOOP("Robot");
00175 sMenuText = QT_TR_NOOP("Kuka IR125");
00176 sToolTipText = QT_TR_NOOP("Insert a Kuka IR125 into the document.");
00177 sWhatsThis = sToolTipText;
00178 sStatusTip = sToolTipText;
00179 sPixmap = "Robot_CreateRobot";
00180 }
00181
00182
00183 void CmdRobotInsertKukaIR125::activated(int iMsg)
00184 {
00185 std::string FeatName = getUniqueObjectName("Robot");
00186 std::string RobotPath = "Mod/Robot/Lib/Kuka/kr125_3.wrl";
00187 std::string KinematicPath = "Mod/Robot/Lib/Kuka/kr_125.csv";
00188
00189 openCommand("Place robot");
00190 doCommand(Doc,"App.activeDocument().addObject(\"Robot::RobotObject\",\"%s\")",FeatName.c_str());
00191 doCommand(Doc,"App.activeDocument().%s.RobotVrmlFile = App.getResourceDir()+\"%s\"",FeatName.c_str(),RobotPath.c_str());
00192 doCommand(Doc,"App.activeDocument().%s.RobotKinematicFile = App.getResourceDir()+\"%s\"",FeatName.c_str(),KinematicPath.c_str());
00193 doCommand(Doc,"App.activeDocument().%s.Axis2 = -90",FeatName.c_str());
00194 doCommand(Doc,"App.activeDocument().%s.Axis3 = 90",FeatName.c_str());
00195 doCommand(Doc,"App.activeDocument().%s.Axis5 = 45",FeatName.c_str());
00196 updateActive();
00197 commitCommand();
00198
00199 }
00200
00201 bool CmdRobotInsertKukaIR125::isActive(void)
00202 {
00203 return hasActiveDocument();
00204 }
00205
00206
00207
00208
00209 DEF_STD_CMD_A(CmdRobotAddToolShape);
00210
00211 CmdRobotAddToolShape::CmdRobotAddToolShape()
00212 :Command("Robot_AddToolShape")
00213 {
00214 sAppModule = "Robot";
00215 sGroup = QT_TR_NOOP("Robot");
00216 sMenuText = QT_TR_NOOP("Add tool");
00217 sToolTipText = QT_TR_NOOP("Add a tool shape to the robot");
00218 sWhatsThis = sToolTipText;
00219 sStatusTip = sToolTipText;
00220 sPixmap = "Robot_CreateRobot";
00221 }
00222
00223
00224 void CmdRobotAddToolShape::activated(int iMsg)
00225 {
00226 std::vector<App::DocumentObject*> robots = getSelection()
00227 .getObjectsOfType(Robot::RobotObject::getClassTypeId());
00228 std::vector<App::DocumentObject*> shapes = getSelection()
00229 .getObjectsOfType(Base::Type::fromName("Part::Feature"));
00230 std::vector<App::DocumentObject*> VRMLs = getSelection()
00231 .getObjectsOfType(Base::Type::fromName("App::VRMLObject"));
00232
00233 if (robots.size() != 1 || (shapes.size() != 1 && VRMLs.size() != 1)) {
00234 QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
00235 QObject::tr("Select one robot and one shape or VRML object."));
00236 return;
00237 }
00238
00239 std::string RoboName = robots.front()->getNameInDocument();
00240 std::string ShapeName;
00241 if(shapes.size() == 1)
00242 ShapeName = shapes.front()->getNameInDocument();
00243 else
00244 ShapeName = VRMLs.front()->getNameInDocument();
00245
00246 openCommand("Add tool to robot");
00247 doCommand(Doc,"App.activeDocument().%s.ToolShape = App.activeDocument().%s",RoboName.c_str(),ShapeName.c_str());
00248
00249 updateActive();
00250 commitCommand();
00251 }
00252
00253 bool CmdRobotAddToolShape::isActive(void)
00254 {
00255
00256 return hasActiveDocument();
00257 }
00258
00259 void CreateRobotCommandsInsertRobots(void)
00260 {
00261 Gui::CommandManager &rcCmdMgr = Gui::Application::Instance->commandManager();
00262
00263 rcCmdMgr.addCommand(new CmdRobotInsertKukaIR16());
00264 rcCmdMgr.addCommand(new CmdRobotInsertKukaIR500());
00265 rcCmdMgr.addCommand(new CmdRobotInsertKukaIR210());
00266 rcCmdMgr.addCommand(new CmdRobotInsertKukaIR125());
00267 rcCmdMgr.addCommand(new CmdRobotAddToolShape());
00268 }