307 lines
5.5 KiB
C++
307 lines
5.5 KiB
C++
#ifndef Cockpit_H
|
|
#define Cockpit_H
|
|
|
|
#include <QWidget>
|
|
#include <QMouseEvent>
|
|
#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 = 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;
|
|
|
|
qreal airspeed=0;
|
|
qreal airspeed_t=0;
|
|
qreal verticalspeed = 0;
|
|
qreal verticalspeed_t = 0;
|
|
|
|
qreal horizontalspeed = 0;
|
|
|
|
qreal AOA = 0;
|
|
|
|
|
|
|
|
qreal wp_dist = 0;
|
|
qreal alt_err = 0;
|
|
qreal xtrack = 0;
|
|
|
|
|
|
quint8 AirspeedFlag = 0;
|
|
|
|
bool isUpdate;
|
|
|
|
}_state;
|
|
|
|
typedef struct {
|
|
qreal voltage[10];
|
|
qreal current[10];
|
|
}_battery;
|
|
|
|
|
|
|
|
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;//纵向速度
|
|
|
|
bool isUpdate;
|
|
|
|
}_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);
|
|
|
|
|
|
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);
|
|
|
|
void setAirSpeed(qreal speed,uint8_t flag);
|
|
void setAirSpeedTarget(double speed,uint8_t flag);
|
|
|
|
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);
|
|
|
|
void setXTrack(double value);
|
|
void setWP_dist(double value);
|
|
void setAlt_err(double value);
|
|
|
|
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 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;
|
|
|
|
/*
|
|
QString m_mode;//显示模式
|
|
|
|
QString m_GPS;
|
|
QString m_MODE;
|
|
QString m_STATE;
|
|
|
|
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;
|
|
|
|
QColor m_CurrentColor;
|
|
QColor m_TargetColor;
|
|
QColor m_StatusColor;
|
|
|
|
QColor m_NormalColor;
|
|
QColor m_NoticeColor;
|
|
QColor m_WarningColor;
|
|
|
|
|
|
|
|
QColor m_WColor;
|
|
*/
|
|
|
|
|
|
QPoint m_c;
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif // ALTITUDEPANEL_H
|