2019-12-25 14:27:18 +08:00
|
|
|
#ifndef Cockpit_H
|
|
|
|
|
#define Cockpit_H
|
2019-12-25 10:53:19 +08:00
|
|
|
|
|
|
|
|
#include <QWidget>
|
|
|
|
|
#include <QMouseEvent>
|
2020-01-11 18:09:19 +08:00
|
|
|
#include "QTimer"
|
2020-07-31 15:36:22 +08:00
|
|
|
|
2020-02-20 17:13:31 +08:00
|
|
|
#ifdef QtCockpit
|
2020-02-26 00:19:59 +08:00
|
|
|
#include <cockpitglobal.h>
|
2020-02-20 17:13:31 +08:00
|
|
|
class COCKPITSHARED_EXPORT Cockpit: public QWidget {
|
|
|
|
|
#else
|
2019-12-25 14:27:18 +08:00
|
|
|
class Cockpit: public QWidget
|
2019-12-25 10:53:19 +08:00
|
|
|
{
|
2020-02-20 17:13:31 +08:00
|
|
|
#endif
|
|
|
|
|
|
2019-12-25 10:53:19 +08:00
|
|
|
Q_OBJECT
|
|
|
|
|
public:
|
|
|
|
|
enum ErrorCode {MaxValueError=1,MinValueError,ThresholdError,TargetError,PrecisionError,ColorError,UnitsEmpty,OutOfRange};
|
|
|
|
|
|
2020-02-26 00:19:59 +08:00
|
|
|
explicit Cockpit(QWidget *parent = nullptr);
|
2020-01-11 18:09:19 +08:00
|
|
|
~Cockpit();
|
2019-12-25 10:53:19 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
2020-02-26 00:19:59 +08:00
|
|
|
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;
|
2019-12-25 10:53:19 +08:00
|
|
|
|
|
|
|
|
typedef struct {
|
2020-06-03 18:09:41 +08:00
|
|
|
|
|
|
|
|
QString GPS;
|
|
|
|
|
QString MODE;
|
|
|
|
|
QString STATE;
|
|
|
|
|
|
|
|
|
|
|
2020-06-10 20:04:56 +08:00
|
|
|
qreal ax = 0;
|
|
|
|
|
qreal ay = 0;
|
|
|
|
|
qreal az = 0;
|
2019-12-25 10:53:19 +08:00
|
|
|
|
2020-06-10 20:04:56 +08:00
|
|
|
qreal gx = 0;
|
|
|
|
|
qreal gy = 0;
|
|
|
|
|
qreal gz = 0;
|
2019-12-25 10:53:19 +08:00
|
|
|
|
2020-06-10 20:04:56 +08:00
|
|
|
qreal roll = 0;
|
|
|
|
|
qreal pitch = 0;
|
|
|
|
|
qreal yaw = 0;
|
2019-12-25 10:53:19 +08:00
|
|
|
|
2020-06-10 20:04:56 +08:00
|
|
|
qreal altitude = 0;
|
|
|
|
|
qreal altitude_t = 0;
|
2019-12-25 10:53:19 +08:00
|
|
|
|
2020-01-02 19:25:12 +08:00
|
|
|
|
2020-06-10 20:04:56 +08:00
|
|
|
qreal height = 0;
|
2020-02-26 00:19:59 +08:00
|
|
|
|
2020-06-10 20:04:56 +08:00
|
|
|
qreal airspeed=0;
|
|
|
|
|
qreal airspeed_t=0;
|
|
|
|
|
qreal verticalspeed = 0;
|
|
|
|
|
qreal verticalspeed_t = 0;
|
2020-02-26 00:19:59 +08:00
|
|
|
|
2020-06-10 20:04:56 +08:00
|
|
|
qreal horizontalspeed = 0;
|
2020-02-26 00:19:59 +08:00
|
|
|
|
2020-06-10 20:04:56 +08:00
|
|
|
qreal AOA = 0;
|
2020-06-05 18:05:16 +08:00
|
|
|
|
|
|
|
|
|
2020-01-14 20:02:07 +08:00
|
|
|
|
2020-06-10 20:04:56 +08:00
|
|
|
qreal wp_dist = 0;
|
|
|
|
|
qreal alt_err = 0;
|
|
|
|
|
qreal xtrack = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
quint8 AirspeedFlag = 0;
|
2020-01-14 20:02:07 +08:00
|
|
|
|
2020-03-04 15:06:30 +08:00
|
|
|
bool isUpdate;
|
|
|
|
|
|
2020-02-26 00:19:59 +08:00
|
|
|
}_state;
|
2019-12-25 10:53:19 +08:00
|
|
|
|
|
|
|
|
typedef struct {
|
2020-02-26 00:19:59 +08:00
|
|
|
qreal voltage[10];
|
|
|
|
|
qreal current[10];
|
2019-12-25 10:53:19 +08:00
|
|
|
}_battery;
|
|
|
|
|
|
2020-01-03 16:59:44 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct{
|
2020-06-03 18:09:41 +08:00
|
|
|
|
2020-02-26 00:19:59 +08:00
|
|
|
qreal pitch;
|
|
|
|
|
qreal roll;
|
|
|
|
|
qreal yaw;
|
2020-01-03 16:59:44 +08:00
|
|
|
|
2020-02-26 00:19:59 +08:00
|
|
|
qreal height;
|
2020-01-09 20:57:54 +08:00
|
|
|
|
2020-02-26 00:19:59 +08:00
|
|
|
qreal airspeed_maximun;
|
|
|
|
|
qreal airspeed;
|
|
|
|
|
qreal airspeed_minimun;
|
2020-01-09 20:57:54 +08:00
|
|
|
|
2020-02-26 00:19:59 +08:00
|
|
|
qreal heading;//航线方向
|
|
|
|
|
qreal position;//侧偏距
|
|
|
|
|
qreal altitude;//海拔
|
2020-01-09 20:57:54 +08:00
|
|
|
|
2020-02-26 00:19:59 +08:00
|
|
|
qreal verticalspeed;//纵向速度
|
2020-01-09 20:57:54 +08:00
|
|
|
|
2020-06-03 18:09:41 +08:00
|
|
|
bool isUpdate;
|
|
|
|
|
|
2020-01-03 16:59:44 +08:00
|
|
|
}_target;
|
|
|
|
|
|
|
|
|
|
|
2020-01-04 17:49:28 +08:00
|
|
|
_target m_Target;
|
2020-02-26 00:19:59 +08:00
|
|
|
_state m_State;
|
|
|
|
|
_color m_Color;
|
2019-12-25 10:53:19 +08:00
|
|
|
|
|
|
|
|
Q_SIGNALS:
|
|
|
|
|
void errorSignal(int);
|
|
|
|
|
|
2020-07-01 18:22:49 +08:00
|
|
|
void showMessage(const QString &message,int TimeOut = 0);
|
|
|
|
|
|
2019-12-25 10:53:19 +08:00
|
|
|
public Q_SLOTS:
|
2020-06-04 18:20:13 +08:00
|
|
|
|
|
|
|
|
bool NormalSize()
|
|
|
|
|
{
|
|
|
|
|
return isNormalSize;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void setNormalSize(bool flag)
|
|
|
|
|
{
|
|
|
|
|
isNormalSize = flag;
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-31 15:36:22 +08:00
|
|
|
//void setUseOpenGL(const bool &value);
|
2020-06-04 18:20:13 +08:00
|
|
|
|
|
|
|
|
|
2020-02-26 00:19:59 +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);
|
|
|
|
|
|
2020-06-03 18:09:41 +08:00
|
|
|
void setPitchTarget(qreal Pitch);
|
|
|
|
|
void setRollTarget(qreal Roll);
|
|
|
|
|
void setYawTarget(qreal Yaw);
|
|
|
|
|
void setAttitudeTarget(qreal Pitch,qreal Roll,qreal Yaw);
|
|
|
|
|
|
2020-02-26 00:19:59 +08:00
|
|
|
void setAltitude(qreal Altitude);
|
2020-06-03 18:09:41 +08:00
|
|
|
void setAltitudeTarget(double Altitude);
|
|
|
|
|
|
2020-06-04 18:20:13 +08:00
|
|
|
void setAirSpeed(qreal speed,uint8_t flag);
|
|
|
|
|
void setAirSpeedTarget(double speed,uint8_t flag);
|
2019-12-25 10:53:19 +08:00
|
|
|
|
2020-06-03 18:09:41 +08:00
|
|
|
void setVerticalSpeed(double speed);
|
|
|
|
|
void setVerticalSpeedTarget(double speed);
|
2019-12-25 10:53:19 +08:00
|
|
|
|
2020-06-03 18:09:41 +08:00
|
|
|
void setLed(QColor LED);
|
2019-12-25 10:53:19 +08:00
|
|
|
|
2020-06-03 18:09:41 +08:00
|
|
|
void setGPS(QString str);
|
|
|
|
|
void setMode(QString str);
|
|
|
|
|
void setState(QString str);
|
|
|
|
|
void setAOA(qreal Value);
|
2020-06-05 18:05:16 +08:00
|
|
|
|
2020-06-10 20:04:56 +08:00
|
|
|
void setXTrack(double value);
|
2020-06-05 18:05:16 +08:00
|
|
|
void setWP_dist(double value);
|
|
|
|
|
void setAlt_err(double value);
|
|
|
|
|
|
2019-12-25 10:53:19 +08:00
|
|
|
protected:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void mouseReleaseEvent(QMouseEvent *e);
|
|
|
|
|
void mousePressEvent(QMouseEvent *e);
|
|
|
|
|
void mouseDoubleClickEvent(QMouseEvent *e);
|
|
|
|
|
void wheelEvent(QWheelEvent *e);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void paintEvent(QPaintEvent *);
|
|
|
|
|
|
|
|
|
|
void drawLed(QPainter *painter);
|
|
|
|
|
|
2020-01-02 19:25:12 +08:00
|
|
|
void drawPitch(QPainter *painter);
|
|
|
|
|
void drawRoll(QPainter *painter);
|
|
|
|
|
void drawRollScale(QPainter *painter);
|
|
|
|
|
|
2020-01-14 20:02:07 +08:00
|
|
|
void drawVRate(QPainter *painter);
|
|
|
|
|
|
2019-12-25 10:53:19 +08:00
|
|
|
void drawYawScale(QPainter *painter);
|
2020-01-03 16:59:44 +08:00
|
|
|
void drawLeftScale(QPainter *painter);
|
2020-01-03 18:32:37 +08:00
|
|
|
void drawRightScale(QPainter *painter);
|
2020-01-03 16:59:44 +08:00
|
|
|
|
2020-01-14 20:02:07 +08:00
|
|
|
void drawTopStatuts(QPainter *painter);
|
2019-12-25 10:53:19 +08:00
|
|
|
|
2020-01-11 18:09:19 +08:00
|
|
|
private slots:
|
|
|
|
|
|
|
|
|
|
void UpdateTimeout(void);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-12-25 10:53:19 +08:00
|
|
|
private:
|
2020-06-04 18:20:13 +08:00
|
|
|
bool isNormalSize = true;
|
2019-12-25 10:53:19 +08:00
|
|
|
|
2020-01-11 18:09:19 +08:00
|
|
|
QTimer *UpdateTimer = nullptr;
|
|
|
|
|
|
2020-06-04 18:20:13 +08:00
|
|
|
/*
|
2020-01-02 19:25:12 +08:00
|
|
|
QString m_mode;//显示模式
|
|
|
|
|
|
2020-06-03 18:09:41 +08:00
|
|
|
QString m_GPS;
|
|
|
|
|
QString m_MODE;
|
|
|
|
|
QString m_STATE;
|
2020-01-14 20:02:07 +08:00
|
|
|
|
2019-12-25 10:53:19 +08:00
|
|
|
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;
|
|
|
|
|
|
2020-02-26 00:19:59 +08:00
|
|
|
/*
|
2019-12-25 10:53:19 +08:00
|
|
|
QColor m_CentreLineColor;
|
|
|
|
|
QColor m_ForeColor;
|
|
|
|
|
QColor m_CornerColor;
|
|
|
|
|
|
|
|
|
|
QColor m_GroundColor;//大地颜色
|
|
|
|
|
QColor m_SkyColor;//天空颜色
|
|
|
|
|
|
|
|
|
|
QColor m_LedColor;
|
|
|
|
|
|
2020-01-02 19:25:12 +08:00
|
|
|
QColor m_CurrentColor;
|
|
|
|
|
QColor m_TargetColor;
|
2020-01-12 20:10:41 +08:00
|
|
|
QColor m_StatusColor;
|
2020-01-02 19:25:12 +08:00
|
|
|
|
2020-02-24 18:12:35 +08:00
|
|
|
QColor m_NormalColor;
|
|
|
|
|
QColor m_NoticeColor;
|
|
|
|
|
QColor m_WarningColor;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-01-02 19:25:12 +08:00
|
|
|
QColor m_WColor;
|
2020-02-26 00:19:59 +08:00
|
|
|
*/
|
|
|
|
|
|
2020-01-02 19:25:12 +08:00
|
|
|
|
2019-12-25 10:53:19 +08:00
|
|
|
QPoint m_c;
|
|
|
|
|
|
2020-01-03 18:32:37 +08:00
|
|
|
|
2019-12-25 10:53:19 +08:00
|
|
|
};
|
|
|
|
|
|
2020-01-03 18:32:37 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-12-25 10:53:19 +08:00
|
|
|
#endif // ALTITUDEPANEL_H
|