diff --git a/src/Mod/Robot/Gui/AppRobotGui.cpp b/src/Mod/Robot/Gui/AppRobotGui.cpp index b89b583e48..618e35e970 100644 --- a/src/Mod/Robot/Gui/AppRobotGui.cpp +++ b/src/Mod/Robot/Gui/AppRobotGui.cpp @@ -50,13 +50,15 @@ void loadRobotResource() Gui::Translator::instance()->refresh(); } -namespace RobotGui { -class Module : public Py::ExtensionModule +namespace RobotGui +{ +class Module: public Py::ExtensionModule { public: - Module() : Py::ExtensionModule("RobotGui") + Module() + : Py::ExtensionModule("RobotGui") { - initialize("This module is the RobotGui module."); // register with Python + initialize("This module is the RobotGui module.");// register with Python } private: @@ -67,7 +69,7 @@ PyObject* initModule() return Base::Interpreter().addModule(new Module); } -} // namespace RobotGui +}// namespace RobotGui /* Python entry */ @@ -93,7 +95,7 @@ PyMOD_INIT_FUNC(RobotGui) // default displacement while e.g. picking Base::Interpreter().runString("_DefDisplacement = FreeCAD.Vector(0,0,0)"); } - catch(const Base::Exception& e) { + catch (const Base::Exception& e) { PyErr_SetString(PyExc_ImportError, e.what()); PyMOD_Return(nullptr); } @@ -106,6 +108,7 @@ PyMOD_INIT_FUNC(RobotGui) CreateRobotCommandsInsertRobots(); CreateRobotCommandsTrajectory(); + // clang-format off // addition objects RobotGui::Workbench ::init(); RobotGui::ViewProviderRobotObject ::init(); @@ -113,8 +116,9 @@ PyMOD_INIT_FUNC(RobotGui) RobotGui::ViewProviderEdge2TracObject ::init(); RobotGui::ViewProviderTrajectoryCompound ::init(); RobotGui::ViewProviderTrajectoryDressUp ::init(); + // clang-format on - // add resources and reloads the translators + // add resources and reloads the translators loadRobotResource(); PyMOD_Return(mod); diff --git a/src/Mod/Robot/Gui/Command.cpp b/src/Mod/Robot/Gui/Command.cpp index c6c007fd1e..0328f76d71 100644 --- a/src/Mod/Robot/Gui/Command.cpp +++ b/src/Mod/Robot/Gui/Command.cpp @@ -22,7 +22,7 @@ #include "PreCompiled.h" #ifndef _PreComp_ -# include +#include #endif #include @@ -45,31 +45,31 @@ using namespace RobotGui; DEF_STD_CMD_A(CmdRobotSetHomePos) CmdRobotSetHomePos::CmdRobotSetHomePos() - :Command("Robot_SetHomePos") + : Command("Robot_SetHomePos") { - sAppModule = "Robot"; - sGroup = QT_TR_NOOP("Robot"); - sMenuText = QT_TR_NOOP("Set the home position"); - sToolTipText = QT_TR_NOOP("Set the home position"); - sWhatsThis = "Robot_SetHomePos"; - sStatusTip = sToolTipText; - sPixmap = "Robot_SetHomePos"; + sAppModule = "Robot"; + sGroup = QT_TR_NOOP("Robot"); + sMenuText = QT_TR_NOOP("Set the home position"); + sToolTipText = QT_TR_NOOP("Set the home position"); + sWhatsThis = "Robot_SetHomePos"; + sStatusTip = sToolTipText; + sPixmap = "Robot_SetHomePos"; } void CmdRobotSetHomePos::activated(int) { - const char * SelFilter = - "SELECT Robot::RobotObject COUNT 1 "; + const char* SelFilter = "SELECT Robot::RobotObject COUNT 1 "; Gui::SelectionFilter filter(SelFilter); - Robot::RobotObject *pcRobotObject; + Robot::RobotObject* pcRobotObject; if (filter.match()) { pcRobotObject = static_cast(filter.Result[0][0].getObject()); } else { - QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"), - QObject::tr("Select one Robot to set home position")); + QMessageBox::warning(Gui::getMainWindow(), + QObject::tr("Wrong selection"), + QObject::tr("Select one Robot to set home position")); return; } @@ -78,10 +78,20 @@ void CmdRobotSetHomePos::activated(int) const char* n = FeatName.c_str(); openCommand("Set home"); - doCommand(Doc,"App.activeDocument().%s.Home = [App.activeDocument().%s.Axis1,App.activeDocument().%s.Axis2,App.activeDocument().%s.Axis3,App.activeDocument().%s.Axis4,App.activeDocument().%s.Axis5,App.activeDocument().%s.Axis6]",n,n,n,n,n,n,n); + doCommand(Doc, + "App.activeDocument().%s.Home = " + "[App.activeDocument().%s.Axis1,App.activeDocument().%s.Axis2,App.activeDocument().%" + "s.Axis3,App.activeDocument().%s.Axis4,App.activeDocument().%s.Axis5,App." + "activeDocument().%s.Axis6]", + n, + n, + n, + n, + n, + n, + n); updateActive(); commitCommand(); - } bool CmdRobotSetHomePos::isActive() @@ -94,31 +104,31 @@ bool CmdRobotSetHomePos::isActive() DEF_STD_CMD_A(CmdRobotRestoreHomePos) CmdRobotRestoreHomePos::CmdRobotRestoreHomePos() - :Command("Robot_RestoreHomePos") + : Command("Robot_RestoreHomePos") { - sAppModule = "Robot"; - sGroup = QT_TR_NOOP("Robot"); - sMenuText = QT_TR_NOOP("Move to home"); - sToolTipText = QT_TR_NOOP("Move to home"); - sWhatsThis = "Robot_RestoreHomePos"; - sStatusTip = sToolTipText; - sPixmap = "Robot_RestoreHomePos"; + sAppModule = "Robot"; + sGroup = QT_TR_NOOP("Robot"); + sMenuText = QT_TR_NOOP("Move to home"); + sToolTipText = QT_TR_NOOP("Move to home"); + sWhatsThis = "Robot_RestoreHomePos"; + sStatusTip = sToolTipText; + sPixmap = "Robot_RestoreHomePos"; } void CmdRobotRestoreHomePos::activated(int) { - const char * SelFilter = - "SELECT Robot::RobotObject COUNT 1 "; + const char* SelFilter = "SELECT Robot::RobotObject COUNT 1 "; Gui::SelectionFilter filter(SelFilter); - Robot::RobotObject *pcRobotObject; + Robot::RobotObject* pcRobotObject; if (filter.match()) { pcRobotObject = static_cast(filter.Result[0][0].getObject()); } else { - QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"), - QObject::tr("Select one Robot")); + QMessageBox::warning(Gui::getMainWindow(), + QObject::tr("Wrong selection"), + QObject::tr("Select one Robot")); return; } @@ -127,15 +137,14 @@ void CmdRobotRestoreHomePos::activated(int) const char* n = FeatName.c_str(); openCommand("Move to home"); - doCommand(Doc,"App.activeDocument().%s.Axis1 = App.activeDocument().%s.Home[0]",n,n); - doCommand(Doc,"App.activeDocument().%s.Axis2 = App.activeDocument().%s.Home[1]",n,n); - doCommand(Doc,"App.activeDocument().%s.Axis3 = App.activeDocument().%s.Home[2]",n,n); - doCommand(Doc,"App.activeDocument().%s.Axis4 = App.activeDocument().%s.Home[3]",n,n); - doCommand(Doc,"App.activeDocument().%s.Axis5 = App.activeDocument().%s.Home[4]",n,n); - doCommand(Doc,"App.activeDocument().%s.Axis6 = App.activeDocument().%s.Home[5]",n,n); + doCommand(Doc, "App.activeDocument().%s.Axis1 = App.activeDocument().%s.Home[0]", n, n); + doCommand(Doc, "App.activeDocument().%s.Axis2 = App.activeDocument().%s.Home[1]", n, n); + doCommand(Doc, "App.activeDocument().%s.Axis3 = App.activeDocument().%s.Home[2]", n, n); + doCommand(Doc, "App.activeDocument().%s.Axis4 = App.activeDocument().%s.Home[3]", n, n); + doCommand(Doc, "App.activeDocument().%s.Axis5 = App.activeDocument().%s.Home[4]", n, n); + doCommand(Doc, "App.activeDocument().%s.Axis6 = App.activeDocument().%s.Home[5]", n, n); updateActive(); commitCommand(); - } bool CmdRobotRestoreHomePos::isActive() @@ -148,15 +157,15 @@ bool CmdRobotRestoreHomePos::isActive() DEF_STD_CMD_A(CmdRobotConstraintAxle) CmdRobotConstraintAxle::CmdRobotConstraintAxle() - :Command("Robot_Create") + : Command("Robot_Create") { - sAppModule = "Robot"; - sGroup = QT_TR_NOOP("Robot"); - sMenuText = QT_TR_NOOP("Place robot..."); - sToolTipText = QT_TR_NOOP("Place a robot (experimental!)"); - sWhatsThis = "Robot_Create"; - sStatusTip = sToolTipText; - sPixmap = "Robot_CreateRobot"; + sAppModule = "Robot"; + sGroup = QT_TR_NOOP("Robot"); + sMenuText = QT_TR_NOOP("Place robot..."); + sToolTipText = QT_TR_NOOP("Place a robot (experimental!)"); + sWhatsThis = "Robot_Create"; + sStatusTip = sToolTipText; + sPixmap = "Robot_CreateRobot"; } @@ -167,15 +176,22 @@ void CmdRobotConstraintAxle::activated(int) std::string KinematicPath = "Mod/Robot/Lib/Kuka/kr500_1.csv"; openCommand("Place robot"); - doCommand(Doc,"App.activeDocument().addObject(\"Robot::RobotObject\",\"%s\")",FeatName.c_str()); - doCommand(Doc,"App.activeDocument().%s.RobotVrmlFile = App.getResourceDir()+\"%s\"",FeatName.c_str(),RobotPath.c_str()); - doCommand(Doc,"App.activeDocument().%s.RobotKinematicFile = App.getResourceDir()+\"%s\"",FeatName.c_str(),KinematicPath.c_str()); - doCommand(Doc,"App.activeDocument().%s.Axis2 = -90",FeatName.c_str()); - doCommand(Doc,"App.activeDocument().%s.Axis3 = 90",FeatName.c_str()); - doCommand(Doc,"App.activeDocument().%s.Axis5 = 45",FeatName.c_str()); + doCommand(Doc, + "App.activeDocument().addObject(\"Robot::RobotObject\",\"%s\")", + FeatName.c_str()); + doCommand(Doc, + "App.activeDocument().%s.RobotVrmlFile = App.getResourceDir()+\"%s\"", + FeatName.c_str(), + RobotPath.c_str()); + doCommand(Doc, + "App.activeDocument().%s.RobotKinematicFile = App.getResourceDir()+\"%s\"", + FeatName.c_str(), + KinematicPath.c_str()); + doCommand(Doc, "App.activeDocument().%s.Axis2 = -90", FeatName.c_str()); + doCommand(Doc, "App.activeDocument().%s.Axis3 = 90", FeatName.c_str()); + doCommand(Doc, "App.activeDocument().%s.Axis5 = 45", FeatName.c_str()); updateActive(); commitCommand(); - } bool CmdRobotConstraintAxle::isActive() @@ -189,68 +205,74 @@ bool CmdRobotConstraintAxle::isActive() DEF_STD_CMD_A(CmdRobotSimulate) CmdRobotSimulate::CmdRobotSimulate() - :Command("Robot_Simulate") + : Command("Robot_Simulate") { - sAppModule = "Robot"; - sGroup = QT_TR_NOOP("Robot"); - sMenuText = QT_TR_NOOP("Simulate a trajectory"); - sToolTipText = QT_TR_NOOP("Run a simulation on a trajectory"); - sWhatsThis = "Robot_Simulate"; - sStatusTip = sToolTipText; - sPixmap = "Robot_Simulate"; + sAppModule = "Robot"; + sGroup = QT_TR_NOOP("Robot"); + sMenuText = QT_TR_NOOP("Simulate a trajectory"); + sToolTipText = QT_TR_NOOP("Run a simulation on a trajectory"); + sWhatsThis = "Robot_Simulate"; + sStatusTip = sToolTipText; + sPixmap = "Robot_Simulate"; } void CmdRobotSimulate::activated(int) { #if 1 - const char * SelFilter = - "SELECT Robot::RobotObject \n" - "SELECT Robot::TrajectoryObject "; + const char* SelFilter = "SELECT Robot::RobotObject \n" + "SELECT Robot::TrajectoryObject "; Gui::SelectionFilter filter(SelFilter); - Robot::RobotObject *pcRobotObject; - Robot::TrajectoryObject *pcTrajectoryObject; + Robot::RobotObject* pcRobotObject; + Robot::TrajectoryObject* pcTrajectoryObject; if (filter.match()) { pcRobotObject = static_cast(filter.Result[0][0].getObject()); - pcTrajectoryObject = static_cast(filter.Result[1][0].getObject());; + pcTrajectoryObject = static_cast(filter.Result[1][0].getObject()); + ; } else { - QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"), - QObject::tr("Select one Robot and one Trajectory object.")); + QMessageBox::warning(Gui::getMainWindow(), + QObject::tr("Wrong selection"), + QObject::tr("Select one Robot and one Trajectory object.")); return; } - if(pcTrajectoryObject->Trajectory.getValue().getSize() < 2){ - QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Trajectory not valid"), + if (pcTrajectoryObject->Trajectory.getValue().getSize() < 2) { + QMessageBox::warning( + Gui::getMainWindow(), + QObject::tr("Trajectory not valid"), QObject::tr("You need at least two waypoints in a trajectory to simulate.")); return; } - Gui::TaskView::TaskDialog* dlg = new TaskDlgSimulate(pcRobotObject,pcTrajectoryObject); + Gui::TaskView::TaskDialog* dlg = new TaskDlgSimulate(pcRobotObject, pcTrajectoryObject); Gui::Control().showDialog(dlg); #else - const char * SelFilter = - "SELECT Robot::RobotObject \n" - "SELECT Robot::TrajectoryObject "; + const char* SelFilter = "SELECT Robot::RobotObject \n" + "SELECT Robot::TrajectoryObject "; Gui::SelectionFilter filter(SelFilter); - Robot::RobotObject *pcRobotObject; - Robot::TrajectoryObject *pcTrajectoryObject; + Robot::RobotObject* pcRobotObject; + Robot::TrajectoryObject* pcTrajectoryObject; - if(filter.match()){ + if (filter.match()) { pcRobotObject = dynamic_cast(filter.Result[0][0].getObject()); - pcTrajectoryObject = dynamic_cast(filter.Result[1][0].getObject());; - }else{ - QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"), - QObject::tr("Select one Robot and one Trajectory object.")); + pcTrajectoryObject = + dynamic_cast(filter.Result[1][0].getObject()); + ; + } + else { + QMessageBox::warning(Gui::getMainWindow(), + QObject::tr("Wrong selection"), + QObject::tr("Select one Robot and one Trajectory object.")); } - RobotGui::TrajectorySimulate dlg(pcRobotObject,pcTrajectoryObject,Gui::getMainWindow()); + RobotGui::TrajectorySimulate dlg(pcRobotObject, pcTrajectoryObject, Gui::getMainWindow()); dlg.exec(); #endif } @@ -261,17 +283,15 @@ bool CmdRobotSimulate::isActive() } - // ##################################################################################################### - void CreateRobotCommands() { - Gui::CommandManager &rcCmdMgr = Gui::Application::Instance->commandManager(); + Gui::CommandManager& rcCmdMgr = Gui::Application::Instance->commandManager(); rcCmdMgr.addCommand(new CmdRobotRestoreHomePos()); rcCmdMgr.addCommand(new CmdRobotSetHomePos()); rcCmdMgr.addCommand(new CmdRobotConstraintAxle()); rcCmdMgr.addCommand(new CmdRobotSimulate()); - } +} diff --git a/src/Mod/Robot/Gui/CommandExport.cpp b/src/Mod/Robot/Gui/CommandExport.cpp index b7f6a89613..bbd390529c 100644 --- a/src/Mod/Robot/Gui/CommandExport.cpp +++ b/src/Mod/Robot/Gui/CommandExport.cpp @@ -22,7 +22,7 @@ #include "PreCompiled.h" #ifndef _PreComp_ -# include +#include #endif #include @@ -40,15 +40,15 @@ using namespace std; DEF_STD_CMD_A(CmdRobotExportKukaCompact) CmdRobotExportKukaCompact::CmdRobotExportKukaCompact() - :Command("Robot_ExportKukaCompact") + : Command("Robot_ExportKukaCompact") { - sAppModule = "Robot"; - sGroup = QT_TR_NOOP("Robot"); - sMenuText = QT_TR_NOOP("Kuka compact subroutine..."); - sToolTipText = QT_TR_NOOP("Export the trajectory as a compact KRL subroutine."); - sWhatsThis = "Robot_ExportKukaCompact"; - sStatusTip = sToolTipText; - sPixmap = "Robot_Export"; + sAppModule = "Robot"; + sGroup = QT_TR_NOOP("Robot"); + sMenuText = QT_TR_NOOP("Kuka compact subroutine..."); + sToolTipText = QT_TR_NOOP("Export the trajectory as a compact KRL subroutine."); + sWhatsThis = "Robot_ExportKukaCompact"; + sStatusTip = sToolTipText; + sPixmap = "Robot_Export"; } @@ -58,37 +58,50 @@ void CmdRobotExportKukaCompact::activated(int) unsigned int n2 = getSelection().countObjectsOfType(Robot::TrajectoryObject::getClassTypeId()); if (n1 != 1 || n2 != 1) { - QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"), - QObject::tr("Select one Robot and one Trajectory object.")); + QMessageBox::warning(Gui::getMainWindow(), + QObject::tr("Wrong selection"), + QObject::tr("Select one Robot and one Trajectory object.")); return; } std::vector Sel = getSelection().getSelection(); - Robot::RobotObject *pcRobotObject=nullptr; - if(Sel[0].pObject->getTypeId() == Robot::RobotObject::getClassTypeId()) + Robot::RobotObject* pcRobotObject = nullptr; + if (Sel[0].pObject->getTypeId() == Robot::RobotObject::getClassTypeId()) { pcRobotObject = static_cast(Sel[0].pObject); - else if(Sel[1].pObject->getTypeId() == Robot::RobotObject::getClassTypeId()) + } + else if (Sel[1].pObject->getTypeId() == Robot::RobotObject::getClassTypeId()) { pcRobotObject = static_cast(Sel[1].pObject); + } std::string RoboName = pcRobotObject->getNameInDocument(); - Robot::TrajectoryObject *pcTrajectoryObject=nullptr; - if(Sel[0].pObject->getTypeId() == Robot::TrajectoryObject::getClassTypeId()) + Robot::TrajectoryObject* pcTrajectoryObject = nullptr; + if (Sel[0].pObject->getTypeId() == Robot::TrajectoryObject::getClassTypeId()) { pcTrajectoryObject = static_cast(Sel[0].pObject); - else if(Sel[1].pObject->getTypeId() == Robot::TrajectoryObject::getClassTypeId()) + } + else if (Sel[1].pObject->getTypeId() == Robot::TrajectoryObject::getClassTypeId()) { pcTrajectoryObject = static_cast(Sel[1].pObject); - //std::string TrakName = pcTrajectoryObject->getNameInDocument(); + } + // std::string TrakName = pcTrajectoryObject->getNameInDocument(); QStringList filter; filter << QString::fromLatin1("%1 (*.src)").arg(QObject::tr("KRL file")); filter << QString::fromLatin1("%1 (*.*)").arg(QObject::tr("All Files")); - QString fn = Gui::FileDialog::getSaveFileName(Gui::getMainWindow(), QObject::tr("Export program"), QString(), filter.join(QLatin1String(";;"))); - if (fn.isEmpty()) + QString fn = Gui::FileDialog::getSaveFileName(Gui::getMainWindow(), + QObject::tr("Export program"), + QString(), + filter.join(QLatin1String(";;"))); + if (fn.isEmpty()) { return; + } - doCommand(Doc,"from KukaExporter import ExportCompactSub"); - doCommand(Doc,"ExportCompactSub(App.activeDocument().%s,App.activeDocument().%s,'%s')",pcRobotObject->getNameInDocument(),pcTrajectoryObject->getNameInDocument(),(const char*)fn.toLatin1()); + doCommand(Doc, "from KukaExporter import ExportCompactSub"); + doCommand(Doc, + "ExportCompactSub(App.activeDocument().%s,App.activeDocument().%s,'%s')", + pcRobotObject->getNameInDocument(), + pcTrajectoryObject->getNameInDocument(), + (const char*)fn.toLatin1()); } bool CmdRobotExportKukaCompact::isActive() @@ -102,15 +115,15 @@ bool CmdRobotExportKukaCompact::isActive() DEF_STD_CMD_A(CmdRobotExportKukaFull) CmdRobotExportKukaFull::CmdRobotExportKukaFull() - :Command("Robot_ExportKukaFull") + : Command("Robot_ExportKukaFull") { - sAppModule = "Robot"; - sGroup = QT_TR_NOOP("Robot"); - sMenuText = QT_TR_NOOP("Kuka full subroutine..."); - sToolTipText = QT_TR_NOOP("Export the trajectory as a full KRL subroutine."); - sWhatsThis = "Robot_ExportKukaFull"; - sStatusTip = sToolTipText; - sPixmap = "Robot_Export"; + sAppModule = "Robot"; + sGroup = QT_TR_NOOP("Robot"); + sMenuText = QT_TR_NOOP("Kuka full subroutine..."); + sToolTipText = QT_TR_NOOP("Export the trajectory as a full KRL subroutine."); + sWhatsThis = "Robot_ExportKukaFull"; + sStatusTip = sToolTipText; + sPixmap = "Robot_Export"; } @@ -120,37 +133,50 @@ void CmdRobotExportKukaFull::activated(int) unsigned int n2 = getSelection().countObjectsOfType(Robot::TrajectoryObject::getClassTypeId()); if (n1 != 1 || n2 != 1) { - QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"), - QObject::tr("Select one Robot and one Trajectory object.")); + QMessageBox::warning(Gui::getMainWindow(), + QObject::tr("Wrong selection"), + QObject::tr("Select one Robot and one Trajectory object.")); return; } std::vector Sel = getSelection().getSelection(); - Robot::RobotObject *pcRobotObject=nullptr; - if(Sel[0].pObject->getTypeId() == Robot::RobotObject::getClassTypeId()) + Robot::RobotObject* pcRobotObject = nullptr; + if (Sel[0].pObject->getTypeId() == Robot::RobotObject::getClassTypeId()) { pcRobotObject = static_cast(Sel[0].pObject); - else if(Sel[1].pObject->getTypeId() == Robot::RobotObject::getClassTypeId()) + } + else if (Sel[1].pObject->getTypeId() == Robot::RobotObject::getClassTypeId()) { pcRobotObject = static_cast(Sel[1].pObject); - //std::string RoboName = pcRobotObject->getNameInDocument(); + } + // std::string RoboName = pcRobotObject->getNameInDocument(); - Robot::TrajectoryObject *pcTrajectoryObject=nullptr; - if(Sel[0].pObject->getTypeId() == Robot::TrajectoryObject::getClassTypeId()) + Robot::TrajectoryObject* pcTrajectoryObject = nullptr; + if (Sel[0].pObject->getTypeId() == Robot::TrajectoryObject::getClassTypeId()) { pcTrajectoryObject = static_cast(Sel[0].pObject); - else if(Sel[1].pObject->getTypeId() == Robot::TrajectoryObject::getClassTypeId()) + } + else if (Sel[1].pObject->getTypeId() == Robot::TrajectoryObject::getClassTypeId()) { pcTrajectoryObject = static_cast(Sel[1].pObject); - //std::string TrakName = pcTrajectoryObject->getNameInDocument(); + } + // std::string TrakName = pcTrajectoryObject->getNameInDocument(); QStringList filter; filter << QString::fromLatin1("%1 (*.src)").arg(QObject::tr("KRL file")); filter << QString::fromLatin1("%1 (*.*)").arg(QObject::tr("All Files")); - QString fn = Gui::FileDialog::getSaveFileName(Gui::getMainWindow(), QObject::tr("Export program"), QString(), filter.join(QLatin1String(";;"))); - if (fn.isEmpty()) + QString fn = Gui::FileDialog::getSaveFileName(Gui::getMainWindow(), + QObject::tr("Export program"), + QString(), + filter.join(QLatin1String(";;"))); + if (fn.isEmpty()) { return; + } - doCommand(Doc,"from KukaExporter import ExportFullSub"); - doCommand(Doc,"ExportFullSub(App.activeDocument().%s,App.activeDocument().%s,'%s')",pcRobotObject->getNameInDocument(),pcTrajectoryObject->getNameInDocument(),(const char*)fn.toLatin1()); + doCommand(Doc, "from KukaExporter import ExportFullSub"); + doCommand(Doc, + "ExportFullSub(App.activeDocument().%s,App.activeDocument().%s,'%s')", + pcRobotObject->getNameInDocument(), + pcTrajectoryObject->getNameInDocument(), + (const char*)fn.toLatin1()); } bool CmdRobotExportKukaFull::isActive() @@ -161,11 +187,10 @@ bool CmdRobotExportKukaFull::isActive() // ##################################################################################################### - void CreateRobotCommandsExport() { - Gui::CommandManager &rcCmdMgr = Gui::Application::Instance->commandManager(); + Gui::CommandManager& rcCmdMgr = Gui::Application::Instance->commandManager(); rcCmdMgr.addCommand(new CmdRobotExportKukaFull()); rcCmdMgr.addCommand(new CmdRobotExportKukaCompact()); - } +} diff --git a/src/Mod/Robot/Gui/CommandInsertRobot.cpp b/src/Mod/Robot/Gui/CommandInsertRobot.cpp index 2ce779bfe5..d990c48d58 100644 --- a/src/Mod/Robot/Gui/CommandInsertRobot.cpp +++ b/src/Mod/Robot/Gui/CommandInsertRobot.cpp @@ -22,7 +22,7 @@ #include "PreCompiled.h" #ifndef _PreComp_ -# include +#include #endif #include @@ -40,15 +40,15 @@ using namespace std; DEF_STD_CMD_A(CmdRobotInsertKukaIR500) CmdRobotInsertKukaIR500::CmdRobotInsertKukaIR500() - :Command("Robot_InsertKukaIR500") + : Command("Robot_InsertKukaIR500") { - sAppModule = "Robot"; - sGroup = QT_TR_NOOP("Robot"); - sMenuText = QT_TR_NOOP("Kuka IR500"); - sToolTipText = QT_TR_NOOP("Insert a Kuka IR500 into the document."); - sWhatsThis = "Robot_InsertKukaIR500"; - sStatusTip = sToolTipText; - sPixmap = "Robot_CreateRobot"; + sAppModule = "Robot"; + sGroup = QT_TR_NOOP("Robot"); + sMenuText = QT_TR_NOOP("Kuka IR500"); + sToolTipText = QT_TR_NOOP("Insert a Kuka IR500 into the document."); + sWhatsThis = "Robot_InsertKukaIR500"; + sStatusTip = sToolTipText; + sPixmap = "Robot_CreateRobot"; } @@ -59,16 +59,25 @@ void CmdRobotInsertKukaIR500::activated(int) std::string KinematicPath = "Mod/Robot/Lib/Kuka/kr500_1.csv"; openCommand("Place robot"); - doCommand(Doc,"App.activeDocument().addObject(\"Robot::RobotObject\",\"%s\")",FeatName.c_str()); - doCommand(Doc,"App.activeDocument().%s.RobotVrmlFile = App.getResourceDir()+\"%s\"",FeatName.c_str(),RobotPath.c_str()); - doCommand(Doc,"App.activeDocument().%s.RobotKinematicFile = App.getResourceDir()+\"%s\"",FeatName.c_str(),KinematicPath.c_str()); - doCommand(Doc,"App.activeDocument().%s.Axis2 = -90",FeatName.c_str()); - doCommand(Doc,"App.activeDocument().%s.Axis3 = 90",FeatName.c_str()); - doCommand(Doc,"App.activeDocument().%s.Axis5 = 45",FeatName.c_str()); - doCommand(Doc,"App.activeDocument().%s.Home = [0.0,-90.0,90.0,0.0,45.0,0.0]",FeatName.c_str()); + doCommand(Doc, + "App.activeDocument().addObject(\"Robot::RobotObject\",\"%s\")", + FeatName.c_str()); + doCommand(Doc, + "App.activeDocument().%s.RobotVrmlFile = App.getResourceDir()+\"%s\"", + FeatName.c_str(), + RobotPath.c_str()); + doCommand(Doc, + "App.activeDocument().%s.RobotKinematicFile = App.getResourceDir()+\"%s\"", + FeatName.c_str(), + KinematicPath.c_str()); + doCommand(Doc, "App.activeDocument().%s.Axis2 = -90", FeatName.c_str()); + doCommand(Doc, "App.activeDocument().%s.Axis3 = 90", FeatName.c_str()); + doCommand(Doc, "App.activeDocument().%s.Axis5 = 45", FeatName.c_str()); + doCommand(Doc, + "App.activeDocument().%s.Home = [0.0,-90.0,90.0,0.0,45.0,0.0]", + FeatName.c_str()); updateActive(); commitCommand(); - } bool CmdRobotInsertKukaIR500::isActive() @@ -82,15 +91,15 @@ bool CmdRobotInsertKukaIR500::isActive() DEF_STD_CMD_A(CmdRobotInsertKukaIR16) CmdRobotInsertKukaIR16::CmdRobotInsertKukaIR16() - :Command("Robot_InsertKukaIR16") + : Command("Robot_InsertKukaIR16") { - sAppModule = "Robot"; - sGroup = QT_TR_NOOP("Robot"); - sMenuText = QT_TR_NOOP("Kuka IR16"); - sToolTipText = QT_TR_NOOP("Insert a Kuka IR16 into the document."); - sWhatsThis = "Robot_InsertKukaIR16"; - sStatusTip = sToolTipText; - sPixmap = "Robot_CreateRobot"; + sAppModule = "Robot"; + sGroup = QT_TR_NOOP("Robot"); + sMenuText = QT_TR_NOOP("Kuka IR16"); + sToolTipText = QT_TR_NOOP("Insert a Kuka IR16 into the document."); + sWhatsThis = "Robot_InsertKukaIR16"; + sStatusTip = sToolTipText; + sPixmap = "Robot_CreateRobot"; } @@ -101,15 +110,22 @@ void CmdRobotInsertKukaIR16::activated(int) std::string KinematicPath = "Mod/Robot/Lib/Kuka/kr_16.csv"; openCommand("Place robot"); - doCommand(Doc,"App.activeDocument().addObject(\"Robot::RobotObject\",\"%s\")",FeatName.c_str()); - doCommand(Doc,"App.activeDocument().%s.RobotVrmlFile = App.getResourceDir()+\"%s\"",FeatName.c_str(),RobotPath.c_str()); - doCommand(Doc,"App.activeDocument().%s.RobotKinematicFile = App.getResourceDir()+\"%s\"",FeatName.c_str(),KinematicPath.c_str()); - doCommand(Doc,"App.activeDocument().%s.Axis2 = -90",FeatName.c_str()); - doCommand(Doc,"App.activeDocument().%s.Axis3 = 90",FeatName.c_str()); - doCommand(Doc,"App.activeDocument().%s.Axis5 = 45",FeatName.c_str()); + doCommand(Doc, + "App.activeDocument().addObject(\"Robot::RobotObject\",\"%s\")", + FeatName.c_str()); + doCommand(Doc, + "App.activeDocument().%s.RobotVrmlFile = App.getResourceDir()+\"%s\"", + FeatName.c_str(), + RobotPath.c_str()); + doCommand(Doc, + "App.activeDocument().%s.RobotKinematicFile = App.getResourceDir()+\"%s\"", + FeatName.c_str(), + KinematicPath.c_str()); + doCommand(Doc, "App.activeDocument().%s.Axis2 = -90", FeatName.c_str()); + doCommand(Doc, "App.activeDocument().%s.Axis3 = 90", FeatName.c_str()); + doCommand(Doc, "App.activeDocument().%s.Axis5 = 45", FeatName.c_str()); updateActive(); commitCommand(); - } bool CmdRobotInsertKukaIR16::isActive() @@ -123,15 +139,15 @@ bool CmdRobotInsertKukaIR16::isActive() DEF_STD_CMD_A(CmdRobotInsertKukaIR210) CmdRobotInsertKukaIR210::CmdRobotInsertKukaIR210() - :Command("Robot_InsertKukaIR210") + : Command("Robot_InsertKukaIR210") { - sAppModule = "Robot"; - sGroup = QT_TR_NOOP("Robot"); - sMenuText = QT_TR_NOOP("Kuka IR210"); - sToolTipText = QT_TR_NOOP("Insert a Kuka IR210 into the document."); - sWhatsThis = "Robot_InsertKukaIR210"; - sStatusTip = sToolTipText; - sPixmap = "Robot_CreateRobot"; + sAppModule = "Robot"; + sGroup = QT_TR_NOOP("Robot"); + sMenuText = QT_TR_NOOP("Kuka IR210"); + sToolTipText = QT_TR_NOOP("Insert a Kuka IR210 into the document."); + sWhatsThis = "Robot_InsertKukaIR210"; + sStatusTip = sToolTipText; + sPixmap = "Robot_CreateRobot"; } @@ -142,15 +158,22 @@ void CmdRobotInsertKukaIR210::activated(int) std::string KinematicPath = "Mod/Robot/Lib/Kuka/kr_210_2.csv"; openCommand("Place robot"); - doCommand(Doc,"App.activeDocument().addObject(\"Robot::RobotObject\",\"%s\")",FeatName.c_str()); - doCommand(Doc,"App.activeDocument().%s.RobotVrmlFile = App.getResourceDir()+\"%s\"",FeatName.c_str(),RobotPath.c_str()); - doCommand(Doc,"App.activeDocument().%s.RobotKinematicFile = App.getResourceDir()+\"%s\"",FeatName.c_str(),KinematicPath.c_str()); - doCommand(Doc,"App.activeDocument().%s.Axis2 = -90",FeatName.c_str()); - doCommand(Doc,"App.activeDocument().%s.Axis3 = 90",FeatName.c_str()); - doCommand(Doc,"App.activeDocument().%s.Axis5 = 45",FeatName.c_str()); + doCommand(Doc, + "App.activeDocument().addObject(\"Robot::RobotObject\",\"%s\")", + FeatName.c_str()); + doCommand(Doc, + "App.activeDocument().%s.RobotVrmlFile = App.getResourceDir()+\"%s\"", + FeatName.c_str(), + RobotPath.c_str()); + doCommand(Doc, + "App.activeDocument().%s.RobotKinematicFile = App.getResourceDir()+\"%s\"", + FeatName.c_str(), + KinematicPath.c_str()); + doCommand(Doc, "App.activeDocument().%s.Axis2 = -90", FeatName.c_str()); + doCommand(Doc, "App.activeDocument().%s.Axis3 = 90", FeatName.c_str()); + doCommand(Doc, "App.activeDocument().%s.Axis5 = 45", FeatName.c_str()); updateActive(); commitCommand(); - } bool CmdRobotInsertKukaIR210::isActive() @@ -163,15 +186,15 @@ bool CmdRobotInsertKukaIR210::isActive() DEF_STD_CMD_A(CmdRobotInsertKukaIR125) CmdRobotInsertKukaIR125::CmdRobotInsertKukaIR125() - :Command("Robot_InsertKukaIR125") + : Command("Robot_InsertKukaIR125") { - sAppModule = "Robot"; - sGroup = QT_TR_NOOP("Robot"); - sMenuText = QT_TR_NOOP("Kuka IR125"); - sToolTipText = QT_TR_NOOP("Insert a Kuka IR125 into the document."); - sWhatsThis = "Robot_InsertKukaIR125"; - sStatusTip = sToolTipText; - sPixmap = "Robot_CreateRobot"; + sAppModule = "Robot"; + sGroup = QT_TR_NOOP("Robot"); + sMenuText = QT_TR_NOOP("Kuka IR125"); + sToolTipText = QT_TR_NOOP("Insert a Kuka IR125 into the document."); + sWhatsThis = "Robot_InsertKukaIR125"; + sStatusTip = sToolTipText; + sPixmap = "Robot_CreateRobot"; } @@ -182,15 +205,22 @@ void CmdRobotInsertKukaIR125::activated(int) std::string KinematicPath = "Mod/Robot/Lib/Kuka/kr_125.csv"; openCommand("Place robot"); - doCommand(Doc,"App.activeDocument().addObject(\"Robot::RobotObject\",\"%s\")",FeatName.c_str()); - doCommand(Doc,"App.activeDocument().%s.RobotVrmlFile = App.getResourceDir()+\"%s\"",FeatName.c_str(),RobotPath.c_str()); - doCommand(Doc,"App.activeDocument().%s.RobotKinematicFile = App.getResourceDir()+\"%s\"",FeatName.c_str(),KinematicPath.c_str()); - doCommand(Doc,"App.activeDocument().%s.Axis2 = -90",FeatName.c_str()); - doCommand(Doc,"App.activeDocument().%s.Axis3 = 90",FeatName.c_str()); - doCommand(Doc,"App.activeDocument().%s.Axis5 = 45",FeatName.c_str()); + doCommand(Doc, + "App.activeDocument().addObject(\"Robot::RobotObject\",\"%s\")", + FeatName.c_str()); + doCommand(Doc, + "App.activeDocument().%s.RobotVrmlFile = App.getResourceDir()+\"%s\"", + FeatName.c_str(), + RobotPath.c_str()); + doCommand(Doc, + "App.activeDocument().%s.RobotKinematicFile = App.getResourceDir()+\"%s\"", + FeatName.c_str(), + KinematicPath.c_str()); + doCommand(Doc, "App.activeDocument().%s.Axis2 = -90", FeatName.c_str()); + doCommand(Doc, "App.activeDocument().%s.Axis3 = 90", FeatName.c_str()); + doCommand(Doc, "App.activeDocument().%s.Axis5 = 45", FeatName.c_str()); updateActive(); commitCommand(); - } bool CmdRobotInsertKukaIR125::isActive() @@ -204,60 +234,66 @@ bool CmdRobotInsertKukaIR125::isActive() DEF_STD_CMD_A(CmdRobotAddToolShape) CmdRobotAddToolShape::CmdRobotAddToolShape() - :Command("Robot_AddToolShape") + : Command("Robot_AddToolShape") { - sAppModule = "Robot"; - sGroup = QT_TR_NOOP("Robot"); - sMenuText = QT_TR_NOOP("Add tool"); - sToolTipText = QT_TR_NOOP("Add a tool shape to the robot"); - sWhatsThis = "Robot_AddToolShape"; - sStatusTip = sToolTipText; - sPixmap = "Robot_CreateRobot"; + sAppModule = "Robot"; + sGroup = QT_TR_NOOP("Robot"); + sMenuText = QT_TR_NOOP("Add tool"); + sToolTipText = QT_TR_NOOP("Add 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")); + 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.")); + 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) + if (shapes.size() == 1) { ShapeName = shapes.front()->getNameInDocument(); - else + } + 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()); + 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 false; // not yet implemented and thus not active return hasActiveDocument(); } void CreateRobotCommandsInsertRobots() { - Gui::CommandManager &rcCmdMgr = Gui::Application::Instance->commandManager(); + Gui::CommandManager& rcCmdMgr = Gui::Application::Instance->commandManager(); rcCmdMgr.addCommand(new CmdRobotInsertKukaIR16()); rcCmdMgr.addCommand(new CmdRobotInsertKukaIR500()); rcCmdMgr.addCommand(new CmdRobotInsertKukaIR210()); rcCmdMgr.addCommand(new CmdRobotInsertKukaIR125()); rcCmdMgr.addCommand(new CmdRobotAddToolShape()); - } +} diff --git a/src/Mod/Robot/Gui/CommandTrajectory.cpp b/src/Mod/Robot/Gui/CommandTrajectory.cpp index 3836bf0db2..f87604e4fa 100644 --- a/src/Mod/Robot/Gui/CommandTrajectory.cpp +++ b/src/Mod/Robot/Gui/CommandTrajectory.cpp @@ -22,8 +22,8 @@ #include "PreCompiled.h" #ifndef _PreComp_ -# include -# include +#include +#include #endif #include @@ -49,15 +49,15 @@ using namespace RobotGui; DEF_STD_CMD_A(CmdRobotCreateTrajectory) CmdRobotCreateTrajectory::CmdRobotCreateTrajectory() - :Command("Robot_CreateTrajectory") + : Command("Robot_CreateTrajectory") { - sAppModule = "Robot"; - sGroup = QT_TR_NOOP("Robot"); - sMenuText = QT_TR_NOOP("Create trajectory"); - sToolTipText = QT_TR_NOOP("Create a new empty trajectory"); - sWhatsThis = "Robot_CreateTrajectory"; - sStatusTip = sToolTipText; - sPixmap = "Robot_CreateTrajectory"; + sAppModule = "Robot"; + sGroup = QT_TR_NOOP("Robot"); + sMenuText = QT_TR_NOOP("Create trajectory"); + sToolTipText = QT_TR_NOOP("Create a new empty trajectory"); + sWhatsThis = "Robot_CreateTrajectory"; + sStatusTip = sToolTipText; + sPixmap = "Robot_CreateTrajectory"; } @@ -66,10 +66,11 @@ void CmdRobotCreateTrajectory::activated(int) std::string FeatName = getUniqueObjectName("Trajectory"); openCommand("Create trajectory"); - doCommand(Doc,"App.activeDocument().addObject(\"Robot::TrajectoryObject\",\"%s\")",FeatName.c_str()); + doCommand(Doc, + "App.activeDocument().addObject(\"Robot::TrajectoryObject\",\"%s\")", + FeatName.c_str()); updateActive(); commitCommand(); - } bool CmdRobotCreateTrajectory::isActive() @@ -82,16 +83,16 @@ bool CmdRobotCreateTrajectory::isActive() DEF_STD_CMD_A(CmdRobotInsertWaypoint) CmdRobotInsertWaypoint::CmdRobotInsertWaypoint() - :Command("Robot_InsertWaypoint") + : Command("Robot_InsertWaypoint") { - sAppModule = "Robot"; - sGroup = QT_TR_NOOP("Robot"); - sMenuText = QT_TR_NOOP("Insert in trajectory"); - sToolTipText = QT_TR_NOOP("Insert robot Tool location into trajectory"); - sWhatsThis = "Robot_InsertWaypoint"; - sStatusTip = sToolTipText; - sPixmap = "Robot_InsertWaypoint"; - sAccel = "A"; + sAppModule = "Robot"; + sGroup = QT_TR_NOOP("Robot"); + sMenuText = QT_TR_NOOP("Insert in trajectory"); + sToolTipText = QT_TR_NOOP("Insert robot Tool location into trajectory"); + sWhatsThis = "Robot_InsertWaypoint"; + sStatusTip = sToolTipText; + sPixmap = "Robot_InsertWaypoint"; + sAccel = "A"; } @@ -101,32 +102,44 @@ void CmdRobotInsertWaypoint::activated(int) unsigned int n2 = getSelection().countObjectsOfType(Robot::TrajectoryObject::getClassTypeId()); if (n1 != 1 || n2 != 1) { - QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"), - QObject::tr("Select one Robot and one Trajectory object.")); + QMessageBox::warning(Gui::getMainWindow(), + QObject::tr("Wrong selection"), + QObject::tr("Select one Robot and one Trajectory object.")); return; } std::vector Sel = getSelection().getSelection(); - Robot::RobotObject *pcRobotObject=nullptr; - if(Sel[0].pObject->getTypeId() == Robot::RobotObject::getClassTypeId()) + Robot::RobotObject* pcRobotObject = nullptr; + if (Sel[0].pObject->getTypeId() == Robot::RobotObject::getClassTypeId()) { pcRobotObject = static_cast(Sel[0].pObject); - else if(Sel[1].pObject->getTypeId() == Robot::RobotObject::getClassTypeId()) + } + else if (Sel[1].pObject->getTypeId() == Robot::RobotObject::getClassTypeId()) { pcRobotObject = static_cast(Sel[1].pObject); + } std::string RoboName = pcRobotObject->getNameInDocument(); - Robot::TrajectoryObject *pcTrajectoryObject=nullptr; - if(Sel[0].pObject->getTypeId() == Robot::TrajectoryObject::getClassTypeId()) + Robot::TrajectoryObject* pcTrajectoryObject = nullptr; + if (Sel[0].pObject->getTypeId() == Robot::TrajectoryObject::getClassTypeId()) { pcTrajectoryObject = static_cast(Sel[0].pObject); - else if(Sel[1].pObject->getTypeId() == Robot::TrajectoryObject::getClassTypeId()) + } + else if (Sel[1].pObject->getTypeId() == Robot::TrajectoryObject::getClassTypeId()) { pcTrajectoryObject = static_cast(Sel[1].pObject); + } std::string TrakName = pcTrajectoryObject->getNameInDocument(); openCommand("Insert waypoint"); - doCommand(Doc,"App.activeDocument().%s.Trajectory = App.activeDocument().%s.Trajectory.insertWaypoints(Robot.Waypoint(App.activeDocument().%s.Tcp.multiply(App.activeDocument().%s.Tool),type='LIN',name='Pt',vel=_DefSpeed,cont=_DefCont,acc=_DefAcceleration,tool=1))",TrakName.c_str(),TrakName.c_str(),RoboName.c_str(),RoboName.c_str()); + doCommand(Doc, + "App.activeDocument().%s.Trajectory = " + "App.activeDocument().%s.Trajectory.insertWaypoints(Robot.Waypoint(App." + "activeDocument().%s.Tcp.multiply(App.activeDocument().%s.Tool),type='LIN',name='Pt'," + "vel=_DefSpeed,cont=_DefCont,acc=_DefAcceleration,tool=1))", + TrakName.c_str(), + TrakName.c_str(), + RoboName.c_str(), + RoboName.c_str()); updateActive(); commitCommand(); - } bool CmdRobotInsertWaypoint::isActive() @@ -139,58 +152,71 @@ bool CmdRobotInsertWaypoint::isActive() DEF_STD_CMD_A(CmdRobotInsertWaypointPreselect) CmdRobotInsertWaypointPreselect::CmdRobotInsertWaypointPreselect() - :Command("Robot_InsertWaypointPreselect") + : Command("Robot_InsertWaypointPreselect") { - sAppModule = "Robot"; - sGroup = QT_TR_NOOP("Robot"); - sMenuText = QT_TR_NOOP("Insert in trajectory"); - sToolTipText = QT_TR_NOOP("Insert preselection position into trajectory (W)"); - sWhatsThis = "Robot_InsertWaypointPreselect"; - sStatusTip = sToolTipText; - sPixmap = "Robot_InsertWaypointPre"; - sAccel = "W"; - + sAppModule = "Robot"; + sGroup = QT_TR_NOOP("Robot"); + sMenuText = QT_TR_NOOP("Insert in trajectory"); + sToolTipText = QT_TR_NOOP("Insert preselection position into trajectory (W)"); + sWhatsThis = "Robot_InsertWaypointPreselect"; + sStatusTip = sToolTipText; + sPixmap = "Robot_InsertWaypointPre"; + sAccel = "W"; } void CmdRobotInsertWaypointPreselect::activated(int) { - if (getSelection().size() != 1 ) { - QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"), - QObject::tr("Select one Trajectory object.")); + if (getSelection().size() != 1) { + QMessageBox::warning(Gui::getMainWindow(), + QObject::tr("Wrong selection"), + QObject::tr("Select one Trajectory object.")); return; } std::vector Sel = getSelection().getSelection(); - const Gui::SelectionChanges & PreSel = getSelection().getPreselection(); + const Gui::SelectionChanges& PreSel = getSelection().getPreselection(); float x = PreSel.x; float y = PreSel.y; float z = PreSel.z; - Robot::TrajectoryObject *pcTrajectoryObject; - if (Sel[0].pObject->getTypeId() == Robot::TrajectoryObject::getClassTypeId()) + Robot::TrajectoryObject* pcTrajectoryObject; + if (Sel[0].pObject->getTypeId() == Robot::TrajectoryObject::getClassTypeId()) { pcTrajectoryObject = static_cast(Sel[0].pObject); + } else { - QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"), - QObject::tr("Select one Trajectory object.")); + QMessageBox::warning(Gui::getMainWindow(), + QObject::tr("Wrong selection"), + QObject::tr("Select one Trajectory object.")); return; } std::string TrakName = pcTrajectoryObject->getNameInDocument(); if (!PreSel.pDocName) { - QMessageBox::warning(Gui::getMainWindow(), QObject::tr("No preselection"), - QObject::tr("You have to hover above a geometry (Preselection) with the mouse to use this command. See documentation for details.")); + QMessageBox::warning( + Gui::getMainWindow(), + QObject::tr("No preselection"), + QObject::tr("You have to hover above a geometry (Preselection) with the mouse to use " + "this command. See documentation for details.")); return; } openCommand("Insert waypoint"); - doCommand(Doc,"App.activeDocument().%s.Trajectory = App.activeDocument().%s.Trajectory.insertWaypoints(Robot.Waypoint(FreeCAD.Placement(FreeCAD.Vector(%f,%f,%f)+_DefDisplacement,_DefOrientation),type='LIN',name='Pt',vel=_DefSpeed,cont=_DefCont,acc=_DefAcceleration,tool=1))",TrakName.c_str(),TrakName.c_str(),x,y,z); + doCommand(Doc, + "App.activeDocument().%s.Trajectory = " + "App.activeDocument().%s.Trajectory.insertWaypoints(Robot.Waypoint(FreeCAD.Placement(" + "FreeCAD.Vector(%f,%f,%f)+_DefDisplacement,_DefOrientation),type='LIN',name='Pt',vel=" + "_DefSpeed,cont=_DefCont,acc=_DefAcceleration,tool=1))", + TrakName.c_str(), + TrakName.c_str(), + x, + y, + z); updateActive(); commitCommand(); - } bool CmdRobotInsertWaypointPreselect::isActive() @@ -203,16 +229,16 @@ bool CmdRobotInsertWaypointPreselect::isActive() DEF_STD_CMD_A(CmdRobotSetDefaultOrientation) CmdRobotSetDefaultOrientation::CmdRobotSetDefaultOrientation() - :Command("Robot_SetDefaultOrientation") + : Command("Robot_SetDefaultOrientation") { - sAppModule = "Robot"; - sGroup = QT_TR_NOOP("Robot"); - sMenuText = QT_TR_NOOP("Set default orientation"); - sToolTipText = QT_TR_NOOP("Set the default orientation for subsequent commands for waypoint creation"); - sWhatsThis = "Robot_SetDefaultOrientation"; - sStatusTip = sToolTipText; - sPixmap = nullptr; - + sAppModule = "Robot"; + sGroup = QT_TR_NOOP("Robot"); + sMenuText = QT_TR_NOOP("Set default orientation"); + sToolTipText = + QT_TR_NOOP("Set the default orientation for subsequent commands for waypoint creation"); + sWhatsThis = "Robot_SetDefaultOrientation"; + sStatusTip = sToolTipText; + sPixmap = nullptr; } @@ -223,12 +249,17 @@ void CmdRobotSetDefaultOrientation::activated(int) Dlg.setSelection(Gui::Selection().getSelectionEx()); Base::Placement place; Dlg.setPlacement(place); - if (Dlg.exec() == QDialog::Accepted ){ + if (Dlg.exec() == QDialog::Accepted) { place = Dlg.getPlacement(); Base::Rotation rot = place.getRotation(); Base::Vector3d disp = place.getPosition(); - doCommand(Doc,"_DefOrientation = FreeCAD.Rotation(%f,%f,%f,%f)",rot[0],rot[1],rot[2],rot[3]); - doCommand(Doc,"_DefDisplacement = FreeCAD.Vector(%f,%f,%f)",disp[0],disp[1],disp[2]); + doCommand(Doc, + "_DefOrientation = FreeCAD.Rotation(%f,%f,%f,%f)", + rot[0], + rot[1], + rot[2], + rot[3]); + doCommand(Doc, "_DefDisplacement = FreeCAD.Vector(%f,%f,%f)", disp[0], disp[1], disp[2]); } } @@ -242,16 +273,16 @@ bool CmdRobotSetDefaultOrientation::isActive() DEF_STD_CMD_A(CmdRobotSetDefaultValues) CmdRobotSetDefaultValues::CmdRobotSetDefaultValues() - :Command("Robot_SetDefaultValues") + : Command("Robot_SetDefaultValues") { - sAppModule = "Robot"; - sGroup = QT_TR_NOOP("Robot"); - sMenuText = QT_TR_NOOP("Set default values"); - sToolTipText = QT_TR_NOOP("Set the default values for speed, acceleration and continuity for subsequent commands of waypoint creation"); - sWhatsThis = "Robot_SetDefaultValues"; - sStatusTip = sToolTipText; - sPixmap = nullptr; - + sAppModule = "Robot"; + sGroup = QT_TR_NOOP("Robot"); + sMenuText = QT_TR_NOOP("Set default values"); + sToolTipText = QT_TR_NOOP("Set the default values for speed, acceleration and continuity for " + "subsequent commands of waypoint creation"); + sWhatsThis = "Robot_SetDefaultValues"; + sStatusTip = sToolTipText; + sPixmap = nullptr; } @@ -259,43 +290,58 @@ void CmdRobotSetDefaultValues::activated(int) { bool ok; - QString text = QInputDialog::getText(nullptr, QObject::tr("Set default speed"), - QObject::tr("speed: (e.g. 1 m/s or 3 cm/s)"), QLineEdit::Normal, - QString::fromLatin1("1 m/s"), &ok, Qt::MSWindowsFixedSizeDialogHint); - if ( ok && !text.isEmpty() ) { - doCommand(Doc,"_DefSpeed = '%s'",text.toLatin1().constData()); + QString text = QInputDialog::getText(nullptr, + QObject::tr("Set default speed"), + QObject::tr("speed: (e.g. 1 m/s or 3 cm/s)"), + QLineEdit::Normal, + QString::fromLatin1("1 m/s"), + &ok, + Qt::MSWindowsFixedSizeDialogHint); + if (ok && !text.isEmpty()) { + doCommand(Doc, "_DefSpeed = '%s'", text.toLatin1().constData()); } QStringList items; - items << QString::fromLatin1("False") << QString::fromLatin1("True"); + items << QString::fromLatin1("False") << QString::fromLatin1("True"); - QString item = QInputDialog::getItem(nullptr, QObject::tr("Set default continuity"), - QObject::tr("continuous ?"), items, 0, false, &ok, Qt::MSWindowsFixedSizeDialogHint); - if (ok && !item.isEmpty()) - doCommand(Doc,"_DefCont = %s",item.toLatin1().constData()); + QString item = QInputDialog::getItem(nullptr, + QObject::tr("Set default continuity"), + QObject::tr("continuous ?"), + items, + 0, + false, + &ok, + Qt::MSWindowsFixedSizeDialogHint); + if (ok && !item.isEmpty()) { + doCommand(Doc, "_DefCont = %s", item.toLatin1().constData()); + } text.clear(); - text = QInputDialog::getText(nullptr, QObject::tr("Set default acceleration"), - QObject::tr("acceleration: (e.g. 1 m/s^2 or 3 cm/s^2)"), QLineEdit::Normal, - QString::fromLatin1("1 m/s^2"), &ok, Qt::MSWindowsFixedSizeDialogHint); - if ( ok && !text.isEmpty() ) { - doCommand(Doc,"_DefAcceleration = '%s'",text.toLatin1().constData()); + text = QInputDialog::getText(nullptr, + QObject::tr("Set default acceleration"), + QObject::tr("acceleration: (e.g. 1 m/s^2 or 3 cm/s^2)"), + QLineEdit::Normal, + QString::fromLatin1("1 m/s^2"), + &ok, + Qt::MSWindowsFixedSizeDialogHint); + if (ok && !text.isEmpty()) { + doCommand(Doc, "_DefAcceleration = '%s'", text.toLatin1().constData()); } // create placement dialog - //Gui::Dialog::Placement *Dlg = new Gui::Dialog::Placement(); - //Base::Placement place; - //Dlg->setPlacement(place); - //if(Dlg->exec() == QDialog::Accepted ){ + // Gui::Dialog::Placement *Dlg = new Gui::Dialog::Placement(); + // Base::Placement place; + // Dlg->setPlacement(place); + // if(Dlg->exec() == QDialog::Accepted ){ // place = Dlg->getPlacement(); // Base::Rotation rot = place.getRotation(); // Base::Vector3d disp = place.getPosition(); - // doCommand(Doc,"_DefOrientation = FreeCAD.Rotation(%f,%f,%f,%f)",rot[0],rot[1],rot[2],rot[3]); + // doCommand(Doc,"_DefOrientation = + // FreeCAD.Rotation(%f,%f,%f,%f)",rot[0],rot[1],rot[2],rot[3]); // doCommand(Doc,"_DefDisplacement = FreeCAD.Vector(%f,%f,%f)",disp[0],disp[1],disp[2]); //} - } bool CmdRobotSetDefaultValues::isActive() @@ -308,58 +354,60 @@ bool CmdRobotSetDefaultValues::isActive() DEF_STD_CMD_A(CmdRobotEdge2Trac) CmdRobotEdge2Trac::CmdRobotEdge2Trac() - :Command("Robot_Edge2Trac") + : Command("Robot_Edge2Trac") { - sAppModule = "Robot"; - sGroup = QT_TR_NOOP("Robot"); - sMenuText = QT_TR_NOOP("Edge to Trajectory..."); - sToolTipText = QT_TR_NOOP("Generate a Trajectory from a set of edges"); - sWhatsThis = "Robot_Edge2Trac"; - sStatusTip = sToolTipText; - sPixmap = "Robot_Edge2Trac"; - + sAppModule = "Robot"; + sGroup = QT_TR_NOOP("Robot"); + sMenuText = QT_TR_NOOP("Edge to Trajectory..."); + sToolTipText = QT_TR_NOOP("Generate a Trajectory from a set of edges"); + sWhatsThis = "Robot_Edge2Trac"; + sStatusTip = sToolTipText; + sPixmap = "Robot_Edge2Trac"; } void CmdRobotEdge2Trac::activated(int) { - /* App::DocumentObject *obj = this->getDocument()->getObject(FeatName.c_str()); - App::Property *prop = &(dynamic_cast(obj)->Source); + /* App::DocumentObject *obj = this->getDocument()->getObject(FeatName.c_str()); + App::Property *prop = &(dynamic_cast(obj)->Source); - Gui::TaskView::TaskDialog* dlg = new TaskDlgEdge2Trac(dynamic_cast(obj)); - Gui::Control().showDialog(dlg);*/ + Gui::TaskView::TaskDialog* dlg = new TaskDlgEdge2Trac(dynamic_cast(obj)); Gui::Control().showDialog(dlg);*/ Gui::SelectionFilter ObjectFilter("SELECT Robot::Edge2TracObject COUNT 1"); - Gui::SelectionFilter EdgeFilter ("SELECT Part::Feature SUBELEMENT Edge COUNT 1.."); + Gui::SelectionFilter EdgeFilter("SELECT Part::Feature SUBELEMENT Edge COUNT 1.."); if (ObjectFilter.match()) { - Robot::Edge2TracObject *EdgeObj = static_cast(ObjectFilter.Result[0][0].getObject()); + Robot::Edge2TracObject* EdgeObj = + static_cast(ObjectFilter.Result[0][0].getObject()); openCommand("Edit Edge2TracObject"); - doCommand(Gui,"Gui.activeDocument().setEdit('%s')",EdgeObj->getNameInDocument()); - }else if (EdgeFilter.match()) { + doCommand(Gui, "Gui.activeDocument().setEdit('%s')", EdgeObj->getNameInDocument()); + } + else if (EdgeFilter.match()) { // get the selected object - //Part::Feature *part = static_cast(EdgeFilter.Result[0][0].getObject()); + // Part::Feature *part = static_cast(EdgeFilter.Result[0][0].getObject()); std::string obj_sub = EdgeFilter.Result[0][0].getAsPropertyLinkSubString(); std::string FeatName = getUniqueObjectName("Edge2Trac"); openCommand("Create a new Edge2TracObject"); - doCommand(Doc,"App.activeDocument().addObject('Robot::Edge2TracObject','%s')",FeatName.c_str()); - doCommand(Gui,"App.activeDocument().%s.Source = %s",FeatName.c_str(),obj_sub.c_str()); - doCommand(Gui,"Gui.activeDocument().setEdit('%s')",FeatName.c_str()); - - }else { + doCommand(Doc, + "App.activeDocument().addObject('Robot::Edge2TracObject','%s')", + FeatName.c_str()); + doCommand(Gui, "App.activeDocument().%s.Source = %s", FeatName.c_str(), obj_sub.c_str()); + doCommand(Gui, "Gui.activeDocument().setEdit('%s')", FeatName.c_str()); + } + else { std::string FeatName = getUniqueObjectName("Edge2Trac"); openCommand("Create a new Edge2TracObject"); - doCommand(Doc,"App.activeDocument().addObject('Robot::Edge2TracObject','%s')",FeatName.c_str()); - doCommand(Gui,"Gui.activeDocument().setEdit('%s')",FeatName.c_str()); + doCommand(Doc, + "App.activeDocument().addObject('Robot::Edge2TracObject','%s')", + FeatName.c_str()); + doCommand(Gui, "Gui.activeDocument().setEdit('%s')", FeatName.c_str()); } - - - } bool CmdRobotEdge2Trac::isActive() @@ -372,16 +420,16 @@ bool CmdRobotEdge2Trac::isActive() DEF_STD_CMD_A(CmdRobotTrajectoryDressUp) CmdRobotTrajectoryDressUp::CmdRobotTrajectoryDressUp() - :Command("Robot_TrajectoryDressUp") + : Command("Robot_TrajectoryDressUp") { - sAppModule = "Robot"; - sGroup = QT_TR_NOOP("Robot"); - sMenuText = QT_TR_NOOP("Dress-up trajectory..."); - sToolTipText = QT_TR_NOOP("Create a dress-up object which overrides some aspects of a trajectory"); - sWhatsThis = "Robot_TrajectoryDressUp"; - sStatusTip = sToolTipText; - sPixmap = "Robot_TrajectoryDressUp"; - + sAppModule = "Robot"; + sGroup = QT_TR_NOOP("Robot"); + sMenuText = QT_TR_NOOP("Dress-up trajectory..."); + sToolTipText = + QT_TR_NOOP("Create a dress-up object which overrides some aspects of a trajectory"); + sWhatsThis = "Robot_TrajectoryDressUp"; + sStatusTip = sToolTipText; + sPixmap = "Robot_TrajectoryDressUp"; } @@ -391,23 +439,33 @@ void CmdRobotTrajectoryDressUp::activated(int) Gui::SelectionFilter ObjectFilter("SELECT Robot::TrajectoryObject COUNT 1"); if (ObjectFilterDressUp.match()) { - Robot::TrajectoryDressUpObject *Object = static_cast(ObjectFilterDressUp.Result[0][0].getObject()); + Robot::TrajectoryDressUpObject* Object = static_cast( + ObjectFilterDressUp.Result[0][0].getObject()); openCommand("Edit Sketch"); - doCommand(Gui,"Gui.activeDocument().setEdit('%s')",Object->getNameInDocument()); - }else if (ObjectFilter.match()) { + doCommand(Gui, "Gui.activeDocument().setEdit('%s')", Object->getNameInDocument()); + } + else if (ObjectFilter.match()) { std::string FeatName = getUniqueObjectName("DressUpObject"); - Robot::TrajectoryObject *Object = static_cast(ObjectFilter.Result[0][0].getObject()); + Robot::TrajectoryObject* Object = + static_cast(ObjectFilter.Result[0][0].getObject()); openCommand("Create a new TrajectoryDressUp"); - doCommand(Doc,"App.activeDocument().addObject('Robot::TrajectoryDressUpObject','%s')",FeatName.c_str()); - doCommand(Gui,"App.activeDocument().%s.Source = App.activeDocument().%s",FeatName.c_str(),Object->getNameInDocument()); - doCommand(Gui,"Gui.activeDocument().hide(\"%s\")",Object->getNameInDocument()); - doCommand(Gui,"Gui.activeDocument().setEdit('%s')",FeatName.c_str()); - }else { - QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"), - QObject::tr("Select the Trajectory which you want to dress up.")); + doCommand(Doc, + "App.activeDocument().addObject('Robot::TrajectoryDressUpObject','%s')", + FeatName.c_str()); + doCommand(Gui, + "App.activeDocument().%s.Source = App.activeDocument().%s", + FeatName.c_str(), + Object->getNameInDocument()); + doCommand(Gui, "Gui.activeDocument().hide(\"%s\")", Object->getNameInDocument()); + doCommand(Gui, "Gui.activeDocument().setEdit('%s')", FeatName.c_str()); + } + else { + QMessageBox::warning(Gui::getMainWindow(), + QObject::tr("Wrong selection"), + QObject::tr("Select the Trajectory which you want to dress up.")); return; } - } +} bool CmdRobotTrajectoryDressUp::isActive() { @@ -419,16 +477,15 @@ bool CmdRobotTrajectoryDressUp::isActive() DEF_STD_CMD_A(CmdRobotTrajectoryCompound) CmdRobotTrajectoryCompound::CmdRobotTrajectoryCompound() - :Command("Robot_TrajectoryCompound") + : Command("Robot_TrajectoryCompound") { - sAppModule = "Robot"; - sGroup = QT_TR_NOOP("Robot"); - sMenuText = QT_TR_NOOP("Trajectory compound..."); - sToolTipText = QT_TR_NOOP("Group and connect some trajectories to one"); - sWhatsThis = "Robot_TrajectoryCompound"; - sStatusTip = sToolTipText; - sPixmap = "Robot_TrajectoryCompound"; - + sAppModule = "Robot"; + sGroup = QT_TR_NOOP("Robot"); + sMenuText = QT_TR_NOOP("Trajectory compound..."); + sToolTipText = QT_TR_NOOP("Group and connect some trajectories to one"); + sWhatsThis = "Robot_TrajectoryCompound"; + sStatusTip = sToolTipText; + sPixmap = "Robot_TrajectoryCompound"; } @@ -437,15 +494,19 @@ void CmdRobotTrajectoryCompound::activated(int) Gui::SelectionFilter ObjectFilter("SELECT Robot::TrajectoryCompound COUNT 1"); if (ObjectFilter.match()) { - Robot::TrajectoryCompound *Object = static_cast(ObjectFilter.Result[0][0].getObject()); + Robot::TrajectoryCompound* Object = + static_cast(ObjectFilter.Result[0][0].getObject()); openCommand("Edit TrajectoryCompound"); - doCommand(Gui,"Gui.activeDocument().setEdit('%s')",Object->getNameInDocument()); - }else { + doCommand(Gui, "Gui.activeDocument().setEdit('%s')", Object->getNameInDocument()); + } + else { std::string FeatName = getUniqueObjectName("TrajectoryCompound"); openCommand("Create a new TrajectoryDressUp"); - doCommand(Doc,"App.activeDocument().addObject('Robot::TrajectoryCompound','%s')",FeatName.c_str()); - doCommand(Gui,"Gui.activeDocument().setEdit('%s')",FeatName.c_str()); + doCommand(Doc, + "App.activeDocument().addObject('Robot::TrajectoryCompound','%s')", + FeatName.c_str()); + doCommand(Gui, "Gui.activeDocument().setEdit('%s')", FeatName.c_str()); } } @@ -455,14 +516,12 @@ bool CmdRobotTrajectoryCompound::isActive() } - // ##################################################################################################### - void CreateRobotCommandsTrajectory() { - Gui::CommandManager &rcCmdMgr = Gui::Application::Instance->commandManager(); + Gui::CommandManager& rcCmdMgr = Gui::Application::Instance->commandManager(); rcCmdMgr.addCommand(new CmdRobotCreateTrajectory()); rcCmdMgr.addCommand(new CmdRobotInsertWaypoint()); @@ -472,4 +531,4 @@ void CreateRobotCommandsTrajectory() rcCmdMgr.addCommand(new CmdRobotEdge2Trac()); rcCmdMgr.addCommand(new CmdRobotTrajectoryDressUp()); rcCmdMgr.addCommand(new CmdRobotTrajectoryCompound()); - } +} diff --git a/src/Mod/Robot/Gui/PreCompiled.h b/src/Mod/Robot/Gui/PreCompiled.h index eb2a061446..b380dfcb27 100644 --- a/src/Mod/Robot/Gui/PreCompiled.h +++ b/src/Mod/Robot/Gui/PreCompiled.h @@ -27,22 +27,22 @@ // Importing of App classes #ifdef FC_OS_WIN32 -# define RobotExport __declspec(dllimport) -# define PartExport __declspec(dllimport) -# define PartGuiExport __declspec(dllimport) -# define RobotGuiExport __declspec(dllexport) -#else // for Linux -# define PartExport -# define RobotExport -# define PartGuiExport -# define RobotGuiExport +#define RobotExport __declspec(dllimport) +#define PartExport __declspec(dllimport) +#define PartGuiExport __declspec(dllimport) +#define RobotGuiExport __declspec(dllexport) +#else// for Linux +#define PartExport +#define RobotExport +#define PartGuiExport +#define RobotGuiExport #endif #include #ifdef _MSC_VER -# pragma warning(disable : 4005) -# pragma warning(disable : 4273) +#pragma warning(disable : 4005) +#pragma warning(disable : 4273) #endif #ifdef _PreComp_ @@ -59,15 +59,16 @@ #include #include #include -#include -#include #include #include +#include +#include // Inventor +#include #include #include -#include +#include #include #include #include @@ -76,8 +77,7 @@ #include #include #include -#include -#endif //_PreComp_ +#endif//_PreComp_ -#endif // ROBOTGUI_PRECOMPILED_H +#endif// ROBOTGUI_PRECOMPILED_H diff --git a/src/Mod/Robot/Gui/Resources/Robot.qrc b/src/Mod/Robot/Gui/Resources/Robot.qrc index b3c16b1edb..ae118c8377 100644 --- a/src/Mod/Robot/Gui/Resources/Robot.qrc +++ b/src/Mod/Robot/Gui/Resources/Robot.qrc @@ -1,5 +1,5 @@ - + icons/Robot_CreateRobot.svg icons/Robot_CreateTrajectory.svg icons/Robot_Edge2Trac.svg @@ -15,4 +15,4 @@ icons/Robot_TrajectoryDressUp.svg icons/RobotWorkbench.svg - + diff --git a/src/Mod/Robot/Gui/TaskDlgEdge2Trac.cpp b/src/Mod/Robot/Gui/TaskDlgEdge2Trac.cpp index a0a7239d1e..c5d43531af 100644 --- a/src/Mod/Robot/Gui/TaskDlgEdge2Trac.cpp +++ b/src/Mod/Robot/Gui/TaskDlgEdge2Trac.cpp @@ -22,7 +22,7 @@ #include "PreCompiled.h" #ifndef _PreComp_ -# include +#include #endif #include @@ -42,11 +42,14 @@ using namespace RobotGui; // TaskDialog //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -TaskDlgEdge2Trac::TaskDlgEdge2Trac(Robot::Edge2TracObject *obj) - : TaskDialog(),Edge2TaskObject(obj) +TaskDlgEdge2Trac::TaskDlgEdge2Trac(Robot::Edge2TracObject* obj) + : TaskDialog() + , Edge2TaskObject(obj) { - param = new TaskEdge2TracParameter(obj); - select = new Gui::TaskView::TaskSelectLinkProperty("SELECT Part::Feature SUBELEMENT Edge COUNT 1..",&(obj->Source)); + param = new TaskEdge2TracParameter(obj); + select = + new Gui::TaskView::TaskSelectLinkProperty("SELECT Part::Feature SUBELEMENT Edge COUNT 1..", + &(obj->Source)); Content.push_back(param); Content.push_back(select); @@ -59,23 +62,23 @@ void TaskDlgEdge2Trac::open() { select->activate(); Edge2TaskObject->execute(); - param->setEdgeAndClusterNbr(Edge2TaskObject->NbrOfEdges,Edge2TaskObject->NbrOfCluster); - + param->setEdgeAndClusterNbr(Edge2TaskObject->NbrOfEdges, Edge2TaskObject->NbrOfCluster); } void TaskDlgEdge2Trac::clicked(int button) { try { - if(QDialogButtonBox::Apply == button) - { - if (select->isSelectionValid()){ + if (QDialogButtonBox::Apply == button) { + if (select->isSelectionValid()) { select->sendSelection2Property(); // May throw an exception which we must handle here Edge2TaskObject->execute(); - param->setEdgeAndClusterNbr(Edge2TaskObject->NbrOfEdges,Edge2TaskObject->NbrOfCluster); - } else { + param->setEdgeAndClusterNbr(Edge2TaskObject->NbrOfEdges, + Edge2TaskObject->NbrOfCluster); + } + else { QApplication::beep(); - param->setEdgeAndClusterNbr(0,0); + param->setEdgeAndClusterNbr(0, 0); } } } @@ -87,16 +90,18 @@ void TaskDlgEdge2Trac::clicked(int button) bool TaskDlgEdge2Trac::accept() { try { - if (select->isSelectionValid()){ + if (select->isSelectionValid()) { select->accept(); Edge2TaskObject->recomputeFeature(); Gui::Document* doc = Gui::Application::Instance->activeDocument(); - if(doc) + if (doc) { doc->resetEdit(); + } return true; } - else + else { QApplication::beep(); + } } catch (const Base::Exception& e) { Base::Console().Warning("TaskDlgEdge2Trac::accept(): %s\n", e.what()); @@ -113,9 +118,7 @@ bool TaskDlgEdge2Trac::reject() } void TaskDlgEdge2Trac::helpRequested() -{ - -} +{} #include "moc_TaskDlgEdge2Trac.cpp" diff --git a/src/Mod/Robot/Gui/TaskDlgEdge2Trac.h b/src/Mod/Robot/Gui/TaskDlgEdge2Trac.h index 8d6b7f6cb9..02b987a684 100644 --- a/src/Mod/Robot/Gui/TaskDlgEdge2Trac.h +++ b/src/Mod/Robot/Gui/TaskDlgEdge2Trac.h @@ -30,17 +30,24 @@ // forward -namespace Gui { namespace TaskView { class TaskSelectLinkProperty;}} +namespace Gui +{ +namespace TaskView +{ +class TaskSelectLinkProperty; +} +}// namespace Gui -namespace RobotGui { +namespace RobotGui +{ /// simulation dialog for the TaskView -class RobotGuiExport TaskDlgEdge2Trac : public Gui::TaskView::TaskDialog +class RobotGuiExport TaskDlgEdge2Trac: public Gui::TaskView::TaskDialog { Q_OBJECT public: - explicit TaskDlgEdge2Trac(Robot::Edge2TracObject *); + explicit TaskDlgEdge2Trac(Robot::Edge2TracObject*); public: /// is called the TaskView when the dialog is opened @@ -51,21 +58,22 @@ public: bool accept() override; /// is called by the framework if the dialog is rejected (Cancel) bool reject() override; - /// is called by the framework if the user press the help button + /// is called by the framework if the user press the help button void helpRequested() override; - /// returns for Close and Help button + /// returns for Close and Help button QDialogButtonBox::StandardButtons getStandardButtons() const override - { return QDialogButtonBox::Ok|QDialogButtonBox::Apply|QDialogButtonBox::Cancel; } + { + return QDialogButtonBox::Ok | QDialogButtonBox::Apply | QDialogButtonBox::Cancel; + } protected: - TaskEdge2TracParameter *param; - Gui::TaskView::TaskSelectLinkProperty *select; - Robot::Edge2TracObject *Edge2TaskObject; + TaskEdge2TracParameter* param; + Gui::TaskView::TaskSelectLinkProperty* select; + Robot::Edge2TracObject* Edge2TaskObject; }; +}// namespace RobotGui -} //namespace RobotGui - -#endif // ROBOTGUI_TASKDLGSIMULATE_H +#endif// ROBOTGUI_TASKDLGSIMULATE_H diff --git a/src/Mod/Robot/Gui/TaskDlgSimulate.cpp b/src/Mod/Robot/Gui/TaskDlgSimulate.cpp index c3ed656f56..9404917579 100644 --- a/src/Mod/Robot/Gui/TaskDlgSimulate.cpp +++ b/src/Mod/Robot/Gui/TaskDlgSimulate.cpp @@ -32,14 +32,15 @@ using namespace RobotGui; // TaskDialog //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -TaskDlgSimulate::TaskDlgSimulate(Robot::RobotObject *pcRobotObject,Robot::TrajectoryObject *pcTrajectoryObject) +TaskDlgSimulate::TaskDlgSimulate(Robot::RobotObject* pcRobotObject, + Robot::TrajectoryObject* pcTrajectoryObject) : TaskDialog() { - rob = new TaskRobot6Axis(pcRobotObject); - ctr = new TaskRobotControl(pcRobotObject); + rob = new TaskRobot6Axis(pcRobotObject); + ctr = new TaskRobotControl(pcRobotObject); - trac = new TaskTrajectory(pcRobotObject,pcTrajectoryObject); - msg = new TaskRobotMessages(pcRobotObject); + trac = new TaskTrajectory(pcRobotObject, pcTrajectoryObject); + msg = new TaskRobotMessages(pcRobotObject); QObject::connect(trac, &TaskTrajectory::axisChanged, rob, &TaskRobot6Axis::setAxis); @@ -59,9 +60,7 @@ void TaskDlgSimulate::open() } void TaskDlgSimulate::clicked(int) -{ - -} +{} bool TaskDlgSimulate::accept() { @@ -74,9 +73,7 @@ bool TaskDlgSimulate::reject() } void TaskDlgSimulate::helpRequested() -{ - -} +{} #include "moc_TaskDlgSimulate.cpp" diff --git a/src/Mod/Robot/Gui/TaskDlgSimulate.h b/src/Mod/Robot/Gui/TaskDlgSimulate.h index edd0fc30a7..9ee089ec7d 100644 --- a/src/Mod/Robot/Gui/TaskDlgSimulate.h +++ b/src/Mod/Robot/Gui/TaskDlgSimulate.h @@ -33,15 +33,16 @@ #include "TaskTrajectory.h" -namespace RobotGui { +namespace RobotGui +{ /// simulation dialog for the TaskView -class RobotGuiExport TaskDlgSimulate : public Gui::TaskView::TaskDialog +class RobotGuiExport TaskDlgSimulate: public Gui::TaskView::TaskDialog { Q_OBJECT public: - TaskDlgSimulate(Robot::RobotObject *pcRobotObject,Robot::TrajectoryObject *pcTrajectoryObject); + TaskDlgSimulate(Robot::RobotObject* pcRobotObject, Robot::TrajectoryObject* pcTrajectoryObject); public: /// is called the TaskView when the dialog is opened @@ -52,23 +53,23 @@ public: bool accept() override; /// is called by the framework if the dialog is rejected (Cancel) bool reject() override; - /// is called by the framework if the user press the help button + /// is called by the framework if the user press the help button void helpRequested() override; - /// returns for Close and Help button + /// returns for Close and Help button QDialogButtonBox::StandardButtons getStandardButtons() const override - { return QDialogButtonBox::Close|QDialogButtonBox::Help; } + { + return QDialogButtonBox::Close | QDialogButtonBox::Help; + } protected: - TaskRobot6Axis *rob; - TaskRobotControl *ctr ; - TaskTrajectory *trac; - TaskRobotMessages *msg ; - + TaskRobot6Axis* rob; + TaskRobotControl* ctr; + TaskTrajectory* trac; + TaskRobotMessages* msg; }; +}// namespace RobotGui -} //namespace RobotGui - -#endif // ROBOTGUI_TASKDLGSIMULATE_H +#endif// ROBOTGUI_TASKDLGSIMULATE_H diff --git a/src/Mod/Robot/Gui/TaskDlgTrajectoryCompound.cpp b/src/Mod/Robot/Gui/TaskDlgTrajectoryCompound.cpp index fcc967dce4..73b418b887 100644 --- a/src/Mod/Robot/Gui/TaskDlgTrajectoryCompound.cpp +++ b/src/Mod/Robot/Gui/TaskDlgTrajectoryCompound.cpp @@ -22,7 +22,7 @@ #include "PreCompiled.h" #ifndef _PreComp_ -# include +#include #endif #include @@ -39,10 +39,12 @@ using namespace RobotGui; // TaskDialog //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -TaskDlgTrajectoryCompound::TaskDlgTrajectoryCompound(Robot::TrajectoryCompound *obj) - : TaskDialog(),TrajectoryCompound(obj) +TaskDlgTrajectoryCompound::TaskDlgTrajectoryCompound(Robot::TrajectoryCompound* obj) + : TaskDialog() + , TrajectoryCompound(obj) { - select = new Gui::TaskView::TaskSelectLinkProperty("SELECT Robot::TrajectoryObject COUNT 1..",&(obj->Source)); + select = new Gui::TaskView::TaskSelectLinkProperty("SELECT Robot::TrajectoryObject COUNT 1..", + &(obj->Source)); Content.push_back(select); } @@ -53,20 +55,23 @@ TaskDlgTrajectoryCompound::TaskDlgTrajectoryCompound(Robot::TrajectoryCompound * void TaskDlgTrajectoryCompound::open() { select->activate(); - } bool TaskDlgTrajectoryCompound::accept() { - if(select->isSelectionValid()){ + if (select->isSelectionValid()) { select->accept(); TrajectoryCompound->execute(); Gui::Document* doc = Gui::Application::Instance->activeDocument(); - if(doc) doc->resetEdit(); + if (doc) { + doc->resetEdit(); + } return true; - }else + } + else { QApplication::beep(); + } return false; } @@ -76,14 +81,14 @@ bool TaskDlgTrajectoryCompound::reject() select->reject(); TrajectoryCompound->execute(); Gui::Document* doc = Gui::Application::Instance->activeDocument(); - if(doc) doc->resetEdit(); + if (doc) { + doc->resetEdit(); + } return true; } void TaskDlgTrajectoryCompound::helpRequested() -{ - -} +{} #include "moc_TaskDlgTrajectoryCompound.cpp" diff --git a/src/Mod/Robot/Gui/TaskDlgTrajectoryCompound.h b/src/Mod/Robot/Gui/TaskDlgTrajectoryCompound.h index 7934dcdfd6..0a0a75b073 100644 --- a/src/Mod/Robot/Gui/TaskDlgTrajectoryCompound.h +++ b/src/Mod/Robot/Gui/TaskDlgTrajectoryCompound.h @@ -28,17 +28,24 @@ // forward -namespace Gui { namespace TaskView { class TaskSelectLinkProperty;}} +namespace Gui +{ +namespace TaskView +{ +class TaskSelectLinkProperty; +} +}// namespace Gui -namespace RobotGui { +namespace RobotGui +{ /// simulation dialog for the TaskView -class RobotGuiExport TaskDlgTrajectoryCompound : public Gui::TaskView::TaskDialog +class RobotGuiExport TaskDlgTrajectoryCompound: public Gui::TaskView::TaskDialog { Q_OBJECT public: - TaskDlgTrajectoryCompound(Robot::TrajectoryCompound *); + TaskDlgTrajectoryCompound(Robot::TrajectoryCompound*); public: /// is called the TaskView when the dialog is opened @@ -47,20 +54,21 @@ public: bool accept() override; /// is called by the framework if the dialog is rejected (Cancel) bool reject() override; - /// is called by the framework if the user press the help button + /// is called by the framework if the user press the help button void helpRequested() override; - /// returns for Close and Help button + /// returns for Close and Help button QDialogButtonBox::StandardButtons getStandardButtons() const override - { return QDialogButtonBox::Ok|QDialogButtonBox::Cancel; } + { + return QDialogButtonBox::Ok | QDialogButtonBox::Cancel; + } protected: - Gui::TaskView::TaskSelectLinkProperty *select; - Robot::TrajectoryCompound *TrajectoryCompound; + Gui::TaskView::TaskSelectLinkProperty* select; + Robot::TrajectoryCompound* TrajectoryCompound; }; +}// namespace RobotGui -} //namespace RobotGui - -#endif // ROBOTGUI_TASKDLGSIMULATE_H +#endif// ROBOTGUI_TASKDLGSIMULATE_H diff --git a/src/Mod/Robot/Gui/TaskDlgTrajectoryDressUp.cpp b/src/Mod/Robot/Gui/TaskDlgTrajectoryDressUp.cpp index 3f91a904a5..3143bd682f 100644 --- a/src/Mod/Robot/Gui/TaskDlgTrajectoryDressUp.cpp +++ b/src/Mod/Robot/Gui/TaskDlgTrajectoryDressUp.cpp @@ -35,10 +35,11 @@ using namespace RobotGui; // TaskDialog //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -TaskDlgTrajectoryDressUp::TaskDlgTrajectoryDressUp(Robot::TrajectoryDressUpObject *obj) - : TaskDialog(),pcObject(obj) +TaskDlgTrajectoryDressUp::TaskDlgTrajectoryDressUp(Robot::TrajectoryDressUpObject* obj) + : TaskDialog() + , pcObject(obj) { - param = new TaskTrajectoryDressUpParameter(obj); + param = new TaskTrajectoryDressUpParameter(obj); Content.push_back(param); } @@ -47,14 +48,11 @@ TaskDlgTrajectoryDressUp::TaskDlgTrajectoryDressUp(Robot::TrajectoryDressUpObjec void TaskDlgTrajectoryDressUp::open() -{ - -} +{} void TaskDlgTrajectoryDressUp::clicked(int button) { - if(QDialogButtonBox::Apply == button) - { + if (QDialogButtonBox::Apply == button) { // transfer the values to the object param->writeValues(); // May throw an exception which we must handle here @@ -68,24 +66,23 @@ bool TaskDlgTrajectoryDressUp::accept() pcObject->recomputeFeature(); Gui::Document* doc = Gui::Application::Instance->activeDocument(); - if(doc) + if (doc) { doc->resetEdit(); + } return true; - } bool TaskDlgTrajectoryDressUp::reject() { Gui::Document* doc = Gui::Application::Instance->activeDocument(); - if(doc) + if (doc) { doc->resetEdit(); + } return true; } void TaskDlgTrajectoryDressUp::helpRequested() -{ - -} +{} #include "moc_TaskDlgTrajectoryDressUp.cpp" diff --git a/src/Mod/Robot/Gui/TaskDlgTrajectoryDressUp.h b/src/Mod/Robot/Gui/TaskDlgTrajectoryDressUp.h index 5ee99a6fe0..ab4147e745 100644 --- a/src/Mod/Robot/Gui/TaskDlgTrajectoryDressUp.h +++ b/src/Mod/Robot/Gui/TaskDlgTrajectoryDressUp.h @@ -30,17 +30,24 @@ // forward -namespace Gui { namespace TaskView { class TaskSelectLinkProperty;}} +namespace Gui +{ +namespace TaskView +{ +class TaskSelectLinkProperty; +} +}// namespace Gui -namespace RobotGui { +namespace RobotGui +{ /// simulation dialog for the TaskView -class RobotGuiExport TaskDlgTrajectoryDressUp : public Gui::TaskView::TaskDialog +class RobotGuiExport TaskDlgTrajectoryDressUp: public Gui::TaskView::TaskDialog { Q_OBJECT public: - explicit TaskDlgTrajectoryDressUp(Robot::TrajectoryDressUpObject *); + explicit TaskDlgTrajectoryDressUp(Robot::TrajectoryDressUpObject*); public: /// is called the TaskView when the dialog is opened @@ -51,20 +58,21 @@ public: bool accept() override; /// is called by the framework if the dialog is rejected (Cancel) bool reject() override; - /// is called by the framework if the user press the help button + /// is called by the framework if the user press the help button void helpRequested() override; - /// returns for Close and Help button + /// returns for Close and Help button QDialogButtonBox::StandardButtons getStandardButtons() const override - { return QDialogButtonBox::Ok|QDialogButtonBox::Apply|QDialogButtonBox::Cancel; } + { + return QDialogButtonBox::Ok | QDialogButtonBox::Apply | QDialogButtonBox::Cancel; + } protected: - TaskTrajectoryDressUpParameter *param; - Robot::TrajectoryDressUpObject *pcObject; + TaskTrajectoryDressUpParameter* param; + Robot::TrajectoryDressUpObject* pcObject; }; +}// namespace RobotGui -} //namespace RobotGui - -#endif // ROBOTGUI_TASKDLGSIMULATE_H +#endif// ROBOTGUI_TASKDLGSIMULATE_H diff --git a/src/Mod/Robot/Gui/TaskEdge2TracParameter.cpp b/src/Mod/Robot/Gui/TaskEdge2TracParameter.cpp index 42e78fccab..128c3424ba 100644 --- a/src/Mod/Robot/Gui/TaskEdge2TracParameter.cpp +++ b/src/Mod/Robot/Gui/TaskEdge2TracParameter.cpp @@ -22,7 +22,7 @@ #include "PreCompiled.h" #ifndef _PreComp_ -# include +#include #endif #include @@ -30,20 +30,20 @@ #include #include -#include "ui_TaskEdge2TracParameter.h" #include "TaskEdge2TracParameter.h" +#include "ui_TaskEdge2TracParameter.h" using namespace RobotGui; using namespace Gui; -TaskEdge2TracParameter::TaskEdge2TracParameter(Robot::Edge2TracObject *pcObject,QWidget *parent) +TaskEdge2TracParameter::TaskEdge2TracParameter(Robot::Edge2TracObject* pcObject, QWidget* parent) : TaskBox(Gui::BitmapFactory().pixmap("Robot_Edge2Trac"), - tr("TaskEdge2TracParameter"), - true, - parent), - pcObject(pcObject), - HideShowObj(nullptr) + tr("TaskEdge2TracParameter"), + true, + parent) + , pcObject(pcObject) + , HideShowObj(nullptr) { // we need a separate container widget to add all controls to proxy = new QWidget(this); @@ -53,23 +53,26 @@ TaskEdge2TracParameter::TaskEdge2TracParameter(Robot::Edge2TracObject *pcObject, this->groupLayout()->addWidget(proxy); - QObject::connect(ui->pushButton_HideShow, &QPushButton::clicked, this, &TaskEdge2TracParameter::hideShow); - QObject::connect(ui->doubleSpinBoxSizing, qOverload(&QDoubleSpinBox::valueChanged), - this, &TaskEdge2TracParameter::sizingValueChanged); - QObject::connect(ui->checkBoxOrientation, &QCheckBox::toggled, - this, &TaskEdge2TracParameter::orientationToggled); + // clang-format off + connect(ui->pushButton_HideShow, &QPushButton::clicked, + this, &TaskEdge2TracParameter::hideShow); + connect(ui->doubleSpinBoxSizing, qOverload(&QDoubleSpinBox::valueChanged), + this, &TaskEdge2TracParameter::sizingValueChanged); + connect(ui->checkBoxOrientation, &QCheckBox::toggled, + this, &TaskEdge2TracParameter::orientationToggled); + // clang-format on setHideShowObject(); - } void TaskEdge2TracParameter::setHideShowObject() { HideShowObj = pcObject->Source.getValue(); - if(HideShowObj){ + if (HideShowObj) { QString ObjectName = QString::fromUtf8(HideShowObj->Label.getValue()); ui->lineEdit_ObjectName->setText(ObjectName); - }else{ + } + else { ui->lineEdit_ObjectName->setText(QString()); } } @@ -78,12 +81,14 @@ void TaskEdge2TracParameter::hideShow() { setHideShowObject(); - if(HideShowObj){ + if (HideShowObj) { Gui::Document* doc = Gui::Application::Instance->activeDocument(); - if(doc->getViewProvider(HideShowObj)->isVisible()) + if (doc->getViewProvider(HideShowObj)->isVisible()) { doc->getViewProvider(HideShowObj)->setVisible(false); - else + } + else { doc->getViewProvider(HideShowObj)->setVisible(true); + } } } @@ -97,18 +102,19 @@ void TaskEdge2TracParameter::orientationToggled(bool Value) pcObject->UseRotation.setValue(Value); } -void TaskEdge2TracParameter::setEdgeAndClusterNbr(int NbrEdges,int NbrClusters) +void TaskEdge2TracParameter::setEdgeAndClusterNbr(int NbrEdges, int NbrClusters) { QPalette palette(QApplication::palette()); - QString text; + QString text; - const int a=200,p=0; + const int a = 200, p = 0; // set the text and the background color for the Edges label - if(NbrEdges > 0){ - palette.setBrush(QPalette::WindowText,QColor(p,a,p)); - }else{ - palette.setBrush(QPalette::WindowText,QColor(a,p,p)); + if (NbrEdges > 0) { + palette.setBrush(QPalette::WindowText, QColor(p, a, p)); + } + else { + palette.setBrush(QPalette::WindowText, QColor(a, p, p)); } text = QString::fromLatin1("Edges: %1").arg(NbrEdges); @@ -116,18 +122,16 @@ void TaskEdge2TracParameter::setEdgeAndClusterNbr(int NbrEdges,int NbrClusters) ui->label_Edges->setText(text); // set the text and the background color for the Clusters label - if(NbrClusters == 1){ - palette.setBrush(QPalette::WindowText,QColor(p,a,p)); - }else{ - palette.setBrush(QPalette::WindowText,QColor(a,p,p)); + if (NbrClusters == 1) { + palette.setBrush(QPalette::WindowText, QColor(p, a, p)); + } + else { + palette.setBrush(QPalette::WindowText, QColor(a, p, p)); } text = QString::fromLatin1("Cluster: %1").arg(NbrClusters); ui->label_Cluster->setPalette(palette); ui->label_Cluster->setText(text); - - - } diff --git a/src/Mod/Robot/Gui/TaskEdge2TracParameter.h b/src/Mod/Robot/Gui/TaskEdge2TracParameter.h index 950b2ee188..62ec607433 100644 --- a/src/Mod/Robot/Gui/TaskEdge2TracParameter.h +++ b/src/Mod/Robot/Gui/TaskEdge2TracParameter.h @@ -27,27 +27,29 @@ #include -class Ui_TaskEdge2TracParameter; - -namespace App { +namespace App +{ class Property; } -namespace Gui { +namespace Gui +{ class ViewProvider; } -namespace RobotGui { +namespace RobotGui +{ -class TaskEdge2TracParameter : public Gui::TaskView::TaskBox +class Ui_TaskEdge2TracParameter; +class TaskEdge2TracParameter: public Gui::TaskView::TaskBox { Q_OBJECT public: - explicit TaskEdge2TracParameter(Robot::Edge2TracObject *pcObject,QWidget *parent = nullptr); + explicit TaskEdge2TracParameter(Robot::Edge2TracObject* pcObject, QWidget* parent = nullptr); ~TaskEdge2TracParameter() override; - void setEdgeAndClusterNbr(int NbrEdges,int NbrClusters); + void setEdgeAndClusterNbr(int NbrEdges, int NbrClusters); private Q_SLOTS: void hideShow(); @@ -55,17 +57,17 @@ private Q_SLOTS: void orientationToggled(bool Value); protected: - Robot::Edge2TracObject *pcObject; - App::DocumentObject *HideShowObj; + Robot::Edge2TracObject* pcObject; + App::DocumentObject* HideShowObj; void setHideShowObject(); -private: +private: private: QWidget* proxy; Ui_TaskEdge2TracParameter* ui; }; -} //namespace PartDesignGui +}// namespace RobotGui -#endif // GUI_TASKVIEW_TASKAPPERANCE_H +#endif// GUI_TASKVIEW_TASKAPPERANCE_H diff --git a/src/Mod/Robot/Gui/TaskEdge2TracParameter.ui b/src/Mod/Robot/Gui/TaskEdge2TracParameter.ui index 088a55b247..5b9ce5fbb1 100644 --- a/src/Mod/Robot/Gui/TaskEdge2TracParameter.ui +++ b/src/Mod/Robot/Gui/TaskEdge2TracParameter.ui @@ -1,6 +1,6 @@ - TaskEdge2TracParameter + RobotGui::TaskEdge2TracParameter diff --git a/src/Mod/Robot/Gui/TaskRobot6Axis.cpp b/src/Mod/Robot/Gui/TaskRobot6Axis.cpp index 1acf5d16bc..94668777cd 100644 --- a/src/Mod/Robot/Gui/TaskRobot6Axis.cpp +++ b/src/Mod/Robot/Gui/TaskRobot6Axis.cpp @@ -22,24 +22,25 @@ #include "PreCompiled.h" #ifndef _PreComp_ -# include -# include +#include +#include #endif #include #include #include -#include "ui_TaskRobot6Axis.h" #include "TaskRobot6Axis.h" +#include "ui_TaskRobot6Axis.h" using namespace RobotGui; using namespace Gui; -TaskRobot6Axis::TaskRobot6Axis(Robot::RobotObject *pcRobotObject,QWidget *parent) - : TaskBox(Gui::BitmapFactory().pixmap("Robot_CreateRobot"),tr("TaskRobot6Axis"),true, parent), - pcRobot(pcRobotObject),Rob() +TaskRobot6Axis::TaskRobot6Axis(Robot::RobotObject* pcRobotObject, QWidget* parent) + : TaskBox(Gui::BitmapFactory().pixmap("Robot_CreateRobot"), tr("TaskRobot6Axis"), true, parent) + , pcRobot(pcRobotObject) + , Rob() { // we need a separate container widget to add all controls to proxy = new QWidget(this); @@ -49,13 +50,22 @@ TaskRobot6Axis::TaskRobot6Axis(Robot::RobotObject *pcRobotObject,QWidget *parent this->groupLayout()->addWidget(proxy); - QObject::connect(ui->horizontalSlider_Axis1, &QSlider::sliderMoved, this, &TaskRobot6Axis::changeSliderA1); - QObject::connect(ui->horizontalSlider_Axis2, &QSlider::sliderMoved, this, &TaskRobot6Axis::changeSliderA2); - QObject::connect(ui->horizontalSlider_Axis3, &QSlider::sliderMoved, this, &TaskRobot6Axis::changeSliderA3); - QObject::connect(ui->horizontalSlider_Axis4, &QSlider::sliderMoved, this, &TaskRobot6Axis::changeSliderA4); - QObject::connect(ui->horizontalSlider_Axis5, &QSlider::sliderMoved, this, &TaskRobot6Axis::changeSliderA5); - QObject::connect(ui->horizontalSlider_Axis6, &QSlider::sliderMoved, this, &TaskRobot6Axis::changeSliderA6); - QObject::connect(ui->pushButtonChooseTool, &QPushButton::clicked, this, &TaskRobot6Axis::createPlacementDlg); + // clang-format off + connect(ui->horizontalSlider_Axis1, &QSlider::sliderMoved, + this, &TaskRobot6Axis::changeSliderA1); + connect(ui->horizontalSlider_Axis2, &QSlider::sliderMoved, + this, &TaskRobot6Axis::changeSliderA2); + connect(ui->horizontalSlider_Axis3, &QSlider::sliderMoved, + this, &TaskRobot6Axis::changeSliderA3); + connect(ui->horizontalSlider_Axis4, &QSlider::sliderMoved, + this, &TaskRobot6Axis::changeSliderA4); + connect(ui->horizontalSlider_Axis5, &QSlider::sliderMoved, + this, &TaskRobot6Axis::changeSliderA5); + connect(ui->horizontalSlider_Axis6, &QSlider::sliderMoved, + this, &TaskRobot6Axis::changeSliderA6); + connect(ui->pushButtonChooseTool, &QPushButton::clicked, + this, &TaskRobot6Axis::createPlacementDlg); + // clang-format on if (pcRobotObject) { setRobot(pcRobotObject); @@ -67,32 +77,32 @@ TaskRobot6Axis::~TaskRobot6Axis() delete ui; } -void TaskRobot6Axis::setRobot(Robot::RobotObject *pcRobotObject) +void TaskRobot6Axis::setRobot(Robot::RobotObject* pcRobotObject) { pcRobot = pcRobotObject; - if(!pcRobotObject){ + if (!pcRobotObject) { delete Rob; return; } Rob = new Robot::Robot6Axis(pcRobot->getRobot()); - ui->horizontalSlider_Axis1->setMaximum( (int ) Rob->getMaxAngle(0) ); - ui->horizontalSlider_Axis1->setMinimum( (int ) Rob->getMinAngle(0) ); - - ui->horizontalSlider_Axis2->setMaximum( (int ) Rob->getMaxAngle(1) ); - ui->horizontalSlider_Axis2->setMinimum( (int ) Rob->getMinAngle(1) ); + ui->horizontalSlider_Axis1->setMaximum((int)Rob->getMaxAngle(0)); + ui->horizontalSlider_Axis1->setMinimum((int)Rob->getMinAngle(0)); - ui->horizontalSlider_Axis3->setMaximum( (int ) Rob->getMaxAngle(2) ); - ui->horizontalSlider_Axis3->setMinimum( (int ) Rob->getMinAngle(2) ); + ui->horizontalSlider_Axis2->setMaximum((int)Rob->getMaxAngle(1)); + ui->horizontalSlider_Axis2->setMinimum((int)Rob->getMinAngle(1)); - ui->horizontalSlider_Axis4->setMaximum( (int ) Rob->getMaxAngle(3) ); - ui->horizontalSlider_Axis4->setMinimum( (int ) Rob->getMinAngle(3) ); + ui->horizontalSlider_Axis3->setMaximum((int)Rob->getMaxAngle(2)); + ui->horizontalSlider_Axis3->setMinimum((int)Rob->getMinAngle(2)); - ui->horizontalSlider_Axis5->setMaximum( (int ) Rob->getMaxAngle(4) ); - ui->horizontalSlider_Axis5->setMinimum( (int ) Rob->getMinAngle(4) ); + ui->horizontalSlider_Axis4->setMaximum((int)Rob->getMaxAngle(3)); + ui->horizontalSlider_Axis4->setMinimum((int)Rob->getMinAngle(3)); - ui->horizontalSlider_Axis6->setMaximum( (int ) Rob->getMaxAngle(5) ); - ui->horizontalSlider_Axis6->setMinimum( (int ) Rob->getMinAngle(5) ); + ui->horizontalSlider_Axis5->setMaximum((int)Rob->getMaxAngle(4)); + ui->horizontalSlider_Axis5->setMinimum((int)Rob->getMinAngle(4)); + + ui->horizontalSlider_Axis6->setMaximum((int)Rob->getMaxAngle(5)); + ui->horizontalSlider_Axis6->setMinimum((int)Rob->getMinAngle(5)); setAxis(pcRobot->Axis1.getValue(), pcRobot->Axis2.getValue(), @@ -109,140 +119,141 @@ void TaskRobot6Axis::createPlacementDlg() Gui::Dialog::Placement plc; plc.setSelection(Gui::Selection().getSelectionEx()); plc.setPlacement(pcRobot->Tool.getValue()); - if (plc.exec()==QDialog::Accepted) + if (plc.exec() == QDialog::Accepted) { pcRobot->Tool.setValue(plc.getPlacement()); + } viewTool(pcRobot->Tool.getValue()); } void TaskRobot6Axis::viewTcp(const Base::Placement& pos) { - double A,B,C; - pos.getRotation().getYawPitchRoll(A,B,C); + double A, B, C; + pos.getRotation().getYawPitchRoll(A, B, C); QString result = QString::fromLatin1("TCP:( %1, %2, %3, %4, %5, %6 )") - .arg(pos.getPosition().x,0,'f',1) - .arg(pos.getPosition().y,0,'f',1) - .arg(pos.getPosition().z,0,'f',1) - .arg(A,0,'f',1) - .arg(B,0,'f',1) - .arg(C,0,'f',1); + .arg(pos.getPosition().x, 0, 'f', 1) + .arg(pos.getPosition().y, 0, 'f', 1) + .arg(pos.getPosition().z, 0, 'f', 1) + .arg(A, 0, 'f', 1) + .arg(B, 0, 'f', 1) + .arg(C, 0, 'f', 1); ui->label_TCP->setText(result); } void TaskRobot6Axis::viewTool(const Base::Placement& pos) { - double A,B,C; - pos.getRotation().getYawPitchRoll(A,B,C); + double A, B, C; + pos.getRotation().getYawPitchRoll(A, B, C); QString result = QString::fromLatin1("Tool:( %1, %2, %3, %4, %5, %6 )") - .arg(pos.getPosition().x,0,'f',1) - .arg(pos.getPosition().y,0,'f',1) - .arg(pos.getPosition().z,0,'f',1) - .arg(A,0,'f',1) - .arg(B,0,'f',1) - .arg(C,0,'f',1); + .arg(pos.getPosition().x, 0, 'f', 1) + .arg(pos.getPosition().y, 0, 'f', 1) + .arg(pos.getPosition().z, 0, 'f', 1) + .arg(A, 0, 'f', 1) + .arg(B, 0, 'f', 1) + .arg(C, 0, 'f', 1); ui->label_Tool->setText(result); } -void TaskRobot6Axis::changeSliderA1(int value){ - pcRobot->Axis1.setValue(float (value)); +void TaskRobot6Axis::changeSliderA1(int value) +{ + pcRobot->Axis1.setValue(float(value)); viewTcp(pcRobot->Tcp.getValue()); - ui->lineEdit_Axis1->setText(QString::fromUtf8("%1\xc2\xb0").arg((float)value,0,'f',1)); - setColor(0,float (value),*(ui->lineEdit_Axis1)); + ui->lineEdit_Axis1->setText(QString::fromUtf8("%1\xc2\xb0").arg((float)value, 0, 'f', 1)); + setColor(0, float(value), *(ui->lineEdit_Axis1)); } void TaskRobot6Axis::changeSliderA2(int value) { - pcRobot->Axis2.setValue(float (value)); + pcRobot->Axis2.setValue(float(value)); viewTcp(pcRobot->Tcp.getValue()); - ui->lineEdit_Axis2->setText(QString::fromUtf8("%1\xc2\xb0").arg((float)value,0,'f',1)); - setColor(1,float (value),*(ui->lineEdit_Axis2)); - + ui->lineEdit_Axis2->setText(QString::fromUtf8("%1\xc2\xb0").arg((float)value, 0, 'f', 1)); + setColor(1, float(value), *(ui->lineEdit_Axis2)); } void TaskRobot6Axis::changeSliderA3(int value) { - pcRobot->Axis3.setValue(float (value)); + pcRobot->Axis3.setValue(float(value)); viewTcp(pcRobot->Tcp.getValue()); - ui->lineEdit_Axis3->setText(QString::fromUtf8("%1\xc2\xb0").arg((float)value,0,'f',1)); - setColor(2,float (value),*(ui->lineEdit_Axis3)); - + ui->lineEdit_Axis3->setText(QString::fromUtf8("%1\xc2\xb0").arg((float)value, 0, 'f', 1)); + setColor(2, float(value), *(ui->lineEdit_Axis3)); } void TaskRobot6Axis::changeSliderA4(int value) { - pcRobot->Axis4.setValue(float (value)); + pcRobot->Axis4.setValue(float(value)); viewTcp(pcRobot->Tcp.getValue()); - ui->lineEdit_Axis4->setText(QString::fromLatin1("%1°").arg((float)value,0,'f',1)); - setColor(3,float (value),*(ui->lineEdit_Axis4)); - + ui->lineEdit_Axis4->setText(QString::fromLatin1("%1°").arg((float)value, 0, 'f', 1)); + setColor(3, float(value), *(ui->lineEdit_Axis4)); } void TaskRobot6Axis::changeSliderA5(int value) { - pcRobot->Axis5.setValue(float (value)); + pcRobot->Axis5.setValue(float(value)); viewTcp(pcRobot->Tcp.getValue()); - ui->lineEdit_Axis5->setText(QString::fromLatin1("%1°").arg((float)value,0,'f',1)); - setColor(4,float (value),*(ui->lineEdit_Axis5)); - + ui->lineEdit_Axis5->setText(QString::fromLatin1("%1°").arg((float)value, 0, 'f', 1)); + setColor(4, float(value), *(ui->lineEdit_Axis5)); } void TaskRobot6Axis::changeSliderA6(int value) { - pcRobot->Axis6.setValue(float (value)); + pcRobot->Axis6.setValue(float(value)); viewTcp(pcRobot->Tcp.getValue()); - ui->lineEdit_Axis6->setText(QString::fromLatin1("%1°").arg((float)value,0,'f',1)); - setColor(5,float (value),*(ui->lineEdit_Axis6)); - + ui->lineEdit_Axis6->setText(QString::fromLatin1("%1°").arg((float)value, 0, 'f', 1)); + setColor(5, float(value), *(ui->lineEdit_Axis6)); } -void TaskRobot6Axis::setColor(int i,float angle, QLineEdit &lineEdit){ +void TaskRobot6Axis::setColor(int i, float angle, QLineEdit& lineEdit) +{ - if( angle > Rob->getMaxAngle(i) || angle < Rob->getMinAngle(i)){ + if (angle > Rob->getMaxAngle(i) || angle < Rob->getMinAngle(i)) { QPalette p = lineEdit.palette(); - p.setColor(QPalette::Base, QColor(255,220,220));//green color - lineEdit.setPalette(p); - }else{ - QPalette p = lineEdit.palette(); - p.setColor(QPalette::Base, QColor(220,255,220));//green color + p.setColor(QPalette::Base, QColor(255, 220, 220));// green color + lineEdit.setPalette(p); + } + else { + QPalette p = lineEdit.palette(); + p.setColor(QPalette::Base, QColor(220, 255, 220));// green color lineEdit.setPalette(p); } - } -void TaskRobot6Axis::setAxis(float A1,float A2,float A3,float A4,float A5,float A6,const Base::Placement &Tcp) +void TaskRobot6Axis::setAxis(float A1, + float A2, + float A3, + float A4, + float A5, + float A6, + const Base::Placement& Tcp) { ui->horizontalSlider_Axis1->setSliderPosition((int)A1); - ui->lineEdit_Axis1->setText(QString::fromLatin1("%1°").arg(A1,0,'f',1)); - setColor(0,A1,*(ui->lineEdit_Axis1)); + ui->lineEdit_Axis1->setText(QString::fromLatin1("%1°").arg(A1, 0, 'f', 1)); + setColor(0, A1, *(ui->lineEdit_Axis1)); ui->horizontalSlider_Axis2->setSliderPosition((int)A2); - ui->lineEdit_Axis2->setText(QString::fromLatin1("%1°").arg(A2,0,'f',1)); - setColor(1,A2,*(ui->lineEdit_Axis2)); + ui->lineEdit_Axis2->setText(QString::fromLatin1("%1°").arg(A2, 0, 'f', 1)); + setColor(1, A2, *(ui->lineEdit_Axis2)); ui->horizontalSlider_Axis3->setSliderPosition((int)A3); - ui->lineEdit_Axis3->setText(QString::fromLatin1("%1°").arg(A3,0,'f',1)); - setColor(2,A3,*(ui->lineEdit_Axis3)); + ui->lineEdit_Axis3->setText(QString::fromLatin1("%1°").arg(A3, 0, 'f', 1)); + setColor(2, A3, *(ui->lineEdit_Axis3)); ui->horizontalSlider_Axis4->setSliderPosition((int)A4); - ui->lineEdit_Axis4->setText(QString::fromLatin1("%1°").arg(A4,0,'f',1)); - setColor(3,A4,*(ui->lineEdit_Axis4)); + ui->lineEdit_Axis4->setText(QString::fromLatin1("%1°").arg(A4, 0, 'f', 1)); + setColor(3, A4, *(ui->lineEdit_Axis4)); ui->horizontalSlider_Axis5->setSliderPosition((int)A5); - ui->lineEdit_Axis5->setText(QString::fromLatin1("%1°").arg(A5,0,'f',1)); - setColor(4,A5,*(ui->lineEdit_Axis5)); + ui->lineEdit_Axis5->setText(QString::fromLatin1("%1°").arg(A5, 0, 'f', 1)); + setColor(4, A5, *(ui->lineEdit_Axis5)); ui->horizontalSlider_Axis6->setSliderPosition((int)A6); - ui->lineEdit_Axis6->setText(QString::fromLatin1("%1°").arg(A6,0,'f',1)); - setColor(5,A6,*(ui->lineEdit_Axis6)); + ui->lineEdit_Axis6->setText(QString::fromLatin1("%1°").arg(A6, 0, 'f', 1)); + setColor(5, A6, *(ui->lineEdit_Axis6)); viewTcp(Tcp); - - } - #include "moc_TaskRobot6Axis.cpp" diff --git a/src/Mod/Robot/Gui/TaskRobot6Axis.h b/src/Mod/Robot/Gui/TaskRobot6Axis.h index b47067cfef..8a3590ab42 100644 --- a/src/Mod/Robot/Gui/TaskRobot6Axis.h +++ b/src/Mod/Robot/Gui/TaskRobot6Axis.h @@ -27,33 +27,36 @@ #include -class Ui_TaskRobot6Axis; class QLineEdit; -namespace App { +namespace App +{ class Property; } -namespace Gui { +namespace Gui +{ class ViewProvider; } -namespace RobotGui { +namespace RobotGui +{ - -class TaskRobot6Axis : public Gui::TaskView::TaskBox +class Ui_TaskRobot6Axis; +class TaskRobot6Axis: public Gui::TaskView::TaskBox { Q_OBJECT public: - explicit TaskRobot6Axis(Robot::RobotObject *pcRobotObject,QWidget *parent = nullptr); + explicit TaskRobot6Axis(Robot::RobotObject* pcRobotObject, QWidget* parent = nullptr); ~TaskRobot6Axis() override; - void setRobot(Robot::RobotObject *pcRobotObject); + void setRobot(Robot::RobotObject* pcRobotObject); public Q_SLOTS: - void setAxis(float A1,float A2,float A3,float A4,float A5,float A6,const Base::Placement &Tcp); + void + setAxis(float A1, float A2, float A3, float A4, float A5, float A6, const Base::Placement& Tcp); void changeSliderA1(int value); void changeSliderA2(int value); void changeSliderA3(int value); @@ -63,18 +66,18 @@ public Q_SLOTS: void createPlacementDlg(); protected: - Robot::RobotObject *pcRobot; + Robot::RobotObject* pcRobot; void viewTcp(const Base::Placement& pos); void viewTool(const Base::Placement& pos); - void setColor(int i,float angle, QLineEdit &lineEdit); -private: + void setColor(int i, float angle, QLineEdit& lineEdit); +private: private: QWidget* proxy; Ui_TaskRobot6Axis* ui; - Robot::Robot6Axis *Rob; + Robot::Robot6Axis* Rob; }; -} //namespace PartDesignGui +}// namespace RobotGui -#endif // GUI_TASKVIEW_TASKAPPERANCE_H +#endif// GUI_TASKVIEW_TASKAPPERANCE_H diff --git a/src/Mod/Robot/Gui/TaskRobotControl.cpp b/src/Mod/Robot/Gui/TaskRobotControl.cpp index 73674e8678..d21bcc1007 100644 --- a/src/Mod/Robot/Gui/TaskRobotControl.cpp +++ b/src/Mod/Robot/Gui/TaskRobotControl.cpp @@ -24,16 +24,19 @@ #include -#include "ui_TaskRobotControl.h" #include "TaskRobotControl.h" +#include "ui_TaskRobotControl.h" using namespace RobotGui; using namespace Gui; -TaskRobotControl::TaskRobotControl(Robot::RobotObject *pcRobotObject,QWidget *parent) - : TaskBox(Gui::BitmapFactory().pixmap("Robot_CreateRobot"),tr("TaskRobotControl"),true, parent), - pcRobot(pcRobotObject) +TaskRobotControl::TaskRobotControl(Robot::RobotObject* pcRobotObject, QWidget* parent) + : TaskBox(Gui::BitmapFactory().pixmap("Robot_CreateRobot"), + tr("TaskRobotControl"), + true, + parent) + , pcRobot(pcRobotObject) { // we need a separate container widget to add all controls to proxy = new QWidget(this); @@ -43,12 +46,12 @@ TaskRobotControl::TaskRobotControl(Robot::RobotObject *pcRobotObject,QWidget *pa this->groupLayout()->addWidget(proxy); - if(pcRobotObject) + if (pcRobotObject) { setRobot(pcRobotObject); - + } } -void TaskRobotControl::setRobot(Robot::RobotObject *pcRobotObject) +void TaskRobotControl::setRobot(Robot::RobotObject* pcRobotObject) { pcRobot = pcRobotObject; } diff --git a/src/Mod/Robot/Gui/TaskRobotControl.h b/src/Mod/Robot/Gui/TaskRobotControl.h index b007054ecb..c7948ae395 100644 --- a/src/Mod/Robot/Gui/TaskRobotControl.h +++ b/src/Mod/Robot/Gui/TaskRobotControl.h @@ -28,41 +28,42 @@ #include -class Ui_TaskRobotControl; - -namespace App { +namespace App +{ class Property; } -namespace Gui { +namespace Gui +{ class ViewProvider; } -namespace RobotGui { +namespace RobotGui +{ -class TaskRobotControl : public Gui::TaskView::TaskBox +class Ui_TaskRobotControl; +class TaskRobotControl: public Gui::TaskView::TaskBox { Q_OBJECT public: - explicit TaskRobotControl(Robot::RobotObject *pcRobotObject,QWidget *parent = nullptr); + explicit TaskRobotControl(Robot::RobotObject* pcRobotObject, QWidget* parent = nullptr); ~TaskRobotControl() override; - void setRobot(Robot::RobotObject *pcRobotObject); + void setRobot(Robot::RobotObject* pcRobotObject); private Q_SLOTS: - + protected: - Robot::RobotObject *pcRobot; + Robot::RobotObject* pcRobot; private: - private: QWidget* proxy; Ui_TaskRobotControl* ui; }; -} //namespace PartDesignGui +}// namespace RobotGui -#endif // GUI_TASKVIEW_TASKAPPERANCE_H +#endif// GUI_TASKVIEW_TASKAPPERANCE_H diff --git a/src/Mod/Robot/Gui/TaskRobotControl.ui b/src/Mod/Robot/Gui/TaskRobotControl.ui index d6fe44afa4..771bbe26b7 100644 --- a/src/Mod/Robot/Gui/TaskRobotControl.ui +++ b/src/Mod/Robot/Gui/TaskRobotControl.ui @@ -1,6 +1,6 @@ - TaskRobotControl + RobotGui::TaskRobotControl diff --git a/src/Mod/Robot/Gui/TaskRobotMessages.cpp b/src/Mod/Robot/Gui/TaskRobotMessages.cpp index b5fdffeaaf..ad15dd961a 100644 --- a/src/Mod/Robot/Gui/TaskRobotMessages.cpp +++ b/src/Mod/Robot/Gui/TaskRobotMessages.cpp @@ -24,16 +24,16 @@ #include -#include "ui_TaskRobotMessages.h" #include "TaskRobotMessages.h" +#include "ui_TaskRobotMessages.h" using namespace RobotGui; using namespace Gui; -TaskRobotMessages::TaskRobotMessages(Robot::RobotObject *pcRobotObject,QWidget *parent) - : TaskBox(Gui::BitmapFactory().pixmap("document-new"),tr("TaskRobotMessages"),true, parent), - pcRobot(pcRobotObject) +TaskRobotMessages::TaskRobotMessages(Robot::RobotObject* pcRobotObject, QWidget* parent) + : TaskBox(Gui::BitmapFactory().pixmap("document-new"), tr("TaskRobotMessages"), true, parent) + , pcRobot(pcRobotObject) { // we need a separate container widget to add all controls to proxy = new QWidget(this); diff --git a/src/Mod/Robot/Gui/TaskRobotMessages.h b/src/Mod/Robot/Gui/TaskRobotMessages.h index c4b8d519a5..a3fbcb661e 100644 --- a/src/Mod/Robot/Gui/TaskRobotMessages.h +++ b/src/Mod/Robot/Gui/TaskRobotMessages.h @@ -27,41 +27,41 @@ #include -class Ui_TaskRobotMessages; - -namespace App { +namespace App +{ class Property; } -namespace Gui { +namespace Gui +{ class ViewProvider; } -namespace RobotGui { +namespace RobotGui +{ - -class TaskRobotMessages : public Gui::TaskView::TaskBox +class Ui_TaskRobotMessages; +class TaskRobotMessages: public Gui::TaskView::TaskBox { Q_OBJECT public: - explicit TaskRobotMessages(Robot::RobotObject *pcRobotObject,QWidget *parent = nullptr); + explicit TaskRobotMessages(Robot::RobotObject* pcRobotObject, QWidget* parent = nullptr); ~TaskRobotMessages() override; private Q_SLOTS: - + protected: - Robot::RobotObject *pcRobot; + Robot::RobotObject* pcRobot; private: - private: QWidget* proxy; Ui_TaskRobotMessages* ui; }; -} //namespace PartDesignGui +}// namespace RobotGui -#endif // GUI_TASKVIEW_TASKAPPERANCE_H +#endif// GUI_TASKVIEW_TASKAPPERANCE_H diff --git a/src/Mod/Robot/Gui/TaskRobotMessages.ui b/src/Mod/Robot/Gui/TaskRobotMessages.ui index e4821b987e..4370dac0b8 100644 --- a/src/Mod/Robot/Gui/TaskRobotMessages.ui +++ b/src/Mod/Robot/Gui/TaskRobotMessages.ui @@ -1,6 +1,6 @@ - TaskRobotMessages + RobotGui::TaskRobotMessages diff --git a/src/Mod/Robot/Gui/TaskTrajectory.cpp b/src/Mod/Robot/Gui/TaskTrajectory.cpp index f052535545..7db9b05fa8 100644 --- a/src/Mod/Robot/Gui/TaskTrajectory.cpp +++ b/src/Mod/Robot/Gui/TaskTrajectory.cpp @@ -26,20 +26,22 @@ #include #include -#include "ui_TaskTrajectory.h" #include "TaskTrajectory.h" +#include "ui_TaskTrajectory.h" using namespace RobotGui; using namespace Gui; -TaskTrajectory::TaskTrajectory(Robot::RobotObject *pcRobotObject,Robot::TrajectoryObject *pcTrajectoryObject,QWidget *parent) - : TaskBox(Gui::BitmapFactory().pixmap("document-new"),tr("Trajectory"),true, parent), - sim(pcTrajectoryObject->Trajectory.getValue(),pcRobotObject->getRobot()), - pcRobot(pcRobotObject), - Run(false), - block(false), - timePos(0.0) +TaskTrajectory::TaskTrajectory(Robot::RobotObject* pcRobotObject, + Robot::TrajectoryObject* pcTrajectoryObject, + QWidget* parent) + : TaskBox(Gui::BitmapFactory().pixmap("document-new"), tr("Trajectory"), true, parent) + , sim(pcTrajectoryObject->Trajectory.getValue(), pcRobotObject->getRobot()) + , pcRobot(pcRobotObject) + , Run(false) + , block(false) + , timePos(0.0) { // we need a separate container widget to add all controls to proxy = new QWidget(this); @@ -49,7 +51,7 @@ TaskTrajectory::TaskTrajectory(Robot::RobotObject *pcRobotObject,Robot::Trajecto this->groupLayout()->addWidget(proxy); - // set Tool + // set Tool sim.Tool = pcRobotObject->Tool.getValue(); ui->trajectoryTable->setSortingEnabled(false); @@ -59,25 +61,49 @@ TaskTrajectory::TaskTrajectory(Robot::RobotObject *pcRobotObject,Robot::Trajecto duration = trac.getDuration(); ui->timeSpinBox->setMaximum(duration); - for(unsigned int i=0;itrajectoryTable->setItem(i, 0, new QTableWidgetItem(QString::fromLatin1("UNDEF")));break; - case Robot::Waypoint::CIRC: ui->trajectoryTable->setItem(i, 0, new QTableWidgetItem(QString::fromLatin1("CIRC")));break; - case Robot::Waypoint::PTP: ui->trajectoryTable->setItem(i, 0, new QTableWidgetItem(QString::fromLatin1("PTP")));break; - case Robot::Waypoint::LINE: ui->trajectoryTable->setItem(i, 0, new QTableWidgetItem(QString::fromLatin1("LIN")));break; - default: ui->trajectoryTable->setItem(i, 0, new QTableWidgetItem(QString::fromLatin1("UNDEF")));break; + switch (pt.Type) { + case Robot::Waypoint::UNDEF: + ui->trajectoryTable->setItem(i, + 0, + new QTableWidgetItem(QString::fromLatin1("UNDEF"))); + break; + case Robot::Waypoint::CIRC: + ui->trajectoryTable->setItem(i, + 0, + new QTableWidgetItem(QString::fromLatin1("CIRC"))); + break; + case Robot::Waypoint::PTP: + ui->trajectoryTable->setItem(i, + 0, + new QTableWidgetItem(QString::fromLatin1("PTP"))); + break; + case Robot::Waypoint::LINE: + ui->trajectoryTable->setItem(i, + 0, + new QTableWidgetItem(QString::fromLatin1("LIN"))); + break; + default: + ui->trajectoryTable->setItem(i, + 0, + new QTableWidgetItem(QString::fromLatin1("UNDEF"))); + break; } - ui->trajectoryTable->setItem(i, 1, new QTableWidgetItem(QString::fromUtf8(pt.Name.c_str()))); - if(pt.Cont) + ui->trajectoryTable->setItem(i, + 1, + new QTableWidgetItem(QString::fromUtf8(pt.Name.c_str()))); + if (pt.Cont) { ui->trajectoryTable->setItem(i, 2, new QTableWidgetItem(QString::fromLatin1("|"))); - else + } + else { ui->trajectoryTable->setItem(i, 2, new QTableWidgetItem(QString::fromLatin1("-"))); + } ui->trajectoryTable->setItem(i, 3, new QTableWidgetItem(QString::number(pt.Velocity))); ui->trajectoryTable->setItem(i, 4, new QTableWidgetItem(QString::number(pt.Acceleration))); - } + // clang-format off QObject::connect(ui->ButtonStepStart , &QPushButton::clicked, this, &TaskTrajectory::start); QObject::connect(ui->ButtonStepStop , &QPushButton::clicked, this, &TaskTrajectory::stop); QObject::connect(ui->ButtonStepRun , &QPushButton::clicked, this, &TaskTrajectory::run); @@ -95,9 +121,11 @@ TaskTrajectory::TaskTrajectory(Robot::RobotObject *pcRobotObject,Robot::Trajecto this, qOverload(&TaskTrajectory::valueChanged)); QObject::connect(ui->timeSlider, qOverload(&QSlider::valueChanged), this, qOverload(&TaskTrajectory::valueChanged)); + // clang-format on // get the view provider - ViewProv = dynamic_cast(Gui::Application::Instance->activeDocument()->getViewProvider(pcRobotObject) ); + ViewProv = dynamic_cast( + Gui::Application::Instance->activeDocument()->getViewProvider(pcRobotObject)); setTo(); } @@ -105,21 +133,20 @@ TaskTrajectory::TaskTrajectory(Robot::RobotObject *pcRobotObject,Robot::Trajecto TaskTrajectory::~TaskTrajectory() { delete ui; - } void TaskTrajectory::viewTool(const Base::Placement& pos) { - double A,B,C; - pos.getRotation().getYawPitchRoll(A,B,C); + double A, B, C; + pos.getRotation().getYawPitchRoll(A, B, C); QString result = QString::fromLatin1("Pos:(%1, %2, %3, %4, %5, %6)") - .arg(pos.getPosition().x,0,'f',1) - .arg(pos.getPosition().y,0,'f',1) - .arg(pos.getPosition().z,0,'f',1) - .arg(A,0,'f',1) - .arg(B,0,'f',1) - .arg(C,0,'f',1); + .arg(pos.getPosition().x, 0, 'f', 1) + .arg(pos.getPosition().y, 0, 'f', 1) + .arg(pos.getPosition().z, 0, 'f', 1) + .arg(A, 0, 'f', 1) + .arg(B, 0, 'f', 1) + .arg(C, 0, 'f', 1); ui->label_Pos->setText(result); } @@ -128,13 +155,26 @@ void TaskTrajectory::setTo() { sim.Tool = pcRobot->Tool.getValue(); - if(timePos < 0.0001) + if (timePos < 0.0001) { sim.reset(); - else{ + } + else { sim.setToTime(timePos); } - ViewProv->setAxisTo(sim.Axis[0],sim.Axis[1],sim.Axis[2],sim.Axis[3],sim.Axis[4],sim.Axis[5],sim.Rob.getTcp()); - Q_EMIT axisChanged(sim.Axis[0],sim.Axis[1],sim.Axis[2],sim.Axis[3],sim.Axis[4],sim.Axis[5],sim.Rob.getTcp()); + ViewProv->setAxisTo(sim.Axis[0], + sim.Axis[1], + sim.Axis[2], + sim.Axis[3], + sim.Axis[4], + sim.Axis[5], + sim.Rob.getTcp()); + Q_EMIT axisChanged(sim.Axis[0], + sim.Axis[1], + sim.Axis[2], + sim.Axis[3], + sim.Axis[4], + sim.Axis[5], + sim.Rob.getTcp()); viewTool(sim.Rob.getTcp()); } @@ -142,9 +182,8 @@ void TaskTrajectory::start() { timePos = 0.0f; ui->timeSpinBox->setValue(timePos); - ui->timeSlider->setValue(int((timePos/duration)*1000)); + ui->timeSlider->setValue(int((timePos / duration) * 1000)); setTo(); - } void TaskTrajectory::stop() { @@ -157,51 +196,50 @@ void TaskTrajectory::run() Run = true; } void TaskTrajectory::back() -{ -} +{} void TaskTrajectory::forward() -{ -} +{} void TaskTrajectory::end() { timePos = duration; ui->timeSpinBox->setValue(timePos); - ui->timeSlider->setValue(int((timePos/duration)*1000)); + ui->timeSlider->setValue(int((timePos / duration) * 1000)); setTo(); } void TaskTrajectory::timerDone() { - if(timePos < duration){ + if (timePos < duration) { timePos += .1f; ui->timeSpinBox->setValue(timePos); - ui->timeSlider->setValue(int((timePos/duration)*1000)); + ui->timeSlider->setValue(int((timePos / duration) * 1000)); setTo(); timer->start(); - }else{ + } + else { timer->stop(); Run = false; } } -void TaskTrajectory::valueChanged ( int value ) +void TaskTrajectory::valueChanged(int value) { - if(!block){ - timePos = duration*(value/1000.0); - block=true; + if (!block) { + timePos = duration * (value / 1000.0); + block = true; ui->timeSpinBox->setValue(timePos); - block=false; + block = false; setTo(); } } -void TaskTrajectory::valueChanged ( double value ) +void TaskTrajectory::valueChanged(double value) { - if(!block){ + if (!block) { timePos = value; - block=true; - ui->timeSlider->setValue(int((timePos/duration)*1000)); - block=false; + block = true; + ui->timeSlider->setValue(int((timePos / duration) * 1000)); + block = false; setTo(); } } diff --git a/src/Mod/Robot/Gui/TaskTrajectory.h b/src/Mod/Robot/Gui/TaskTrajectory.h index 67ca8deb4b..f1e3a751c4 100644 --- a/src/Mod/Robot/Gui/TaskTrajectory.h +++ b/src/Mod/Robot/Gui/TaskTrajectory.h @@ -32,29 +32,32 @@ #include "ViewProviderRobotObject.h" -class Ui_TaskTrajectory; - -namespace App { +namespace App +{ class Property; } -namespace Gui { +namespace Gui +{ class ViewProvider; } -namespace RobotGui { +namespace RobotGui +{ - -class TaskTrajectory : public Gui::TaskView::TaskBox +class Ui_TaskTrajectory; +class TaskTrajectory: public Gui::TaskView::TaskBox { Q_OBJECT public: - TaskTrajectory(Robot::RobotObject *pcRobotObject,Robot::TrajectoryObject *pcTrajectoryObject,QWidget *parent = nullptr); + TaskTrajectory(Robot::RobotObject* pcRobotObject, + Robot::TrajectoryObject* pcTrajectoryObject, + QWidget* parent = nullptr); ~TaskTrajectory() override; /// Observer message from the Selection - void OnChange(Gui::SelectionSingleton::SubjectType &rCaller, + void OnChange(Gui::SelectionSingleton::SubjectType& rCaller, Gui::SelectionSingleton::MessageType Reason); private Q_SLOTS: @@ -66,21 +69,27 @@ private Q_SLOTS: void end(); void timerDone(); - void valueChanged ( int value ); - void valueChanged ( double d ); + void valueChanged(int value); + void valueChanged(double d); Q_SIGNALS: - void axisChanged(float A1,float A2,float A3,float A4,float A5,float A6,const Base::Placement &Tcp); + void axisChanged(float A1, + float A2, + float A3, + float A4, + float A5, + float A6, + const Base::Placement& Tcp); protected: void setTo(); void viewTool(const Base::Placement& pos); - QTimer *timer; + QTimer* timer; Robot::Simulation sim; - Robot::RobotObject *pcRobot; - ViewProviderRobotObject *ViewProv; + Robot::RobotObject* pcRobot; + ViewProviderRobotObject* ViewProv; bool Run; bool block; @@ -93,6 +102,6 @@ private: Ui_TaskTrajectory* ui; }; -} //namespace PartDesignGui +}// namespace RobotGui -#endif // GUI_TASKVIEW_TASKAPPERANCE_H +#endif// GUI_TASKVIEW_TASKAPPERANCE_H diff --git a/src/Mod/Robot/Gui/TaskTrajectoryDressUpParameter.cpp b/src/Mod/Robot/Gui/TaskTrajectoryDressUpParameter.cpp index ac87760151..33ea8b3e6e 100644 --- a/src/Mod/Robot/Gui/TaskTrajectoryDressUpParameter.cpp +++ b/src/Mod/Robot/Gui/TaskTrajectoryDressUpParameter.cpp @@ -22,7 +22,7 @@ #include "PreCompiled.h" #ifndef _PreComp_ -# include +#include #endif #include @@ -36,12 +36,13 @@ using namespace RobotGui; using namespace Gui; -TaskTrajectoryDressUpParameter::TaskTrajectoryDressUpParameter(Robot::TrajectoryDressUpObject *obj,QWidget *parent) +TaskTrajectoryDressUpParameter::TaskTrajectoryDressUpParameter(Robot::TrajectoryDressUpObject* obj, + QWidget* parent) : TaskBox(Gui::BitmapFactory().pixmap("Robot_TrajectoryDressUp"), - tr("Dress Up Parameter"), - true, - parent), - pcObject(obj) + tr("Dress Up Parameter"), + true, + parent) + , pcObject(obj) { // we need a separate container widget to add all controls to proxy = new QWidget(this); @@ -52,23 +53,23 @@ TaskTrajectoryDressUpParameter::TaskTrajectoryDressUpParameter(Robot::Trajectory this->groupLayout()->addWidget(proxy); // pump the actual values in the Gui - ui->doubleSpinBoxSpeed->setValue (pcObject->Speed.getValue() / 1000.0) ; - ui->doubleSpinBoxAccel->setValue (pcObject->Acceleration.getValue() / 1000.0) ; - ui->checkBoxUseSpeed ->setChecked (pcObject->UseSpeed.getValue()) ; - ui->checkBoxUseAccel ->setChecked (pcObject->UseAcceleration.getValue()) ; - ui->comboBoxCont ->setCurrentIndex (pcObject->ContType.getValue()) ; - ui->comboBoxOrientation->setCurrentIndex (pcObject->AddType.getValue()) ; + ui->doubleSpinBoxSpeed->setValue(pcObject->Speed.getValue() / 1000.0); + ui->doubleSpinBoxAccel->setValue(pcObject->Acceleration.getValue() / 1000.0); + ui->checkBoxUseSpeed->setChecked(pcObject->UseSpeed.getValue()); + ui->checkBoxUseAccel->setChecked(pcObject->UseAcceleration.getValue()); + ui->comboBoxCont->setCurrentIndex(pcObject->ContType.getValue()); + ui->comboBoxOrientation->setCurrentIndex(pcObject->AddType.getValue()); PosAdd = pcObject->PosAdd.getValue(); viewPlacement(); - QObject::connect(ui->toolButtonChoosePlacement, &QToolButton::clicked, - this, &TaskTrajectoryDressUpParameter::createPlacementDlg); - + QObject::connect(ui->toolButtonChoosePlacement, + &QToolButton::clicked, + this, + &TaskTrajectoryDressUpParameter::createPlacementDlg); } - TaskTrajectoryDressUpParameter::~TaskTrajectoryDressUpParameter() { delete ui; @@ -76,12 +77,12 @@ TaskTrajectoryDressUpParameter::~TaskTrajectoryDressUpParameter() void TaskTrajectoryDressUpParameter::writeValues() { - pcObject->Speed.setValue ( ui->doubleSpinBoxSpeed->value()*1000.0); - pcObject->Acceleration.setValue ( ui->doubleSpinBoxAccel->value()*1000.0); - pcObject->UseSpeed.setValue ( ui->checkBoxUseSpeed ->isChecked() ); - pcObject->UseAcceleration.setValue( ui->checkBoxUseAccel ->isChecked() ); - pcObject->ContType.setValue ( ui->comboBoxCont ->currentIndex()); - pcObject->AddType.setValue ( ui->comboBoxOrientation->currentIndex()); + pcObject->Speed.setValue(ui->doubleSpinBoxSpeed->value() * 1000.0); + pcObject->Acceleration.setValue(ui->doubleSpinBoxAccel->value() * 1000.0); + pcObject->UseSpeed.setValue(ui->checkBoxUseSpeed->isChecked()); + pcObject->UseAcceleration.setValue(ui->checkBoxUseAccel->isChecked()); + pcObject->ContType.setValue(ui->comboBoxCont->currentIndex()); + pcObject->AddType.setValue(ui->comboBoxOrientation->currentIndex()); pcObject->PosAdd.setValue(PosAdd); } @@ -94,22 +95,21 @@ void TaskTrajectoryDressUpParameter::createPlacementDlg() PosAdd = plc.getPlacement(); viewPlacement(); } - } void TaskTrajectoryDressUpParameter::viewPlacement() { - double A,B,C; + double A, B, C; Base::Vector3d pos = PosAdd.getPosition(); - PosAdd.getRotation().getYawPitchRoll(A,B,C); + PosAdd.getRotation().getYawPitchRoll(A, B, C); QString val = QString::fromLatin1("(%1,%2,%3),(%4,%5,%6)\n") - .arg(pos.x,0,'g',6) - .arg(pos.y,0,'g',6) - .arg(pos.z,0,'g',6) - .arg(A,0,'g',6) - .arg(B,0,'g',6) - .arg(C,0,'g',6); + .arg(pos.x, 0, 'g', 6) + .arg(pos.y, 0, 'g', 6) + .arg(pos.z, 0, 'g', 6) + .arg(A, 0, 'g', 6) + .arg(B, 0, 'g', 6) + .arg(C, 0, 'g', 6); ui->lineEditPlacement->setText(val); } diff --git a/src/Mod/Robot/Gui/TaskTrajectoryDressUpParameter.h b/src/Mod/Robot/Gui/TaskTrajectoryDressUpParameter.h index e208d508a6..265cc30759 100644 --- a/src/Mod/Robot/Gui/TaskTrajectoryDressUpParameter.h +++ b/src/Mod/Robot/Gui/TaskTrajectoryDressUpParameter.h @@ -27,26 +27,27 @@ #include -class Ui_TaskTrajectoryDressUpParameter; - -namespace RobotGui { +namespace RobotGui +{ -class TaskTrajectoryDressUpParameter : public Gui::TaskView::TaskBox +class Ui_TaskTrajectoryDressUpParameter; +class TaskTrajectoryDressUpParameter: public Gui::TaskView::TaskBox { Q_OBJECT public: - explicit TaskTrajectoryDressUpParameter(Robot::TrajectoryDressUpObject *obj,QWidget *parent = nullptr); + explicit TaskTrajectoryDressUpParameter(Robot::TrajectoryDressUpObject* obj, + QWidget* parent = nullptr); ~TaskTrajectoryDressUpParameter() override; /// this methode write the values from the Gui to the object, usually in accept() void writeValues(); - + private Q_SLOTS: /// edit the placement void createPlacementDlg(); - + protected: Base::Placement PosAdd; @@ -55,9 +56,9 @@ protected: private: QWidget* proxy; Ui_TaskTrajectoryDressUpParameter* ui; - Robot::TrajectoryDressUpObject *pcObject; + Robot::TrajectoryDressUpObject* pcObject; }; -} //namespace PartDesignGui +}// namespace RobotGui -#endif // GUI_TASKVIEW_TASKAPPERANCE_H +#endif// GUI_TASKVIEW_TASKAPPERANCE_H diff --git a/src/Mod/Robot/Gui/TaskTrajectoryDressUpParameter.ui b/src/Mod/Robot/Gui/TaskTrajectoryDressUpParameter.ui index 3d13d3fb3e..ec2be73fe0 100644 --- a/src/Mod/Robot/Gui/TaskTrajectoryDressUpParameter.ui +++ b/src/Mod/Robot/Gui/TaskTrajectoryDressUpParameter.ui @@ -1,6 +1,6 @@ - TaskTrajectoryDressUpParameter + RobotGui::TaskTrajectoryDressUpParameter diff --git a/src/Mod/Robot/Gui/TaskWatcher.cpp b/src/Mod/Robot/Gui/TaskWatcher.cpp index 818cdd81a3..31df471ac3 100644 --- a/src/Mod/Robot/Gui/TaskWatcher.cpp +++ b/src/Mod/Robot/Gui/TaskWatcher.cpp @@ -35,27 +35,24 @@ using namespace RobotGui; TaskWatcherRobot::TaskWatcherRobot() : Gui::TaskView::TaskWatcher("SELECT Robot::RobotObject COUNT 1") { - rob = new TaskRobot6Axis(nullptr); - ctr = new TaskRobotControl(nullptr); + rob = new TaskRobot6Axis(nullptr); + ctr = new TaskRobotControl(nullptr); Content.push_back(rob); Content.push_back(ctr); - } //==== calls from the TaskView =============================================================== bool TaskWatcherRobot::shouldShow() { - if(match()){ - rob->setRobot((Robot::RobotObject *)Result[0][0].getObject()); - ctr->setRobot((Robot::RobotObject *)Result[0][0].getObject()); + if (match()) { + rob->setRobot((Robot::RobotObject*)Result[0][0].getObject()); + ctr->setRobot((Robot::RobotObject*)Result[0][0].getObject()); return true; } return false; } - - #include "moc_TaskWatcher.cpp" diff --git a/src/Mod/Robot/Gui/TaskWatcher.h b/src/Mod/Robot/Gui/TaskWatcher.h index d94c003db3..5cd227557b 100644 --- a/src/Mod/Robot/Gui/TaskWatcher.h +++ b/src/Mod/Robot/Gui/TaskWatcher.h @@ -29,27 +29,28 @@ #include "TaskRobotControl.h" -namespace RobotGui { +namespace RobotGui +{ class TaskContent; /// Father class of watcher classes -class RobotGuiExport TaskWatcherRobot : public Gui::TaskView::TaskWatcher +class RobotGuiExport TaskWatcherRobot: public Gui::TaskView::TaskWatcher { Q_OBJECT public: TaskWatcherRobot(); - /// is called when the document or the selection changes. + /// is called when the document or the selection changes. bool shouldShow() override; protected: - TaskRobot6Axis *rob; - TaskRobotControl *ctr ; + TaskRobot6Axis* rob; + TaskRobotControl* ctr; }; -} //namespace RobotGui +}// namespace RobotGui -#endif // ROBOTGUI_TASKWATCHER_H +#endif// ROBOTGUI_TASKWATCHER_H diff --git a/src/Mod/Robot/Gui/TrajectorySimulate.cpp b/src/Mod/Robot/Gui/TrajectorySimulate.cpp index 04ec504b3c..378f027279 100644 --- a/src/Mod/Robot/Gui/TrajectorySimulate.cpp +++ b/src/Mod/Robot/Gui/TrajectorySimulate.cpp @@ -22,23 +22,25 @@ #include "PreCompiled.h" #ifndef _PreComp_ -# include +#include #endif #include #include #include -#include "ui_TrajectorySimulate.h" #include "TrajectorySimulate.h" +#include "ui_TrajectorySimulate.h" using namespace RobotGui; using namespace Gui; -TrajectorySimulate::TrajectorySimulate(Robot::RobotObject *pcRobotObject,Robot::TrajectoryObject *pcTrajectoryObject,QWidget *parent) - : QDialog( parent) - , sim(pcTrajectoryObject->Trajectory.getValue(),pcRobotObject->getRobot()) +TrajectorySimulate::TrajectorySimulate(Robot::RobotObject* pcRobotObject, + Robot::TrajectoryObject* pcTrajectoryObject, + QWidget* parent) + : QDialog(parent) + , sim(pcTrajectoryObject->Trajectory.getValue(), pcRobotObject->getRobot()) , Run(false) , block(false) , timePos(0.0) @@ -57,25 +59,49 @@ TrajectorySimulate::TrajectorySimulate(Robot::RobotObject *pcRobotObject,Robot:: duration = trac.getDuration(); ui->timeSpinBox->setMaximum(duration); - for(unsigned int i=0;itrajectoryTable->setItem(i, 0, new QTableWidgetItem(QString::fromLatin1("UNDEF")));break; - case Robot::Waypoint::CIRC: ui->trajectoryTable->setItem(i, 0, new QTableWidgetItem(QString::fromLatin1("CIRC")));break; - case Robot::Waypoint::PTP: ui->trajectoryTable->setItem(i, 0, new QTableWidgetItem(QString::fromLatin1("PTP")));break; - case Robot::Waypoint::LINE: ui->trajectoryTable->setItem(i, 0, new QTableWidgetItem(QString::fromLatin1("LIN")));break; - default: ui->trajectoryTable->setItem(i, 0, new QTableWidgetItem(QString::fromLatin1("UNDEF")));break; + switch (pt.Type) { + case Robot::Waypoint::UNDEF: + ui->trajectoryTable->setItem(i, + 0, + new QTableWidgetItem(QString::fromLatin1("UNDEF"))); + break; + case Robot::Waypoint::CIRC: + ui->trajectoryTable->setItem(i, + 0, + new QTableWidgetItem(QString::fromLatin1("CIRC"))); + break; + case Robot::Waypoint::PTP: + ui->trajectoryTable->setItem(i, + 0, + new QTableWidgetItem(QString::fromLatin1("PTP"))); + break; + case Robot::Waypoint::LINE: + ui->trajectoryTable->setItem(i, + 0, + new QTableWidgetItem(QString::fromLatin1("LIN"))); + break; + default: + ui->trajectoryTable->setItem(i, + 0, + new QTableWidgetItem(QString::fromLatin1("UNDEF"))); + break; } - ui->trajectoryTable->setItem(i, 1, new QTableWidgetItem(QString::fromUtf8(pt.Name.c_str()))); - if(pt.Cont) + ui->trajectoryTable->setItem(i, + 1, + new QTableWidgetItem(QString::fromUtf8(pt.Name.c_str()))); + if (pt.Cont) { ui->trajectoryTable->setItem(i, 2, new QTableWidgetItem(QString::fromLatin1("|"))); - else + } + else { ui->trajectoryTable->setItem(i, 2, new QTableWidgetItem(QString::fromLatin1("-"))); + } ui->trajectoryTable->setItem(i, 3, new QTableWidgetItem(QString::number(pt.Velocity))); ui->trajectoryTable->setItem(i, 4, new QTableWidgetItem(QString::number(pt.Acceleration))); - } + // clang-format off QObject::connect(ui->ButtonStepStart, &QPushButton::clicked, this, &TrajectorySimulate::start); QObject::connect(ui->ButtonStepStop, &QPushButton::clicked, this, &TrajectorySimulate::stop); QObject::connect(ui->ButtonStepRun, &QPushButton::clicked, this, &TrajectorySimulate::run); @@ -91,9 +117,11 @@ TrajectorySimulate::TrajectorySimulate(Robot::RobotObject *pcRobotObject,Robot:: this, qOverload(&TrajectorySimulate::valueChanged)); QObject::connect(ui->timeSlider, qOverload(&QSlider::valueChanged), this, qOverload(&TrajectorySimulate::valueChanged)); + // clang-format on // get the view provider - ViewProv = static_cast(Gui::Application::Instance->activeDocument()->getViewProvider(pcRobotObject) ); + ViewProv = static_cast( + Gui::Application::Instance->activeDocument()->getViewProvider(pcRobotObject)); setTo(); } @@ -103,16 +131,21 @@ TrajectorySimulate::~TrajectorySimulate() = default; void TrajectorySimulate::setTo() { sim.setToTime(timePos); - ViewProv->setAxisTo(sim.Axis[0],sim.Axis[1],sim.Axis[2],sim.Axis[3],sim.Axis[4],sim.Axis[5],sim.Rob.getTcp()); + ViewProv->setAxisTo(sim.Axis[0], + sim.Axis[1], + sim.Axis[2], + sim.Axis[3], + sim.Axis[4], + sim.Axis[5], + sim.Rob.getTcp()); } void TrajectorySimulate::start() { timePos = 0.0f; ui->timeSpinBox->setValue(timePos); - ui->timeSlider->setValue(int((timePos/duration)*1000)); + ui->timeSlider->setValue(int((timePos / duration) * 1000)); setTo(); - } void TrajectorySimulate::stop() { @@ -125,51 +158,50 @@ void TrajectorySimulate::run() Run = true; } void TrajectorySimulate::back() -{ -} +{} void TrajectorySimulate::forward() -{ -} +{} void TrajectorySimulate::end() { timePos = duration; ui->timeSpinBox->setValue(timePos); - ui->timeSlider->setValue(int((timePos/duration)*1000)); + ui->timeSlider->setValue(int((timePos / duration) * 1000)); setTo(); } void TrajectorySimulate::timerDone() { - if(timePos < duration){ + if (timePos < duration) { timePos += .1f; ui->timeSpinBox->setValue(timePos); - ui->timeSlider->setValue(int((timePos/duration)*1000)); + ui->timeSlider->setValue(int((timePos / duration) * 1000)); setTo(); timer->start(); - }else{ + } + else { timer->stop(); Run = false; } } -void TrajectorySimulate::valueChanged ( int value ) +void TrajectorySimulate::valueChanged(int value) { - if(!block){ - timePos = duration*(value/1000.0); - block=true; + if (!block) { + timePos = duration * (value / 1000.0); + block = true; ui->timeSpinBox->setValue(timePos); - block=false; + block = false; setTo(); } } -void TrajectorySimulate::valueChanged ( double value ) +void TrajectorySimulate::valueChanged(double value) { - if(!block){ + if (!block) { timePos = value; - block=true; - ui->timeSlider->setValue(int((timePos/duration)*1000)); - block=false; + block = true; + ui->timeSlider->setValue(int((timePos / duration) * 1000)); + block = false; setTo(); } } diff --git a/src/Mod/Robot/Gui/TrajectorySimulate.h b/src/Mod/Robot/Gui/TrajectorySimulate.h index 8317560113..9e40c19f50 100644 --- a/src/Mod/Robot/Gui/TrajectorySimulate.h +++ b/src/Mod/Robot/Gui/TrajectorySimulate.h @@ -23,8 +23,8 @@ #ifndef GUI_TASKVIEW_TrajectorySimulate_H #define GUI_TASKVIEW_TrajectorySimulate_H -#include #include +#include #include #include @@ -33,16 +33,19 @@ #include "ViewProviderRobotObject.h" -namespace RobotGui { +namespace RobotGui +{ class Ui_DlgTrajectorySimulate; -class TrajectorySimulate : public QDialog +class TrajectorySimulate: public QDialog { Q_OBJECT public: - TrajectorySimulate(Robot::RobotObject *pcRobotObject,Robot::TrajectoryObject *pcTrajectoryObject,QWidget *parent = nullptr); + TrajectorySimulate(Robot::RobotObject* pcRobotObject, + Robot::TrajectoryObject* pcTrajectoryObject, + QWidget* parent = nullptr); ~TrajectorySimulate() override; private Q_SLOTS: @@ -54,17 +57,17 @@ private Q_SLOTS: void end(); void timerDone(); - void valueChanged ( int value ); - void valueChanged ( double d ); + void valueChanged(int value); + void valueChanged(double d); protected: void setTo(); - QTimer *timer; + QTimer* timer; Robot::Simulation sim; - ViewProviderRobotObject *ViewProv; + ViewProviderRobotObject* ViewProv; bool Run; bool block; @@ -76,6 +79,6 @@ private: std::unique_ptr ui; }; -} //namespace PartDesignGui +}// namespace RobotGui -#endif // GUI_TASKVIEW_TrajectorySimulate_H +#endif// GUI_TASKVIEW_TrajectorySimulate_H diff --git a/src/Mod/Robot/Gui/ViewProviderEdge2TracObject.cpp b/src/Mod/Robot/Gui/ViewProviderEdge2TracObject.cpp index 359b7b2b58..19bc267355 100644 --- a/src/Mod/Robot/Gui/ViewProviderEdge2TracObject.cpp +++ b/src/Mod/Robot/Gui/ViewProviderEdge2TracObject.cpp @@ -35,7 +35,8 @@ PROPERTY_SOURCE(RobotGui::ViewProviderEdge2TracObject, RobotGui::ViewProviderTra bool ViewProviderEdge2TracObject::doubleClicked() { - Gui::TaskView::TaskDialog* dlg = new TaskDlgEdge2Trac(static_cast(getObject())); + Gui::TaskView::TaskDialog* dlg = + new TaskDlgEdge2Trac(static_cast(getObject())); Gui::Control().showDialog(dlg); return true; } @@ -43,12 +44,11 @@ bool ViewProviderEdge2TracObject::doubleClicked() bool ViewProviderEdge2TracObject::setEdit(int) { - Gui::TaskView::TaskDialog* dlg = new TaskDlgEdge2Trac(static_cast(getObject())); + Gui::TaskView::TaskDialog* dlg = + new TaskDlgEdge2Trac(static_cast(getObject())); Gui::Control().showDialog(dlg); return true; } void ViewProviderEdge2TracObject::unsetEdit(int) -{ - -} +{} diff --git a/src/Mod/Robot/Gui/ViewProviderEdge2TracObject.h b/src/Mod/Robot/Gui/ViewProviderEdge2TracObject.h index a2d60dd5fa..89d52f10ab 100644 --- a/src/Mod/Robot/Gui/ViewProviderEdge2TracObject.h +++ b/src/Mod/Robot/Gui/ViewProviderEdge2TracObject.h @@ -29,19 +29,19 @@ namespace RobotGui { -class RobotGuiExport ViewProviderEdge2TracObject : public ViewProviderTrajectory +class RobotGuiExport ViewProviderEdge2TracObject: public ViewProviderTrajectory { PROPERTY_HEADER_WITH_OVERRIDE(RobotGui::ViewProviderEdge2TracObject); public: - bool doubleClicked() override; -protected: - bool setEdit(int ModNum) override; - void unsetEdit(int ModNum) override; + bool doubleClicked() override; +protected: + bool setEdit(int ModNum) override; + void unsetEdit(int ModNum) override; }; -} //namespace RobotGui +}// namespace RobotGui -#endif // ROBOT_VIEWPROVIDEREDGE2TRACOBJECT_H +#endif// ROBOT_VIEWPROVIDEREDGE2TRACOBJECT_H diff --git a/src/Mod/Robot/Gui/ViewProviderRobotObject.cpp b/src/Mod/Robot/Gui/ViewProviderRobotObject.cpp index 900e701f0a..1690738ba2 100644 --- a/src/Mod/Robot/Gui/ViewProviderRobotObject.cpp +++ b/src/Mod/Robot/Gui/ViewProviderRobotObject.cpp @@ -22,23 +22,23 @@ #include "PreCompiled.h" #ifndef _PreComp_ -# include -# include +#include +#include -# include -# include -# include -# include -# include -# include -# include +#include +#include +#include +#include +#include +#include +#include #endif #include #include #include -#include #include +#include #include "ViewProviderRobotObject.h" @@ -50,17 +50,17 @@ PROPERTY_SOURCE(RobotGui::ViewProviderRobotObject, Gui::ViewProviderGeometryObje ViewProviderRobotObject::ViewProviderRobotObject() { - ADD_PROPERTY(Manipulator,(0)); + ADD_PROPERTY(Manipulator, (0)); pcRobotRoot = new Gui::SoFCSelection(); pcRobotRoot->highlightMode = Gui::SoFCSelection::OFF; - //pcRobotRoot->selectionMode = Gui::SoFCSelection::SEL_OFF; - //pcRobotRoot->style = Gui::SoFCSelection::BOX; + // pcRobotRoot->selectionMode = Gui::SoFCSelection::SEL_OFF; + // pcRobotRoot->style = Gui::SoFCSelection::BOX; pcRobotRoot->ref(); pcSimpleRoot = new Gui::SoFCSelection(); pcSimpleRoot->highlightMode = Gui::SoFCSelection::OFF; - //pcSimpleRoot->selectionMode = Gui::SoFCSelection::SEL_OFF; + // pcSimpleRoot->selectionMode = Gui::SoFCSelection::SEL_OFF; pcSimpleRoot->ref(); pcOffRoot = new SoGroup(); @@ -86,17 +86,19 @@ void ViewProviderRobotObject::setDragger() { assert(!pcDragger); pcDragger = new SoJackDragger(); - pcDragger->addMotionCallback(sDraggerMotionCallback,this); + pcDragger->addMotionCallback(sDraggerMotionCallback, this); pcTcpRoot->addChild(pcDragger); // set the actual TCP position Robot::RobotObject* robObj = static_cast(pcObject); Base::Placement loc = robObj->Tcp.getValue(); - SbMatrix M; - M.setTransform(SbVec3f(loc.getPosition().x,loc.getPosition().y,loc.getPosition().z), - SbRotation(loc.getRotation()[0],loc.getRotation()[1],loc.getRotation()[2],loc.getRotation()[3]), - SbVec3f(150,150,150) - ); + SbMatrix M; + M.setTransform(SbVec3f(loc.getPosition().x, loc.getPosition().y, loc.getPosition().z), + SbRotation(loc.getRotation()[0], + loc.getRotation()[1], + loc.getRotation()[2], + loc.getRotation()[3]), + SbVec3f(150, 150, 150)); pcDragger->setMotionMatrix(M); } @@ -107,7 +109,7 @@ void ViewProviderRobotObject::resetDragger() pcDragger = nullptr; } -void ViewProviderRobotObject::attach(App::DocumentObject *pcObj) +void ViewProviderRobotObject::attach(App::DocumentObject* pcObj) { ViewProviderGeometryObject::attach(pcObj); @@ -129,13 +131,16 @@ void ViewProviderRobotObject::attach(App::DocumentObject *pcObj) void ViewProviderRobotObject::setDisplayMode(const char* ModeName) { - if ( strcmp("VRML",ModeName)==0 ) + if (strcmp("VRML", ModeName) == 0) { setDisplayMaskMode("VRML"); - if ( strcmp("Simple",ModeName)==0 ) + } + if (strcmp("Simple", ModeName) == 0) { setDisplayMaskMode("Simple"); - if ( strcmp("Off",ModeName)==0 ) + } + if (strcmp("Off", ModeName) == 0) { setDisplayMaskMode("Off"); - ViewProviderGeometryObject::setDisplayMode( ModeName ); + } + ViewProviderGeometryObject::setDisplayMode(ModeName); } std::vector ViewProviderRobotObject::getDisplayModes() const @@ -151,12 +156,14 @@ void ViewProviderRobotObject::onChanged(const App::Property* prop) { if (prop == &Manipulator) { if (Manipulator.getValue()) { - if (!this->pcDragger) + if (!this->pcDragger) { this->setDragger(); + } } else { - if (this->pcDragger) + if (this->pcDragger) { this->resetDragger(); + } } } else { @@ -176,198 +183,269 @@ void ViewProviderRobotObject::updateData(const App::Property* prop) Gui::coinRemoveAllChildren(pcRobotRoot); if (!fn.isEmpty() && file.open(QFile::ReadOnly)) { QByteArray buffer = file.readAll(); - in.setBuffer((void *)buffer.constData(), buffer.length()); - SoSeparator * node = SoDB::readAll(&in); - if (node) pcRobotRoot->addChild(node); + in.setBuffer((void*)buffer.constData(), buffer.length()); + SoSeparator* node = SoDB::readAll(&in); + if (node) { + pcRobotRoot->addChild(node); + } pcRobotRoot->addChild(pcTcpRoot); } - // search for the connection points +++++++++++++++++++++++++++++++++++++++++++++++++ - Axis1Node = Axis2Node = Axis3Node = Axis4Node = Axis5Node = Axis6Node = nullptr; - SoSearchAction searchAction; - SoPath * path; + // search for the connection points +++++++++++++++++++++++++++++++++++++++++++++++++ + Axis1Node = Axis2Node = Axis3Node = Axis4Node = Axis5Node = Axis6Node = nullptr; + SoSearchAction searchAction; + SoPath* path; - // Axis 1 - searchAction.setName("FREECAD_AXIS1"); - searchAction.setInterest(SoSearchAction::FIRST); - searchAction.setSearchingAll(false); - searchAction.apply(pcRobotRoot); - path = searchAction.getPath(); - if(path){ - SoNode* node = path->getTail(); - if (node && node->getTypeId() == SoVRMLTransform::getClassTypeId()) - Axis1Node = static_cast(node); - } - // Axis 2 - searchAction.setName("FREECAD_AXIS2"); - searchAction.setInterest(SoSearchAction::FIRST); - searchAction.setSearchingAll(false); - searchAction.apply(pcRobotRoot); - path = searchAction.getPath(); - if(path){ - SoNode* node = path->getTail(); - if (node && node->getTypeId() == SoVRMLTransform::getClassTypeId()) - Axis2Node = static_cast(node); - } - // Axis 3 - searchAction.setName("FREECAD_AXIS3"); - searchAction.setInterest(SoSearchAction::FIRST); - searchAction.setSearchingAll(false); - searchAction.apply(pcRobotRoot); - path = searchAction.getPath(); - if(path){ - SoNode* node = path->getTail(); - if (node && node->getTypeId() == SoVRMLTransform::getClassTypeId()) - Axis3Node = static_cast(node); - } - // Axis 4 - searchAction.setName("FREECAD_AXIS4"); - searchAction.setInterest(SoSearchAction::FIRST); - searchAction.setSearchingAll(false); - searchAction.apply(pcRobotRoot); - path = searchAction.getPath(); - if(path){ - SoNode* node = path->getTail(); - if (node && node->getTypeId() == SoVRMLTransform::getClassTypeId()) - Axis4Node = static_cast(node); - } - // Axis 5 - searchAction.setName("FREECAD_AXIS5"); - searchAction.setInterest(SoSearchAction::FIRST); - searchAction.setSearchingAll(false); - searchAction.apply(pcRobotRoot); - path = searchAction.getPath(); - if(path){ - SoNode* node = path->getTail(); - if (node && node->getTypeId() == SoVRMLTransform::getClassTypeId()) - Axis5Node = static_cast(node); - } - // Axis 6 - searchAction.setName("FREECAD_AXIS6"); - searchAction.setInterest(SoSearchAction::FIRST); - searchAction.setSearchingAll(false); - searchAction.apply(pcRobotRoot); - path = searchAction.getPath(); - if(path){ - SoNode* node = path->getTail(); - if (node && node->getTypeId() == SoVRMLTransform::getClassTypeId()) - Axis6Node = static_cast(node); - } - if(Axis1Node) - Axis1Node->rotation.setValue(SbVec3f(0.0,1.0,0.0),robObj->Axis1.getValue()*(M_PI/180)); - if(Axis2Node) - Axis2Node->rotation.setValue(SbVec3f(0.0,1.0,0.0),robObj->Axis2.getValue()*(M_PI/180)); - if(Axis3Node) - Axis3Node->rotation.setValue(SbVec3f(0.0,1.0,0.0),robObj->Axis3.getValue()*(M_PI/180)); - if(Axis4Node) - Axis4Node->rotation.setValue(SbVec3f(0.0,1.0,0.0),robObj->Axis4.getValue()*(M_PI/180)); - if(Axis5Node) - Axis5Node->rotation.setValue(SbVec3f(0.0,1.0,0.0),robObj->Axis5.getValue()*(M_PI/180)); - if(Axis6Node) - Axis6Node->rotation.setValue(SbVec3f(0.0,1.0,0.0),robObj->Axis6.getValue()*(M_PI/180)); - }else if (prop == &robObj->Axis1) { - if(Axis1Node){ - Axis1Node->rotation.setValue(SbVec3f(0.0,1.0,0.0),robObj->Axis1.getValue()*(M_PI/180)); - if(toolShape) - toolShape->setTransformation((robObj->Tcp.getValue() * (robObj->ToolBase.getValue().inverse())).toMatrix()); + // Axis 1 + searchAction.setName("FREECAD_AXIS1"); + searchAction.setInterest(SoSearchAction::FIRST); + searchAction.setSearchingAll(false); + searchAction.apply(pcRobotRoot); + path = searchAction.getPath(); + if (path) { + SoNode* node = path->getTail(); + if (node && node->getTypeId() == SoVRMLTransform::getClassTypeId()) { + Axis1Node = static_cast(node); + } } - }else if (prop == &robObj->Axis2) { - if(Axis2Node){ - Axis2Node->rotation.setValue(SbVec3f(0.0,1.0,0.0),robObj->Axis2.getValue()*(M_PI/180)); - if(toolShape) - toolShape->setTransformation((robObj->Tcp.getValue() * (robObj->ToolBase.getValue().inverse())).toMatrix()); + // Axis 2 + searchAction.setName("FREECAD_AXIS2"); + searchAction.setInterest(SoSearchAction::FIRST); + searchAction.setSearchingAll(false); + searchAction.apply(pcRobotRoot); + path = searchAction.getPath(); + if (path) { + SoNode* node = path->getTail(); + if (node && node->getTypeId() == SoVRMLTransform::getClassTypeId()) { + Axis2Node = static_cast(node); + } } - }else if (prop == &robObj->Axis3) { - if(Axis3Node){ - Axis3Node->rotation.setValue(SbVec3f(0.0,1.0,0.0),robObj->Axis3.getValue()*(M_PI/180)); - if(toolShape) - toolShape->setTransformation((robObj->Tcp.getValue() * (robObj->ToolBase.getValue().inverse())).toMatrix()); + // Axis 3 + searchAction.setName("FREECAD_AXIS3"); + searchAction.setInterest(SoSearchAction::FIRST); + searchAction.setSearchingAll(false); + searchAction.apply(pcRobotRoot); + path = searchAction.getPath(); + if (path) { + SoNode* node = path->getTail(); + if (node && node->getTypeId() == SoVRMLTransform::getClassTypeId()) { + Axis3Node = static_cast(node); + } } - }else if (prop == &robObj->Axis4) { - if(Axis4Node){ - Axis4Node->rotation.setValue(SbVec3f(0.0,1.0,0.0),robObj->Axis4.getValue()*(M_PI/180)); - if(toolShape) - toolShape->setTransformation((robObj->Tcp.getValue() * (robObj->ToolBase.getValue().inverse())).toMatrix()); + // Axis 4 + searchAction.setName("FREECAD_AXIS4"); + searchAction.setInterest(SoSearchAction::FIRST); + searchAction.setSearchingAll(false); + searchAction.apply(pcRobotRoot); + path = searchAction.getPath(); + if (path) { + SoNode* node = path->getTail(); + if (node && node->getTypeId() == SoVRMLTransform::getClassTypeId()) { + Axis4Node = static_cast(node); + } } - }else if (prop == &robObj->Axis5) { - if(Axis5Node){ - Axis5Node->rotation.setValue(SbVec3f(0.0,1.0,0.0),robObj->Axis5.getValue()*(M_PI/180)); - if(toolShape) - toolShape->setTransformation((robObj->Tcp.getValue() * (robObj->ToolBase.getValue().inverse())).toMatrix()); + // Axis 5 + searchAction.setName("FREECAD_AXIS5"); + searchAction.setInterest(SoSearchAction::FIRST); + searchAction.setSearchingAll(false); + searchAction.apply(pcRobotRoot); + path = searchAction.getPath(); + if (path) { + SoNode* node = path->getTail(); + if (node && node->getTypeId() == SoVRMLTransform::getClassTypeId()) { + Axis5Node = static_cast(node); + } } - }else if (prop == &robObj->Axis6) { - if(Axis6Node){ - Axis6Node->rotation.setValue(SbVec3f(0.0,1.0,0.0),robObj->Axis6.getValue()*(M_PI/180)); - if(toolShape) - toolShape->setTransformation((robObj->Tcp.getValue() * (robObj->ToolBase.getValue().inverse())).toMatrix()); + // Axis 6 + searchAction.setName("FREECAD_AXIS6"); + searchAction.setInterest(SoSearchAction::FIRST); + searchAction.setSearchingAll(false); + searchAction.apply(pcRobotRoot); + path = searchAction.getPath(); + if (path) { + SoNode* node = path->getTail(); + if (node && node->getTypeId() == SoVRMLTransform::getClassTypeId()) { + Axis6Node = static_cast(node); + } } - }else if (prop == &robObj->Tcp) { + if (Axis1Node) { + Axis1Node->rotation.setValue(SbVec3f(0.0, 1.0, 0.0), + robObj->Axis1.getValue() * (M_PI / 180)); + } + if (Axis2Node) { + Axis2Node->rotation.setValue(SbVec3f(0.0, 1.0, 0.0), + robObj->Axis2.getValue() * (M_PI / 180)); + } + if (Axis3Node) { + Axis3Node->rotation.setValue(SbVec3f(0.0, 1.0, 0.0), + robObj->Axis3.getValue() * (M_PI / 180)); + } + if (Axis4Node) { + Axis4Node->rotation.setValue(SbVec3f(0.0, 1.0, 0.0), + robObj->Axis4.getValue() * (M_PI / 180)); + } + if (Axis5Node) { + Axis5Node->rotation.setValue(SbVec3f(0.0, 1.0, 0.0), + robObj->Axis5.getValue() * (M_PI / 180)); + } + if (Axis6Node) { + Axis6Node->rotation.setValue(SbVec3f(0.0, 1.0, 0.0), + robObj->Axis6.getValue() * (M_PI / 180)); + } + } + else if (prop == &robObj->Axis1) { + if (Axis1Node) { + Axis1Node->rotation.setValue(SbVec3f(0.0, 1.0, 0.0), + robObj->Axis1.getValue() * (M_PI / 180)); + if (toolShape) { + toolShape->setTransformation( + (robObj->Tcp.getValue() * (robObj->ToolBase.getValue().inverse())).toMatrix()); + } + } + } + else if (prop == &robObj->Axis2) { + if (Axis2Node) { + Axis2Node->rotation.setValue(SbVec3f(0.0, 1.0, 0.0), + robObj->Axis2.getValue() * (M_PI / 180)); + if (toolShape) { + toolShape->setTransformation( + (robObj->Tcp.getValue() * (robObj->ToolBase.getValue().inverse())).toMatrix()); + } + } + } + else if (prop == &robObj->Axis3) { + if (Axis3Node) { + Axis3Node->rotation.setValue(SbVec3f(0.0, 1.0, 0.0), + robObj->Axis3.getValue() * (M_PI / 180)); + if (toolShape) { + toolShape->setTransformation( + (robObj->Tcp.getValue() * (robObj->ToolBase.getValue().inverse())).toMatrix()); + } + } + } + else if (prop == &robObj->Axis4) { + if (Axis4Node) { + Axis4Node->rotation.setValue(SbVec3f(0.0, 1.0, 0.0), + robObj->Axis4.getValue() * (M_PI / 180)); + if (toolShape) { + toolShape->setTransformation( + (robObj->Tcp.getValue() * (robObj->ToolBase.getValue().inverse())).toMatrix()); + } + } + } + else if (prop == &robObj->Axis5) { + if (Axis5Node) { + Axis5Node->rotation.setValue(SbVec3f(0.0, 1.0, 0.0), + robObj->Axis5.getValue() * (M_PI / 180)); + if (toolShape) { + toolShape->setTransformation( + (robObj->Tcp.getValue() * (robObj->ToolBase.getValue().inverse())).toMatrix()); + } + } + } + else if (prop == &robObj->Axis6) { + if (Axis6Node) { + Axis6Node->rotation.setValue(SbVec3f(0.0, 1.0, 0.0), + robObj->Axis6.getValue() * (M_PI / 180)); + if (toolShape) { + toolShape->setTransformation( + (robObj->Tcp.getValue() * (robObj->ToolBase.getValue().inverse())).toMatrix()); + } + } + } + else if (prop == &robObj->Tcp) { Base::Placement loc = robObj->Tcp.getValue(); - SbMatrix M; - M.setTransform(SbVec3f(loc.getPosition().x,loc.getPosition().y,loc.getPosition().z), - SbRotation(loc.getRotation()[0],loc.getRotation()[1],loc.getRotation()[2],loc.getRotation()[3]), - SbVec3f(150,150,150) - ); - if(pcDragger) + SbMatrix M; + M.setTransform(SbVec3f(loc.getPosition().x, loc.getPosition().y, loc.getPosition().z), + SbRotation(loc.getRotation()[0], + loc.getRotation()[1], + loc.getRotation()[2], + loc.getRotation()[3]), + SbVec3f(150, 150, 150)); + if (pcDragger) { pcDragger->setMotionMatrix(M); - if(toolShape) - toolShape->setTransformation((robObj->Tcp.getValue() * (robObj->ToolBase.getValue().inverse())).toMatrix()); - //pcTcpTransform->translation = SbVec3f(loc.getPosition().x,loc.getPosition().y,loc.getPosition().z); - //pcTcpTransform->rotation = SbRotation(loc.getRotation()[0],loc.getRotation()[1],loc.getRotation()[2],loc.getRotation()[3]); - }else if (prop == &robObj->ToolShape) { + } + if (toolShape) { + toolShape->setTransformation( + (robObj->Tcp.getValue() * (robObj->ToolBase.getValue().inverse())).toMatrix()); + } + // pcTcpTransform->translation = + // SbVec3f(loc.getPosition().x,loc.getPosition().y,loc.getPosition().z); + // pcTcpTransform->rotation = + // SbRotation(loc.getRotation()[0],loc.getRotation()[1],loc.getRotation()[2],loc.getRotation()[3]); + } + else if (prop == &robObj->ToolShape) { App::DocumentObject* o = robObj->ToolShape.getValue(); - if(o && (o->isDerivedFrom(Part::Feature::getClassTypeId()) || o->isDerivedFrom(App::VRMLObject::getClassTypeId())) ){ - //Part::Feature *p = dynamic_cast(o); + if (o + && (o->isDerivedFrom(Part::Feature::getClassTypeId()) + || o->isDerivedFrom(App::VRMLObject::getClassTypeId()))) { + // Part::Feature *p = dynamic_cast(o); toolShape = Gui::Application::Instance->getViewProvider(o); - toolShape->setTransformation((robObj->Tcp.getValue() * (robObj->ToolBase.getValue().inverse())).toMatrix()); - }else + toolShape->setTransformation( + (robObj->Tcp.getValue() * (robObj->ToolBase.getValue().inverse())).toMatrix()); + } + else { toolShape = nullptr; - } - + } + } } -void ViewProviderRobotObject::setAxisTo(float A1,float A2,float A3,float A4,float A5,float A6,const Base::Placement &Tcp) +void ViewProviderRobotObject::setAxisTo(float A1, + float A2, + float A3, + float A4, + float A5, + float A6, + const Base::Placement& Tcp) { Robot::RobotObject* robObj = static_cast(pcObject); - if(Axis1Node) - // FIXME Ugly hack for the wrong transformation of the Kuka 500 robot VRML the minus sign on Axis 1 - Axis1Node->rotation.setValue(SbVec3f(0.0,1.0,0.0),A1*(M_PI/180)); - if(Axis2Node) - Axis2Node->rotation.setValue(SbVec3f(0.0,1.0,0.0),A2*(M_PI/180)); - if(Axis3Node) - Axis3Node->rotation.setValue(SbVec3f(0.0,1.0,0.0),A3*(M_PI/180)); - if(Axis4Node) - Axis4Node->rotation.setValue(SbVec3f(0.0,1.0,0.0),A4*(M_PI/180)); - if(Axis5Node) - Axis5Node->rotation.setValue(SbVec3f(0.0,1.0,0.0),A5*(M_PI/180)); - if(Axis6Node) - Axis6Node->rotation.setValue(SbVec3f(0.0,1.0,0.0),A6*(M_PI/180)); + if (Axis1Node) { + // FIXME Ugly hack for the wrong transformation of the Kuka 500 robot VRML the minus sign on + // Axis 1 + Axis1Node->rotation.setValue(SbVec3f(0.0, 1.0, 0.0), A1 * (M_PI / 180)); + } + if (Axis2Node) { + Axis2Node->rotation.setValue(SbVec3f(0.0, 1.0, 0.0), A2 * (M_PI / 180)); + } + if (Axis3Node) { + Axis3Node->rotation.setValue(SbVec3f(0.0, 1.0, 0.0), A3 * (M_PI / 180)); + } + if (Axis4Node) { + Axis4Node->rotation.setValue(SbVec3f(0.0, 1.0, 0.0), A4 * (M_PI / 180)); + } + if (Axis5Node) { + Axis5Node->rotation.setValue(SbVec3f(0.0, 1.0, 0.0), A5 * (M_PI / 180)); + } + if (Axis6Node) { + Axis6Node->rotation.setValue(SbVec3f(0.0, 1.0, 0.0), A6 * (M_PI / 180)); + } // update tool position - if(toolShape) + if (toolShape) { toolShape->setTransformation((Tcp * (robObj->ToolBase.getValue().inverse())).toMatrix()); + } } -void ViewProviderRobotObject::sDraggerMotionCallback(void *data, SoDragger *dragger) +void ViewProviderRobotObject::sDraggerMotionCallback(void* data, SoDragger* dragger) { static_cast(data)->DraggerMotionCallback(dragger); } -void ViewProviderRobotObject::DraggerMotionCallback(SoDragger *dragger) +void ViewProviderRobotObject::DraggerMotionCallback(SoDragger* dragger) { float q0, q1, q2, q3; Robot::RobotObject* robObj = static_cast(pcObject); Base::Placement Tcp = robObj->Tcp.getValue(); - const SbMatrix & M = dragger->getMotionMatrix (); - SbVec3f translation; + const SbMatrix& M = dragger->getMotionMatrix(); + SbVec3f translation; SbRotation rotation; - SbVec3f scaleFactor; + SbVec3f scaleFactor; SbRotation scaleOrientation; - SbVec3f center(Tcp.getPosition().x,Tcp.getPosition().y,Tcp.getPosition().z); + SbVec3f center(Tcp.getPosition().x, Tcp.getPosition().y, Tcp.getPosition().z); M.getTransform(translation, rotation, scaleFactor, scaleOrientation); rotation.getValue(q0, q1, q2, q3); - //Base::Console().Message("M %f %f %f\n", M[3][0], M[3][1], M[3][2]); + // Base::Console().Message("M %f %f %f\n", M[3][0], M[3][1], M[3][2]); Base::Rotation rot(q0, q1, q2, q3); - Base::Vector3d pos(translation[0],translation[1],translation[2]); - robObj->Tcp.setValue(Base::Placement(pos,rot)); + Base::Vector3d pos(translation[0], translation[1], translation[2]); + robObj->Tcp.setValue(Base::Placement(pos, rot)); } diff --git a/src/Mod/Robot/Gui/ViewProviderRobotObject.h b/src/Mod/Robot/Gui/ViewProviderRobotObject.h index fc8e294be9..7f908683c5 100644 --- a/src/Mod/Robot/Gui/ViewProviderRobotObject.h +++ b/src/Mod/Robot/Gui/ViewProviderRobotObject.h @@ -37,7 +37,7 @@ class SoTrackballDragger; namespace RobotGui { -class RobotGuiExport ViewProviderRobotObject : public Gui::ViewProviderGeometryObject +class RobotGuiExport ViewProviderRobotObject: public Gui::ViewProviderGeometryObject { PROPERTY_HEADER_WITH_OVERRIDE(RobotGui::ViewProviderRobotObject); @@ -50,7 +50,7 @@ public: App::PropertyBool Manipulator; - void attach(App::DocumentObject *pcObject) override; + void attach(App::DocumentObject* pcObject) override; void setDisplayMode(const char* ModeName) override; std::vector getDisplayModes() const override; void updateData(const App::Property*) override; @@ -58,38 +58,44 @@ public: void onChanged(const App::Property* prop) override; /// for simulation without changing the document: - void setAxisTo(float A1,float A2,float A3,float A4,float A5,float A6,const Base::Placement &Tcp); + void setAxisTo(float A1, + float A2, + float A3, + float A4, + float A5, + float A6, + const Base::Placement& Tcp); protected: - static void sDraggerMotionCallback(void *data, SoDragger *dragger); - void DraggerMotionCallback(SoDragger *dragger); + static void sDraggerMotionCallback(void* data, SoDragger* dragger); + void DraggerMotionCallback(SoDragger* dragger); void setDragger(); void resetDragger(); - Gui::SoFCSelection * pcRobotRoot; - Gui::SoFCSelection * pcSimpleRoot; - SoGroup * pcOffRoot; + Gui::SoFCSelection* pcRobotRoot; + Gui::SoFCSelection* pcSimpleRoot; + SoGroup* pcOffRoot; - SoGroup * pcTcpRoot; - //SoTransform * pcTcpTransform; + SoGroup* pcTcpRoot; + // SoTransform * pcTcpTransform; - //SoTrackballDragger * pcDragger; - SoJackDragger * pcDragger{nullptr}; + // SoTrackballDragger * pcDragger; + SoJackDragger* pcDragger {nullptr}; // view provider of the toolshape if set - Gui::ViewProvider *toolShape{nullptr}; + Gui::ViewProvider* toolShape {nullptr}; - // Pointers to the robot axis nodes in the VRML model - SoVRMLTransform *Axis1Node; - SoVRMLTransform *Axis2Node; - SoVRMLTransform *Axis3Node; - SoVRMLTransform *Axis4Node; - SoVRMLTransform *Axis5Node; - SoVRMLTransform *Axis6Node; + // Pointers to the robot axis nodes in the VRML model + SoVRMLTransform* Axis1Node; + SoVRMLTransform* Axis2Node; + SoVRMLTransform* Axis3Node; + SoVRMLTransform* Axis4Node; + SoVRMLTransform* Axis5Node; + SoVRMLTransform* Axis6Node; }; -} //namespace RobotGui +}// namespace RobotGui -#endif // ROBOT_VIEWPROVIDERROBOTOBJECT_H +#endif// ROBOT_VIEWPROVIDERROBOTOBJECT_H diff --git a/src/Mod/Robot/Gui/ViewProviderTrajectory.cpp b/src/Mod/Robot/Gui/ViewProviderTrajectory.cpp index b7843f62e1..3674a81e5a 100644 --- a/src/Mod/Robot/Gui/ViewProviderTrajectory.cpp +++ b/src/Mod/Robot/Gui/ViewProviderTrajectory.cpp @@ -22,16 +22,16 @@ #include "PreCompiled.h" #ifndef _PreComp_ -# include -# include -# include +#include +#include +#include -# include -# include -# include -# include -# include -# include +#include +#include +#include +#include +#include +#include #endif #include @@ -51,10 +51,10 @@ PROPERTY_SOURCE(RobotGui::ViewProviderTrajectory, Gui::ViewProviderGeometryObjec ViewProviderTrajectory::ViewProviderTrajectory() { - pcTrajectoryRoot = new Gui::SoFCSelection(); + pcTrajectoryRoot = new Gui::SoFCSelection(); pcTrajectoryRoot->highlightMode = Gui::SoFCSelection::OFF; pcTrajectoryRoot->selectionMode = Gui::SoFCSelection::SEL_OFF; - //pcRobotRoot->style = Gui::SoFCSelection::BOX; + // pcRobotRoot->style = Gui::SoFCSelection::BOX; pcTrajectoryRoot->ref(); pcCoords = new SoCoordinate3(); @@ -66,8 +66,6 @@ ViewProviderTrajectory::ViewProviderTrajectory() pcLines = new SoLineSet; pcLines->ref(); - - } ViewProviderTrajectory::~ViewProviderTrajectory() @@ -76,26 +74,29 @@ ViewProviderTrajectory::~ViewProviderTrajectory() pcCoords->unref(); pcDrawStyle->unref(); pcLines->unref(); - } -void ViewProviderTrajectory::attach(App::DocumentObject *pcObj) +void ViewProviderTrajectory::attach(App::DocumentObject* pcObj) { ViewProviderGeometryObject::attach(pcObj); // Draw trajectory lines SoSeparator* linesep = new SoSeparator; - SoBaseColor * basecol = new SoBaseColor; - basecol->rgb.setValue( 1.0f, 0.5f, 0.0f ); + SoBaseColor* basecol = new SoBaseColor; + basecol->rgb.setValue(1.0f, 0.5f, 0.0f); linesep->addChild(basecol); linesep->addChild(pcCoords); linesep->addChild(pcLines); // Draw markers - SoBaseColor * markcol = new SoBaseColor; - markcol->rgb.setValue( 1.0f, 1.0f, 0.0f ); + SoBaseColor* markcol = new SoBaseColor; + markcol->rgb.setValue(1.0f, 1.0f, 0.0f); SoMarkerSet* marker = new SoMarkerSet; - marker->markerIndex=Gui::Inventor::MarkerBitmaps::getMarkerIndex("CROSS", App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/View")->GetInt("MarkerSize", 5)); + marker->markerIndex = Gui::Inventor::MarkerBitmaps::getMarkerIndex( + "CROSS", + App::GetApplication() + .GetParameterGroupByPath("User parameter:BaseApp/Preferences/View") + ->GetInt("MarkerSize", 5)); linesep->addChild(markcol); linesep->addChild(marker); @@ -105,14 +106,14 @@ void ViewProviderTrajectory::attach(App::DocumentObject *pcObj) pcTrajectoryRoot->objectName = pcObj->getNameInDocument(); pcTrajectoryRoot->documentName = pcObj->getDocument()->getName(); pcTrajectoryRoot->subElementName = "Main"; - } void ViewProviderTrajectory::setDisplayMode(const char* ModeName) { - if ( strcmp("Waypoints",ModeName)==0 ) + if (strcmp("Waypoints", ModeName) == 0) { setDisplayMaskMode("Waypoints"); - ViewProviderGeometryObject::setDisplayMode( ModeName ); + } + ViewProviderGeometryObject::setDisplayMode(ModeName); } std::vector ViewProviderTrajectory::getDisplayModes() const @@ -126,22 +127,20 @@ void ViewProviderTrajectory::updateData(const App::Property* prop) { Robot::TrajectoryObject* pcTracObj = static_cast(pcObject); if (prop == &pcTracObj->Trajectory) { - const Trajectory &trak = pcTracObj->Trajectory.getValue(); + const Trajectory& trak = pcTracObj->Trajectory.getValue(); pcCoords->point.deleteValues(0); pcCoords->point.setNum(trak.getSize()); - for(unsigned int i=0;ipoint.set1Value(i,pos.x,pos.y,pos.z); - + pcCoords->point.set1Value(i, pos.x, pos.y, pos.z); } pcLines->numVertices.set1Value(0, trak.getSize()); } else if (prop == &pcTracObj->Base) { Base::Placement loc = *(&pcTracObj->Base.getValue()); } - } void ViewProviderTrajectory::setupContextMenu(QMenu* menu, QObject* receiver, const char* member) @@ -149,4 +148,3 @@ void ViewProviderTrajectory::setupContextMenu(QMenu* menu, QObject* receiver, co QAction* act = menu->addAction(QObject::tr("Modify"), receiver, member); act->setData(QVariant((int)ViewProvider::Default)); } - diff --git a/src/Mod/Robot/Gui/ViewProviderTrajectory.h b/src/Mod/Robot/Gui/ViewProviderTrajectory.h index d7f903883f..3329b02aef 100644 --- a/src/Mod/Robot/Gui/ViewProviderTrajectory.h +++ b/src/Mod/Robot/Gui/ViewProviderTrajectory.h @@ -37,7 +37,7 @@ class SoLineSet; namespace RobotGui { -class RobotGuiExport ViewProviderTrajectory : public Gui::ViewProviderGeometryObject +class RobotGuiExport ViewProviderTrajectory: public Gui::ViewProviderGeometryObject { PROPERTY_HEADER_WITH_OVERRIDE(RobotGui::ViewProviderTrajectory); @@ -48,22 +48,20 @@ public: /// destructor. ~ViewProviderTrajectory() override; - void attach(App::DocumentObject *pcObject) override; + void attach(App::DocumentObject* pcObject) override; void setDisplayMode(const char* ModeName) override; std::vector getDisplayModes() const override; void updateData(const App::Property*) override; void setupContextMenu(QMenu* menu, QObject* receiver, const char* member) override; protected: + Gui::SoFCSelection* pcTrajectoryRoot; + SoCoordinate3* pcCoords; + SoDrawStyle* pcDrawStyle; + SoLineSet* pcLines; +}; - Gui::SoFCSelection * pcTrajectoryRoot; - SoCoordinate3 * pcCoords; - SoDrawStyle * pcDrawStyle; - SoLineSet * pcLines; - - }; - -} //namespace RobotGui +}// namespace RobotGui -#endif // ROBOT_VIEWPROVIDERROBOTOBJECT_H +#endif// ROBOT_VIEWPROVIDERROBOTOBJECT_H diff --git a/src/Mod/Robot/Gui/ViewProviderTrajectoryCompound.cpp b/src/Mod/Robot/Gui/ViewProviderTrajectoryCompound.cpp index 6d041db056..ac0153578f 100644 --- a/src/Mod/Robot/Gui/ViewProviderTrajectoryCompound.cpp +++ b/src/Mod/Robot/Gui/ViewProviderTrajectoryCompound.cpp @@ -23,8 +23,8 @@ #include "PreCompiled.h" #include -#include #include +#include #include "ViewProviderTrajectoryCompound.h" @@ -34,31 +34,30 @@ using namespace RobotGui; PROPERTY_SOURCE(RobotGui::ViewProviderTrajectoryCompound, RobotGui::ViewProviderTrajectory) -//bool ViewProviderTrajectoryCompound::doubleClicked(void) +// bool ViewProviderTrajectoryCompound::doubleClicked(void) //{ -// Gui::TaskView::TaskDialog* dlg = new TaskDlgTrajectoryCompound(dynamic_cast(getObject())); -// Gui::Control().showDialog(dlg); -// return true; -//} +// Gui::TaskView::TaskDialog* dlg = new +// TaskDlgTrajectoryCompound(dynamic_cast(getObject())); +// Gui::Control().showDialog(dlg); +// return true; +// } bool ViewProviderTrajectoryCompound::setEdit(int) { - Gui::TaskView::TaskDialog* dlg = new TaskDlgTrajectoryCompound(dynamic_cast(getObject())); + Gui::TaskView::TaskDialog* dlg = + new TaskDlgTrajectoryCompound(dynamic_cast(getObject())); Gui::Control().showDialog(dlg); return true; - } void ViewProviderTrajectoryCompound::unsetEdit(int) { // when pressing ESC make sure to close the dialog Gui::Control().closeDialog(); - - } -std::vector ViewProviderTrajectoryCompound::claimChildren()const +std::vector ViewProviderTrajectoryCompound::claimChildren() const { - return static_cast(getObject())->Source.getValues(); + return static_cast(getObject())->Source.getValues(); } diff --git a/src/Mod/Robot/Gui/ViewProviderTrajectoryCompound.h b/src/Mod/Robot/Gui/ViewProviderTrajectoryCompound.h index 504aa7621f..5c3d4e4b7d 100644 --- a/src/Mod/Robot/Gui/ViewProviderTrajectoryCompound.h +++ b/src/Mod/Robot/Gui/ViewProviderTrajectoryCompound.h @@ -34,16 +34,15 @@ class RobotGuiExport ViewProviderTrajectoryCompound: public ViewProviderTrajecto PROPERTY_HEADER_WITH_OVERRIDE(RobotGui::ViewProviderTrajectoryCompound); public: - /// grouping handling + /// grouping handling std::vector claimChildren() const override; protected: bool setEdit(int ModNum) override; void unsetEdit(int ModNum) override; - }; -} //namespace RobotGui +}// namespace RobotGui -#endif // ROBOT_ViewProviderTrajectoryCompound_H +#endif// ROBOT_ViewProviderTrajectoryCompound_H diff --git a/src/Mod/Robot/Gui/ViewProviderTrajectoryDressUp.cpp b/src/Mod/Robot/Gui/ViewProviderTrajectoryDressUp.cpp index 9d9f81000d..e753484b6a 100644 --- a/src/Mod/Robot/Gui/ViewProviderTrajectoryDressUp.cpp +++ b/src/Mod/Robot/Gui/ViewProviderTrajectoryDressUp.cpp @@ -33,17 +33,19 @@ using namespace RobotGui; PROPERTY_SOURCE(RobotGui::ViewProviderTrajectoryDressUp, RobotGui::ViewProviderTrajectory) -//bool ViewProviderTrajectoryDressUp::doubleClicked(void) +// bool ViewProviderTrajectoryDressUp::doubleClicked(void) //{ -// Gui::TaskView::TaskDialog* dlg = new TaskDlgTrajectoryDressUp(dynamic_cast(getObject())); -// Gui::Control().showDialog(dlg); -// return true; -//} +// Gui::TaskView::TaskDialog* dlg = new +// TaskDlgTrajectoryDressUp(dynamic_cast(getObject())); +// Gui::Control().showDialog(dlg); +// return true; +// } // bool ViewProviderTrajectoryDressUp::setEdit(int) { - Gui::TaskView::TaskDialog* dlg = new TaskDlgTrajectoryDressUp(static_cast(getObject())); + Gui::TaskView::TaskDialog* dlg = + new TaskDlgTrajectoryDressUp(static_cast(getObject())); Gui::Control().showDialog(dlg); return true; } @@ -52,11 +54,9 @@ void ViewProviderTrajectoryDressUp::unsetEdit(int) { // when pressing ESC make sure to close the dialog Gui::Control().closeDialog(); - - } -std::vector ViewProviderTrajectoryDressUp::claimChildren()const +std::vector ViewProviderTrajectoryDressUp::claimChildren() const { std::vector temp; temp.push_back(static_cast(getObject())->Source.getValue()); diff --git a/src/Mod/Robot/Gui/ViewProviderTrajectoryDressUp.h b/src/Mod/Robot/Gui/ViewProviderTrajectoryDressUp.h index 5b14899a7b..9642bc7bb5 100644 --- a/src/Mod/Robot/Gui/ViewProviderTrajectoryDressUp.h +++ b/src/Mod/Robot/Gui/ViewProviderTrajectoryDressUp.h @@ -29,12 +29,12 @@ namespace RobotGui { -class RobotGuiExport ViewProviderTrajectoryDressUp : public ViewProviderTrajectory +class RobotGuiExport ViewProviderTrajectoryDressUp: public ViewProviderTrajectory { PROPERTY_HEADER_WITH_OVERRIDE(RobotGui::ViewProviderTrajectoryDressUp); public: - //virtual bool doubleClicked(void); + // virtual bool doubleClicked(void); /// grouping handling std::vector claimChildren() const override; @@ -42,10 +42,9 @@ public: protected: bool setEdit(int ModNum) override; void unsetEdit(int ModNum) override; - }; -} //namespace RobotGui +}// namespace RobotGui -#endif // ROBOT_ViewProviderTrajectoryDressUp_H +#endif// ROBOT_ViewProviderTrajectoryDressUp_H diff --git a/src/Mod/Robot/Gui/Workbench.cpp b/src/Mod/Robot/Gui/Workbench.cpp index fa9aeed7aa..da04733258 100644 --- a/src/Mod/Robot/Gui/Workbench.cpp +++ b/src/Mod/Robot/Gui/Workbench.cpp @@ -22,28 +22,28 @@ #include "PreCompiled.h" #ifndef _PreComp_ -# include -# include -# include -# include +#include +#include +#include +#include #endif #include #include #include #include -#include -#include #include #include +#include +#include -#include "Workbench.h" #include "TaskWatcher.h" +#include "Workbench.h" using namespace RobotGui; -#if 0 // needed for Qt's lupdate utility +#if 0// needed for Qt's lupdate utility qApp->translate("Workbench", "Robot"); qApp->translate("Workbench", "Insert Robots"); qApp->translate("Workbench", "&Robot"); @@ -63,8 +63,7 @@ Workbench::~Workbench() = default; void Workbench::activated() { std::string res = App::Application::getResourceDir(); - QString dir = QString::fromLatin1("%1/Mod/Robot/Lib/Kuka") - .arg(QString::fromUtf8(res.c_str())); + QString dir = QString::fromLatin1("%1/Mod/Robot/Lib/Kuka").arg(QString::fromUtf8(res.c_str())); QFileInfo fi(dir, QString::fromLatin1("kr_16.csv")); if (!fi.exists()) { @@ -74,81 +73,63 @@ void Workbench::activated() Gui::getMainWindow(), QObject::tr("No robot files installed"), QObject::tr("Please visit %1 and copy the files to %2") - .arg(QString::fromLatin1( - "https://github.com/FreeCAD/FreeCAD/tree/master" - "/src/Mod/Robot/Lib/Kuka"), dir) - ); + .arg(QString::fromLatin1("https://github.com/FreeCAD/FreeCAD/tree/master" + "/src/Mod/Robot/Lib/Kuka"), + dir)); wc.setWaitCursor(); } Gui::Workbench::activated(); - const char* RobotAndTrac[] = { - "Robot_InsertWaypoint", - "Robot_InsertWaypointPreselect", - nullptr}; + const char* RobotAndTrac[] = {"Robot_InsertWaypoint", "Robot_InsertWaypointPreselect", nullptr}; - const char* Robot[] = { - "Robot_AddToolShape", - "Robot_SetHomePos", - "Robot_RestoreHomePos", - nullptr}; + const char* Robot[] = {"Robot_AddToolShape", + "Robot_SetHomePos", + "Robot_RestoreHomePos", + nullptr}; - const char* Empty[] = { - "Robot_InsertKukaIR500", - "Robot_InsertKukaIR16", - "Robot_InsertKukaIR210", - "Robot_InsertKukaIR125", - nullptr}; + const char* Empty[] = {"Robot_InsertKukaIR500", + "Robot_InsertKukaIR16", + "Robot_InsertKukaIR210", + "Robot_InsertKukaIR125", + nullptr}; - const char* TracSingle[] = { - "Robot_TrajectoryDressUp", - nullptr}; + const char* TracSingle[] = {"Robot_TrajectoryDressUp", nullptr}; - const char* TracMore[] = { - "Robot_TrajectoryCompound", - nullptr}; + const char* TracMore[] = {"Robot_TrajectoryCompound", nullptr}; std::vector Watcher; - Watcher.push_back(new Gui::TaskView::TaskWatcherCommands( - "SELECT Robot::TrajectoryObject COUNT 1" - "SELECT Robot::RobotObject COUNT 1", - RobotAndTrac, - "Trajectory tools", - "Robot_InsertWaypoint" - )); + Watcher.push_back( + new Gui::TaskView::TaskWatcherCommands("SELECT Robot::TrajectoryObject COUNT 1" + "SELECT Robot::RobotObject COUNT 1", + RobotAndTrac, + "Trajectory tools", + "Robot_InsertWaypoint")); Watcher.push_back(new TaskWatcherRobot); - Watcher.push_back(new Gui::TaskView::TaskWatcherCommands( - "SELECT Robot::RobotObject COUNT 1", - Robot, - "Robot tools", - "Robot_CreateRobot" - )); + Watcher.push_back(new Gui::TaskView::TaskWatcherCommands("SELECT Robot::RobotObject COUNT 1", + Robot, + "Robot tools", + "Robot_CreateRobot")); - Watcher.push_back(new Gui::TaskView::TaskWatcherCommands( - "SELECT Robot::TrajectoryObject COUNT 1", - TracSingle, - "Trajectory tools", - "Robot_CreateRobot" - )); + Watcher.push_back( + new Gui::TaskView::TaskWatcherCommands("SELECT Robot::TrajectoryObject COUNT 1", + TracSingle, + "Trajectory tools", + "Robot_CreateRobot")); - Watcher.push_back(new Gui::TaskView::TaskWatcherCommands( - "SELECT Robot::TrajectoryObject COUNT 2..", - TracMore, - "Trajectory tools", - "Robot_CreateRobot" - )); + Watcher.push_back( + new Gui::TaskView::TaskWatcherCommands("SELECT Robot::TrajectoryObject COUNT 2..", + TracMore, + "Trajectory tools", + "Robot_CreateRobot")); + + Watcher.push_back( + new Gui::TaskView::TaskWatcherCommandsEmptyDoc(Empty, "Insert Robot", "Robot_CreateRobot")); - Watcher.push_back(new Gui::TaskView::TaskWatcherCommandsEmptyDoc( - Empty, - "Insert Robot", - "Robot_CreateRobot" - )); - addTaskWatcher(Watcher); Gui::Control().showTaskView(); } @@ -158,7 +139,6 @@ void Workbench::deactivated() { Gui::Workbench::deactivated(); removeTaskWatcher(); - } @@ -176,7 +156,7 @@ Gui::ToolBarItem* Workbench::setupToolBars() const *part << "Robot_Edge2Trac"; *part << "Robot_TrajectoryDressUp"; *part << "Robot_TrajectoryCompound"; - *part << "Separator"; + *part << "Separator"; *part << "Robot_SetHomePos"; *part << "Robot_RestoreHomePos"; *part << "Separator"; @@ -189,29 +169,26 @@ Gui::MenuItem* Workbench::setupMenuBar() const Gui::MenuItem* root = StdWorkbench::setupMenuBar(); Gui::MenuItem* item = root->findItem("&Windows"); Gui::MenuItem* robot = new Gui::MenuItem; - root->insertItem( item, robot ); + root->insertItem(item, robot); // analyze Gui::MenuItem* insertRobots = new Gui::MenuItem; insertRobots->setCommand("Insert Robots"); - *insertRobots << "Robot_InsertKukaIR500" - << "Robot_InsertKukaIR210" - << "Robot_InsertKukaIR125" - << "Robot_InsertKukaIR16" + *insertRobots << "Robot_InsertKukaIR500" + << "Robot_InsertKukaIR210" + << "Robot_InsertKukaIR125" + << "Robot_InsertKukaIR16" << "Separator" - << "Robot_AddToolShape" - ; + << "Robot_AddToolShape"; // boolean Gui::MenuItem* exportM = new Gui::MenuItem; exportM->setCommand("Export trajectory"); - *exportM << "Robot_ExportKukaCompact" - << "Robot_ExportKukaFull" - ; - + *exportM << "Robot_ExportKukaCompact" + << "Robot_ExportKukaFull"; + robot->setCommand("&Robot"); - *robot << insertRobots - << "Robot_CreateTrajectory" + *robot << insertRobots << "Robot_CreateTrajectory" << "Separator" << "Robot_CreateTrajectory" << "Robot_InsertWaypoint" @@ -224,8 +201,6 @@ Gui::MenuItem* Workbench::setupMenuBar() const << "Robot_SetDefaultOrientation" << "Robot_SetDefaultValues" << "Separator" - << "Robot_Simulate" - << exportM - ; + << "Robot_Simulate" << exportM; return root; } diff --git a/src/Mod/Robot/Gui/Workbench.h b/src/Mod/Robot/Gui/Workbench.h index 6aa96a2345..8da3130980 100644 --- a/src/Mod/Robot/Gui/Workbench.h +++ b/src/Mod/Robot/Gui/Workbench.h @@ -20,20 +20,21 @@ * * ***************************************************************************/ -#ifndef IMAGE_WORKBENCH_H -#define IMAGE_WORKBENCH_H +#ifndef ROBOT_WORKBENCH_H +#define ROBOT_WORKBENCH_H -#include #include +#include #include -namespace RobotGui { +namespace RobotGui +{ /** * @author Werner Mayer */ -class RobotGuiExport Workbench : public Gui::StdWorkbench +class RobotGuiExport Workbench: public Gui::StdWorkbench { TYPESYSTEM_HEADER_WITH_OVERRIDE(); @@ -41,7 +42,7 @@ public: Workbench(); ~Workbench() override; - /** Run some actions when the workbench gets activated. */ + /** Run some actions when the workbench gets activated. */ void activated() override; /** Run some actions when the workbench gets deactivated. */ void deactivated() override; @@ -49,12 +50,12 @@ public: protected: Gui::ToolBarItem* setupToolBars() const override; - Gui::MenuItem* setupMenuBar() const override; + Gui::MenuItem* setupMenuBar() const override; std::vector Watcher; }; -} // namespace RobotGui +}// namespace RobotGui -#endif // IMAGE_WORKBENCH_H +#endif// ROBOT_WORKBENCH_H