left compelet
This commit is contained in:
+132
-73
@@ -105,8 +105,12 @@ void Cockpit::wheelEvent(QWheelEvent *e)
|
||||
setYaw(m_Attitude.yaw +0.1f * e->angleDelta().y()/120.0f);
|
||||
|
||||
setAirSpeed(m_Attitude.airspeed +0.1f * e->angleDelta().y()/120.0f);
|
||||
setGPSAltitude(m_GPS.altitude + e->angleDelta().y()/120.0f);
|
||||
|
||||
qDebug() << "wheel event" << m_Attitude.roll << m_Attitude.pitch << m_Attitude.yaw;
|
||||
|
||||
m_Target.airspeed = 20;//0.1f * e->angleDelta().y()/120.0f;
|
||||
|
||||
qDebug() << "wheel event" << m_Attitude.roll << m_Attitude.pitch << m_Attitude.yaw << m_Target.airspeed;
|
||||
|
||||
update();
|
||||
}
|
||||
@@ -308,8 +312,8 @@ void Cockpit::drawPitch(QPainter *painter)
|
||||
if((i%10) == 0)
|
||||
{
|
||||
painter->drawLine(-290,i * h,290,i * h);
|
||||
painter->drawText(-380,i * h + 30, strText);//减去字体的一半
|
||||
painter->drawText( 300,i * h + 30, strText);
|
||||
painter->drawText(QRect(-530,i * h - 40,230,80),Qt::AlignVCenter | Qt::AlignRight, strText);//减去字体的一半
|
||||
painter->drawText(QRect( 300,i * h - 40,240,80),Qt::AlignVCenter | Qt::AlignLeft, strText);
|
||||
}
|
||||
|
||||
|
||||
@@ -458,6 +462,7 @@ void Cockpit::drawYawScale(QPainter *painter)
|
||||
painter->save();
|
||||
|
||||
QPen ePen;
|
||||
QFont font;
|
||||
//平移坐标
|
||||
painter->translate(0,950);
|
||||
|
||||
@@ -473,7 +478,7 @@ void Cockpit::drawYawScale(QPainter *painter)
|
||||
//画一个顶部三角形
|
||||
//painter->setOpacity(1.0f);
|
||||
|
||||
static const QPointF points[3] = {
|
||||
static const QPointF Tranpoints[3] = {
|
||||
QPointF(-30,-560),
|
||||
QPointF(0,-500),
|
||||
QPointF(30,-560)
|
||||
@@ -483,16 +488,40 @@ void Cockpit::drawYawScale(QPainter *painter)
|
||||
ePen.setColor(m_CurrentColor);
|
||||
painter->setPen(ePen);
|
||||
painter->setBrush(m_CurrentColor);
|
||||
painter->drawPolygon(points,3);
|
||||
painter->drawPolygon(Tranpoints,3);
|
||||
|
||||
painter->restore();
|
||||
|
||||
|
||||
//画一个顶部黑色显示框
|
||||
painter->save();
|
||||
|
||||
static const QPointF Rectpoints[4] = {
|
||||
QPointF(-90,-610),
|
||||
QPointF( 90,-610),
|
||||
QPointF( 90, -540),
|
||||
QPointF(-90, -540),
|
||||
};
|
||||
|
||||
ePen.setWidth(1);
|
||||
ePen.setColor(Qt::black);
|
||||
painter->setPen(ePen);
|
||||
painter->setBrush(Qt::black);
|
||||
painter->drawPolygon(Rectpoints,4);
|
||||
|
||||
ePen.setColor(m_CurrentColor);
|
||||
font.setPointSize(60);
|
||||
painter->setPen(ePen);
|
||||
painter->setFont(font);
|
||||
painter->drawText(QRect(-90,-610,180,60),Qt::AlignVCenter|Qt::AlignHCenter,QString::number(m_Attitude.yaw,'f',0));
|
||||
|
||||
painter->restore();
|
||||
|
||||
|
||||
|
||||
|
||||
ePen.setColor(m_CentreLineColor);
|
||||
ePen.setWidth(10);
|
||||
QFont font;
|
||||
|
||||
font.setPointSize(60);
|
||||
|
||||
painter->setPen(ePen);
|
||||
@@ -590,7 +619,7 @@ void Cockpit::drawLeftScale(QPainter *painter)
|
||||
painter->setBrush(QColor("#000000"));
|
||||
painter->drawRect(0,600,300,100);
|
||||
|
||||
painter->drawText(QRect(20,600,280,100),Qt::AlignLeft|Qt::AlignVCenter,"TAS " + QString::number(m_Attitude.airspeed));
|
||||
painter->drawText(QRect(20,600,280,100),Qt::AlignLeft|Qt::AlignVCenter,"TAS " + QString::number(m_Attitude.airspeed,'f',0));
|
||||
|
||||
painter->restore();
|
||||
|
||||
@@ -753,6 +782,37 @@ void Cockpit::drawLeftScale(QPainter *painter)
|
||||
|
||||
painter->restore();
|
||||
|
||||
|
||||
|
||||
//画速度目标值(紫色小箭头)
|
||||
painter->save();
|
||||
|
||||
painter->translate(275,-1200.0f/40.0f * (m_Target.airspeed- m_Attitude.airspeed));//设置原点
|
||||
|
||||
ePen.setColor(m_TargetColor);
|
||||
ePen.setWidth(10);
|
||||
painter->setPen(ePen);
|
||||
|
||||
static const QPointF ASTargetpoints2[7] = {
|
||||
QPointF(30, 0),
|
||||
QPointF(10, -30),
|
||||
QPointF(10, -45),
|
||||
QPointF(60,-45),
|
||||
QPointF(60, 45),
|
||||
QPointF(10, 45),
|
||||
QPointF(10, 30)
|
||||
};
|
||||
|
||||
painter->drawPolygon(ASTargetpoints2, 7);
|
||||
|
||||
painter->restore();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
painter->restore();
|
||||
|
||||
}
|
||||
@@ -790,7 +850,7 @@ void Cockpit::drawRightScale(QPainter *painter)
|
||||
painter->setBrush(QColor("#000000"));
|
||||
painter->drawRect(0,600,300,100);
|
||||
|
||||
painter->drawText(QRect(20,600,280,100),Qt::AlignLeft|Qt::AlignVCenter,"Hei " + QString::number(m_Attitude.airspeed));
|
||||
painter->drawText(QRect(20,600,280,100),Qt::AlignLeft|Qt::AlignVCenter,"Hei " + QString::number(m_GPS.altitude));
|
||||
|
||||
painter->restore();
|
||||
|
||||
@@ -798,12 +858,12 @@ void Cockpit::drawRightScale(QPainter *painter)
|
||||
//画旁边的速度刻度,并显示
|
||||
painter->save();
|
||||
|
||||
painter->translate(0,1200.0f/40.0f * m_Attitude.airspeed);
|
||||
painter->translate(0,1200.0f/40.0f * m_GPS.altitude);
|
||||
|
||||
float h = 1200.0f/40.0f;//单位高度
|
||||
|
||||
|
||||
for(int i = -19 - m_Attitude.airspeed;i<=(19 - m_Attitude.airspeed);i+=1)
|
||||
for(int i = -19 - m_GPS.altitude;i<=(19 - m_GPS.altitude);i+=1)
|
||||
{
|
||||
|
||||
QString strText = QString::number(-i); //设置当前字体
|
||||
@@ -820,11 +880,13 @@ void Cockpit::drawRightScale(QPainter *painter)
|
||||
|
||||
if((i%10) == 0)
|
||||
{
|
||||
//if((i * h > 100)||(i * h < -100))
|
||||
//{
|
||||
painter->drawLine(0,i * h,70,i * h);
|
||||
painter->drawText(QRect(-20,i * h - 30,190,60),Qt::AlignVCenter|Qt::AlignRight, strText);
|
||||
//}
|
||||
|
||||
painter->drawLine(0,i * h,70,i * h);
|
||||
|
||||
if(((i + m_GPS.altitude)* h > 130)||((i + m_GPS.altitude) * h < -130))
|
||||
{
|
||||
painter->drawText(QRect(80,i * h - 30,190,60),Qt::AlignVCenter|Qt::AlignLeft, strText);
|
||||
}
|
||||
}
|
||||
else if((i%2) == 0)
|
||||
{
|
||||
@@ -848,11 +910,11 @@ void Cockpit::drawRightScale(QPainter *painter)
|
||||
static const QPointF points1[11] = {
|
||||
QPointF( 25,-50),
|
||||
QPointF(200,-50),
|
||||
QPointF(200,-100),
|
||||
QPointF(300,-100),
|
||||
QPointF(200,-125),
|
||||
QPointF(350,-125),
|
||||
|
||||
QPointF(300, 100),
|
||||
QPointF(200, 100),
|
||||
QPointF(350, 125),
|
||||
QPointF(200, 125),
|
||||
QPointF(200, 50),
|
||||
QPointF( 25, 50),
|
||||
|
||||
@@ -876,74 +938,71 @@ void Cockpit::drawRightScale(QPainter *painter)
|
||||
|
||||
|
||||
|
||||
QString DacadeText = QString::number(int(m_Attitude.airspeed/10)); //设置十位以上
|
||||
QString UnitText = QString::number(qAbs(int(m_Attitude.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);
|
||||
QString DacadeText = QString::number(int(m_GPS.altitude/10)); //设置十位以上
|
||||
QString UnitText = QString::number(qAbs(int(m_GPS.altitude)%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 = m_Attitude.airspeed - int(m_Attitude.airspeed)/10 * 10;
|
||||
float Decimal = qAbs(m_Attitude.airspeed - int(m_Attitude.airspeed));
|
||||
float Unit = m_GPS.altitude - int(m_GPS.altitude)/10 * 10;
|
||||
float Decimal = qAbs(m_GPS.altitude - int(m_GPS.altitude));
|
||||
|
||||
|
||||
|
||||
int count = 1;
|
||||
for(int i = -1.5 - Unit;i<(1.5 - Unit);i+=1)
|
||||
{
|
||||
int count = 1;
|
||||
for(int i = -1.5 - Unit;i<(1.5 - Unit);i+=1)
|
||||
{
|
||||
|
||||
QString strText = QString::number(((-i < 0)?(-i+10):((-i>=10)?(-i-10):(-i)))); //设置当前字体
|
||||
painter->save();
|
||||
QString strText = QString::number(((-i < 0)?(-i+10):((-i>=10)?(-i-10):(-i)))); //设置当前字体
|
||||
painter->save();
|
||||
|
||||
ePen.setColor(m_CentreLineColor);
|
||||
ePen.setWidth(15);
|
||||
font.setPointSize(90);
|
||||
ePen.setColor(m_CentreLineColor);
|
||||
ePen.setWidth(15);
|
||||
font.setPointSize(90);
|
||||
|
||||
painter->setPen(ePen);
|
||||
painter->setFont(font);
|
||||
painter->setPen(ePen);
|
||||
painter->setFont(font);
|
||||
|
||||
painter->translate(200,(i + Unit) * 120 - 60);
|
||||
painter->translate(200,(i + Unit) * 120 - 60);
|
||||
|
||||
//此段程序在未理解之前,请不要随意修改
|
||||
switch (count) {
|
||||
case 1:
|
||||
if(Decimal <= 0.5f)
|
||||
{
|
||||
if((60 - 120 * Decimal) != 0)
|
||||
painter->drawText(QRect(0,60 - 120 * Decimal ,60,60 + 120 * Decimal ),Qt::AlignBottom|Qt::AlignLeft, strText);
|
||||
}
|
||||
else //>0.5
|
||||
{
|
||||
painter->drawText(QRect(0,120 - 120 * (Decimal - 0.5) ,60,120 * (Decimal - 0.5)),Qt::AlignBottom|Qt::AlignLeft, strText);
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
painter->drawText(QRect(0,0,60,120),Qt::AlignVCenter|Qt::AlignLeft, strText);
|
||||
break;
|
||||
case 3:
|
||||
if(Decimal <= 0.5f)
|
||||
{
|
||||
if((60 - 120 * Decimal) != 0)
|
||||
painter->drawText(QRect(0,0,60,60 - 120 * Decimal),Qt::AlignTop|Qt::AlignLeft, strText);
|
||||
else
|
||||
//此段程序在未理解之前,请不要随意修改
|
||||
switch (count) {
|
||||
case 1:
|
||||
if(Decimal <= 0.5f)
|
||||
{
|
||||
if((60 - 120 * Decimal) != 0)
|
||||
painter->drawText(QRect(0,60 - 120 * Decimal ,60,60 + 120 * Decimal ),Qt::AlignBottom|Qt::AlignLeft, strText);
|
||||
}
|
||||
else //>0.5
|
||||
{
|
||||
painter->drawText(QRect(0,120 - 120 * (Decimal - 0.5) ,60,120 * (Decimal - 0.5)),Qt::AlignBottom|Qt::AlignLeft, strText);
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
painter->drawText(QRect(0,0,60,120),Qt::AlignVCenter|Qt::AlignLeft, strText);
|
||||
}
|
||||
else
|
||||
{
|
||||
painter->drawText(QRect(0,0,60,120 - 120 * (Decimal - 0.5)),Qt::AlignTop|Qt::AlignLeft, strText);
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
if(Decimal <= 0.5f)
|
||||
{
|
||||
if((60 - 120 * Decimal) != 0)
|
||||
painter->drawText(QRect(0,0,60,60 - 120 * Decimal),Qt::AlignTop|Qt::AlignLeft, strText);
|
||||
else
|
||||
painter->drawText(QRect(0,0,60,120),Qt::AlignVCenter|Qt::AlignLeft, strText);
|
||||
}
|
||||
else
|
||||
{
|
||||
painter->drawText(QRect(0,0,60,120 - 120 * (Decimal - 0.5)),Qt::AlignTop|Qt::AlignLeft, strText);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
count++;
|
||||
count++;
|
||||
painter->restore();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
painter->restore();
|
||||
}
|
||||
|
||||
|
||||
|
||||
painter->restore();
|
||||
painter->restore();
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user