This commit is contained in:
hm
2019-12-27 17:26:08 +08:00
parent c56960fedc
commit a550735eb9
9 changed files with 190 additions and 21 deletions
+2
View File
@@ -65,6 +65,8 @@ LIBS += -L$$PWD/../thirdpart/lib -lqNavigation
LIBS += -L$$PWD/../thirdpart/lib -lCockpit
LIBS += -L$$PWD/../thirdpart/lib -lMavLinkNode
#temp file
DESTDIR = $$PWD/../app_bin
+20 -6
View File
@@ -13,6 +13,10 @@
#include "Cockpit.h"
#include "mavlinknode.h"
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
{
@@ -21,7 +25,7 @@ MainWindow::MainWindow(QWidget *parent)
QNavigationWidget *nav = new QNavigationWidget(this);
Cockpit *copk = new Cockpit(this);
copk = new Cockpit(this);
copk->setGeometry(this->width() - copk->width(),0,copk->width(),copk->height());
@@ -56,11 +60,7 @@ MainWindow::MainWindow(QWidget *parent)
//this->layout()->addWidget(connectpush);
//this->layout()->addWidget(disconnectpush);
//this->setLayout(layout);
//this->setLayout(layout);
}
MainWindow::~MainWindow()
@@ -68,6 +68,20 @@ MainWindow::~MainWindow()
}
void MainWindow::resizeEvent(QResizeEvent *e)
{
qDebug() << e;
copk->setGeometry(this->width() - copk->width(),0,copk->width(),copk->height());
update();
}
void MainWindow::dlink_triggered()
{
//if(dlink->statesPort())
+10
View File
@@ -3,8 +3,11 @@
#include <QMainWindow>
#include "Cockpit.h"
#include "mavlinknode.h"
@@ -24,6 +27,13 @@ public slots:
void dlink_triggered();
protected:
void resizeEvent(QResizeEvent * e);
protected:
Cockpit *copk;
};
+25 -12
View File
@@ -87,22 +87,23 @@ Cockpit::Cockpit(QWidget *parent): QWidget(parent)
m_LedColor = Qt::green;
setMinimumSize(QSize(10, 10));
resize(200, 200);
resize(600, 200);
}
void Cockpit::mouseReleaseEvent(QMouseEvent *e)
{
qDebug() << "release" << e;
update();
}
void Cockpit::mousePressEvent(QMouseEvent *e)
{
qDebug() << "press" << this->pos() << e->localPos() << e->screenPos();
qDebug() << "press" << e;
m_LedColor = Qt::blue;
m_c = this->pos();
update();
}
void Cockpit::mouseDoubleClickEvent(QMouseEvent *e)
@@ -119,12 +120,28 @@ void Cockpit::wheelEvent(QWheelEvent *e)
void Cockpit::setPitch(double Pitch)
{
m_Attitude.pitch = Pitch;
if(m_Attitude.pitch < -90)
{
m_Attitude.pitch += 180;
}
else if(m_Attitude.pitch > 90)
{
m_Attitude.pitch -= 180;
}
update();
}
void Cockpit::setRoll(double Roll)
{
m_Attitude.roll = Roll;
if(m_Attitude.roll < -180)
{
m_Attitude.roll += 360;
}
else if(m_Attitude.roll > 180)
{
m_Attitude.roll -= 360;
}
update();
}
@@ -141,14 +158,9 @@ void Cockpit::setYaw(double Yaw)
void Cockpit::setAttitude(double Pitch,double Roll,double Yaw)
{
m_Attitude.pitch = Pitch;
m_Attitude.roll = Roll;
m_Attitude.yaw = Yaw;
if(m_Attitude.yaw < 0)
{
m_Attitude.yaw += 360;
}
update();
setPitch(Pitch);
setRoll(Roll);
setYaw(Yaw);
}
void Cockpit::setAttitudeSpeed(double PitchSpeed,double RollSpeed,double YawSpeed)
@@ -212,7 +224,8 @@ void Cockpit::paintEvent(QPaintEvent *)
{
QPainter painter(this);
painter.setRenderHint(QPainter::Antialiasing); /* 使用反锯齿(如果可用) */
painter.translate(width() / 2, height() / 2); /* 坐标变换为窗体中心 */
painter.translate(width() / 2, 2 * height() / 5); /* 坐标变换为窗体中心 */
int side = qMin(width(), height()); /* 这一句决定了这个模块只能是方形 */
painter.scale(side / 2000.0, side / 2000.0); /* 比例缩放 */
painter.setPen(Qt::NoPen);
+1
View File
@@ -68,6 +68,7 @@ public Q_SLOTS:
void setYaw(double Yaw);
void setAttitude(double Pitch,double Roll,double Yaw);
void setAttitudeSpeed(double PitchSpeed,double RollSpeed,double YawSpeed);
void setGPSCourse(double Course);
void setGPSSVN(int Number);
void setGPSAltitude(double Altitude);
+4
View File
@@ -9,3 +9,7 @@ SUBDIRS += Skin
SUBDIRS += qnavigationwidget
SUBDIRS += Cockpit
SUBDIRS += MavLinkNode
+76
View File
@@ -0,0 +1,76 @@
QT += core gui network
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = MavlinkNode
TEMPLATE = lib
DEFINES += MAV_LIBRARY
# The following define makes your compiler emit warnings if you use
# any feature of Qt which has been marked as deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
DESTDIR = $$PWD/../thirdpart/lib
MOC_DIR = $$PWD/../build
OBJECTS_DIR = $$PWD/../build
DEFINES += QtMavlinkNode
win32 {
src_dir = $$PWD\\*.h
dst_dir = $$PWD\\..\\thirdpart\\include\\
# dst_dir 最后的 \\ 是必须的,用来标示 xcopy 到一个文件夹,若不存在,创建之
# Replace slashes in paths with backslashes for Windows
src_dir ~= s,/,\\,g
dst_dir ~= s,/,\\,g
system(xcopy $$src_dir $$dst_dir /y /e)
}
HEADERS += \
mavlinknode.h
SOURCES += \
mavlinknode.cpp
+35 -2
View File
@@ -1,6 +1,39 @@
#include "mavlinknode.h"
#include "mavlinknode.h"
MavLinkNode::MavLinkNode(QObject *parent) : QObject(parent)
{
this->run();
}
int MavLinkNode::run()//线程函数
{
while(1)
{
qDebug() << "run 1ms";
QThread::sleep(1);
}
return 0;
}
+17 -1
View File
@@ -1,7 +1,11 @@
#ifndef MAVLINKNODE_H
#ifndef MAVLINKNODE_H
#define MAVLINKNODE_H
#include <QObject>
#include "QThread"
#include "QDebug"
class MavLinkNode : public QObject
{
@@ -9,9 +13,21 @@ class MavLinkNode : public QObject
public:
explicit MavLinkNode(QObject *parent = nullptr);
signals:
public slots:
protected:
int run();
};
#endif // MAVLINKNODE_H