pull/38/head
pvqf6mep3 3 years ago
commit de5e6c02f5

@ -16,10 +16,7 @@ find_package(catkin REQUIRED COMPONENTS
## DEPENDS: system dependencies of this project that dependent projects also need ## DEPENDS: system dependencies of this project that dependent projects also need
catkin_package( catkin_package(
# INCLUDE_DIRS include
# LIBRARIES Air_Ground_CEC
# CATKIN_DEPENDS roscpp
# DEPENDS system_lib
) )
########### ###########

@ -1,32 +0,0 @@
#ifndef LOGIN_H
#define LOGIN_H
#include <QMainWindow>
#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

@ -0,0 +1,40 @@
#ifndef LOGINUI_H
#define LOGINUI_H
#include <QMainWindow>
#include "ui_loginui.h"
#include <iostream>
#include <cstring>
using namespace std;
namespace Ui {
class LoginUi;
}
class LoginUi : public QMainWindow
{
Q_OBJECT
public:
explicit LoginUi(QWidget *parent = nullptr);
~LoginUi();
private:
Ui::LoginUi *ui;
bool isPressedWidget;
QPoint m_lastPos;
void initWindow();
void mousePressEvent(QMouseEvent *event);
void mouseMoveEvent(QMouseEvent *event);
void mouseReleaseEvent(QMouseEvent *event);
void setWindowState();
void setBtnAndLabelState();
bool verifyAccount(string usr, string pwd);
void changetoMainwindow();
};
#endif // LOGINUI_H

@ -1,6 +1,6 @@
#include"Djitellowhite.h" #include "../include/Djitellowhite.h"
#include<iostream> #include <iostream>
#include<opencv2/opencv.hpp> #include <opencv2/opencv.hpp>
#include<stdio.h> #include<stdio.h>

@ -1,6 +1,7 @@
#include"Djitellowhite.h" #include "../include/Djitellowhite.h"
#include"Hardwarelistener.h" #include "../include/Hardwarelistener.h"
#include<iostream> #include <iostream>
/*
using namespace std; using namespace std;
int main(void){ int main(void){
Tello T("192.168.10.1"); Tello T("192.168.10.1");
@ -43,3 +44,4 @@ int main(void){
listenkeyboard(T,serveraddr); listenkeyboard(T,serveraddr);
return 0; return 0;
} }
*/

@ -1,6 +1,6 @@
#include <termio.h> #include <termio.h>
#include <stdio.h> #include <stdio.h>
#include "Hardwarelistener.h" #include "../include/Hardwarelistener.h"
#include <iostream> #include <iostream>
using namespace std; using namespace std;

@ -1,35 +1,36 @@
#include "../include/Air_Ground_CEC/login.h" #include "../include/Air_Ground_CEC/loginui.h"
#include "../include/Air_Ground_CEC/mainwindow.hpp"
#include <QMovie> #include <QMovie>
#include <QWidget> #include <QWidget>
#include <QMouseEvent> #include <QMouseEvent>
Login::Login(QWidget *parent) : LoginUi::LoginUi(QWidget *parent) :
QMainWindow(parent), QMainWindow(parent),
ui(new Ui::Login) ui(new Ui::LoginUi)
{ {
ui->setupUi(this); ui->setupUi(this);
initWindow(); initWindow();
} }
Login::~Login() LoginUi::~LoginUi()
{ {
delete ui; delete ui;
} }
void Login::initWindow(){ void LoginUi::initWindow(){
setWindowState(); setWindowState();
setBtnAndLabelState(); setBtnAndLabelState();
} }
void Login::setWindowState(){ void LoginUi::setWindowState(){
this->setAttribute(Qt::WA_TranslucentBackground); this->setAttribute(Qt::WA_TranslucentBackground);
this->setWindowFlags(Qt::FramelessWindowHint);//隐藏边框 this->setWindowFlags(Qt::FramelessWindowHint);//隐藏边框
} }
void Login::setBtnAndLabelState(){ void LoginUi::setBtnAndLabelState(){
QMovie* movie = new QMovie("://images/background.gif"); QMovie* movie = new QMovie("://images/background.gif");
ui->label_video->setMovie(movie); ui->label_video->setMovie(movie);
movie->start(); movie->start();
@ -47,14 +48,18 @@ void Login::setBtnAndLabelState(){
connect(ui->btnWinClose, &QPushButton::clicked, this, [=]() { this->close(); }); connect(ui->btnWinClose, &QPushButton::clicked, this, [=]() { this->close(); });
connect(ui->btnWinClose_2, &QPushButton::clicked, this, [=]() { this->close(); }); connect(ui->btnWinClose_2, &QPushButton::clicked, this, [=]() { this->close(); });
connect(ui->btnLogin, &QPushButton::clicked, this, [=]() {
changetoMainwindow();}
);
} }
void Login::mousePressEvent(QMouseEvent *event) { void LoginUi::mousePressEvent(QMouseEvent *event) {
m_lastPos = event->globalPos(); m_lastPos = event->globalPos();
isPressedWidget = true; // 当前鼠标按下的即是QWidget而非界面上布局的其它控件 isPressedWidget = true; // 当前鼠标按下的即是QWidget而非界面上布局的其它控件
} }
void Login::mouseMoveEvent(QMouseEvent *event) { void LoginUi::mouseMoveEvent(QMouseEvent *event) {
if (isPressedWidget) { if (isPressedWidget) {
this->move(this->x() + (event->globalX() - m_lastPos.x()), this->move(this->x() + (event->globalX() - m_lastPos.x()),
this->y() + (event->globalY() - m_lastPos.y())); this->y() + (event->globalY() - m_lastPos.y()));
@ -62,8 +67,30 @@ void Login::mouseMoveEvent(QMouseEvent *event) {
} }
} }
void Login::mouseReleaseEvent(QMouseEvent *event) { void LoginUi::mouseReleaseEvent(QMouseEvent *event) {
// 其实这里的mouseReleaseEvent函数可以不用重写 // 其实这里的mouseReleaseEvent函数可以不用重写
m_lastPos = event->globalPos(); m_lastPos = event->globalPos();
isPressedWidget = false; // 鼠标松开时置为false isPressedWidget = false; // 鼠标松开时置为false
} }
bool LoginUi::verifyAccount(string usr, string pwd){
if (usr == "admin" && pwd == "admin"){
return true;
}
return false;
}
void LoginUi::changetoMainwindow(){
this->close();
MainWindow CEC(0,0,0);
CEC.show();
}

@ -1,5 +1,5 @@
#include "../include/Air_Ground_CEC/mainwindow.hpp" #include "../include/Air_Ground_CEC/mainwindow.hpp"
#include "../include/Air_Ground_CEC/login.h" #include "../include/Air_Ground_CEC/loginui.h"
#include <QApplication> #include <QApplication>
@ -13,10 +13,10 @@ int main(int argc, char** argv)
QApplication app(argc, argv); QApplication app(argc, argv);
//MainWindow CEC(0,0,0); MainWindow CEC(0,0,0);
//CEC.show(); CEC.show();
Login a(0); //LoginUi a(0);
a.show(); //a.show();
return app.exec(); return app.exec();
return(0); return(0);
@ -26,6 +26,7 @@ int main(int argc, char** argv)
/* /*
* find . "(" -name "*.cpp" -or -name "*.h" -or -name "*.hpp" -or -name "*.qrc" ")" -print | xargs wc -l * find . "(" -name "*.cpp" -or -name "*.h" -or -name "*.hpp" -or -name "*.qrc" ")" -print | xargs wc -l
* git fame --incl '\.[cht]' -twMC
* rosrun rqt_graph rqt_graph * rosrun rqt_graph rqt_graph
* git fame * git fame
*/ */

@ -1,6 +1,8 @@
#include "../include/Air_Ground_CEC/qnode.hpp" #include "../include/Air_Ground_CEC/qnode.hpp"
#include "sensor_msgs/image_encodings.h" #include "sensor_msgs/image_encodings.h"
#include "sensor_msgs/CompressedImage.h"
#include <QtConcurrent/QtConcurrent> #include <QtConcurrent/QtConcurrent>
QNode::QNode(int argc, char **argv) : init_argc(argc), init_argv(argv){ QNode::QNode(int argc, char **argv) : init_argc(argc), init_argv(argv){
@ -47,7 +49,8 @@ void QNode::SubAndPubTopic(){
&QNode::batteryCallback, this); &QNode::batteryCallback, this);
image_transport::ImageTransport it(n); image_transport::ImageTransport it(n);
image_sub = it.subscribe("camera/rgb/image_raw", 100, &QNode::imageCallback, this); //camera/rgb/image_raw
image_sub = it.subscribe("raspicam_node/image", 10, &QNode::imageCallback, this);
//image_sub0 = n.subscribe("camera/rgb/image_raw",100,&QNode::imageCallback,this) //image_sub0 = n.subscribe("camera/rgb/image_raw",100,&QNode::imageCallback,this)
@ -172,12 +175,12 @@ void QNode::speedCallback(const nav_msgs::Odometry::ConstPtr& msg)
{ {
emit speed_x(msg->twist.twist.linear.x); emit speed_x(msg->twist.twist.linear.x);
emit speed_th(msg->twist.twist.angular.z); emit speed_th(msg->twist.twist.angular.z);
} }
void QNode::imageCallback(const sensor_msgs::ImageConstPtr &msg) void QNode::imageCallback(const sensor_msgs::ImageConstPtr &msg)
{ {
ROS_INFO("i am ok");
try try
{ {
cv_bridge::CvImageConstPtr cv_ptr = cv_bridge::CvImageConstPtr cv_ptr =

@ -40,7 +40,7 @@ void udp_server(int sockfd)
close(sockfd); close(sockfd);
} }
/*
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
int sockfd; int sockfd;
@ -54,5 +54,6 @@ int main(int argc, char **argv)
exit(0); exit(0);
} }
*/

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0"> <ui version="4.0">
<class>Login</class> <class>LoginUi</class>
<widget class="QWidget" name="Login"> <widget class="QWidget" name="LoginUi">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
@ -841,8 +841,8 @@ background-color:none</string>
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>579</width> <width>205</width>
<height>196</height> <height>104</height>
</rect> </rect>
</property> </property>
<attribute name="label"> <attribute name="label">
@ -902,8 +902,8 @@ background-color:none</string>
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>579</width> <width>88</width>
<height>196</height> <height>88</height>
</rect> </rect>
</property> </property>
<attribute name="label"> <attribute name="label">
@ -926,7 +926,7 @@ background-color:none</string>
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>565</width> <width>267</width>
<height>312</height> <height>312</height>
</rect> </rect>
</property> </property>
@ -1251,8 +1251,8 @@ background-color:none</string>
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>579</width> <width>313</width>
<height>196</height> <height>133</height>
</rect> </rect>
</property> </property>
<attribute name="label"> <attribute name="label">
Loading…
Cancel
Save