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 #endif
00028
00029 #include <Base/Console.h>
00030 #include <Base/UnitsApi.h>
00031
00032 #include <QString>
00033 #include <qpalette.h>
00034 #include <QSlider>
00035 #include "ui_TaskRobot6Axis.h"
00036 #include "TaskRobot6Axis.h"
00037
00038 #include <Gui/Application.h>
00039 #include <Gui/Document.h>
00040 #include <Gui/BitmapFactory.h>
00041 #include <Gui/ViewProvider.h>
00042 #include <Gui/WaitCursor.h>
00043 #include <Gui/Selection.h>
00044 #include <Gui/Placement.h>
00045
00046
00047
00048 using namespace RobotGui;
00049 using namespace Gui;
00050
00051 TaskRobot6Axis::TaskRobot6Axis(Robot::RobotObject *pcRobotObject,QWidget *parent)
00052 : TaskBox(Gui::BitmapFactory().pixmap("Robot_CreateRobot"),tr("TaskRobot6Axis"),true, parent),
00053 pcRobot(pcRobotObject),Rob()
00054 {
00055
00056 proxy = new QWidget(this);
00057 ui = new Ui_TaskRobot6Axis();
00058 ui->setupUi(proxy);
00059 QMetaObject::connectSlotsByName(this);
00060
00061 this->groupLayout()->addWidget(proxy);
00062
00063 QObject::connect(ui->horizontalSlider_Axis1,SIGNAL(sliderMoved(int)),this,SLOT(changeSliderA1(int)));
00064 QObject::connect(ui->horizontalSlider_Axis2,SIGNAL(sliderMoved(int)),this,SLOT(changeSliderA2(int)));
00065 QObject::connect(ui->horizontalSlider_Axis3,SIGNAL(sliderMoved(int)),this,SLOT(changeSliderA3(int)));
00066 QObject::connect(ui->horizontalSlider_Axis4,SIGNAL(sliderMoved(int)),this,SLOT(changeSliderA4(int)));
00067 QObject::connect(ui->horizontalSlider_Axis5,SIGNAL(sliderMoved(int)),this,SLOT(changeSliderA5(int)));
00068 QObject::connect(ui->horizontalSlider_Axis6,SIGNAL(sliderMoved(int)),this,SLOT(changeSliderA6(int)));
00069
00070 QObject::connect(ui->pushButtonChooseTool,SIGNAL(clicked()),this,SLOT(createPlacementDlg()));
00071
00072 if(pcRobotObject)
00073 setRobot(pcRobotObject);
00074 }
00075
00076 TaskRobot6Axis::~TaskRobot6Axis()
00077 {
00078 delete ui;
00079 }
00080
00081 void TaskRobot6Axis::setRobot(Robot::RobotObject *pcRobotObject)
00082 {
00083 pcRobot = pcRobotObject;
00084 if(!pcRobotObject){
00085 delete Rob;
00086 return;
00087 }
00088
00089 Rob = new Robot::Robot6Axis(pcRobot->getRobot());
00090 ui->horizontalSlider_Axis1->setMaximum( (int ) Rob->getMaxAngle(0) );
00091 ui->horizontalSlider_Axis1->setMinimum( (int ) Rob->getMinAngle(0) );
00092
00093 ui->horizontalSlider_Axis2->setMaximum( (int ) Rob->getMaxAngle(1) );
00094 ui->horizontalSlider_Axis2->setMinimum( (int ) Rob->getMinAngle(1) );
00095
00096 ui->horizontalSlider_Axis3->setMaximum( (int ) Rob->getMaxAngle(2) );
00097 ui->horizontalSlider_Axis3->setMinimum( (int ) Rob->getMinAngle(2) );
00098
00099 ui->horizontalSlider_Axis4->setMaximum( (int ) Rob->getMaxAngle(3) );
00100 ui->horizontalSlider_Axis4->setMinimum( (int ) Rob->getMinAngle(3) );
00101
00102 ui->horizontalSlider_Axis5->setMaximum( (int ) Rob->getMaxAngle(4) );
00103 ui->horizontalSlider_Axis5->setMinimum( (int ) Rob->getMinAngle(4) );
00104
00105 ui->horizontalSlider_Axis6->setMaximum( (int ) Rob->getMaxAngle(5) );
00106 ui->horizontalSlider_Axis6->setMinimum( (int ) Rob->getMinAngle(5) );
00107
00108 setAxis(pcRobot->Axis1.getValue(),
00109 pcRobot->Axis2.getValue(),
00110 pcRobot->Axis3.getValue(),
00111 pcRobot->Axis4.getValue(),
00112 pcRobot->Axis5.getValue(),
00113 pcRobot->Axis6.getValue(),
00114 pcRobot->Tcp.getValue());
00115 viewTool(pcRobot->Tool.getValue());
00116 }
00117
00118 void TaskRobot6Axis::createPlacementDlg(void)
00119 {
00120 Gui::Dialog::Placement *plc = new Gui::Dialog::Placement();
00121 plc->setPlacement(pcRobot->Tool.getValue());
00122 if(plc->exec()==QDialog::Accepted)
00123 pcRobot->Tool.setValue(plc->getPlacement());
00124 viewTool(pcRobot->Tool.getValue());
00125 }
00126
00127
00128 void TaskRobot6Axis::viewTcp(const Base::Placement pos)
00129 {
00130 double A,B,C;
00131 pos.getRotation().getYawPitchRoll(A,B,C);
00132
00133 QString result = QString::fromAscii("TCP:( %1, %2, %3, %4, %5, %6 )")
00134 .arg(Base::UnitsApi::toDblWithUserPrefs(Base::Length,pos.getPosition().x),0,'f',1)
00135 .arg(Base::UnitsApi::toDblWithUserPrefs(Base::Length,pos.getPosition().y),0,'f',1)
00136 .arg(Base::UnitsApi::toDblWithUserPrefs(Base::Length,pos.getPosition().z),0,'f',1)
00137 .arg(Base::UnitsApi::toDblWithUserPrefs(Base::Angle,A),0,'f',1)
00138 .arg(Base::UnitsApi::toDblWithUserPrefs(Base::Angle,B),0,'f',1)
00139 .arg(Base::UnitsApi::toDblWithUserPrefs(Base::Angle,C),0,'f',1);
00140
00141 ui->label_TCP->setText(result);
00142 }
00143
00144 void TaskRobot6Axis::viewTool(const Base::Placement pos)
00145 {
00146 double A,B,C;
00147 pos.getRotation().getYawPitchRoll(A,B,C);
00148
00149 QString result = QString::fromAscii("Tool:( %1, %2, %3, %4, %5, %6 )")
00150 .arg(Base::UnitsApi::toDblWithUserPrefs(Base::Length,pos.getPosition().x),0,'f',1)
00151 .arg(Base::UnitsApi::toDblWithUserPrefs(Base::Length,pos.getPosition().y),0,'f',1)
00152 .arg(Base::UnitsApi::toDblWithUserPrefs(Base::Length,pos.getPosition().z),0,'f',1)
00153 .arg(Base::UnitsApi::toDblWithUserPrefs(Base::Angle,A),0,'f',1)
00154 .arg(Base::UnitsApi::toDblWithUserPrefs(Base::Angle,B),0,'f',1)
00155 .arg(Base::UnitsApi::toDblWithUserPrefs(Base::Angle,C),0,'f',1);
00156
00157 ui->label_Tool->setText(result);
00158 }
00159
00160 void TaskRobot6Axis::changeSliderA1(int value){
00161 pcRobot->Axis1.setValue(float (value));
00162 viewTcp(pcRobot->Tcp.getValue());
00163 ui->lineEdit_Axis1->setText(QString::fromLatin1("%1°").arg((float)value,0,'f',1));
00164 setColor(0,float (value),*(ui->lineEdit_Axis1));
00165 }
00166
00167 void TaskRobot6Axis::changeSliderA2(int value)
00168 {
00169 pcRobot->Axis2.setValue(float (value));
00170 viewTcp(pcRobot->Tcp.getValue());
00171 ui->lineEdit_Axis2->setText(QString::fromLatin1("%1°").arg((float)value,0,'f',1));
00172 setColor(1,float (value),*(ui->lineEdit_Axis2));
00173
00174 }
00175
00176 void TaskRobot6Axis::changeSliderA3(int value)
00177 {
00178 pcRobot->Axis3.setValue(float (value));
00179 viewTcp(pcRobot->Tcp.getValue());
00180 ui->lineEdit_Axis3->setText(QString::fromLatin1("%1°").arg((float)value,0,'f',1));
00181 setColor(2,float (value),*(ui->lineEdit_Axis3));
00182
00183 }
00184
00185 void TaskRobot6Axis::changeSliderA4(int value)
00186 {
00187 pcRobot->Axis4.setValue(float (value));
00188 viewTcp(pcRobot->Tcp.getValue());
00189 ui->lineEdit_Axis4->setText(QString::fromLatin1("%1°").arg((float)value,0,'f',1));
00190 setColor(3,float (value),*(ui->lineEdit_Axis4));
00191
00192 }
00193
00194 void TaskRobot6Axis::changeSliderA5(int value)
00195 {
00196 pcRobot->Axis5.setValue(float (value));
00197 viewTcp(pcRobot->Tcp.getValue());
00198 ui->lineEdit_Axis5->setText(QString::fromLatin1("%1°").arg((float)value,0,'f',1));
00199 setColor(4,float (value),*(ui->lineEdit_Axis5));
00200
00201 }
00202
00203 void TaskRobot6Axis::changeSliderA6(int value)
00204 {
00205 pcRobot->Axis6.setValue(float (value));
00206 viewTcp(pcRobot->Tcp.getValue());
00207 ui->lineEdit_Axis6->setText(QString::fromLatin1("%1°").arg((float)value,0,'f',1));
00208 setColor(5,float (value),*(ui->lineEdit_Axis6));
00209
00210 }
00211 void TaskRobot6Axis::setColor(int i,float angle, QLineEdit &lineEdit){
00212
00213 if( angle > Rob->getMaxAngle(i) || angle < Rob->getMinAngle(i)){
00214 QPalette p = lineEdit.palette();
00215 p.setColor(QPalette::Base, QColor(255,220,220));
00216 lineEdit.setPalette(p);
00217 }else{
00218 QPalette p = lineEdit.palette();
00219 p.setColor(QPalette::Base, QColor(220,255,220));
00220 lineEdit.setPalette(p);
00221 }
00222
00223 }
00224
00225 void TaskRobot6Axis::setAxis(float A1,float A2,float A3,float A4,float A5,float A6,const Base::Placement &Tcp)
00226 {
00227 ui->horizontalSlider_Axis1->setSliderPosition((int)A1);
00228 ui->lineEdit_Axis1->setText(QString::fromLatin1("%1°").arg(A1,0,'f',1));
00229 setColor(0,A1,*(ui->lineEdit_Axis1));
00230
00231 ui->horizontalSlider_Axis2->setSliderPosition((int)A2);
00232 ui->lineEdit_Axis2->setText(QString::fromLatin1("%1°").arg(A2,0,'f',1));
00233 setColor(1,A2,*(ui->lineEdit_Axis2));
00234
00235 ui->horizontalSlider_Axis3->setSliderPosition((int)A3);
00236 ui->lineEdit_Axis3->setText(QString::fromLatin1("%1°").arg(A3,0,'f',1));
00237 setColor(2,A3,*(ui->lineEdit_Axis3));
00238
00239 ui->horizontalSlider_Axis4->setSliderPosition((int)A4);
00240 ui->lineEdit_Axis4->setText(QString::fromLatin1("%1°").arg(A4,0,'f',1));
00241 setColor(3,A4,*(ui->lineEdit_Axis4));
00242
00243 ui->horizontalSlider_Axis5->setSliderPosition((int)A5);
00244 ui->lineEdit_Axis5->setText(QString::fromLatin1("%1°").arg(A5,0,'f',1));
00245 setColor(4,A5,*(ui->lineEdit_Axis5));
00246
00247 ui->horizontalSlider_Axis6->setSliderPosition((int)A6);
00248 ui->lineEdit_Axis6->setText(QString::fromLatin1("%1°").arg(A6,0,'f',1));
00249 setColor(5,A6,*(ui->lineEdit_Axis6));
00250
00251 viewTcp(Tcp);
00252
00253
00254 }
00255
00256
00257
00258 #include "moc_TaskRobot6Axis.cpp"