保存程序
This commit is contained in:
+48
-21
@@ -84,11 +84,11 @@ void Cockpit::UpdateTimeout(void)
|
||||
//如果已经设置了新的数据,那么刷新
|
||||
if(m_State.isUpdate == true)
|
||||
{
|
||||
m_State.airspeed = m_State.airspeed*0.9 + m_State.airspeed_t*0.1;
|
||||
m_State.airspeed = m_State.airspeed*0.75 + m_State.airspeed_t*0.25;
|
||||
|
||||
m_State.altitude = m_State.altitude*0.95 + m_State.altitude_t*0.05;
|
||||
m_State.altitude = m_State.altitude*0.75 + m_State.altitude_t*0.25;
|
||||
|
||||
m_State.verticalspeed = m_State.verticalspeed*0.8 + m_State.verticalspeed_t*0.2;
|
||||
m_State.verticalspeed = m_State.verticalspeed*0.75 + m_State.verticalspeed_t*0.25;
|
||||
|
||||
update();
|
||||
m_State.isUpdate = false;
|
||||
@@ -141,8 +141,8 @@ void Cockpit::setPitch(double Pitch)
|
||||
}
|
||||
#endif
|
||||
|
||||
if(Pitch > 360) Pitch = 360;
|
||||
else if(Pitch < -360) Pitch = -360;
|
||||
//if(Pitch > 360) Pitch = 360;
|
||||
//else if(Pitch < -360) Pitch = -360;
|
||||
|
||||
int n = Pitch/360;
|
||||
Pitch = Pitch - n*360;
|
||||
@@ -169,8 +169,8 @@ void Cockpit::setPitchTarget(double Pitch)
|
||||
}
|
||||
#endif
|
||||
|
||||
if(Pitch > 360) Pitch = 360;
|
||||
else if(Pitch < -360) Pitch = -360;
|
||||
//if(Pitch > 360) Pitch = 360;
|
||||
//else if(Pitch < -360) Pitch = -360;
|
||||
|
||||
int n = Pitch/360;
|
||||
Pitch = Pitch - n*360;
|
||||
@@ -198,8 +198,8 @@ void Cockpit::setRoll(double Roll)
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
if(Roll > 360) Roll = 360;
|
||||
else if(Roll < -360) Roll = -360;
|
||||
//if(Roll > 360) Roll = 360;
|
||||
//else if(Roll < -360) Roll = -360;
|
||||
|
||||
int n = Roll/360;
|
||||
Roll = Roll - n*360;
|
||||
@@ -226,8 +226,8 @@ void Cockpit::setRollTarget(double Roll)
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
if(Roll > 360) Roll = 360;
|
||||
else if(Roll < -360) Roll = -360;
|
||||
//if(Roll > 360) Roll = 360;
|
||||
//else if(Roll < -360) Roll = -360;
|
||||
|
||||
int n = Roll/360;
|
||||
Roll = Roll - n*360;
|
||||
@@ -1596,15 +1596,10 @@ void Cockpit::drawYawScale(QPainter *painter)
|
||||
//画顶部紫色目标值 (紫色在白色下面,并且在刻度上面,并且有一部分会重叠)
|
||||
painter->save();
|
||||
//旋转
|
||||
float rotate_deg = m_State.yaw - m_Target.yaw;
|
||||
|
||||
if(rotate_deg < 0) rotate_deg += 360;
|
||||
else if(rotate_deg > 360) rotate_deg -= 360;
|
||||
|
||||
//qDebug() << rotate_deg;
|
||||
|
||||
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),
|
||||
@@ -1626,6 +1621,29 @@ void Cockpit::drawYawScale(QPainter *painter)
|
||||
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();
|
||||
|
||||
@@ -1673,13 +1691,13 @@ void Cockpit::drawYawScale(QPainter *painter)
|
||||
painter->save();
|
||||
painter->translate(i*100,0);
|
||||
|
||||
painter->drawEllipse(-5,-5,10,10);
|
||||
painter->drawEllipse(-8,-8,16,16);
|
||||
painter->restore();
|
||||
|
||||
painter->save();
|
||||
painter->translate(0,i*100);
|
||||
|
||||
painter->drawEllipse(-5,-5,10,10);
|
||||
painter->drawEllipse(-8,-8,16,16);
|
||||
painter->restore();
|
||||
}
|
||||
|
||||
@@ -1774,15 +1792,21 @@ void Cockpit::drawYawScale(QPainter *painter)
|
||||
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";
|
||||
@@ -1791,7 +1815,10 @@ void Cockpit::drawYawScale(QPainter *painter)
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
|
||||
painter->drawText(QRect(-40,-450,80,80),Qt::AlignVCenter|Qt::AlignHCenter,Flag);
|
||||
painter->restore();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user