diff --git a/src/include/Air_Ground_CEC/login.h b/src/include/Air_Ground_CEC/login.h new file mode 100644 index 0000000..f7c85d2 --- /dev/null +++ b/src/include/Air_Ground_CEC/login.h @@ -0,0 +1,32 @@ +#ifndef LOGIN_H +#define LOGIN_H + +#include +#include "ui_login.h" + +namespace Ui { +class Login; +} + +class Login : public QMainWindow +{ + Q_OBJECT + +public: + explicit Login(QWidget *parent = nullptr); + ~Login(); + +private: + Ui::Login *ui; + bool isPressedWidget; + QPoint m_lastPos; + + void initWindow(); + void mousePressEvent(QMouseEvent *event); + void mouseMoveEvent(QMouseEvent *event); + void mouseReleaseEvent(QMouseEvent *event); + void setWindowState(); + void setBtnAndLabelState(); +}; + +#endif // LOGIN_H diff --git a/src/main/login.cpp b/src/main/login.cpp new file mode 100644 index 0000000..d189ad3 --- /dev/null +++ b/src/main/login.cpp @@ -0,0 +1,69 @@ +#include "../include/Air_Ground_CEC/login.h" +#include +#include +#include + +Login::Login(QWidget *parent) : + QMainWindow(parent), + ui(new Ui::Login) +{ + ui->setupUi(this); + initWindow(); + +} + +Login::~Login() +{ + delete ui; +} + +void Login::initWindow(){ + setWindowState(); + setBtnAndLabelState(); +} + +void Login::setWindowState(){ + this->setAttribute(Qt::WA_TranslucentBackground); + this->setWindowFlags(Qt::FramelessWindowHint);//隐藏边框 +} + + + +void Login::setBtnAndLabelState(){ + QMovie* movie = new QMovie("://images/background.gif"); + ui->label_video->setMovie(movie); + movie->start(); + + ui->btnWinMin->setIcon(QIcon("://images/min.png")); + ui->btnWinMin_2->setIcon(QIcon("://images/min.png")); + ui->btnWinClose->setIcon(QIcon("://images/close.png")); + ui->btnWinClose_2->setIcon(QIcon("://images/close.png")); + + connect(ui->btnWinMin, &QPushButton::clicked, this, + [=]() { this->showMinimized(); }); + connect(ui->btnWinMin_2, &QPushButton::clicked, this, + [=]() { this->showMinimized(); }); + + connect(ui->btnWinClose, &QPushButton::clicked, this, [=]() { this->close(); }); + connect(ui->btnWinClose_2, &QPushButton::clicked, this, [=]() { this->close(); }); + +} + +void Login::mousePressEvent(QMouseEvent *event) { + m_lastPos = event->globalPos(); + isPressedWidget = true; // 当前鼠标按下的即是QWidget而非界面上布局的其它控件 +} + +void Login::mouseMoveEvent(QMouseEvent *event) { + if (isPressedWidget) { + this->move(this->x() + (event->globalX() - m_lastPos.x()), + this->y() + (event->globalY() - m_lastPos.y())); + m_lastPos = event->globalPos(); + } +} + +void Login::mouseReleaseEvent(QMouseEvent *event) { + // 其实这里的mouseReleaseEvent函数可以不用重写 + m_lastPos = event->globalPos(); + isPressedWidget = false; // 鼠标松开时,置为false +} diff --git a/src/main/main.cpp b/src/main/main.cpp index e06e3b5..1542c5a 100644 --- a/src/main/main.cpp +++ b/src/main/main.cpp @@ -1,4 +1,5 @@ #include "../include/Air_Ground_CEC/mainwindow.hpp" +#include "../include/Air_Ground_CEC/login.h" #include @@ -11,9 +12,11 @@ int main(int argc, char** argv) QApplication app(argc, argv); - MainWindow CEC(0,0,0); - CEC.show(); + //MainWindow CEC(0,0,0); + //CEC.show(); + Login a(0); + a.show(); return app.exec(); return(0); diff --git a/src/main/mainwindow.cpp b/src/main/mainwindow.cpp index ad29714..3e6936b 100644 --- a/src/main/mainwindow.cpp +++ b/src/main/mainwindow.cpp @@ -14,7 +14,11 @@ MainWindow::MainWindow(int argc, char **argv, QWidget *parent) : ui->setupUi(this); initUis(); + timer = new QTimer(this); + connections(); + + } MainWindow::~MainWindow() @@ -155,6 +159,9 @@ void MainWindow::connections(){ ui->stackedWidget_ros_control->setCurrentIndex(0); }); + //label -> stream + connect(timer, SIGNAL(timeout()), this, SLOT(importFrame())); + /* * 绑定速度控制按钮 */ @@ -378,7 +385,7 @@ void MainWindow::importFrame() void MainWindow::on_Open_receive_clicked() { - capture.open(1); + capture.open(0); //capture.open("udp://@0.0.0.0:11111"); timer->start(30); } diff --git a/src/main/qnode.cpp b/src/main/qnode.cpp index 850a2e4..2ba92dc 100644 --- a/src/main/qnode.cpp +++ b/src/main/qnode.cpp @@ -29,7 +29,7 @@ bool QNode::init() { SubAndPubTopic(); }); - //start(); + return true; } @@ -90,7 +90,7 @@ void QNode::KeyboardMove(char key, float speed_linear, float speed_trun){ cmd_pub.publish(twist); - ros::spinOnce(); + //ros::spinOnce(); } void QNode::AutoMove(float speed_linear, float speed_turn, diff --git a/src/resources/images.qrc b/src/resources/images.qrc index 5b4cff0..27784cb 100644 --- a/src/resources/images.qrc +++ b/src/resources/images.qrc @@ -16,5 +16,10 @@ images/up_left_2.png images/up_right.png images/up_right_2.png + images/close.png + images/min.png + images/power.png + images/power-v.png + images/background.gif diff --git a/src/resources/images/background.gif b/src/resources/images/background.gif new file mode 100755 index 0000000..4c060bf Binary files /dev/null and b/src/resources/images/background.gif differ diff --git a/src/resources/images/close.png b/src/resources/images/close.png new file mode 100644 index 0000000..eda4ca6 Binary files /dev/null and b/src/resources/images/close.png differ diff --git a/src/resources/images/min.png b/src/resources/images/min.png new file mode 100644 index 0000000..2b8d614 Binary files /dev/null and b/src/resources/images/min.png differ diff --git a/src/resources/images/power-v.png b/src/resources/images/power-v.png new file mode 100644 index 0000000..3706acf Binary files /dev/null and b/src/resources/images/power-v.png differ diff --git a/src/resources/images/power.png b/src/resources/images/power.png new file mode 100644 index 0000000..68c60f3 Binary files /dev/null and b/src/resources/images/power.png differ diff --git a/src/ui/login.ui b/src/ui/login.ui new file mode 100755 index 0000000..911119f --- /dev/null +++ b/src/ui/login.ui @@ -0,0 +1,1458 @@ + + + Login + + + + 0 + 0 + 600 + 450 + + + + + 600 + 450 + + + + + 600 + 450 + + + + 登录界面 + + + + :/resource/ico/QQ.png:/resource/ico/QQ.png + + + background-color:rgb(255, 255, 255); +padding:0; + + + + + + 0 + 0 + 602 + 515 + + + + 0 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 600 + 300 + + + + + 99999 + 99999 + + + + + + 0 + 471 + 16 + 17 + + + + + + + Qt::AlignCenter + + + + + + 0 + 549 + 30 + 30 + + + + + 30 + 30 + + + + + 30 + 30 + + + + + + + :/resource/images/QQ.png + + + + + + 0 + 520 + 400 + 29 + + + + + 400 + 29 + + + + + 400 + 29 + + + + color: #FFFFFF; + + + + + + + + + 0 + 422 + 16 + 17 + + + + + + + + + + 0 + 0 + 600 + 200 + + + + + 600 + 200 + + + + + 600 + 200 + + + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + + + + + + + + 110 + 210 + 372 + 195 + + + + + 0 + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + + + + + border:0px; + +color:GRAY; + + + 账 号: + + + + + + + + 0 + 41 + + + + + 16777215 + 41 + + + + admin + + + 主节点地址 + + + + + + + + + + + border:0px; + +color:GRAY; + + + 密 码: + + + + + + + + 0 + 41 + + + + + 16777215 + 41 + + + + admin + + + QLineEdit::Normal + + + 本机地址 + + + + + + + + + + + PointingHandCursor + + + border:0px; +color:GRAY; + + + push + + + + + + + + + + + + 270 + 41 + + + + + 270 + 41 + + + + PointingHandCursor + + + Qt::NoFocus + + + 连接 + + + border:0px; +background-color:#F81243; +color:WHITE; + + + + LOGIN + + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + 10 + 420 + 581 + 25 + + + + + 0 + + + + + PointingHandCursor + + + border:0px; +color:GRAY; + + + 帮助 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + PointingHandCursor + + + border:0px; +color:GRAY; + + + 设置 + + + + + + + + + 541 + 11 + 20 + 16 + + + + PointingHandCursor + + + Qt::NoFocus + + + border:none; +background-color:none + + + + + + + :/resource/common/ic_min.png:/resource/common/ic_min.png + + + + + + 567 + 11 + 20 + 16 + + + + + 0 + 0 + + + + PointingHandCursor + + + Qt::NoFocus + + + border:none; +background-color:none + + + + + + + :/resource/common/ic_close_white.png:/resource/common/ic_close_white.png + + + + + + + + + + + + + 0 + + + 1 + + + 1 + + + 1 + + + 1 + + + + + + + 9 + 474 + 582 + 30 + + + + + 0 + 30 + + + + + 16777215 + 30 + + + + + + + 9 + 9 + 581 + 431 + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + PointingHandCursor + + + Qt::NoFocus + + + border:none; +background-color:none + + + + + + + :/resource/common/ic_min.png:/resource/common/ic_min.png + + + + + + + + 0 + 0 + + + + PointingHandCursor + + + Qt::NoFocus + + + border:none; +background-color:none + + + + + + + :/resource/common/ic_close_white.png:/resource/common/ic_close_white.png + + + + + + + + + 0 + + + + + 0 + 0 + 565 + 232 + + + + 话题设置 + + + + + + + + + + 速度控制话题: + + + + + + + cmd_vel + + + + + + + + + + + 导航目标点话题: + + + + + + + move_base_simple/goal + + + + + + + + + + + 导航初始点话题: + + + + + + + initialpose + + + + + + + + + + + 转向灯亮起的yaw角阈值: + + + + + + + + + + + + + + + + + + 里程计话题: + + + + + + + raw_odom + + + + + + + + + + + 电池电量话题: + + + + + + + battery_state + + + + + + + sensor_msgs/BatteryState + + + + + + + + + + + + + + 机器人坐标话题: + + + + + + + amcl_pose + + + + + + + + + + + + + 0 + 0 + 579 + 196 + + + + 坐标系设置 + + + + + + + + + + 激光雷达Frame: + + + + + + + + + + + + + + 地图Frame: + + + + + + + + + + + + + + 底盘坐标Frame: + + + + + + + + + + + + + + + + 0 + 0 + 579 + 196 + + + + 图层设置 + + + + + + + 1 + + + + + + + + + + 0 + 0 + 565 + 312 + + + + Video + + + + + + + + + + + 61 + 17 + + + + Video0: + + + + + + + + + + + + + + + + + 16777215 + 17 + + + + video0 需为压缩图像话题 + + + + + + + + + + 61 + 17 + + + + Name: + + + + + + + compressed1 + + + + + + + + + + + + 61 + 17 + + + + Topic: + + + + + + + image_raw/compressed + + + + + + + + + + + + + QFrame::HLine + + + QFrame::Raised + + + + + + + + + + 61 + 17 + + + + Video1: + + + + + + + + + + + + 61 + 17 + + + + Name: + + + + + + + + + + + + + + + + + + + 61 + 17 + + + + Topic: + + + + + + + + + + + + + + + + QFrame::HLine + + + QFrame::Raised + + + + + + + + + + 61 + 17 + + + + Video2: + + + + + + + + + + + + 61 + 17 + + + + Name: + + + + + + + + + + + + + + + 61 + 17 + + + + Topic: + + + + + + + + + + + + + + + + QFrame::HLine + + + QFrame::Raised + + + + + + + + + + 61 + 17 + + + + Video3: + + + + + + + + + + + + 61 + 17 + + + + Name: + + + + + + + + + + + + + + + 61 + 17 + + + + Topic: + + + + + + + + + + + + + + + + + + + + 0 + 0 + 579 + 196 + + + + 通用设置 + + + + + + + + 机器人模型图: + + + + + + + + + + 浏览 + + + + + + + + + + + + 16777215 + 40 + + + + 显示模式: + + + + + + + + 16777215 + 60 + + + + border:none + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + 机器人端 + + + + + + + 控制端 + + + + + + + + + + + + + + + + 话题订阅线程数: + + + + + + + + + + FrameRate: + + + + + + + + + + + + + 16777215 + 30 + + + + + + + + + + + + + + + + + PointingHandCursor + + + border:0px; +color:GRAY; + + + 保存 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + PointingHandCursor + + + border:0px; +color:GRAY; + + + 返回主界面 + + + + + + + + + + + + + + + + 0 + 0 + 2 + 2 + + + + + + + +