2020-10-22 21:52:01 +08:00
|
|
|
#ifndef Cockpit_H
|
2020-09-23 18:41:12 +08:00
|
|
|
#define Cockpit_H
|
|
|
|
|
|
|
|
|
|
#include <QWidget>
|
|
|
|
|
#include <QMouseEvent>
|
|
|
|
|
#include "QTimer"
|
2020-10-22 21:52:01 +08:00
|
|
|
#include "QDebug"
|
2020-09-23 18:41:12 +08:00
|
|
|
|
|
|
|
|
#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 = nullptr);
|
|
|
|
|
~Cockpit();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
|
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 {
|
|
|
|
|
|
|
|
|
|
QString GPS;
|
|
|
|
|
QString MODE;
|
|
|
|
|
QString STATE;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
qreal ax = 0;
|
|
|
|
|
qreal ay = 0;
|
|
|
|
|
qreal az = 0;
|
|
|
|
|
|
|
|
|
|
qreal gx = 0;
|
|
|
|
|
qreal gy = 0;
|
|
|
|
|
qreal gz = 0;
|
|
|
|
|
|
|
|
|
|
qreal roll = 0;
|
|
|
|
|
qreal pitch = 0;
|
|
|
|
|
qreal yaw = 0;
|
|
|
|
|
|
|
|
|
|
qreal altitude = 0;
|
|
|
|
|
qreal altitude_t = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
qreal height = 0;
|
|
|
|
|
|
2020-10-22 21:52:01 +08:00
|
|
|
qreal speed = 0;
|
2020-09-23 18:41:12 +08:00
|
|
|
qreal airspeed=0;
|
|
|
|
|
qreal airspeed_t=0;
|
|
|
|
|
qreal verticalspeed = 0;
|
|
|
|
|
qreal verticalspeed_t = 0;
|
|
|
|
|
|
|
|
|
|
qreal horizontalspeed = 0;
|
|
|
|
|
|
|
|
|
|
qreal AOA = 0;
|
|
|
|
|
qreal OL = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
qreal wp_dist = 0;
|
|
|
|
|
qreal alt_err = 0;
|
|
|
|
|
qreal xtrack = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
quint8 AirspeedFlag = 0;
|
|
|
|
|
|
2020-10-22 21:52:01 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-09-23 18:41:12 +08:00
|
|
|
bool isUpdate;
|
|
|
|
|
|
|
|
|
|
}_state;
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
|
qreal voltage[10];
|
|
|
|
|
qreal current[10];
|
|
|
|
|
}_battery;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct{
|
|
|
|
|
|
|
|
|
|
qreal pitch = 0;
|
|
|
|
|
qreal roll = 0;
|
|
|
|
|
qreal yaw = 0;
|
|
|
|
|
|
|
|
|
|
qreal height = 0;
|
|
|
|
|
|
|
|
|
|
qreal airspeed_maximun = 0;
|
|
|
|
|
qreal airspeed = 0;
|
|
|
|
|
qreal airspeed_minimun = 0;
|
|
|
|
|
|
|
|
|
|
qreal heading = 0;//航线方向
|
|
|
|
|
qreal position = 0;//侧偏距
|
|
|
|
|
qreal altitude = 0;//海拔
|
|
|
|
|
|
|
|
|
|
qreal verticalspeed = 0;//纵向速度
|
|
|
|
|
|
|
|
|
|
bool isUpdate = false;
|
|
|
|
|
|
|
|
|
|
}_target;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_target m_Target;
|
|
|
|
|
_state m_State;
|
|
|
|
|
_color m_Color;
|
|
|
|
|
|
|
|
|
|
Q_SIGNALS:
|
|
|
|
|
void errorSignal(int);
|
|
|
|
|
|
|
|
|
|
void showMessage(const QString &message,int TimeOut = 0);
|
|
|
|
|
|
|
|
|
|
public Q_SLOTS:
|
|
|
|
|
|
|
|
|
|
bool NormalSize()
|
|
|
|
|
{
|
|
|
|
|
return isNormalSize;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void setNormalSize(bool flag)
|
|
|
|
|
{
|
|
|
|
|
isNormalSize = flag;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//void setUseOpenGL(const bool &value);
|
|
|
|
|
|
|
|
|
|
|
2020-10-22 21:52:01 +08:00
|
|
|
|
|
|
|
|
|
2020-09-23 18:41:12 +08:00
|
|
|
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 setPitchTarget(qreal Pitch);
|
|
|
|
|
void setRollTarget(qreal Roll);
|
|
|
|
|
void setYawTarget(qreal Yaw);
|
|
|
|
|
void setAttitudeTarget(qreal Pitch,qreal Roll,qreal Yaw);
|
|
|
|
|
|
|
|
|
|
void setAltitude(qreal Altitude);
|
|
|
|
|
void setAltitudeTarget(double Altitude);
|
|
|
|
|
|
2020-10-22 21:52:01 +08:00
|
|
|
void setSpeed(double speed,uint8_t flag);
|
2020-09-23 18:41:12 +08:00
|
|
|
void setAirSpeed(qreal speed,uint8_t flag);
|
|
|
|
|
void setAirSpeedTarget(double speed,uint8_t flag);
|
2020-10-22 21:52:01 +08:00
|
|
|
void setAirSpeedFlag(quint8 flag);
|
|
|
|
|
|
|
|
|
|
quint8 AirSpeedFlag(void)
|
|
|
|
|
{
|
|
|
|
|
return m_State.AirspeedFlag;
|
|
|
|
|
}
|
2020-09-23 18:41:12 +08:00
|
|
|
|
|
|
|
|
void setVerticalSpeed(double speed);
|
|
|
|
|
void setVerticalSpeedTarget(double speed);
|
|
|
|
|
|
|
|
|
|
void setLed(QColor LED);
|
|
|
|
|
|
|
|
|
|
void setGPS(QString str);
|
|
|
|
|
void setMode(QString str);
|
|
|
|
|
void setState(QString str);
|
|
|
|
|
void setAOA(qreal Value);
|
2020-10-28 13:48:15 +08:00
|
|
|
void setOL(qreal Value);
|
2020-09-23 18:41:12 +08:00
|
|
|
void setXTrack(double value);
|
|
|
|
|
void setWP_dist(double value);
|
|
|
|
|
void setAlt_err(double value);
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
|
|
void mouseMoveEvent(QMouseEvent *e);
|
|
|
|
|
void mouseReleaseEvent(QMouseEvent *e);
|
|
|
|
|
void mousePressEvent(QMouseEvent *e);
|
|
|
|
|
void mouseDoubleClickEvent(QMouseEvent *e);
|
|
|
|
|
void wheelEvent(QWheelEvent *e);
|
|
|
|
|
//void resizeEvent(QResizeEvent *);
|
|
|
|
|
|
|
|
|
|
//void hideEvent(QHideEvent *);
|
|
|
|
|
//void showEvent(QShowEvent *);
|
|
|
|
|
|
|
|
|
|
void paintEvent(QPaintEvent *);
|
|
|
|
|
|
|
|
|
|
void drawLed(QPainter *painter);
|
|
|
|
|
|
|
|
|
|
void drawPitch(QPainter *painter);
|
|
|
|
|
void drawRoll(QPainter *painter);
|
|
|
|
|
void drawRollScale(QPainter *painter);
|
|
|
|
|
|
|
|
|
|
void drawVRate(QPainter *painter);
|
|
|
|
|
|
|
|
|
|
void drawYawScale(QPainter *painter);
|
|
|
|
|
void drawLeftScale(QPainter *painter);
|
|
|
|
|
void drawRightScale(QPainter *painter);
|
|
|
|
|
|
|
|
|
|
void drawTopStatuts(QPainter *painter);
|
|
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
|
|
|
|
|
|
void UpdateTimeout(void);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
bool isNormalSize = true;
|
|
|
|
|
|
|
|
|
|
QTimer *UpdateTimer = nullptr;
|
|
|
|
|
|
|
|
|
|
qreal Scale = 2100;//默认很大
|
|
|
|
|
qreal H_pos = 44.7059;
|
|
|
|
|
qreal V_pos = 43.8235;
|
|
|
|
|
|
|
|
|
|
QPoint lastPoint;
|
|
|
|
|
bool isPress = false;
|
|
|
|
|
|
2020-10-22 21:52:01 +08:00
|
|
|
//uint8_t speedSelect = 0;
|
|
|
|
|
|
|
|
|
|
|
2020-09-23 18:41:12 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif // ALTITUDEPANEL_H
|