2284 lines
54 KiB
C++
2284 lines
54 KiB
C++
#include "Cockpit.h"
|
|
#include <QPainter>
|
|
#include <QtCore/qmath.h>
|
|
#include "QThread"
|
|
#include "QDebug"
|
|
#include "QPicture"
|
|
#include "QtMath"
|
|
|
|
|
|
Cockpit::Cockpit(QWidget *parent): QWidget(parent)
|
|
{
|
|
//载入配置参数
|
|
|
|
|
|
//颜色初始化
|
|
m_Color.NormalColor = QColor("#00FF00");
|
|
m_Color.NoticeColor = QColor("#FF8C00");
|
|
m_Color.WarningColor = QColor("#FF0000");
|
|
|
|
m_Color.GroundColor = QColor("#8B5A2B");
|
|
m_Color.SkyColor = QColor("#5CACEE");
|
|
|
|
m_Color.ForeColor = Qt::darkGray;
|
|
m_Color.CentreLineColor = QColor("#FFFFFF");
|
|
|
|
m_Color.LedColor = Qt::green;
|
|
|
|
m_Color.TargetColor = QColor("#FF00FF");
|
|
m_Color.CurrentColor = QColor("#FFFFFF");
|
|
m_Color.StatusColor = QColor("#00FF00");
|
|
|
|
m_Color.WColor = QColor("#000000");
|
|
|
|
//状态初始化
|
|
m_State.ax = 0;
|
|
m_State.ay = 0;
|
|
m_State.az = 0;
|
|
|
|
m_State.gx = 0;
|
|
m_State.gy = 0;
|
|
m_State.gz = 0;
|
|
|
|
m_State.roll = 0;
|
|
m_State.pitch = 0;
|
|
m_State.yaw = 0;
|
|
|
|
m_State.AOA = 0;
|
|
m_State.OL = 0;
|
|
|
|
m_State.altitude = 0;
|
|
m_State.height = 0;
|
|
|
|
m_State.speed = 0;
|
|
m_State.airspeed = 0;//空速
|
|
m_State.AirspeedFlag = 1;//c t g m
|
|
m_State.horizontalspeed = 0;//侧滑速度
|
|
m_State.verticalspeed = 0;//爬升速度
|
|
|
|
m_Target.verticalspeed = 0;
|
|
m_Target.yaw = 0;
|
|
|
|
m_Target.airspeed_maximun = 1.5 * 340;
|
|
m_Target.airspeed_minimun = 80;
|
|
|
|
m_State.GPS = "GPS";
|
|
m_State.MODE = "MODE";
|
|
m_State.STATE = "ARM";
|
|
|
|
//m_State.verticalspeed
|
|
|
|
//初始化完成后打开定时器开始计数刷新
|
|
UpdateTimer = new QTimer(this);
|
|
connect(UpdateTimer,SIGNAL(timeout()),
|
|
this,SLOT(UpdateTimeout()));
|
|
UpdateTimer->start(100);//10Hz
|
|
|
|
|
|
}
|
|
|
|
Cockpit::~Cockpit()
|
|
{
|
|
if(UpdateTimer)
|
|
{
|
|
UpdateTimer->stop();
|
|
delete UpdateTimer;
|
|
UpdateTimer = nullptr;
|
|
}
|
|
|
|
}
|
|
|
|
|
|
void Cockpit::UpdateTimeout(void)
|
|
{
|
|
//如果已经设置了新的数据,那么刷新
|
|
if(m_State.isUpdate == true)
|
|
{
|
|
m_State.airspeed = m_State.airspeed*0.75 + m_State.airspeed_t*0.25;
|
|
|
|
m_State.altitude = m_State.altitude*0.75 + m_State.altitude_t*0.25;
|
|
|
|
m_State.verticalspeed = m_State.verticalspeed*0.75 + m_State.verticalspeed_t*0.25;
|
|
|
|
update();
|
|
m_State.isUpdate = false;
|
|
}
|
|
|
|
}
|
|
|
|
void Cockpit::mouseMoveEvent(QMouseEvent *e)
|
|
{
|
|
const QPoint curPos = e->pos();
|
|
if (isPress)
|
|
{
|
|
QPoint offset = curPos - lastPoint;
|
|
lastPoint = curPos;
|
|
|
|
V_pos += 100.0 * offset.y()/height();
|
|
H_pos += 100.0 * offset.x()/width();
|
|
}
|
|
|
|
update();
|
|
}
|
|
|
|
void Cockpit::mouseReleaseEvent(QMouseEvent *e)
|
|
{
|
|
isPress = false;
|
|
setCursor(Qt::ArrowCursor);
|
|
}
|
|
|
|
void Cockpit::mousePressEvent(QMouseEvent *e)
|
|
{
|
|
qDebug() << "mouse pos" << e->pos();
|
|
|
|
if (e->button() == Qt::RightButton)
|
|
{
|
|
lastPoint = e->pos();
|
|
isPress = true;
|
|
setCursor(Qt::ClosedHandCursor);
|
|
}
|
|
else if(e->buttons() == Qt::MiddleButton)
|
|
{
|
|
Scale = 2100;//默认很大
|
|
H_pos = 44.7059;
|
|
V_pos = 43.8235;
|
|
}
|
|
|
|
QPoint minpos(29,252);
|
|
QPoint maxpos(99,281);
|
|
|
|
|
|
if(((e->pos().x() < maxpos.x())&&(e->pos().y() < maxpos.y()))&&
|
|
((e->pos().x() > minpos.x())&&(e->pos().y() > minpos.y())))
|
|
{
|
|
m_State.AirspeedFlag ++;
|
|
if(m_State.AirspeedFlag > 3)
|
|
{
|
|
m_State.AirspeedFlag = 0;
|
|
}
|
|
}
|
|
|
|
update();
|
|
}
|
|
|
|
void Cockpit::mouseDoubleClickEvent(QMouseEvent *e)
|
|
{
|
|
qDebug() << "cockpit double clicked" << e;
|
|
}
|
|
|
|
void Cockpit::wheelEvent(QWheelEvent *e)
|
|
{
|
|
switch(e->modifiers())
|
|
{
|
|
case Qt::ControlModifier://垂直移动
|
|
{
|
|
if(e->delta() > 0)
|
|
{
|
|
V_pos -= 1;
|
|
if(V_pos < 1)
|
|
{
|
|
V_pos = 1;
|
|
}
|
|
}
|
|
else if(e->delta() < 0)
|
|
{
|
|
V_pos += 1;
|
|
if(V_pos > 100)
|
|
{
|
|
V_pos = 100;
|
|
}
|
|
}
|
|
}break;
|
|
case Qt::ShiftModifier://水平移动
|
|
{
|
|
if(e->delta() > 0)
|
|
{
|
|
H_pos -= 1;
|
|
if(H_pos < 1)
|
|
{
|
|
H_pos = 1;
|
|
}
|
|
}
|
|
else if(e->delta() < 0)
|
|
{
|
|
H_pos += 1;
|
|
if(H_pos > 100)
|
|
{
|
|
H_pos = 100;
|
|
}
|
|
}
|
|
}break;
|
|
case Qt::AltModifier://水平移动
|
|
{
|
|
if(e->delta() > 0)
|
|
{
|
|
m_State.altitude -= 0.1;
|
|
}
|
|
else if(e->delta() < 0)
|
|
{
|
|
m_State.altitude += 0.1;
|
|
}
|
|
}break;
|
|
default://水平移动
|
|
{
|
|
/*
|
|
if(e->delta() > 0)
|
|
{
|
|
Scale -= 50;
|
|
if(Scale < 50)
|
|
{
|
|
Scale = 50;
|
|
}
|
|
}
|
|
else if(e->delta() < 0)
|
|
{
|
|
Scale += 50;
|
|
}
|
|
*/
|
|
|
|
//m_State.airspeed += e->delta() * 0.1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
//保存配置参数
|
|
|
|
update();
|
|
}
|
|
|
|
|
|
void Cockpit::setPitch(double Pitch)
|
|
{
|
|
#ifdef unix
|
|
|
|
#else
|
|
#ifdef __MINGW32__
|
|
|
|
#else
|
|
if(isnan(Pitch))
|
|
{
|
|
return;
|
|
}
|
|
#endif
|
|
#endif
|
|
|
|
//if(Pitch > 360) Pitch = 360;
|
|
//else if(Pitch < -360) Pitch = -360;
|
|
|
|
int n = Pitch/360;
|
|
Pitch = Pitch - n*360;
|
|
m_State.pitch = Pitch;
|
|
if(m_State.pitch < -90)
|
|
{
|
|
m_State.pitch += 180;
|
|
}
|
|
else if(m_State.pitch > 90)
|
|
{
|
|
m_State.pitch -= 180;
|
|
}
|
|
m_State.isUpdate = true;
|
|
}
|
|
|
|
void Cockpit::setPitchTarget(double Pitch)
|
|
{
|
|
#ifdef unix
|
|
|
|
#else
|
|
#ifdef __MINGW32__
|
|
|
|
#else
|
|
if(isnan(Pitch))
|
|
{
|
|
return;
|
|
}
|
|
#endif
|
|
#endif
|
|
|
|
//if(Pitch > 360) Pitch = 360;
|
|
//else if(Pitch < -360) Pitch = -360;
|
|
|
|
int n = Pitch/360;
|
|
Pitch = Pitch - n*360;
|
|
m_Target.pitch = Pitch;
|
|
if(m_Target.pitch < -90)
|
|
{
|
|
m_Target.pitch += 180;
|
|
}
|
|
else if(m_Target.pitch > 90)
|
|
{
|
|
m_Target.pitch -= 180;
|
|
}
|
|
m_Target.isUpdate = true;
|
|
}
|
|
|
|
|
|
void Cockpit::setRoll(double Roll)
|
|
{
|
|
#ifdef unix
|
|
|
|
#else
|
|
#ifdef __MINGW32__
|
|
|
|
#else
|
|
if(isnan(Roll))
|
|
{
|
|
return;
|
|
}
|
|
#endif
|
|
#endif
|
|
//if(Roll > 360) Roll = 360;
|
|
//else if(Roll < -360) Roll = -360;
|
|
|
|
int n = Roll/360;
|
|
Roll = Roll - n*360;
|
|
m_State.roll = Roll;
|
|
if(m_State.roll < -180)
|
|
{
|
|
m_State.roll += 360;
|
|
}
|
|
else if(m_State.roll > 180)
|
|
{
|
|
m_State.roll -= 360;
|
|
}
|
|
m_State.isUpdate = true;
|
|
}
|
|
|
|
void Cockpit::setRollTarget(double Roll)
|
|
{
|
|
#ifdef unix
|
|
|
|
#else
|
|
#ifdef __MINGW32__
|
|
|
|
#else
|
|
if(isnan(Roll))
|
|
{
|
|
return;
|
|
}
|
|
#endif
|
|
#endif
|
|
//if(Roll > 360) Roll = 360;
|
|
//else if(Roll < -360) Roll = -360;
|
|
|
|
int n = Roll/360;
|
|
Roll = Roll - n*360;
|
|
m_Target.roll = Roll;
|
|
if(m_Target.roll < -180)
|
|
{
|
|
m_Target.roll += 360;
|
|
}
|
|
else if(m_Target.roll > 180)
|
|
{
|
|
m_Target.roll -= 360;
|
|
}
|
|
m_Target.isUpdate = true;
|
|
}
|
|
|
|
|
|
void Cockpit::setYaw(double Yaw)
|
|
{
|
|
|
|
#ifdef unix
|
|
|
|
#else
|
|
#ifdef __MINGW32__
|
|
|
|
#else
|
|
if(isnan(Yaw))
|
|
{
|
|
return;
|
|
}
|
|
#endif
|
|
#endif
|
|
|
|
if(Yaw < 0) Yaw += 360;
|
|
else if(Yaw > 360) Yaw -= 360;
|
|
|
|
m_State.yaw = Yaw;
|
|
if(m_State.yaw < 0)
|
|
{
|
|
m_State.yaw += 360;
|
|
}
|
|
m_State.isUpdate = true;
|
|
}
|
|
|
|
void Cockpit::setYawTarget(double Yaw)
|
|
{
|
|
#ifdef unix
|
|
|
|
#else
|
|
#ifdef __MINGW32__
|
|
|
|
|
|
#else
|
|
if(isnan(Yaw))
|
|
{
|
|
return;
|
|
}
|
|
#endif
|
|
#endif
|
|
if(Yaw < 0) Yaw += 360;
|
|
else if(Yaw > 360) Yaw -= 360;
|
|
|
|
m_Target.yaw = Yaw;
|
|
if(m_Target.yaw < 0)
|
|
{
|
|
m_Target.yaw += 360;
|
|
}
|
|
m_Target.isUpdate = true;
|
|
}
|
|
|
|
|
|
|
|
void Cockpit::setAttitude(double Pitch,double Roll,double Yaw)
|
|
{
|
|
setPitch(Pitch);
|
|
setRoll(Roll);
|
|
setYaw(Yaw);
|
|
}
|
|
|
|
void Cockpit::setAttitudeTarget(double Pitch,double Roll,double Yaw)
|
|
{
|
|
setPitchTarget(Pitch);
|
|
setRollTarget(Roll);
|
|
setYawTarget(Yaw);
|
|
}
|
|
|
|
void Cockpit::setAttitudeSpeed(double PitchSpeed,double RollSpeed,double YawSpeed)
|
|
{
|
|
#ifdef unix
|
|
|
|
#else
|
|
#ifdef __MINGW32__
|
|
|
|
#else
|
|
if(isnan(PitchSpeed))
|
|
{
|
|
return;
|
|
}
|
|
|
|
if(isnan(RollSpeed))
|
|
{
|
|
return;
|
|
}
|
|
|
|
if(isnan(YawSpeed))
|
|
{
|
|
return;
|
|
}
|
|
#endif
|
|
#endif
|
|
|
|
m_State.gy = PitchSpeed;
|
|
m_State.gx = RollSpeed;
|
|
m_State.gz = YawSpeed;
|
|
m_State.isUpdate = true;
|
|
}
|
|
|
|
|
|
void Cockpit::setAltitude(double Altitude)
|
|
{
|
|
#ifdef unix
|
|
|
|
#else
|
|
#ifdef __MINGW32__
|
|
|
|
#else
|
|
if(isnan(Altitude))
|
|
{
|
|
return;
|
|
}
|
|
#endif
|
|
#endif
|
|
|
|
if(Altitude > 99999) Altitude = 99999;
|
|
else if(Altitude < (-9999)) Altitude = -9999;
|
|
|
|
m_State.altitude_t = Altitude;
|
|
m_State.isUpdate = true;
|
|
}
|
|
|
|
void Cockpit::setAltitudeTarget(double Altitude)
|
|
{
|
|
#ifdef unix
|
|
|
|
#else
|
|
#ifdef __MINGW32__
|
|
|
|
#else
|
|
if(isnan(Altitude))
|
|
{
|
|
return;
|
|
}
|
|
#endif
|
|
#endif
|
|
|
|
if(Altitude > 99999) Altitude = 99999;
|
|
else if(Altitude < (-9999)) Altitude = -9999;
|
|
|
|
m_Target.altitude = Altitude;
|
|
m_Target.isUpdate = true;
|
|
}
|
|
|
|
|
|
void Cockpit::setSpeed(double speed,uint8_t flag)
|
|
{
|
|
#ifdef unix
|
|
|
|
#else
|
|
#ifdef __MINGW32__
|
|
|
|
|
|
#else
|
|
if(isnan(speed))
|
|
{
|
|
return;
|
|
}
|
|
#endif
|
|
#endif
|
|
|
|
m_State.AirspeedFlag = flag;
|
|
|
|
m_State.speed = speed;
|
|
m_State.isUpdate = true;
|
|
}
|
|
|
|
void Cockpit::setAirSpeed(double speed,uint8_t flag)
|
|
{
|
|
#ifdef unix
|
|
|
|
#else
|
|
#ifdef __MINGW32__
|
|
|
|
|
|
#else
|
|
if(isnan(speed))
|
|
{
|
|
return;
|
|
}
|
|
#endif
|
|
#endif
|
|
|
|
if(speed < 0) speed = 0;
|
|
else if(speed > 9999) speed = 9999;
|
|
m_State.airspeed_t = speed;
|
|
m_State.isUpdate = true;
|
|
}
|
|
|
|
void Cockpit::setAirSpeedTarget(double speed, uint8_t flag)
|
|
{
|
|
Q_UNUSED(flag)
|
|
|
|
#ifdef unix
|
|
|
|
#else
|
|
#ifdef __MINGW32__
|
|
|
|
|
|
#else
|
|
if(isnan(speed))
|
|
{
|
|
return;
|
|
}
|
|
#endif
|
|
#endif
|
|
|
|
if(speed < 0) speed = 0;
|
|
else if(speed > 9999) speed = 999;
|
|
|
|
m_Target.airspeed = speed;
|
|
m_Target.isUpdate = true;
|
|
}
|
|
|
|
void Cockpit::setAirSpeedFlag(quint8 flag)
|
|
{
|
|
m_State.AirspeedFlag = flag;
|
|
}
|
|
|
|
|
|
void Cockpit::setVerticalSpeed(double speed)
|
|
{
|
|
#ifdef unix
|
|
|
|
#else
|
|
#ifdef __MINGW32__
|
|
|
|
#else
|
|
if(isnan(speed))
|
|
{
|
|
return;
|
|
}
|
|
#endif
|
|
#endif
|
|
|
|
m_State.verticalspeed_t = speed;
|
|
m_State.isUpdate = true;
|
|
}
|
|
|
|
void Cockpit::setVerticalSpeedTarget(double speed)
|
|
{
|
|
#ifdef unix
|
|
|
|
#else
|
|
#ifdef __MINGW32__
|
|
|
|
#else
|
|
if(isnan(speed))
|
|
{
|
|
return;
|
|
}
|
|
#endif
|
|
#endif
|
|
|
|
m_Target.verticalspeed = speed;
|
|
m_Target.isUpdate = true;
|
|
}
|
|
|
|
void Cockpit::setXTrack(double value)//飞机在航线右边为正
|
|
{
|
|
#ifdef unix
|
|
|
|
#else
|
|
#ifdef __MINGW32__
|
|
|
|
#else
|
|
if(isnan(value))
|
|
{
|
|
return;
|
|
}
|
|
#endif
|
|
#endif
|
|
|
|
if(value > 9999) value = 9999;
|
|
else if(value < (-9999)) value = -9999;
|
|
|
|
m_State.xtrack = -value;
|
|
m_State.isUpdate = true;
|
|
}
|
|
|
|
void Cockpit::setWP_dist(double value)
|
|
{
|
|
#ifdef unix
|
|
|
|
#else
|
|
#ifdef __MINGW32__
|
|
|
|
#else
|
|
if(isnan(value))
|
|
{
|
|
return;
|
|
}
|
|
#endif
|
|
#endif
|
|
|
|
if(value > 9999) value = 9999;
|
|
else if(value < (-9999)) value = -9999;
|
|
|
|
m_State.wp_dist = value;
|
|
m_State.isUpdate = true;
|
|
}
|
|
|
|
void Cockpit::setAlt_err(double value)//飞机在航线下面为正
|
|
{
|
|
#ifdef unix
|
|
|
|
#else
|
|
#ifdef __MINGW32__
|
|
|
|
#else
|
|
if(isnan(value))
|
|
{
|
|
return;
|
|
}
|
|
#endif
|
|
#endif
|
|
|
|
if(value > 9999) value = 9999;
|
|
else if(value < (-9999)) value = -9999;
|
|
|
|
m_State.alt_err = -value;
|
|
m_State.isUpdate = true;
|
|
}
|
|
|
|
|
|
void Cockpit::setGPS(QString str)
|
|
{
|
|
m_State.GPS = str;
|
|
m_Target.isUpdate = true;
|
|
}
|
|
|
|
void Cockpit::setMode(QString str)
|
|
{
|
|
m_State.MODE = str;
|
|
m_Target.isUpdate = true;
|
|
}
|
|
|
|
void Cockpit::setState(QString str)
|
|
{
|
|
m_State.STATE = str;
|
|
m_Target.isUpdate = true;
|
|
}
|
|
|
|
void Cockpit::setAOA(qreal Value)
|
|
{
|
|
#ifdef unix
|
|
|
|
#else
|
|
#ifdef __MINGW32__
|
|
|
|
#else
|
|
if(isnan(Value))
|
|
{
|
|
return;
|
|
}
|
|
#endif
|
|
#endif
|
|
|
|
m_State.AOA = Value;
|
|
m_Target.isUpdate = true;
|
|
}
|
|
|
|
void Cockpit::setOL(qreal Value)
|
|
{
|
|
#ifdef unix
|
|
|
|
#else
|
|
#ifdef __MINGW32__
|
|
|
|
#else
|
|
if(isnan(Value))
|
|
{
|
|
return;
|
|
}
|
|
#endif
|
|
#endif
|
|
|
|
m_State.OL = Value;
|
|
m_Target.isUpdate = true;
|
|
}
|
|
|
|
|
|
void Cockpit::setLed(QColor LED)
|
|
{
|
|
m_Color.LedColor = LED;
|
|
m_Target.isUpdate = true;
|
|
}
|
|
|
|
|
|
void Cockpit::paintEvent(QPaintEvent *)
|
|
{
|
|
QPainter painter(this);
|
|
painter.setRenderHint(QPainter::Antialiasing); /* 使用反锯齿(如果可用) */
|
|
painter.setRenderHint(QPainter::TextAntialiasing);
|
|
painter.setRenderHint(QPainter::SmoothPixmapTransform);
|
|
|
|
painter.translate(width() * H_pos / 100,height() * V_pos / 100); /* 坐标变换为窗体中心 */
|
|
int side = qMin(width(), height()); /* 这一句决定了这个模块只能是方形 */
|
|
painter.scale(side / Scale, side / Scale); /* 比例缩放 */
|
|
painter.setPen(Qt::NoPen);
|
|
|
|
//全局设置字体
|
|
QFont font;
|
|
font.setWeight(QFont::ExtraLight);
|
|
font.setFamily("Arial");//非衬线
|
|
painter.setFont(font);
|
|
|
|
setPalette(QPalette(Qt::black)); //设置背景颜色
|
|
setAutoFillBackground(true);//设置自动填充背景色
|
|
|
|
if(isNormalSize)
|
|
{
|
|
drawPitch(&painter);
|
|
drawRoll(&painter);
|
|
drawRollScale(&painter);
|
|
drawLeftScale(&painter);
|
|
drawRightScale(&painter);
|
|
drawVRate(&painter);
|
|
drawYawScale(&painter);
|
|
drawTopStatuts(&painter);
|
|
}
|
|
else//简单显示
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Cockpit::drawLed(QPainter *painter)
|
|
{
|
|
painter->save();
|
|
painter->setRenderHint(QPainter::Antialiasing);
|
|
painter->setBrush(m_Color.LedColor);
|
|
painter->drawRoundedRect(-970, -970, 100, 100,50,50);
|
|
painter->restore();
|
|
}
|
|
|
|
//使用translate对一幅大图进行平移/旋转变换
|
|
//画姿态pitch
|
|
void Cockpit::drawPitch(QPainter *painter)
|
|
{
|
|
//画俯仰
|
|
QRectF bluerect(-4000,-4000,8000,4000);
|
|
QRectF yellowrect(-4000,0,8000,4000);
|
|
QRectF whiterect(-4000,-5,8000,10);
|
|
|
|
painter->save();
|
|
painter->translate(0,m_State.pitch/45.0 * 1000);
|
|
|
|
painter->setBrush(m_Color.SkyColor);
|
|
painter->drawRect(bluerect);
|
|
painter->setBrush(m_Color.GroundColor);
|
|
painter->drawRect(yellowrect);
|
|
painter->setBrush(QColor("#FFFFFF"));
|
|
painter->drawRect(whiterect);
|
|
|
|
//俯仰刻度表
|
|
qreal h = 1000.0/45.0;//单位高度
|
|
for(int i = -17 - m_State.pitch;i<=(17 - m_State.pitch);i+=1)
|
|
{
|
|
|
|
QString strText = QString::number(qAbs(i)); //设置当前字体
|
|
painter->save();
|
|
|
|
QPen ePen;
|
|
QFont font;
|
|
|
|
ePen.setColor(m_Color.CentreLineColor);
|
|
ePen.setWidth(8);
|
|
font.setPointSize(50);
|
|
font.setFamily("Arial");//非衬线
|
|
|
|
painter->setPen(ePen);
|
|
painter->setFont(font);
|
|
|
|
if((i%10) == 0)
|
|
{
|
|
if( i != 0)//0处不显示
|
|
{
|
|
painter->drawLine(-150,i * h,150,i * h);
|
|
painter->drawText(QRect(-270,i * h - 40,2 * font.pointSize(),80),Qt::AlignVCenter | Qt::AlignRight, strText);//减去字体的一半
|
|
painter->drawText(QRect( 160,i * h - 40,2 * font.pointSize(),80),Qt::AlignVCenter | Qt::AlignLeft, strText);
|
|
}
|
|
}
|
|
else if((i%5) == 0)
|
|
{
|
|
painter->drawLine(-70,i * h,70,i * h);
|
|
}
|
|
painter->restore();
|
|
}
|
|
painter->restore();
|
|
|
|
painter->save();
|
|
|
|
//中间 两块黑块
|
|
static const QPointF points1[6] = {
|
|
QPointF(-475, 0),
|
|
QPointF(-275, 0),
|
|
QPointF(-275, 50),
|
|
QPointF(-300, 50),
|
|
QPointF(-300, 25),
|
|
QPointF(-475, 25)
|
|
};
|
|
static const QPointF points2[6] = {
|
|
QPointF(475, 0),
|
|
QPointF(275, 0),
|
|
QPointF(275, 50),
|
|
QPointF(300, 50),
|
|
QPointF(300, 25),
|
|
QPointF(475, 25)
|
|
};
|
|
|
|
QPen pen;
|
|
pen.setWidth(10);
|
|
pen.setColor(m_Color.CurrentColor);
|
|
painter->setPen(pen);
|
|
painter->setBrush(QColor("#000000"));
|
|
painter->drawPolygon(points1, 6);
|
|
painter->drawPolygon(points2, 6);
|
|
|
|
painter->restore();
|
|
|
|
|
|
//画目标值
|
|
painter->save();
|
|
|
|
qreal tar_y = (m_State.pitch - m_Target.pitch)/45.0 * 1000;
|
|
|
|
//qDebug() << "tar_y" << tar_y;
|
|
|
|
tar_y = (tar_y > 475)?(475):((tar_y<-475)?(-475):(tar_y));
|
|
|
|
painter->translate(0,tar_y);
|
|
|
|
pen.setWidth(10);
|
|
pen.setColor(m_Color.TargetColor);
|
|
painter->setPen(pen);
|
|
painter->drawLine(-200,0,200,0);
|
|
painter->restore();
|
|
|
|
//画黑色背景
|
|
painter->save();
|
|
QPainterPath path;
|
|
//画外面边框
|
|
path.moveTo(-4100,-4100);
|
|
path.lineTo( 4100,-4100);
|
|
path.lineTo( 4100, 4100);
|
|
path.lineTo(-4100, 4100);
|
|
//画里面边框
|
|
path.addRoundRect(-500,-500,1000,1000,20,20);
|
|
//按照规则填充两个边框之间的部分
|
|
path.setFillRule(Qt::OddEvenFill);
|
|
|
|
pen.setColor(Qt::black);
|
|
painter->setPen(pen);
|
|
painter->fillPath(path,Qt::black);
|
|
painter->restore();
|
|
}
|
|
|
|
//画姿态roll
|
|
void Cockpit::drawRoll(QPainter *painter)
|
|
{
|
|
//画俯仰和滚转
|
|
painter->save();
|
|
painter->rotate(m_State.roll);
|
|
//画绿色W和顶部滚转
|
|
static const QPointF W_Line[7] = {
|
|
QPointF(-150, 0),
|
|
QPointF(-100, 0),
|
|
QPointF(-50, 100),
|
|
QPointF( 0,0),
|
|
QPointF( 50, 100),
|
|
QPointF( 100, 0),
|
|
QPointF( 150, 0)
|
|
};
|
|
|
|
QPen pen;
|
|
|
|
pen.setCapStyle(Qt::RoundCap);
|
|
pen.setWidth(30);
|
|
pen.setColor(m_Color.CentreLineColor);
|
|
painter->setPen(pen);
|
|
painter->drawPolyline(W_Line,7);
|
|
|
|
|
|
pen.setWidth(10);
|
|
pen.setColor(m_Color.WColor);
|
|
|
|
|
|
painter->setPen(pen);
|
|
painter->drawPolyline(W_Line,7);
|
|
|
|
//画白色小三角形
|
|
static const QPointF points2[3] = {
|
|
QPointF(-30,-500),
|
|
QPointF(0,-450),
|
|
QPointF(30,-500)
|
|
};
|
|
|
|
pen.setWidth(1);
|
|
pen.setColor(m_Color.CurrentColor);
|
|
painter->setPen(pen);
|
|
painter->setBrush(m_Color.CurrentColor);
|
|
painter->drawPolygon(points2,3);
|
|
|
|
|
|
painter->restore();
|
|
|
|
|
|
//画俯仰和滚转
|
|
painter->save();
|
|
painter->rotate(m_Target.roll);
|
|
//画紫色小三角形
|
|
static const QPointF points1[3] = {
|
|
QPointF(-30,-410),
|
|
QPointF(0,-450),
|
|
QPointF(30,-410)
|
|
};
|
|
|
|
pen.setWidth(1);
|
|
pen.setColor(m_Color.TargetColor);
|
|
painter->setPen(pen);
|
|
painter->setBrush(m_Color.TargetColor);
|
|
painter->drawPolygon(points1,3);
|
|
|
|
painter->restore();
|
|
}
|
|
|
|
void Cockpit::drawRollScale(QPainter *painter)
|
|
{
|
|
painter->save();
|
|
|
|
QPen ePen;
|
|
ePen.setColor(m_Color.CentreLineColor);
|
|
ePen.setWidth(10);
|
|
QFont font;
|
|
font.setPointSize(60);
|
|
|
|
painter->setPen(ePen);
|
|
painter->setFont(font);
|
|
painter->drawArc(-450,-450,900,900,30*16,120*16);
|
|
|
|
|
|
//大刻度盘
|
|
for(int i = -60;i<=60;i+=10)
|
|
{
|
|
//QString strText = QString::number(i); //设置当前字体
|
|
painter->save();
|
|
painter->translate(0,0);
|
|
painter->rotate(-i);
|
|
if((i%20) == 0)
|
|
painter->drawLine(0,-450,0,-490);
|
|
else
|
|
painter->drawLine(0,-450,0,-470);
|
|
//painter->drawText(-30,-750, strText);
|
|
painter->restore();
|
|
}
|
|
painter->restore();
|
|
|
|
}
|
|
|
|
|
|
void Cockpit::drawLeftScale(QPainter *painter)
|
|
{
|
|
|
|
painter->save();
|
|
|
|
//平移坐标
|
|
painter->translate(-900,0);
|
|
QPen ePen;
|
|
QFont font;
|
|
|
|
|
|
//画一个半透明的小方块
|
|
painter->save();
|
|
painter->setOpacity(0.3);
|
|
ePen.setColor(QColor("#7A7A7A"));
|
|
painter->setBrush(QColor("#7A7A7A"));
|
|
painter->drawRect(0,-600,300,1200);
|
|
painter->restore();
|
|
|
|
|
|
|
|
|
|
//画旁边的速度刻度,并显示
|
|
painter->save();
|
|
|
|
painter->translate(0,1200.0/40.0 * m_State.airspeed);
|
|
|
|
float h = 1200.0f/40.0f;//单位高度
|
|
|
|
for(int i = -21 - m_State.airspeed;i<=(21 - m_State.airspeed);i+=1)
|
|
{
|
|
|
|
QString strText = QString::number(-i); //设置当前字体
|
|
painter->save();
|
|
|
|
QPen ePen;
|
|
QFont font;
|
|
ePen.setColor(m_Color.CentreLineColor);
|
|
ePen.setWidth(8);
|
|
font.setPointSize(70);
|
|
font.setWeight(QFont::Bold);
|
|
font.setFamily("Arial");//非衬线
|
|
painter->setPen(ePen);
|
|
painter->setFont(font);
|
|
|
|
|
|
if(i < 0)//小于0的刻度不显示
|
|
{
|
|
if((i%10) == 0)
|
|
{
|
|
painter->drawLine( 220,i * h,290,i * h);
|
|
painter->drawText(QRect(0,i * h - 30,190,80),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("#228B22"));//画绿色
|
|
float y_green = -600;//-1200.0/40.0 * (m_Target.airspeed_maximun- m_State.airspeed);
|
|
float l_green = 1200;//1200.0/40.0 * (m_Target.airspeed_maximun - m_Target.airspeed_minimun);
|
|
|
|
painter->drawRect(275,-600,25,1200);
|
|
|
|
/*
|
|
if((y_green + l_green) > 600)
|
|
{
|
|
l_green = 600 - y_green;
|
|
}
|
|
|
|
if(y_green < 600)
|
|
painter->drawRect(275,(y_green < -600)?(-600):(y_green),25,l_green);
|
|
*/
|
|
|
|
|
|
painter->setBrush(QColor("#FF8C00"));//画橙色
|
|
//painter->drawRect(275,-600,25,1200);
|
|
qreal l_or = 600 - 1200.0/40.0 * (m_Target.airspeed_maximun- m_State.airspeed);
|
|
|
|
|
|
if(l_or > 1200)
|
|
{
|
|
l_or = 1200;
|
|
}
|
|
else if(l_or < 0)
|
|
{
|
|
l_or = 0;
|
|
}
|
|
painter->drawRect(275,-600,25,l_or);
|
|
|
|
|
|
|
|
|
|
|
|
painter->setBrush(QColor("#FF0000"));//画红色
|
|
qreal y_red = -1200.0/40.0 * (m_Target.airspeed_minimun- m_State.airspeed);
|
|
qreal l_red = 600 + 1200.0/40.0 * (m_Target.airspeed_minimun- m_State.airspeed);
|
|
if(y_red < 600)
|
|
{
|
|
if(y_red < -600)
|
|
{
|
|
y_red = -600;
|
|
l_red = 1200;
|
|
}
|
|
painter->drawRect(275,y_red,25,l_red);
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
painter->restore();
|
|
|
|
//画 中间黑色的显示块
|
|
painter->save();
|
|
static const QPointF points1[7] = {
|
|
QPointF( 0,-120),
|
|
QPointF(225,-120),
|
|
QPointF(225, -30),
|
|
QPointF(255, 0),
|
|
QPointF(225, 30),
|
|
QPointF(225, 120),
|
|
QPointF( 0, 120)
|
|
};
|
|
|
|
ePen.setColor(QColor("#FFFFFF"));
|
|
ePen.setWidth(8);
|
|
painter->setPen(ePen);
|
|
painter->setBrush(QColor("#000000"));
|
|
painter->drawPolygon(points1, 7);
|
|
|
|
|
|
|
|
ePen.setColor(m_Color.CentreLineColor);
|
|
ePen.setWidth(15);
|
|
|
|
font.setPixelSize(120);
|
|
font.setWeight(QFont::Bold);
|
|
font.setFamily("Arial");//非衬线
|
|
|
|
painter->setPen(ePen);
|
|
painter->setFont(font);
|
|
|
|
|
|
|
|
qreal Unit = m_State.airspeed - int(m_State.airspeed)/10 * 10;
|
|
qreal Decimal = m_State.airspeed - int(m_State.airspeed);
|
|
|
|
|
|
QString DacadeText; //设置十位以上
|
|
|
|
if(Unit > 9.5)
|
|
{
|
|
DacadeText = QString::number(qAbs(int((m_State.airspeed + 1)/10)));
|
|
}
|
|
else
|
|
{
|
|
DacadeText = QString::number(qAbs(int(m_State.airspeed/10)));
|
|
}
|
|
|
|
//显示10位
|
|
if((m_State.airspeed < 0)&&(m_State.airspeed > -10))
|
|
{
|
|
painter->drawText(QRect(0,-50,150,100),Qt::AlignVCenter|Qt::AlignRight, "-" + DacadeText);
|
|
}
|
|
else
|
|
{
|
|
painter->drawText(QRect(0,-50,150,100),Qt::AlignVCenter|Qt::AlignRight,((m_State.airspeed < 0)?("-"):(" ")) + DacadeText);
|
|
//qDebug() << DacadeText;
|
|
}
|
|
|
|
//qDebug() << Unit << Decimal;
|
|
//显示个位
|
|
int count = 1;
|
|
for(int i = -1.5 - Unit;i<(1.5 - Unit);i+=1)
|
|
{
|
|
|
|
QString strText = QString::number(((-i < 0)?(i):((-i>=10)?(-i-10):(-i)))); //设置当前字体
|
|
|
|
//qDebug() << "strText" << strText << i;
|
|
|
|
//qDebug() << "Decimal" << Decimal;
|
|
|
|
painter->save();
|
|
|
|
ePen.setColor(m_Color.CentreLineColor);
|
|
ePen.setWidth(15);
|
|
font.setPixelSize(120);
|
|
font.setFamily("Arial");//非衬线
|
|
|
|
painter->setPen(ePen);
|
|
painter->setFont(font);
|
|
|
|
if(Unit >= 0)
|
|
painter->translate(150,(i + Unit) * 120 - 60);
|
|
else
|
|
painter->translate(150,(i + Unit) * 120 + 60);
|
|
|
|
|
|
//此段程序在未理解之前,请不要随意修改(负数未解决)
|
|
switch (count) {
|
|
case 1:
|
|
if((Decimal >= (-0.55))&&(Decimal <= 0.5))
|
|
{
|
|
//qDebug() << "strText" << strText;
|
|
if(Decimal >= 0)
|
|
{
|
|
if((60 - 120 * qAbs(Decimal)) != 0)
|
|
painter->drawText(QRect(0,60 - 120 * qAbs(Decimal) ,80,60 + 120 * qAbs(Decimal) ),Qt::AlignBottom|Qt::AlignLeft, strText);
|
|
}
|
|
else
|
|
{
|
|
//if((60 + 120 * Decimal) != 0)
|
|
painter->drawText(QRect(0,60 - 120 * Decimal ,80,120 * qAbs(0.5 + Decimal) ),Qt::AlignBottom|Qt::AlignLeft, strText);
|
|
//qDebug() << "strText" << strText;
|
|
}
|
|
}
|
|
else if(Decimal > 0.5)
|
|
{
|
|
painter->drawText(QRect(0,120 - 120 * (Decimal - 0.5) ,80,120 * (Decimal - 0.5)),Qt::AlignBottom|Qt::AlignLeft, strText);
|
|
}
|
|
else if(Decimal <= -0.5)
|
|
{
|
|
painter->drawText(QRect(0,0 + 120 * (qAbs(Decimal) - 0.5) ,80,120 - 120 * (qAbs(Decimal) - 0.5)),Qt::AlignBottom|Qt::AlignLeft, strText);
|
|
//qDebug() << "3";
|
|
}
|
|
break;
|
|
case 2:
|
|
painter->drawText(QRect(0,0,80,120),Qt::AlignVCenter|Qt::AlignLeft, strText);
|
|
break;
|
|
case 3:
|
|
if((Decimal >= -0.5)&&(Decimal <= 0.5))
|
|
{
|
|
if((60 - 120 * qAbs(Decimal)) != 0)
|
|
painter->drawText(QRect(0,0,80,60 - 120 * Decimal),Qt::AlignTop|Qt::AlignLeft, strText);
|
|
else
|
|
painter->drawText(QRect(0,0,80,120),Qt::AlignVCenter|Qt::AlignLeft, strText);
|
|
}
|
|
else if(Decimal > 0.5)
|
|
{
|
|
painter->drawText(QRect(0,0,80,120 - 120 * (Decimal - 0.5)),Qt::AlignTop|Qt::AlignLeft, strText);
|
|
}
|
|
else if(Decimal < -0.5)
|
|
{
|
|
painter->drawText(QRect(0,120 - 120 * (Decimal + 0.5) ,80,120 * (Decimal - 0.5)),Qt::AlignBottom|Qt::AlignLeft, strText);
|
|
}
|
|
break;
|
|
}
|
|
|
|
count++;
|
|
painter->restore();
|
|
}
|
|
|
|
painter->restore();
|
|
|
|
|
|
|
|
//画速度目标值(紫色小箭头)
|
|
painter->save();
|
|
|
|
ePen.setColor(m_Color.TargetColor);
|
|
ePen.setWidth(8);
|
|
painter->setPen(ePen);
|
|
|
|
qreal t_y = -1200.0/40.0 * (m_Target.airspeed- m_State.airspeed);
|
|
|
|
t_y = (t_y < -600)?(-600):((t_y>600)?(600):(t_y));//限幅
|
|
|
|
painter->translate(260,t_y);//设置原点
|
|
|
|
if((t_y >= -600)&&(t_y <= 600))
|
|
{
|
|
static const QPointF ASTargetpoints2[5] = {
|
|
QPointF(0, 0),
|
|
QPointF(40, -30),
|
|
QPointF(120, -30),
|
|
QPointF(120, 30),
|
|
QPointF(40, 30)
|
|
};
|
|
painter->drawPolygon(ASTargetpoints2, 5);
|
|
}
|
|
painter->restore();
|
|
|
|
//给紫色的目标边框打补丁
|
|
painter->save();
|
|
painter->setBrush(Qt::black);
|
|
painter->drawRect(0,-750,450,150);
|
|
|
|
painter->setBrush(Qt::black);
|
|
painter->drawRect(250, 600,150,150);
|
|
|
|
painter->restore();
|
|
|
|
//画最底下的黑色单位显示框
|
|
painter->save();
|
|
ePen.setColor(QColor("#FFFFFF"));
|
|
ePen.setWidth(8);
|
|
|
|
font.setPixelSize(120);
|
|
font.setWeight(QFont::Bold);
|
|
|
|
painter->setPen(ePen);
|
|
painter->setFont(font);
|
|
painter->setBrush(QColor("#000000"));
|
|
painter->drawRect(0,600,300,150);
|
|
|
|
|
|
QString AS_flag = "I";
|
|
|
|
switch (m_State.AirspeedFlag) {
|
|
default:
|
|
case 0:
|
|
painter->drawText(QRect(20,600,280,150),Qt::AlignLeft|Qt::AlignVCenter,QString::number(m_State.speed,'f',0));
|
|
AS_flag = "C";//表速
|
|
ePen.setColor(m_Color.NormalColor);
|
|
break;
|
|
case 1:
|
|
painter->drawText(QRect(20,600,280,150),Qt::AlignLeft|Qt::AlignVCenter,QString::number(m_State.speed,'f',0));
|
|
AS_flag = "T";//真空速
|
|
ePen.setColor(m_Color.NormalColor);
|
|
break;
|
|
case 2:
|
|
painter->drawText(QRect(20,600,280,150),Qt::AlignLeft|Qt::AlignVCenter,QString::number(m_State.speed,'f',0));
|
|
AS_flag = "G";//地速
|
|
ePen.setColor(m_Color.WarningColor);
|
|
break;
|
|
case 3:
|
|
painter->drawText(QRect(20,600,280,150),Qt::AlignLeft|Qt::AlignVCenter,QString::number(m_State.speed,'f',2));
|
|
AS_flag = "M";//马赫
|
|
ePen.setColor(m_Color.NoticeColor);
|
|
break;
|
|
}
|
|
|
|
ePen.setWidth(15);
|
|
font.setPixelSize(100);
|
|
font.setWeight(QFont::Bold);
|
|
|
|
painter->setPen(ePen);
|
|
painter->setFont(font);
|
|
|
|
painter->drawText(QRect(320,620,90,100),Qt::AlignHCenter|Qt::AlignVCenter,AS_flag);
|
|
|
|
painter->restore();
|
|
|
|
//画顶部的目标值
|
|
painter->save();
|
|
|
|
ePen.setColor(m_Color.TargetColor);
|
|
ePen.setWidth(15);
|
|
font.setPixelSize(120);
|
|
font.setFamily("Arial");//非衬线
|
|
font.setWeight(QFont::Bold);
|
|
|
|
|
|
painter->setPen(ePen);
|
|
painter->setFont(font);
|
|
|
|
painter->drawText(QRect(0,-720,300,120),Qt::AlignRight|Qt::AlignVCenter,QString::number(m_Target.airspeed,'f',0));
|
|
|
|
painter->restore();//画顶部目标值结束
|
|
|
|
|
|
//画顶部的过载值和迎角
|
|
painter->save();
|
|
|
|
ePen.setColor(m_Color.CurrentColor);
|
|
ePen.setWidth(10);
|
|
font.setPixelSize(80);
|
|
font.setFamily("Arial");//非衬线
|
|
|
|
painter->setPen(ePen);
|
|
painter->setFont(font);
|
|
|
|
painter->drawText(QRect(0,-820,300,120),Qt::AlignLeft|Qt::AlignVCenter,"OL " +QString::number(m_State.OL,'f',1));
|
|
painter->drawText(QRect(0,-920,300,120),Qt::AlignLeft|Qt::AlignVCenter,"AOA " +QString::number(m_State.AOA,'f',1));
|
|
|
|
painter->restore();//画顶部过载值和迎角结束
|
|
|
|
|
|
painter->restore();//全部结束
|
|
|
|
}
|
|
|
|
|
|
void Cockpit::drawRightScale(QPainter *painter)
|
|
{
|
|
|
|
painter->save();
|
|
|
|
//平移坐标
|
|
painter->translate(600,0);
|
|
|
|
QPen ePen;
|
|
QFont font;
|
|
//画一个半透明的小方块
|
|
painter->save();
|
|
painter->setOpacity(0.3);
|
|
ePen.setColor(QColor("#7A7A7A"));
|
|
painter->setBrush(QColor("#7A7A7A"));
|
|
painter->drawRect(0,-600,300,1200);
|
|
painter->restore();
|
|
|
|
//画旁边的高度刻度,并显示
|
|
painter->save();
|
|
|
|
painter->translate(0,1200.0/400.0 * m_State.altitude);
|
|
|
|
qreal h = 1200.0/400.0;//单位高度
|
|
for(int i = -210 - m_State.altitude;i<=(210 - m_State.altitude);i+=1)
|
|
{
|
|
|
|
QString strText = QString::number(-i); //设置当前字体
|
|
painter->save();
|
|
|
|
QPen ePen;
|
|
QFont font;
|
|
ePen.setColor(m_Color.CentreLineColor);
|
|
ePen.setWidth(10);
|
|
font.setPixelSize(90);
|
|
|
|
font.setWeight(QFont::Bold);
|
|
font.setFamily("Arial");//非衬线
|
|
|
|
painter->setPen(ePen);
|
|
painter->setFont(font);
|
|
|
|
if((i%100) == 0)
|
|
{
|
|
painter->drawLine(0,i * h,40,i * h);
|
|
painter->drawText(QRect(50,i * h - 75,240,150),Qt::AlignVCenter|Qt::AlignRight, strText);
|
|
}
|
|
else if((i%50) == 0)
|
|
{
|
|
painter->drawLine(0,i * h,20,i * h);
|
|
}
|
|
painter->restore();
|
|
}
|
|
painter->restore();
|
|
|
|
|
|
//画紫色框
|
|
painter->save();
|
|
|
|
static const QPointF t_h[7] = {
|
|
QPointF( 20, 0),
|
|
QPointF( -20,-30),
|
|
QPointF( -20,-125),
|
|
QPointF(100,-125),
|
|
|
|
QPointF(100, 125),
|
|
QPointF( -20, 125),
|
|
QPointF( -20, 30)
|
|
};
|
|
|
|
|
|
qreal h_y = -1200.0/400.0 * (m_Target.altitude- m_State.altitude);
|
|
|
|
h_y = (h_y < -600)?(-600):((h_y>600)?(600):(h_y));//限幅
|
|
|
|
painter->translate(0,h_y);
|
|
|
|
ePen.setColor(m_Color.TargetColor);
|
|
ePen.setWidth(8);
|
|
painter->setPen(ePen);
|
|
painter->drawPolygon(t_h, 7);
|
|
|
|
painter->restore();
|
|
|
|
//给紫色的目标边框打补丁
|
|
painter->save();
|
|
painter->setBrush(Qt::black);
|
|
painter->drawRect(-30,-750,350,150);
|
|
|
|
painter->setBrush(Qt::black);
|
|
painter->drawRect(-30, 600,350,150);
|
|
|
|
painter->restore();
|
|
|
|
//画顶部目标值
|
|
painter->save();
|
|
ePen.setColor(m_Color.TargetColor);
|
|
ePen.setWidth(15);
|
|
|
|
font.setPixelSize(120);
|
|
font.setWeight(QFont::Bold);
|
|
font.setFamily("Arial");//非衬线
|
|
|
|
painter->setPen(ePen);
|
|
painter->setFont(font);
|
|
|
|
painter->drawText(QRect(0,-720,500,120),Qt::AlignLeft|Qt::AlignVCenter,QString::number(m_Target.altitude,'f',0));
|
|
|
|
painter->restore();
|
|
|
|
|
|
//画最底下的黑色单位显示框
|
|
painter->save();
|
|
ePen.setColor(QColor("#FFFFFF"));
|
|
ePen.setWidth(8);
|
|
|
|
|
|
font.setPixelSize(120);
|
|
|
|
font.setWeight(QFont::Bold);
|
|
font.setFamily("Arial");//非衬线
|
|
|
|
painter->setPen(ePen);
|
|
painter->setFont(font);
|
|
painter->setBrush(QColor("#000000"));
|
|
painter->drawRect(0,600,550,150);
|
|
|
|
painter->drawText(QRect(10,600,530,150),Qt::AlignLeft|Qt::AlignVCenter,QString::number(m_State.altitude,'f',0));
|
|
|
|
painter->restore();
|
|
|
|
|
|
|
|
//画黑色显示框
|
|
static const QPointF points1[7] = {
|
|
QPointF( 40, 0),
|
|
QPointF( 70,-30),
|
|
QPointF( 70,-125),
|
|
QPointF(420,-125),
|
|
|
|
QPointF(420, 125),
|
|
QPointF( 70, 125),
|
|
QPointF( 70, 30)
|
|
};
|
|
|
|
|
|
ePen.setColor(m_Color.CentreLineColor);
|
|
ePen.setWidth(8);
|
|
painter->setPen(ePen);
|
|
|
|
painter->setBrush(QColor("#000000"));
|
|
painter->drawPolygon(points1, 7);
|
|
|
|
|
|
|
|
ePen.setColor(m_Color.CentreLineColor);
|
|
ePen.setWidth(10);
|
|
font.setPixelSize(110);
|
|
font.setWeight(QFont::Bold);
|
|
painter->setPen(ePen);
|
|
painter->setFont(font);
|
|
|
|
|
|
|
|
|
|
|
|
qreal Unit = m_State.altitude - int(m_State.altitude)/100 * 100;
|
|
//qreal Dacade = qreal(int(m_State.altitude)%100)/10.0;
|
|
//qreal Decimal = m_State.altitude - int(m_State.altitude);
|
|
|
|
QString thousandText = QString::number(qAbs(int(m_State.altitude/1000)));//设置千位以上
|
|
QString HundredText;//设置百位
|
|
//QString DacadeText = QString::number(int(m_State.altitude/10)); //设置十位
|
|
//QString UnitText = QString::number(qAbs(int(m_State.altitude)%10)); //设置个位
|
|
|
|
if(Unit > 99.5)
|
|
{
|
|
HundredText = QString::number(qAbs(int(m_State.altitude/100)%10)+1);
|
|
if(HundredText.toInt() >= 10)
|
|
{
|
|
HundredText = QString::number(0);
|
|
|
|
thousandText = QString::number(thousandText.toInt() + 1);
|
|
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
HundredText = QString::number(qAbs(int(m_State.altitude/100)%10));
|
|
}
|
|
|
|
//qDebug() << thousandText << HundredText << Unit;
|
|
|
|
//写千位
|
|
if(m_State.altitude >= 0)
|
|
{
|
|
|
|
if(int(m_State.altitude/1000) >= 10)
|
|
{
|
|
painter->drawText(QRect(70,-50,180,100),Qt::AlignVCenter|Qt::AlignRight, thousandText);
|
|
}
|
|
else
|
|
{
|
|
painter->setPen(Qt::NoPen);
|
|
|
|
QBrush eBrush;
|
|
eBrush.setColor(m_Color.StatusColor);
|
|
eBrush.setStyle(Qt::SolidPattern);
|
|
painter->setBrush(Qt::NoBrush);
|
|
painter->setBrush(eBrush);
|
|
painter->drawRect(105,-50,70,100);
|
|
|
|
|
|
ePen.setColor(m_Color.CentreLineColor);
|
|
ePen.setWidth(10);
|
|
font.setPixelSize(100);
|
|
painter->setPen(ePen);
|
|
painter->setFont(font);
|
|
painter->drawText(QRect(160,-50,90,100),Qt::AlignVCenter|Qt::AlignRight, thousandText);
|
|
|
|
}
|
|
|
|
}
|
|
else if(m_State.altitude < 0)
|
|
{
|
|
painter->drawText(QRect(-70,-50,310,100),Qt::AlignVCenter|Qt::AlignRight,tr("-") + thousandText);
|
|
}
|
|
|
|
|
|
ePen.setColor(m_Color.CentreLineColor);
|
|
ePen.setWidth(10);
|
|
font.setPixelSize(100);
|
|
painter->setPen(ePen);
|
|
painter->setFont(font);
|
|
|
|
//写百位
|
|
painter->drawText(QRect(0,-50,300,100),Qt::AlignVCenter|Qt::AlignRight, HundredText);
|
|
/*
|
|
if(int(qAbs(m_State.altitude/100)) > 0)//说明有数
|
|
{
|
|
painter->drawText(QRect(0,-50,300,100),Qt::AlignVCenter|Qt::AlignRight, HundredText);
|
|
}
|
|
else
|
|
{
|
|
painter->drawText(QRect(0,-50,300,100),Qt::AlignVCenter|Qt::AlignRight, "0");
|
|
}
|
|
*/
|
|
|
|
|
|
//写十个位
|
|
// if(qAbs(m_State.altitude) < 100)
|
|
// {
|
|
for(int i = -1.5 - Unit;i<(1.5 - Unit);i+=1)
|
|
{
|
|
QString strText;
|
|
|
|
int number = 0;
|
|
|
|
//这段不能对i进行操作,否则死机
|
|
|
|
if((m_State.altitude < 100)&&(m_State.altitude > (-100)))
|
|
{
|
|
strText= QString::number(((-i < 0)?(i):(-i))); //设置当前字体
|
|
}
|
|
else if(m_State.altitude >= 50)
|
|
{
|
|
if(i == 1) number = i - 100;
|
|
else number = i;
|
|
|
|
strText= QString::number(((-number < 0)?(number):(-number))); //设置当前字体
|
|
}
|
|
else if(m_State.altitude <= (-50))
|
|
{
|
|
if(i == -1) number = i + 100;
|
|
else number = i;
|
|
strText= QString::number(((-number < 0)?(number):(-number))); //设置当前字体
|
|
}
|
|
|
|
|
|
|
|
painter->save();
|
|
|
|
ePen.setColor(m_Color.CentreLineColor);
|
|
ePen.setWidth(10);
|
|
font.setPixelSize(100);
|
|
|
|
painter->setPen(ePen);
|
|
painter->setFont(font);
|
|
|
|
painter->translate(300,(i + Unit) * 120 - 120);
|
|
|
|
//qDebug() << "i" << i << "Decimal" << Decimal << "Unit" << (i + Unit);
|
|
|
|
if(qAbs(i) >= 10)
|
|
{
|
|
painter->drawText(QRect(0,68,110,120),Qt::AlignHCenter|Qt::AlignRight, strText);
|
|
}
|
|
else
|
|
{
|
|
painter->drawText(QRect(0,68,110,120),Qt::AlignHCenter|Qt::AlignRight,"0" + strText);
|
|
}
|
|
|
|
painter->restore();
|
|
}
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//高度数值打补丁
|
|
painter->save();
|
|
|
|
painter->translate(300,0);
|
|
|
|
painter->setPen(Qt::NoPen);
|
|
painter->setBrush(Qt::black);
|
|
|
|
painter->drawRect(0,-350,120,222);
|
|
|
|
painter->drawRect(0, 128,120,222);
|
|
|
|
painter->restore();
|
|
|
|
|
|
painter->restore();
|
|
|
|
|
|
}
|
|
|
|
|
|
void Cockpit::drawVRate(QPainter *painter)
|
|
{
|
|
painter->save();
|
|
//平移坐标
|
|
painter->translate(950,0);
|
|
|
|
QPen ePen;
|
|
QFont font;
|
|
//画一个半透明的小方块
|
|
painter->save();
|
|
painter->setOpacity(0.3);
|
|
|
|
static const QPointF Backpoints[10] = {
|
|
QPointF( 80,-150),
|
|
QPointF( 0,-200),
|
|
QPointF( 0,-460),
|
|
QPointF( 110,-460),
|
|
QPointF( 200,-250),
|
|
|
|
QPointF( 200, 250),
|
|
QPointF( 110, 460),
|
|
QPointF( 0, 460),
|
|
QPointF( 0, 200),
|
|
QPointF( 80, 150),
|
|
};
|
|
painter->setBrush(QColor("#7A7A7A"));
|
|
painter->drawPolygon(Backpoints,10);
|
|
painter->restore();//画底部结束
|
|
|
|
//画刻度
|
|
painter->save();
|
|
|
|
ePen.setWidth(8);
|
|
ePen.setColor(Qt::white);
|
|
painter->setPen(ePen);
|
|
|
|
for(int i = -7;i <= 7;i++)
|
|
{
|
|
painter->save();
|
|
|
|
ePen.setWidth(8);
|
|
ePen.setColor(Qt::white);
|
|
font.setPixelSize(80);
|
|
font.setWeight(QFont::Bold);
|
|
font.setFamily("Arial");//非衬线
|
|
|
|
painter->setPen(ePen);
|
|
painter->setFont(font);
|
|
|
|
|
|
painter->translate(80,((i<0)?(-1):(1))*log10(qAbs(i)) * 500);
|
|
|
|
if(i == 0)
|
|
{
|
|
painter->drawLine(0,0,40,0);
|
|
}
|
|
else
|
|
{
|
|
painter->drawLine(0,0,20,0);
|
|
}
|
|
|
|
|
|
if((qAbs(i)%2) == 1)
|
|
{
|
|
if(qAbs(i) != 1)//除去0位置
|
|
{
|
|
painter->drawText(QRect(-80,-40,60,80),Qt::AlignCenter,QString::number(qAbs(i)-1));
|
|
}
|
|
}
|
|
|
|
painter->restore();
|
|
}
|
|
|
|
painter->restore();//画刻度结束
|
|
|
|
//画当前值
|
|
painter->save();
|
|
painter->translate(80,0);
|
|
|
|
ePen.setWidth(8);
|
|
ePen.setColor(m_Color.CurrentColor);
|
|
painter->setPen(ePen);
|
|
|
|
qreal cur_y = ((m_State.verticalspeed<0)?(1):(-1))*log10(qAbs(m_State.verticalspeed) + 1) * 500;
|
|
|
|
cur_y = (cur_y < -440)?(-440):((cur_y>440)?(440):(cur_y));//位置限幅
|
|
|
|
painter->drawLine(0,cur_y,20,cur_y);
|
|
painter->drawLine(20,cur_y,200,0);
|
|
|
|
painter->restore();//画当前值结束
|
|
|
|
//画当前值打补丁
|
|
painter->save();
|
|
painter->translate(200,0);
|
|
|
|
painter->setBrush(Qt::black);
|
|
painter->drawRect(0,-250,100,500);
|
|
|
|
painter->restore();//画当前值结束
|
|
|
|
|
|
|
|
//画目标标尺
|
|
painter->save();
|
|
|
|
qreal tar_y = ((m_Target.verticalspeed<0)?(1):(-1))*log10(qAbs(m_Target.verticalspeed) + 1) * 500;
|
|
|
|
tar_y = (tar_y < -440)?(-440):((tar_y>440)?(440):(tar_y));//位置限幅
|
|
|
|
painter->translate(80,tar_y);//+1是应为log 1= 0,偏移0的位置
|
|
|
|
//qDebug() << m_Target.verticalspeed;
|
|
|
|
static const QPointF Tarpoints[4] = {
|
|
QPointF( -8,-8),
|
|
QPointF( 28,-8),
|
|
QPointF( 28, 8),
|
|
QPointF( -8, 8)
|
|
};
|
|
ePen.setWidth(8);
|
|
ePen.setColor(m_Color.TargetColor);
|
|
painter->setPen(ePen);
|
|
painter->drawPolygon(Tarpoints,4);
|
|
|
|
painter->restore();//画目标标尺结束
|
|
|
|
//画目标值
|
|
painter->save();
|
|
|
|
painter->translate(80,0);//+1是应为log 1= 0,偏移0的位置
|
|
|
|
ePen.setWidth(8);
|
|
ePen.setColor(m_Color.TargetColor);
|
|
font.setPixelSize(90);
|
|
font.setWeight(QFont::Bold);
|
|
font.setFamily("Arial");//非衬线
|
|
|
|
painter->setPen(ePen);
|
|
painter->setFont(font);
|
|
|
|
painter->drawText(QRect(-80,-600,300,150),Qt::AlignVCenter|Qt::AlignLeft,QString::number(m_Target.verticalspeed,'f',(qAbs(m_Target.verticalspeed) < 10.0)?(1):(0)));
|
|
|
|
painter->restore();//画目标值结束
|
|
|
|
|
|
//画当前值
|
|
painter->save();
|
|
|
|
painter->translate(80,0);//+1是应为log 1= 0,偏移0的位置
|
|
|
|
ePen.setWidth(8);
|
|
ePen.setColor(m_Color.CurrentColor);
|
|
font.setPixelSize(90);
|
|
font.setWeight(QFont::Bold);
|
|
font.setFamily("Arial");//非衬线
|
|
|
|
painter->setPen(ePen);
|
|
painter->setFont(font);
|
|
//在下方显示当前值
|
|
painter->drawText(QRect(-80,450,300,150),Qt::AlignVCenter|Qt::AlignLeft,QString::number(m_State.verticalspeed,'f',(qAbs(m_State.verticalspeed) < 10.0)?(1):(0)));
|
|
|
|
painter->restore();//画当前值结束
|
|
|
|
|
|
|
|
painter->restore();//全部结束
|
|
}
|
|
|
|
|
|
//画航向(位于底部的一个圈)
|
|
void Cockpit::drawYawScale(QPainter *painter)
|
|
{
|
|
|
|
painter->save();
|
|
|
|
QPen ePen;
|
|
QFont font;
|
|
//平移坐标
|
|
|
|
font.setWeight(QFont::ExtraLight);
|
|
font.setFamily("Arial");//非衬线
|
|
painter->translate(0,1050);
|
|
|
|
painter->save();
|
|
//画一个半透明的基础圆
|
|
painter->setOpacity(0.3);
|
|
ePen.setColor(QColor("#7A7A7A"));
|
|
painter->setBrush(QColor("#7A7A7A"));
|
|
painter->drawEllipse(-500,-500,1000,1000);
|
|
painter->restore();
|
|
|
|
//画一个顶部三角形
|
|
painter->save();
|
|
static const QPointF Tranpoints[3] = {
|
|
QPointF(-30,-560),
|
|
QPointF(0,-500),
|
|
QPointF(30,-560)
|
|
};
|
|
|
|
ePen.setWidth(1);
|
|
ePen.setColor(m_Color.CurrentColor);
|
|
painter->setPen(ePen);
|
|
painter->setBrush(m_Color.CurrentColor);
|
|
painter->drawPolygon(Tranpoints,3);
|
|
painter->restore();
|
|
|
|
|
|
|
|
//画顶部紫色目标值 (紫色在白色下面,并且在刻度上面,并且有一部分会重叠)
|
|
painter->save();
|
|
//旋转
|
|
float rotate_deg = -(m_State.yaw - m_Target.yaw);
|
|
int n = rotate_deg/360;
|
|
rotate_deg = rotate_deg - n*360;
|
|
painter->rotate(rotate_deg);
|
|
static const QPointF Tarpoint[8] = {
|
|
QPointF(-40,-500),
|
|
QPointF(-40,-530),
|
|
QPointF(-15,-530),
|
|
QPointF( -5,-500),
|
|
QPointF( 5,-500),
|
|
QPointF( 15,-530),
|
|
QPointF( 40,-530),
|
|
QPointF( 40,-500)
|
|
};
|
|
|
|
ePen.setWidth(8);
|
|
ePen.setColor(m_Color.TargetColor);
|
|
painter->setPen(ePen);
|
|
painter->drawPolygon(Tarpoint,8);
|
|
|
|
//painter->drawLine(0,-100,0,-450);
|
|
|
|
painter->restore();
|
|
|
|
|
|
//画中间大罗盘
|
|
painter->save();
|
|
painter->rotate(-m_State.yaw);
|
|
|
|
static const QPointF Npoints[3] = {
|
|
QPointF(-70,0),
|
|
QPointF( 0,-300),
|
|
QPointF( 70,0)};
|
|
static const QPointF Spoints[3] = {
|
|
QPointF(-70,0),
|
|
QPointF( 0,300),
|
|
QPointF( 70,0)};
|
|
|
|
painter->setPen(Qt::NoPen);
|
|
painter->setBrush(QColor("#FF0000"));
|
|
painter->drawPolygon(Npoints,3);
|
|
|
|
painter->setBrush(QColor("#0000FF"));
|
|
painter->drawPolygon(Spoints,3);
|
|
|
|
painter->restore();
|
|
|
|
|
|
//画一个中间小飞机
|
|
painter->save();
|
|
|
|
static const QPointF Planepoints[18] = {
|
|
QPointF( 0,-50),
|
|
|
|
QPointF(-10,-40),
|
|
QPointF(-10,-20),
|
|
QPointF(-50, 0),
|
|
QPointF(-50, 10),
|
|
QPointF(-10, 5),
|
|
QPointF(-10, 35),
|
|
QPointF(-20, 45),
|
|
QPointF(-20, 50),
|
|
|
|
QPointF( 0, 47),
|
|
|
|
QPointF( 20, 50),
|
|
QPointF( 20, 45),
|
|
QPointF( 10, 35),
|
|
QPointF( 10, 5),
|
|
QPointF( 50, 10),
|
|
QPointF( 50, 0),
|
|
QPointF( 10,-20),
|
|
QPointF( 10,-40)
|
|
|
|
};
|
|
|
|
painter->setPen(Qt::NoPen);
|
|
painter->setBrush(m_Color.CurrentColor);
|
|
painter->drawPolygon(Planepoints,18);
|
|
|
|
//画横竖白色小圈圈
|
|
//画中间小圆
|
|
painter->save();
|
|
|
|
//一直跟目标垂直
|
|
//painter->rotate(m_Target.yaw);
|
|
|
|
ePen.setWidth(5);
|
|
ePen.setColor(QColor("#FFFFFF"));
|
|
painter->setPen(ePen);
|
|
|
|
for (int i = -3;i <= 3;i++) {
|
|
painter->save();
|
|
painter->translate(i*100,0);
|
|
|
|
painter->drawEllipse(-8,-8,16,16);
|
|
painter->restore();
|
|
|
|
painter->save();
|
|
painter->translate(0,i*100);
|
|
|
|
painter->drawEllipse(-8,-8,16,16);
|
|
painter->restore();
|
|
}
|
|
|
|
//画竖条
|
|
painter->save();
|
|
if(abs(m_State.xtrack) >= 10)//大于10,对数显示
|
|
{
|
|
painter->translate(((m_State.xtrack >= 0)?(1.0):(-1.0))*log10(abs(m_State.xtrack)) * 100,0);
|
|
}
|
|
else
|
|
{
|
|
painter->translate(m_State.xtrack * 10.0,0);//小于10,线性 显示
|
|
}
|
|
|
|
ePen.setWidth(8);
|
|
ePen.setColor(m_Color.TargetColor);
|
|
painter->setPen(ePen);
|
|
painter->drawLine(0,-200,0,200);
|
|
painter->restore();//画竖条结束
|
|
|
|
|
|
painter->save();//画横条开始
|
|
if(abs(m_State.alt_err) >= 10)//大于10,对数显示
|
|
{
|
|
painter->translate(0,((m_State.alt_err >= 0)?(1.0):(-1.0))*log10(abs(m_State.alt_err)) * 100);
|
|
}
|
|
else
|
|
{
|
|
painter->translate(0,m_State.alt_err * 10.0);//小于10,线性 显示
|
|
}
|
|
ePen.setWidth(8);
|
|
ePen.setColor(m_Color.TargetColor);
|
|
painter->setPen(ePen);
|
|
painter->drawLine(-200,0,200,0);
|
|
painter->restore();//画横条结束
|
|
|
|
|
|
painter->restore();//画小圆结束
|
|
painter->restore();//画小飞机结束
|
|
|
|
|
|
//画一个顶部黑色显示框
|
|
painter->save();
|
|
|
|
static const QPointF Rectpoints[4] = {
|
|
QPointF(-120,-650),
|
|
QPointF( 120,-650),
|
|
QPointF( 120, -540),
|
|
QPointF(-120, -540),
|
|
};
|
|
|
|
ePen.setWidth(1);
|
|
ePen.setColor(Qt::black);
|
|
painter->setPen(ePen);
|
|
painter->setBrush(Qt::black);
|
|
painter->drawPolygon(Rectpoints,4);
|
|
|
|
ePen.setColor(m_Color.CurrentColor);
|
|
font.setPixelSize(120);
|
|
font.setWeight(QFont::Bold);
|
|
painter->setPen(ePen);
|
|
painter->setFont(font);
|
|
painter->drawText(QRect(-90,-670,180,150),Qt::AlignCenter,QString::number(m_State.yaw,'f',0));
|
|
|
|
painter->restore();
|
|
|
|
ePen.setColor(m_Color.CentreLineColor);
|
|
ePen.setWidth(10);
|
|
|
|
font.setPixelSize(60);
|
|
|
|
painter->setPen(ePen);
|
|
painter->setFont(font);
|
|
|
|
//旋转
|
|
painter->rotate(-m_State.yaw);
|
|
//画刻度
|
|
|
|
for(int i=0;i<72;i++)
|
|
{
|
|
painter->save();
|
|
|
|
painter->setOpacity(1.0);
|
|
|
|
painter->translate(0,0);
|
|
painter->rotate(i * 5.0);
|
|
if((i%2) == 0)
|
|
painter->drawLine(0,-500,0,-460);
|
|
else
|
|
painter->drawLine(0,-500,0,-480);
|
|
|
|
if((i%6) == 0)
|
|
{
|
|
QString Flag = "";
|
|
if((i == 0)||(i == 18)||(i == 36)||(i == 54))
|
|
{
|
|
painter->save();
|
|
|
|
switch (i) {
|
|
case 0:
|
|
Flag = "N";
|
|
ePen.setColor(QColor("#FF0000"));
|
|
painter->setPen(ePen);
|
|
break;
|
|
case 18:
|
|
Flag = "E";
|
|
break;
|
|
case 36:
|
|
Flag = "S";
|
|
ePen.setColor(QColor("#0000FF"));
|
|
painter->setPen(ePen);
|
|
break;
|
|
case 54:
|
|
Flag = "W";
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
font.setPixelSize(120);
|
|
font.setWeight(QFont::Bold);
|
|
|
|
painter->setFont(font);
|
|
|
|
painter->drawText(QRect(-75,-470,150,150),Qt::AlignVCenter|Qt::AlignHCenter,Flag);
|
|
painter->restore();
|
|
}
|
|
else
|
|
{
|
|
QString strText = QString::number(qAbs(i/2));
|
|
if(strText.length() > 1)
|
|
{
|
|
painter->drawText( -40,-380, strText);
|
|
}
|
|
else
|
|
{
|
|
painter->drawText( -20,-380, strText);
|
|
}
|
|
}
|
|
}
|
|
|
|
painter->restore();
|
|
}
|
|
painter->restore();//画YAW结束
|
|
}
|
|
|
|
void Cockpit::drawTopStatuts(QPainter *painter)
|
|
{
|
|
//画状态开始
|
|
painter->save();
|
|
|
|
QPen ePen;
|
|
QFont font;
|
|
|
|
painter->translate(0,-900);
|
|
|
|
//画底层
|
|
painter->save();
|
|
painter->setOpacity(0.3);
|
|
painter->setBrush(QColor("#7A7A7A"));
|
|
|
|
painter->drawRect(-550,0,1100,150);
|
|
|
|
painter->setOpacity(1);
|
|
ePen.setColor(m_Color.CentreLineColor);
|
|
ePen.setWidth(10);
|
|
painter->setPen(ePen);
|
|
painter->drawLine(-185,0,-185,150);
|
|
painter->drawLine( 185,0, 185,150);
|
|
painter->restore();//画底层结束
|
|
|
|
//画状态
|
|
painter->save();
|
|
|
|
//画大字
|
|
ePen.setColor(m_Color.StatusColor);
|
|
ePen.setWidth(12);
|
|
font.setPixelSize(90);
|
|
font.setWeight(QFont::Bold);
|
|
font.setFamily("Arial");//非衬线
|
|
|
|
painter->setPen(ePen);
|
|
painter->setFont(font);
|
|
|
|
painter->drawText(QRect(-550,0,365,150),Qt::AlignCenter,m_State.GPS);
|
|
painter->drawText(QRect(-185,0,365,150),Qt::AlignCenter,m_State. MODE);
|
|
painter->drawText(QRect( 185,0,365,150),Qt::AlignCenter,m_State.STATE);
|
|
|
|
painter->restore();//画状态结束
|
|
|
|
painter->restore();//所有结束
|
|
}
|