slide display ok
This commit is contained in:
+2
-1
@@ -88,7 +88,8 @@ MainWindow::~MainWindow()
|
||||
|
||||
void MainWindow::resizeEvent(QResizeEvent *e)
|
||||
{
|
||||
qDebug() << e;
|
||||
//qDebug() << e;
|
||||
Q_UNUSED(e);
|
||||
|
||||
nav->setGeometry(0,0,50,this->height());
|
||||
|
||||
|
||||
+65
-24
@@ -658,15 +658,15 @@ void Cockpit::drawLeftScale(QPainter *painter)
|
||||
static const QPointF points1[11] = {
|
||||
QPointF( 0,-50),
|
||||
QPointF(200,-50),
|
||||
QPointF(200,-100),
|
||||
QPointF(275,-100),
|
||||
QPointF(200,-125),
|
||||
QPointF(275,-125),
|
||||
|
||||
QPointF(275,-25),
|
||||
QPointF(290, 0),
|
||||
QPointF(275, 25),
|
||||
|
||||
QPointF(275, 100),
|
||||
QPointF(200, 100),
|
||||
QPointF(275, 125),
|
||||
QPointF(200, 125),
|
||||
QPointF(200, 50),
|
||||
QPointF( 0, 50)
|
||||
};
|
||||
@@ -692,12 +692,9 @@ void Cockpit::drawLeftScale(QPainter *painter)
|
||||
//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 = (m_Attitude.airspeed - int(m_Attitude.airspeed));
|
||||
float Decimal = qAbs(m_Attitude.airspeed - int(m_Attitude.airspeed));
|
||||
|
||||
|
||||
qDebug() << Unit;
|
||||
//UnitText.clear();
|
||||
|
||||
|
||||
int count = 1;
|
||||
for(int i = -1.5 - Unit;i<(1.5 - Unit);i+=1)
|
||||
@@ -713,19 +710,36 @@ void Cockpit::drawLeftScale(QPainter *painter)
|
||||
painter->setPen(ePen);
|
||||
painter->setFont(font);
|
||||
|
||||
painter->translate(200,(i + Unit) * 100 - 50);
|
||||
|
||||
//偏移坐标需要修正,现在画的时候从左上开始,因此,总有一个会显示不出来
|
||||
painter->translate(200,(i + Unit) * 120 - 60);
|
||||
|
||||
//此段程序在未理解之前,请不要随意修改
|
||||
switch (count) {
|
||||
case 1:
|
||||
painter->drawText(QRect(0,0,100,90 *(Decimal - 0.5)),Qt::AlignVCenter|Qt::AlignLeft, strText);
|
||||
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,100,90),Qt::AlignVCenter|Qt::AlignLeft, strText);
|
||||
painter->drawText(QRect(0,0,60,120),Qt::AlignVCenter|Qt::AlignLeft, strText);
|
||||
break;
|
||||
case 3:
|
||||
painter->drawText(QRect(0,0,100,90 *(Decimal + 0.5)),Qt::AlignVCenter|Qt::AlignLeft, strText);
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -868,27 +882,58 @@ void Cockpit::drawRightScale(QPainter *painter)
|
||||
//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 = (m_Attitude.airspeed - int(m_Attitude.airspeed));
|
||||
float Decimal = qAbs(m_Attitude.airspeed - int(m_Attitude.airspeed));
|
||||
|
||||
|
||||
//qDebug() << Unit;
|
||||
for(int i = -2 - Unit;i<(2 - 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();
|
||||
|
||||
QPen ePen;
|
||||
QFont font;
|
||||
ePen.setColor(m_CentreLineColor);
|
||||
ePen.setWidth(15);
|
||||
font.setPointSize(90);
|
||||
|
||||
painter->setPen(ePen);
|
||||
painter->setFont(font);
|
||||
painter->drawText(QRect(200,(i + Unit) * 100 - 50,100,90),Qt::AlignVCenter|Qt::AlignLeft, strText);
|
||||
|
||||
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
|
||||
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++;
|
||||
|
||||
|
||||
|
||||
@@ -897,10 +942,6 @@ void Cockpit::drawRightScale(QPainter *painter)
|
||||
}
|
||||
|
||||
|
||||
//painter->restore();
|
||||
|
||||
|
||||
|
||||
|
||||
painter->restore();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user