Mod/Robot/Gui/Workbench.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include "PreCompiled.h"
00025
00026 #ifndef _PreComp_
00027 # include <qobject.h>
00028 # include <QFileInfo>
00029 # include <QMessageBox>
00030 #endif
00031
00032 #include "Workbench.h"
00033 #include <App/Application.h>
00034 #include <Gui/ToolBarManager.h>
00035 #include <Gui/MenuManager.h>
00036 #include <Gui/MainWindow.h>
00037 #include <Gui/Control.h>
00038 #include <Gui/WaitCursor.h>
00039 #include <Gui/TaskView/TaskView.h>
00040 #include <Gui/TaskView/TaskWatcher.h>
00041
00042 #include "TaskWatcher.h"
00043
00044
00045 using namespace RobotGui;
00046
00047 #if 0 // needed for Qt's lupdate utility
00048 qApp->translate("Workbench", "Robot");
00049 qApp->translate("Workbench", "Insert Robots");
00050 qApp->translate("Workbench", "&Robot");
00051 qApp->translate("Workbench", "Export trajectory");
00052 qApp->translate("Gui::TaskView::TaskWatcherCommands", "Trajectory tools");
00053 qApp->translate("Gui::TaskView::TaskWatcherCommands", "Robot tools");
00054 qApp->translate("Gui::TaskView::TaskWatcherCommands", "Insert Robot");
00055 #endif
00056
00058 TYPESYSTEM_SOURCE(RobotGui::Workbench, Gui::StdWorkbench)
00059
00060 Workbench::Workbench()
00061 {
00062 }
00063
00064 Workbench::~Workbench()
00065 {
00066 }
00067
00068 void Workbench::activated()
00069 {
00070 std::string res = App::Application::getResourceDir();
00071 QString dir = QString::fromAscii("%1/Mod/Robot/Lib/Kuka")
00072 .arg(QString::fromUtf8(res.c_str()));
00073 QFileInfo fi(dir, QString::fromAscii("kr_16.csv"));
00074
00075 if (!fi.exists()) {
00076 Gui::WaitCursor wc;
00077 wc.restoreCursor();
00078 QMessageBox::warning(
00079 Gui::getMainWindow(),
00080 QObject::tr("No robot files installed"),
00081 QObject::tr("Please visit %1 and copy the files to %2")
00082 .arg(QString::fromAscii(
00083 "https://free-cad.svn.sourceforge.net"
00084 "/svnroot/free-cad/trunk/src/Mod/Robot/Lib/Kuka")).arg(dir)
00085 );
00086 wc.setWaitCursor();
00087 }
00088
00089 Gui::Workbench::activated();
00090
00091 const char* RobotAndTrac[] = {
00092 "Robot_InsertWaypoint",
00093 "Robot_InsertWaypointPreselect",
00094 0};
00095
00096 const char* Robot[] = {
00097 "Robot_AddToolShape",
00098 "Robot_SetHomePos",
00099 "Robot_RestoreHomePos",
00100 0};
00101
00102 const char* Empty[] = {
00103 "Robot_InsertKukaIR500",
00104 "Robot_InsertKukaIR16",
00105 "Robot_InsertKukaIR210",
00106 "Robot_InsertKukaIR125",
00107 0};
00108
00109 const char* TracSingle[] = {
00110 "Robot_TrajectoryDressUp",
00111 0};
00112
00113 const char* TracMore[] = {
00114 "Robot_TrajectoryCompound",
00115 0};
00116
00117 std::vector<Gui::TaskView::TaskWatcher*> Watcher;
00118
00119 Watcher.push_back(new Gui::TaskView::TaskWatcherCommands(
00120 "SELECT Robot::TrajectoryObject COUNT 1"
00121 "SELECT Robot::RobotObject COUNT 1",
00122 RobotAndTrac,
00123 "Trajectory tools",
00124 "Robot_InsertWaypoint"
00125 ));
00126
00127 Watcher.push_back(new TaskWatcherRobot);
00128
00129 Watcher.push_back(new Gui::TaskView::TaskWatcherCommands(
00130 "SELECT Robot::RobotObject COUNT 1",
00131 Robot,
00132 "Robot tools",
00133 "Robot_CreateRobot"
00134 ));
00135
00136 Watcher.push_back(new Gui::TaskView::TaskWatcherCommands(
00137 "SELECT Robot::TrajectoryObject COUNT 1",
00138 TracSingle,
00139 "Trajectory tools",
00140 "Robot_CreateRobot"
00141 ));
00142
00143 Watcher.push_back(new Gui::TaskView::TaskWatcherCommands(
00144 "SELECT Robot::TrajectoryObject COUNT 2..",
00145 TracMore,
00146 "Trajectory tools",
00147 "Robot_CreateRobot"
00148 ));
00149
00150 Watcher.push_back(new Gui::TaskView::TaskWatcherCommandsEmptyDoc(
00151 Empty,
00152 "Insert Robot",
00153 "Robot_CreateRobot"
00154 ));
00155
00156
00157 addTaskWatcher(Watcher);
00158 Gui::Control().showTaskView();
00159 }
00160
00161
00162 void Workbench::deactivated()
00163 {
00164 Gui::Workbench::deactivated();
00165 removeTaskWatcher();
00166
00167 }
00168
00169
00170 Gui::ToolBarItem* Workbench::setupToolBars() const
00171 {
00172 Gui::ToolBarItem* root = StdWorkbench::setupToolBars();
00173 Gui::ToolBarItem* part = new Gui::ToolBarItem(root);
00174 part->setCommand("Robot");
00175 *part << "Robot_Create";
00176 *part << "Separator";
00177 *part << "Robot_CreateTrajectory";
00178 *part << "Robot_InsertWaypoint";
00179 *part << "Robot_InsertWaypointPreselect";
00180 *part << "Separator";
00181 *part << "Robot_Edge2Trac";
00182 *part << "Robot_TrajectoryDressUp";
00183 *part << "Robot_TrajectoryCompound";
00184 *part << "Separator";
00185 *part << "Robot_SetHomePos";
00186 *part << "Robot_RestoreHomePos";
00187 *part << "Separator";
00188 *part << "Robot_Simulate";
00189 return root;
00190 }
00191
00192 Gui::MenuItem* Workbench::setupMenuBar() const
00193 {
00194 Gui::MenuItem* root = StdWorkbench::setupMenuBar();
00195 Gui::MenuItem* item = root->findItem("&Windows");
00196 Gui::MenuItem* robot = new Gui::MenuItem;
00197 root->insertItem( item, robot );
00198
00199
00200 Gui::MenuItem* insertRobots = new Gui::MenuItem;
00201 insertRobots->setCommand("Insert Robots");
00202 *insertRobots << "Robot_InsertKukaIR500"
00203 << "Robot_InsertKukaIR210"
00204 << "Robot_InsertKukaIR125"
00205 << "Robot_InsertKukaIR16"
00206 << "Separator"
00207 << "Robot_AddToolShape"
00208 ;
00209
00210
00211 Gui::MenuItem* exportM = new Gui::MenuItem;
00212 exportM->setCommand("Export trajectory");
00213 *exportM << "Robot_ExportKukaCompact"
00214 << "Robot_ExportKukaFull"
00215 ;
00216
00217 robot->setCommand("&Robot");
00218 *robot << insertRobots
00219 << "Robot_CreateTrajectory"
00220 << "Separator"
00221 << "Robot_CreateTrajectory"
00222 << "Robot_InsertWaypoint"
00223 << "Robot_InsertWaypointPreselect"
00224 << "Robot_Edge2Trac"
00225 << "Separator"
00226 << "Robot_SetHomePos"
00227 << "Robot_RestoreHomePos"
00228 << "Separator"
00229 << "Robot_SetDefaultOrientation"
00230 << "Robot_SetDefaultValues"
00231 << "Separator"
00232 << "Robot_Simulate"
00233 << exportM
00234 ;
00235 return root;
00236 }