merge hm_work
This commit is contained in:
+1434
-1012
File diff suppressed because it is too large
Load Diff
+138
-54
@@ -4,78 +4,122 @@
|
||||
#include <QWidget>
|
||||
#include <QMouseEvent>
|
||||
|
||||
class QColor;
|
||||
#include "leftladder.h"
|
||||
|
||||
#include "QTimer"
|
||||
|
||||
|
||||
#ifdef QtCockpit
|
||||
#include <cockpitglobal.h>
|
||||
class COCKPITSHARED_EXPORT Cockpit: public QWidget {
|
||||
#else
|
||||
class Cockpit: public QWidget
|
||||
{
|
||||
#endif
|
||||
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum ErrorCode {MaxValueError=1,MinValueError,ThresholdError,TargetError,PrecisionError,ColorError,UnitsEmpty,OutOfRange};
|
||||
|
||||
explicit Cockpit(QWidget *parent = 0);
|
||||
|
||||
explicit Cockpit(QWidget *parent = nullptr);
|
||||
~Cockpit();
|
||||
|
||||
|
||||
typedef struct {
|
||||
quint8 fixtype;
|
||||
quint8 svn;
|
||||
double altitude;
|
||||
double latitude;
|
||||
double longitude;
|
||||
float course;
|
||||
float speed;
|
||||
float vn;
|
||||
float ve;
|
||||
float vd;
|
||||
}_gps;
|
||||
QColor CentreLineColor;
|
||||
QColor ForeColor;
|
||||
QColor CornerColor;
|
||||
|
||||
QColor GroundColor;//大地颜色
|
||||
QColor SkyColor;//天空颜色
|
||||
|
||||
QColor LedColor;
|
||||
|
||||
QColor CurrentColor;
|
||||
QColor TargetColor;
|
||||
QColor StatusColor;
|
||||
|
||||
QColor NormalColor;
|
||||
QColor NoticeColor;
|
||||
QColor WarningColor;
|
||||
|
||||
QColor WColor;
|
||||
|
||||
}_color;
|
||||
|
||||
typedef struct {
|
||||
float ax;
|
||||
float ay;
|
||||
float az;
|
||||
qreal ax;
|
||||
qreal ay;
|
||||
qreal az;
|
||||
|
||||
float gx;
|
||||
float gy;
|
||||
float gz;
|
||||
qreal gx;
|
||||
qreal gy;
|
||||
qreal gz;
|
||||
|
||||
float roll;
|
||||
float pitch;
|
||||
float yaw;
|
||||
qreal roll;
|
||||
qreal pitch;
|
||||
qreal yaw;
|
||||
|
||||
float pressurealtitude;
|
||||
qreal altitude;
|
||||
qreal height;
|
||||
|
||||
float airspeed;
|
||||
float verticalspeed;
|
||||
float horizontalspeed;
|
||||
qreal airspeed;
|
||||
qreal verticalspeed;
|
||||
qreal horizontalspeed;
|
||||
|
||||
}_attitude;
|
||||
qreal AOA;
|
||||
|
||||
|
||||
|
||||
qreal distofly;
|
||||
|
||||
quint8 AirspeedFlag;
|
||||
|
||||
}_state;
|
||||
|
||||
typedef struct {
|
||||
float voltage;
|
||||
float current;
|
||||
qreal voltage[10];
|
||||
qreal current[10];
|
||||
}_battery;
|
||||
|
||||
_gps m_GPS;
|
||||
_battery m_Battery;
|
||||
_attitude m_Attitude;
|
||||
|
||||
|
||||
typedef struct{
|
||||
qreal pitch;
|
||||
qreal roll;
|
||||
qreal yaw;
|
||||
|
||||
qreal height;
|
||||
|
||||
qreal airspeed_maximun;
|
||||
qreal airspeed;
|
||||
qreal airspeed_minimun;
|
||||
|
||||
qreal heading;//航线方向
|
||||
qreal position;//侧偏距
|
||||
qreal altitude;//海拔
|
||||
|
||||
qreal verticalspeed;//纵向速度
|
||||
|
||||
}_target;
|
||||
|
||||
|
||||
_target m_Target;
|
||||
_state m_State;
|
||||
_color m_Color;
|
||||
|
||||
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 setPitch(qreal Pitch);
|
||||
void setRoll(qreal Roll);
|
||||
void setYaw(qreal Yaw);
|
||||
void setAttitude(qreal Pitch,qreal Roll,qreal Yaw);
|
||||
void setAttitudeSpeed(qreal PitchSpeed,qreal RollSpeed,qreal 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 setAltitude(qreal Altitude);
|
||||
void setAirSpeed(qreal speed);
|
||||
|
||||
void setLed(QColor LED);
|
||||
|
||||
@@ -93,22 +137,34 @@ protected:
|
||||
|
||||
void drawLed(QPainter *painter);
|
||||
|
||||
void drawAttitude(QPainter *painter);
|
||||
void drawPitch(QPainter *painter);
|
||||
void drawRoll(QPainter *painter);
|
||||
void drawRollScale(QPainter *painter);
|
||||
|
||||
void drawVRate(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 drawLeftScale(QPainter *painter);
|
||||
void drawRightScale(QPainter *painter);
|
||||
|
||||
void drawTopStatuts(QPainter *painter);
|
||||
|
||||
private slots:
|
||||
|
||||
void UpdateTimeout(void);
|
||||
|
||||
|
||||
void drawLowPanel(QPainter *painter);
|
||||
|
||||
private:
|
||||
|
||||
|
||||
QTimer *UpdateTimer = nullptr;
|
||||
|
||||
QString m_mode;//显示模式
|
||||
|
||||
QString m_SPD_HOLD;
|
||||
QString m_HDG_HOLD;
|
||||
QString m_ALT_HOLD;
|
||||
|
||||
double m_PitchValue;
|
||||
double m_RollValue;
|
||||
@@ -163,6 +219,7 @@ private:
|
||||
double m_BatteryMinValue;
|
||||
double m_BatteryMaxValue;
|
||||
|
||||
/*
|
||||
QColor m_CentreLineColor;
|
||||
QColor m_ForeColor;
|
||||
QColor m_CornerColor;
|
||||
@@ -172,8 +229,35 @@ private:
|
||||
|
||||
QColor m_LedColor;
|
||||
|
||||
QColor m_CurrentColor;
|
||||
QColor m_TargetColor;
|
||||
QColor m_StatusColor;
|
||||
|
||||
QColor m_NormalColor;
|
||||
QColor m_NoticeColor;
|
||||
QColor m_WarningColor;
|
||||
|
||||
|
||||
|
||||
QColor m_WColor;
|
||||
*/
|
||||
|
||||
|
||||
QPoint m_c;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
LeftLadder *leftladder;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // ALTITUDEPANEL_H
|
||||
|
||||
+12
-3
@@ -11,6 +11,12 @@ TEMPLATE = lib
|
||||
|
||||
DEFINES += COCKPIT_LIBRARY
|
||||
|
||||
|
||||
CONFIG += plugin \
|
||||
resources_big
|
||||
|
||||
|
||||
|
||||
# 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
|
||||
@@ -26,10 +32,13 @@ DEFINES += QT_DEPRECATED_WARNINGS
|
||||
|
||||
|
||||
HEADERS += \
|
||||
$$PWD/Cockpit.h
|
||||
$$PWD/Cockpit.h \
|
||||
cockpitglobal.h \
|
||||
leftladder.h
|
||||
|
||||
SOURCES += \
|
||||
$$PWD/Cockpit.cpp
|
||||
$$PWD/Cockpit.cpp \
|
||||
leftladder.cpp
|
||||
|
||||
|
||||
|
||||
@@ -39,7 +48,7 @@ OBJECTS_DIR = $$PWD/../build
|
||||
|
||||
DEFINES += QtCockpit
|
||||
|
||||
win32 {
|
||||
win32|win64 {
|
||||
src_dir = $$PWD\\*.h
|
||||
dst_dir = $$PWD\\..\\thirdpart\\include\\
|
||||
# dst_dir 最后的 \\ 是必须的,用来标示 xcopy 到一个文件夹,若不存在,创建之
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
#ifndef COCKPITGLOBAL_H
|
||||
#define COCKPITGLOBAL_H
|
||||
|
||||
|
||||
#include <QtCore/qglobal.h>
|
||||
|
||||
#ifdef QtCockpit
|
||||
#if defined(COCKPIT_LIBRARY)
|
||||
# define COCKPITSHARED_EXPORT Q_DECL_EXPORT
|
||||
#else
|
||||
# define COCKPITSHARED_EXPORT Q_DECL_IMPORT
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // COPKITGLOBAL_H
|
||||
@@ -0,0 +1,244 @@
|
||||
#include "leftladder.h"
|
||||
|
||||
LeftLadder::LeftLadder(QWidget *parent): QWidget(parent)
|
||||
{
|
||||
|
||||
m_CentreLineColor = Qt::white;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void LeftLadder::setAirSpeed(float speed)
|
||||
{
|
||||
airspeed = speed;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void LeftLadder::mouseReleaseEvent(QMouseEvent *e)
|
||||
{
|
||||
qDebug() << "release" << e;
|
||||
update();
|
||||
}
|
||||
|
||||
void LeftLadder::mousePressEvent(QMouseEvent *e)
|
||||
{
|
||||
qDebug() << "press" << e;
|
||||
|
||||
update();
|
||||
}
|
||||
|
||||
void LeftLadder::mouseDoubleClickEvent(QMouseEvent *e)
|
||||
{
|
||||
qDebug() << "double clicked" << e;
|
||||
update();
|
||||
}
|
||||
|
||||
void LeftLadder::wheelEvent(QWheelEvent *e)
|
||||
{
|
||||
qDebug() << "wheel event" << e;
|
||||
|
||||
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void LeftLadder::paintEvent(QPaintEvent *)
|
||||
{
|
||||
QPainter painter(this);
|
||||
painter.setRenderHint(QPainter::Antialiasing); /* 使用反锯齿(如果可用) */
|
||||
|
||||
painter.translate(0, height() / 2); /* 坐标变换为窗体中心 */
|
||||
int side = qMin(width(), height()); /* 这一句决定了这个模块只能是方形 */
|
||||
painter.scale(side / 1000.0, side / 1000.0); /* 比例缩放 */
|
||||
painter.setPen(Qt::NoPen);
|
||||
|
||||
|
||||
drawLeftScale(&painter);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
//画左刻度尺 用单独的控件最容易解决
|
||||
void LeftLadder::drawLeftScale(QPainter *painter)
|
||||
{
|
||||
painter->save();
|
||||
|
||||
//平移坐标
|
||||
//painter->translate(0,0);
|
||||
|
||||
QPen ePen;
|
||||
QFont font;
|
||||
//画一个半透明的小方块
|
||||
painter->save();
|
||||
painter->setOpacity(0.3f);
|
||||
ePen.setColor(QColor("#7A7A7A"));
|
||||
painter->setBrush(QColor("#7A7A7A"));
|
||||
painter->drawRect(0,-600,300,1200);
|
||||
painter->restore();
|
||||
|
||||
//画最底下的黑色单位显示框
|
||||
painter->save();
|
||||
ePen.setColor(QColor("#FFFFFF"));
|
||||
ePen.setWidth(10);
|
||||
|
||||
|
||||
font.setPixelSize(60);
|
||||
|
||||
painter->setPen(ePen);
|
||||
painter->setFont(font);
|
||||
painter->setBrush(QColor("#000000"));
|
||||
painter->drawRect(0,600,300,100);
|
||||
|
||||
painter->drawText(QRect(20,600,280,100),Qt::AlignLeft|Qt::AlignVCenter,"TAS " + QString::number(airspeed));
|
||||
|
||||
painter->restore();
|
||||
|
||||
|
||||
//画旁边的速度刻度,并显示
|
||||
painter->save();
|
||||
|
||||
painter->translate(0,1200.0f/40.0f * airspeed);
|
||||
|
||||
float h = 1200.0f/40.0f;//单位高度
|
||||
|
||||
|
||||
for(int i = -19 - airspeed;i<=(19 - airspeed);i+=1)
|
||||
{
|
||||
|
||||
QString strText = QString::number(-i); //设置当前字体
|
||||
painter->save();
|
||||
|
||||
QPen ePen;
|
||||
QFont font;
|
||||
ePen.setColor(m_CentreLineColor);
|
||||
ePen.setWidth(10);
|
||||
font.setPointSize(60);
|
||||
|
||||
painter->setPen(ePen);
|
||||
painter->setFont(font);
|
||||
|
||||
if((i%10) == 0)
|
||||
{
|
||||
//if((i * h > 100)||(i * h < -100))
|
||||
//{
|
||||
painter->drawLine( 220,i * h,290,i * h);
|
||||
painter->drawText(QRect(20,i * h - 30,190,60),Qt::AlignVCenter|Qt::AlignRight, strText);
|
||||
//}
|
||||
}
|
||||
else if((i%5) == 0)
|
||||
{
|
||||
painter->drawLine(240,i * h,290,i * h);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
painter->restore();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
painter->restore();
|
||||
|
||||
|
||||
//画旁边的速度彩条
|
||||
painter->save();
|
||||
|
||||
painter->setBrush(QColor("#FFC125"));
|
||||
painter->drawRect(275,-600,25,1200);
|
||||
painter->restore();
|
||||
|
||||
//画 中间黑色的显示块
|
||||
painter->save();
|
||||
|
||||
static const QPointF points1[11] = {
|
||||
QPointF( 0,-50),
|
||||
QPointF(200,-50),
|
||||
QPointF(200,-100),
|
||||
QPointF(275,-100),
|
||||
|
||||
QPointF(275,-25),
|
||||
QPointF(290, 0),
|
||||
QPointF(275, 25),
|
||||
|
||||
QPointF(275, 100),
|
||||
QPointF(200, 100),
|
||||
QPointF(200, 50),
|
||||
QPointF( 0, 50)
|
||||
};
|
||||
|
||||
painter->setBrush(QColor("#000000"));
|
||||
painter->drawPolygon(points1, 11);
|
||||
|
||||
|
||||
|
||||
ePen.setColor(m_CentreLineColor);
|
||||
ePen.setWidth(15);
|
||||
font.setPointSize(90);
|
||||
painter->setPen(ePen);
|
||||
painter->setFont(font);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
QString DacadeText = QString::number(int(airspeed/10)); //设置十位以上
|
||||
QString UnitText = QString::number(qAbs(int(airspeed)%10)); //设置个位
|
||||
painter->drawText(QRect(0,-50,200,100),Qt::AlignVCenter|Qt::AlignRight, DacadeText);
|
||||
//painter->drawText(QRect(200,-50,100,100),Qt::AlignVCenter|Qt::AlignLeft, UnitText);
|
||||
|
||||
float Unit = airspeed - int(airspeed)/10 * 10;
|
||||
float Decimal = (airspeed - int(airspeed));
|
||||
|
||||
|
||||
qDebug() << Unit;
|
||||
for(int i = -2 - Unit;i<(2 - Unit);i+=1)
|
||||
{
|
||||
|
||||
QString strText = QString::number(((-i < 0)?(-i+10):((-i>=10)?(-i-10):(-i)))); //设置当前字体
|
||||
painter->save();
|
||||
|
||||
QPen ePen;
|
||||
QFont font;
|
||||
ePen.setColor(m_CentreLineColor);
|
||||
ePen.setWidth(15);
|
||||
font.setPointSize(90);
|
||||
|
||||
painter->setPen(ePen);
|
||||
painter->setFont(font);
|
||||
painter->drawText(QRect(200,(i + Unit) * 100 - 50,100,90),Qt::AlignVCenter|Qt::AlignLeft, strText);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
painter->restore();
|
||||
}
|
||||
|
||||
|
||||
painter->restore();
|
||||
|
||||
|
||||
|
||||
|
||||
painter->restore();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
#ifndef LEFTLADDER_H
|
||||
#define LEFTLADDER_H
|
||||
|
||||
#include <QObject>
|
||||
#include "QWidget"
|
||||
#include <QMouseEvent>
|
||||
#include "QDebug"
|
||||
|
||||
#include <QPainter>
|
||||
#include <QtCore/qmath.h>
|
||||
#include "QThread"
|
||||
#include "QDebug"
|
||||
#include "QPicture"
|
||||
|
||||
|
||||
#ifdef QtCockpit
|
||||
#include <Cockpitglobal.h>
|
||||
class COCKPITSHARED_EXPORT LeftLadder: public QWidget{
|
||||
#else
|
||||
class LeftLadder: public QWidget
|
||||
{
|
||||
#endif
|
||||
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit LeftLadder(QWidget *parent = 0);
|
||||
|
||||
|
||||
public slots:
|
||||
void setAirSpeed(float speed);
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
void mouseReleaseEvent(QMouseEvent *e);
|
||||
void mousePressEvent(QMouseEvent *e);
|
||||
void mouseDoubleClickEvent(QMouseEvent *e);
|
||||
void wheelEvent(QWheelEvent *e);
|
||||
|
||||
void paintEvent(QPaintEvent *);
|
||||
|
||||
|
||||
void drawLeftScale(QPainter *painter);
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
float airspeed;
|
||||
|
||||
|
||||
QColor m_CentreLineColor;
|
||||
|
||||
};
|
||||
|
||||
#endif // LEFTLADDER_H
|
||||
Reference in New Issue
Block a user