new frame gcs

This commit is contained in:
hm
2019-12-25 10:53:19 +08:00
commit 3ad2850e79
45 changed files with 3646 additions and 0 deletions
File diff suppressed because it is too large Load Diff
+181
View File
@@ -0,0 +1,181 @@
#ifndef ATTITUDEPANEL_H
#define ATTITUDEPANEL_H
#include <QWidget>
#include <QMouseEvent>
#include "battery.h"
class QColor;
class AttitudePanel: public QWidget
{
Q_OBJECT
public:
enum ErrorCode {MaxValueError=1,MinValueError,ThresholdError,TargetError,PrecisionError,ColorError,UnitsEmpty,OutOfRange};
explicit AttitudePanel(QWidget *parent = 0);
typedef struct {
quint8 fixtype;
quint8 svn;
double altitude;
double latitude;
double longitude;
float course;
float speed;
float vn;
float ve;
float vd;
}_gps;
typedef struct {
float ax;
float ay;
float az;
float gx;
float gy;
float gz;
float roll;
float pitch;
float yaw;
float pressurealtitude;
float airspeed;
float verticalspeed;
float horizontalspeed;
}_attitude;
typedef struct {
float voltage;
float current;
}_battery;
_gps m_GPS;
_battery m_Battery;
_attitude m_Attitude;
Q_SIGNALS:
void errorSignal(int);
public Q_SLOTS:
void setPitch(double Pitch);
void setRoll(double Roll);
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);
void setGPSSpeed(double speed);
void setPressureAltitude(double Altitude);
void setAirSpeed(double speed);
void setVoltage(double Voltage);
void setLed(QColor LED);
protected:
void mouseReleaseEvent(QMouseEvent *e);
void mousePressEvent(QMouseEvent *e);
void mouseDoubleClickEvent(QMouseEvent *e);
void wheelEvent(QWheelEvent *e);
void paintEvent(QPaintEvent *);
void drawLed(QPainter *painter);
void drawAttitude(QPainter *painter);
void drawYawScale(QPainter *painter);
void drawScale(QPainter *painter);
void drawCenterLine(QPainter *painter);
void drawText(QPainter *painter);
void drawGPS(QPainter *painter);
void drawHight(QPainter *painter);
void drawSpeed(QPainter *painter);
void drawBattery(QPainter *painter);
void drawLowPanel(QPainter *painter);
private:
Battery *bat;
double m_PitchValue;
double m_RollValue;
double m_YawValue;
double m_CourseValue;
double m_BatteryValue;
double m_GPSAltitudeValue;
double m_PressureAltitudeValue;
int m_Max_Roll;
int m_Min_Roll;
int m_Max_Altitude;
int m_Min_Altitude;
double m_gps_altitude;
double m_pre_altitude;
double m_gps_speed;
double m_air_speed;
QString m_CtrlModeValue;
QString m_AirplaneModeValue;
QString m_CurrentStatusValue;
QString m_LockStatusValue;
QString m_TurningStatusValue;
int m_GPSStatusValue;
int m_GPSStarValue;
float m_Z_SpeedValue;
float m_Z_HightValue;
//float m_X_SpeedValue;
//保护
QString m_ProtectString;
quint8 m_Protect;
//数值的最大最小值
double m_Pitch_MinValue;
double m_Roll_MinValue;
double m_Yaw_MinValue;
double m_CourseMinValue;
double m_Pitch_MaxValue;
double m_Roll_MaxValue;
double m_Yaw_MaxValue;
double m_CourseMaxValue;
double m_BatteryMinValue;
double m_BatteryMaxValue;
QColor m_CentreLineColor;
QColor m_ForeColor;
QColor m_CornerColor;
QColor m_GroundColor;//大地颜色
QColor m_SkyColor;//天空颜色
QColor m_LedColor;
QPoint m_c;
};
#endif // ALTITUDEPANEL_H
+13
View File
@@ -0,0 +1,13 @@
HEADERS += \
$$PWD/attitudepanel.h \
$$PWD/battery.h
SOURCES += \
$$PWD/attitudepanel.cpp \
$$PWD/battery.cpp
RESOURCES += \
$$PWD/img.qrc
+13
View File
@@ -0,0 +1,13 @@
HEADERS += \
$$PWD/attitudepanel.h \
$$PWD/battery.h
SOURCES += \
$$PWD/attitudepanel.cpp \
$$PWD/battery.cpp
RESOURCES += \
$$PWD/img.qrc
+83
View File
@@ -0,0 +1,83 @@
#include "battery.h"
#include <QPainter>
#include <QtCore/qmath.h>
#include "QThread"
#include "QDebug"
#include "QPicture"
Battery::Battery(QWidget *parent) : QWidget(parent)
{
//setMinimumSize(QSize(10, 10));
setMouseTracking(true);
resize(50,50);
//update();
}
void Battery::setSize(int width, int height)
{
resize(width,height);
}
void Battery::setColor(QColor color)
{
m_bodycolor = color;
update();
}
void Battery::setBackgroundColor(QColor color)
{
m_backgroundcolor = color;
update();
}
void Battery::setBorderColor(QColor color)
{
m_bordercolor = color;
update();
}
void Battery::paintEvent(QPaintEvent *)
{
QPainter painter(this);
painter.setRenderHint(QPainter::Antialiasing); /* 使用反锯齿(如果可用) */
painter.translate(width() / 2, height() / 2); /* 坐标变换为窗体中心 */
int side = qMin(width(), height());
painter.scale(side / 2000.0, side / 2000.0); /* 比例缩放 */
painter.setPen(Qt::NoPen);
qDebug() << width() << side << this;
drawBattery(&painter);
}
void Battery::mouseMoveEvent(QMouseEvent *e)
{
qDebug() << e;
}
void Battery::drawBattery(QPainter *painter)
{
painter->save();
//painter->setBrush(QColor("#AAAAAA"));
//painter->drawRect(-1000,-1000,3600,3600);
painter->setBrush(QColor(11,22,33,100));
painter->drawRoundRect(-1000,-1000,2000,2000,5,5);
painter->restore();
}
+51
View File
@@ -0,0 +1,51 @@
#ifndef BATTERY_H
#define BATTERY_H
#include <QObject>
#include <QWidget>
#include "QColor"
#include <QMouseEvent>
class QColor;
class Battery : public QWidget
{
Q_OBJECT
public:
explicit Battery(QWidget *parent = nullptr);
uint8_t type = 0;
signals:
protected:
void paintEvent(QPaintEvent *);
void mouseMoveEvent(QMouseEvent *);
public slots:
void setSize(int width,int height);
void setColor(QColor);
void setBackgroundColor(QColor);
void setBorderColor(QColor);
void drawBattery(QPainter *painter);
private:
QColor m_bodycolor;
QColor m_backgroundcolor;
QColor m_bordercolor;
};
#endif // BATTERY_H
+10
View File
@@ -0,0 +1,10 @@
<RCC>
<qresource prefix="/img">
<file>img/GPS.png</file>
<file>img/Mission.png</file>
<file>img/Position.png</file>
<file>img/mission1.png</file>
<file>img/clock.png</file>
<file>img/RGB.png</file>
</qresource>
</RCC>
Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB