1 Star 0 Fork 10

极速代码/SimpleRobot

forked from firemiles/SimpleRobot 
Create your Gitee Account
Explore and code with more than 12 million developers,Free private repositories !:)
Sign up
文件
Clone or Download
mainwindow.cpp 2.48 KB
Copy Edit Raw Blame History
firemiles authored 2015-04-03 18:34 . 添加停止函数
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "robot/robot.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
robot = new Robot();
view = robot->getView();
control = robot->getControl();
this->setCentralWidget(view);
connect(control, SIGNAL(actionFinished()),
this, SLOT(onReached()));
control->setFinishedSignal(true);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::keyPressEvent(QKeyEvent *event)
{
bool immediate = false;
if(event->modifiers() == Qt::ShiftModifier) immediate = true;
switch (event->key()) {
case Qt::Key_Left:
view->rotateView(0,-10,0);
break;
case Qt::Key_Down:
view->rotateView(10,0,0);
break;
case Qt::Key_Up:
view->rotateView(-10,0,0);
break;
case Qt::Key_Right:
view->rotateView(0,10,0);
break;
case Qt::Key_Q:
control->RotateMaster(-40, 100, immediate);
break;
case Qt::Key_A:
control->RotateMaster(40, 100, immediate);
break;
case Qt::Key_W:
control->RotateAssistant(-40, 100, immediate);
break;
case Qt::Key_S:
control->RotateAssistant(40, 100, immediate);
break;
case Qt::Key_E:
control->RotateBar(-40, 100, immediate);
break;
case Qt::Key_D:
control->RotateBar(40, 100 ,immediate);
break;
case Qt::Key_R:
control->MoveBar(-40, 100, immediate);
break;
case Qt::Key_F:
control->MoveBar(40, 100, immediate);
break;
case Qt::Key_U:
control->RotateMasterAbs(-90, 50, immediate);
break;
case Qt::Key_J:
control->RotateMasterAbs(90, 50, immediate);
break;
case Qt::Key_I:
control->RotateAssistantAbs(-90, 50, immediate);
break;
case Qt::Key_K:
control->RotateAssistantAbs(90, 50, immediate);
break;
case Qt::Key_O:
control->RotateBarAbs(-90, 50, immediate);
break;
case Qt::Key_L:
control->RotateBarAbs(90, 50, immediate);
break;
case Qt::Key_P:
control->MoveBarAbs(40, 50, immediate);
break;
case Qt::Key_Semicolon:
control->MoveBarAbs(0, 50, immediate);
break;
case Qt::Key_Space:
control->Stop();
break;
default:
QMainWindow::keyPressEvent(event);
break;
}
}
void MainWindow::onReached()
{
qDebug()<<"Reached!";
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/andy521/SimpleRobot.git
git@gitee.com:andy521/SimpleRobot.git
andy521
SimpleRobot
SimpleRobot
master

Search