draw speed limit state bar
This commit is contained in:
+58
-16
@@ -43,6 +43,8 @@ Cockpit::Cockpit(QWidget *parent): QWidget(parent)
|
|||||||
m_Attitude.verticalspeed = 0;//爬升速度
|
m_Attitude.verticalspeed = 0;//爬升速度
|
||||||
|
|
||||||
|
|
||||||
|
m_Target.airspeed_maximun = 25;
|
||||||
|
m_Target.airspeed_minimun = 15;
|
||||||
|
|
||||||
|
|
||||||
m_Battery.current[0] = 0;
|
m_Battery.current[0] = 0;
|
||||||
@@ -670,11 +672,10 @@ void Cockpit::drawLeftScale(QPainter *painter)
|
|||||||
|
|
||||||
if(i < 0)//小于0的刻度不显示
|
if(i < 0)//小于0的刻度不显示
|
||||||
{
|
{
|
||||||
|
|
||||||
if((i%10) == 0)
|
if((i%10) == 0)
|
||||||
{
|
{
|
||||||
painter->drawLine( 220,i * h,290,i * h);
|
painter->drawLine( 220,i * h,290,i * h);
|
||||||
painter->drawText(QRect(20,i * h - 30,190,60),Qt::AlignVCenter|Qt::AlignRight, strText);
|
painter->drawText(QRect(0,i * h - 30,190,80),Qt::AlignVCenter|Qt::AlignRight, strText);
|
||||||
|
|
||||||
}
|
}
|
||||||
else if((i%5) == 0)
|
else if((i%5) == 0)
|
||||||
@@ -682,10 +683,6 @@ void Cockpit::drawLeftScale(QPainter *painter)
|
|||||||
painter->drawLine(240,i * h,290,i * h);
|
painter->drawLine(240,i * h,290,i * h);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
painter->restore();
|
painter->restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -699,13 +696,44 @@ void Cockpit::drawLeftScale(QPainter *painter)
|
|||||||
//画旁边的速度彩条
|
//画旁边的速度彩条
|
||||||
painter->save();
|
painter->save();
|
||||||
|
|
||||||
painter->setBrush(QColor("#FFC125"));
|
painter->setBrush(QColor("#FF8C00"));//画橙色
|
||||||
painter->drawRect(275,-600,25,1200);
|
painter->drawRect(275,-600,25,1200);
|
||||||
|
|
||||||
|
painter->setBrush(QColor("#228B22"));//画绿色
|
||||||
|
float y_green = -1200.0f/40.0f * (m_Target.airspeed_maximun- m_Attitude.airspeed);
|
||||||
|
float l_green = 1200.0f/40.0f * (m_Target.airspeed_maximun - m_Target.airspeed_minimun);
|
||||||
|
|
||||||
|
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("#FF0000"));//画红色
|
||||||
|
float y_red = -1200.0f/40.0f * (m_Target.airspeed_minimun- m_Attitude.airspeed);
|
||||||
|
float l_red = 600 + 1200.0f/40.0f * (m_Target.airspeed_minimun- m_Attitude.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->restore();
|
||||||
|
|
||||||
//画 中间黑色的显示块
|
//画 中间黑色的显示块
|
||||||
painter->save();
|
painter->save();
|
||||||
|
|
||||||
|
/*
|
||||||
static const QPointF points1[11] = {
|
static const QPointF points1[11] = {
|
||||||
QPointF( 0,-50),
|
QPointF( 0,-50),
|
||||||
QPointF(200,-50),
|
QPointF(200,-50),
|
||||||
@@ -721,9 +749,23 @@ void Cockpit::drawLeftScale(QPainter *painter)
|
|||||||
QPointF(200, 50),
|
QPointF(200, 50),
|
||||||
QPointF( 0, 50)
|
QPointF( 0, 50)
|
||||||
};
|
};
|
||||||
|
*/
|
||||||
|
|
||||||
|
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->setBrush(QColor("#000000"));
|
||||||
painter->drawPolygon(points1, 11);
|
painter->drawPolygon(points1, 7);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -739,7 +781,7 @@ void Cockpit::drawLeftScale(QPainter *painter)
|
|||||||
|
|
||||||
QString DacadeText = QString::number(int(m_Attitude.airspeed/10)); //设置十位以上
|
QString DacadeText = QString::number(int(m_Attitude.airspeed/10)); //设置十位以上
|
||||||
QString UnitText = QString::number(qAbs(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(0,-50,150,100),Qt::AlignVCenter|Qt::AlignRight, DacadeText);
|
||||||
//painter->drawText(QRect(200,-50,100,100),Qt::AlignVCenter|Qt::AlignLeft, UnitText);
|
//painter->drawText(QRect(200,-50,100,100),Qt::AlignVCenter|Qt::AlignLeft, UnitText);
|
||||||
|
|
||||||
float Unit = m_Attitude.airspeed - int(m_Attitude.airspeed)/10 * 10;
|
float Unit = m_Attitude.airspeed - int(m_Attitude.airspeed)/10 * 10;
|
||||||
@@ -762,7 +804,7 @@ void Cockpit::drawLeftScale(QPainter *painter)
|
|||||||
painter->setPen(ePen);
|
painter->setPen(ePen);
|
||||||
painter->setFont(font);
|
painter->setFont(font);
|
||||||
|
|
||||||
painter->translate(200,(i + Unit) * 120 - 60);
|
painter->translate(150,(i + Unit) * 120 - 60);
|
||||||
|
|
||||||
//此段程序在未理解之前,请不要随意修改
|
//此段程序在未理解之前,请不要随意修改
|
||||||
switch (count) {
|
switch (count) {
|
||||||
@@ -770,27 +812,27 @@ void Cockpit::drawLeftScale(QPainter *painter)
|
|||||||
if(Decimal <= 0.5f)
|
if(Decimal <= 0.5f)
|
||||||
{
|
{
|
||||||
if((60 - 120 * Decimal) != 0)
|
if((60 - 120 * Decimal) != 0)
|
||||||
painter->drawText(QRect(0,60 - 120 * Decimal ,60,60 + 120 * Decimal ),Qt::AlignBottom|Qt::AlignLeft, strText);
|
painter->drawText(QRect(0,60 - 120 * Decimal ,80,60 + 120 * Decimal ),Qt::AlignBottom|Qt::AlignLeft, strText);
|
||||||
}
|
}
|
||||||
else //>0.5
|
else //>0.5
|
||||||
{
|
{
|
||||||
painter->drawText(QRect(0,120 - 120 * (Decimal - 0.5) ,60,120 * (Decimal - 0.5)),Qt::AlignBottom|Qt::AlignLeft, strText);
|
painter->drawText(QRect(0,120 - 120 * (Decimal - 0.5) ,80,120 * (Decimal - 0.5)),Qt::AlignBottom|Qt::AlignLeft, strText);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
painter->drawText(QRect(0,0,60,120),Qt::AlignVCenter|Qt::AlignLeft, strText);
|
painter->drawText(QRect(0,0,80,120),Qt::AlignVCenter|Qt::AlignLeft, strText);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
if(Decimal <= 0.5f)
|
if(Decimal <= 0.5f)
|
||||||
{
|
{
|
||||||
if((60 - 120 * Decimal) != 0)
|
if((60 - 120 * Decimal) != 0)
|
||||||
painter->drawText(QRect(0,0,60,60 - 120 * Decimal),Qt::AlignTop|Qt::AlignLeft, strText);
|
painter->drawText(QRect(0,0,80,60 - 120 * Decimal),Qt::AlignTop|Qt::AlignLeft, strText);
|
||||||
else
|
else
|
||||||
painter->drawText(QRect(0,0,60,120),Qt::AlignVCenter|Qt::AlignLeft, strText);
|
painter->drawText(QRect(0,0,80,120),Qt::AlignVCenter|Qt::AlignLeft, strText);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
painter->drawText(QRect(0,0,60,120 - 120 * (Decimal - 0.5)),Qt::AlignTop|Qt::AlignLeft, strText);
|
painter->drawText(QRect(0,0,80,120 - 120 * (Decimal - 0.5)),Qt::AlignTop|Qt::AlignLeft, strText);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,10 +68,17 @@ typedef struct{
|
|||||||
float yaw;
|
float yaw;
|
||||||
|
|
||||||
float height;
|
float height;
|
||||||
|
|
||||||
|
float airspeed_maximun;
|
||||||
float airspeed;
|
float airspeed;
|
||||||
|
float airspeed_minimun;
|
||||||
|
|
||||||
float heading;//航线方向
|
float heading;//航线方向
|
||||||
float position;//侧偏距
|
float position;//侧偏距
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}_target;
|
}_target;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user