代码拉取完成,页面将自动刷新
同步操作将从 Qt(开源集合)/SimpleRobot 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
#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!";
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。