mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-05-04 08:55:43 +08:00
Ref T736 Refactor CRadarComponent so the polar-to-cartesian conversion happens in one place only.
This commit is contained in:
committed by
Klaus Basan
parent
6d1f0328bf
commit
7b538a560a
@@ -133,7 +133,7 @@ namespace BlackGui
|
|||||||
|
|
||||||
for (qreal angle = 0.0; angle < 359.0; angle += 30.0)
|
for (qreal angle = 0.0; angle < 359.0; angle += 30.0)
|
||||||
{
|
{
|
||||||
const QLineF line(0.0, 0.0, 100.0 * qCos(qDegreesToRadians(angle)), -100.0 * qSin(qDegreesToRadians(angle)));
|
const QLineF line({ 0.0, 0.0 }, polarPoint(100.0, qDegreesToRadians(angle)));
|
||||||
QGraphicsLineItem *li = new QGraphicsLineItem(line, &m_radials);
|
QGraphicsLineItem *li = new QGraphicsLineItem(line, &m_radials);
|
||||||
li->setPen(pen);
|
li->setPen(pen);
|
||||||
}
|
}
|
||||||
@@ -156,7 +156,7 @@ namespace BlackGui
|
|||||||
const double bearingRad = sa.getRelativeBearing().value(CAngleUnit::rad());
|
const double bearingRad = sa.getRelativeBearing().value(CAngleUnit::rad());
|
||||||
const int groundSpeedKts = sa.getGroundSpeed().valueInteger(CSpeedUnit::kts());
|
const int groundSpeedKts = sa.getGroundSpeed().valueInteger(CSpeedUnit::kts());
|
||||||
|
|
||||||
QPointF position(distanceNM * qSin(bearingRad), -distanceNM * qCos(bearingRad));
|
QPointF position(polarPoint(distanceNM, bearingRad));
|
||||||
|
|
||||||
QGraphicsEllipseItem *dot = new QGraphicsEllipseItem(-2.0, -2.0, 4.0, 4.0, &m_radarTargets);
|
QGraphicsEllipseItem *dot = new QGraphicsEllipseItem(-2.0, -2.0, 4.0, 4.0, &m_radarTargets);
|
||||||
dot->setPos(position);
|
dot->setPos(position);
|
||||||
@@ -191,7 +191,7 @@ namespace BlackGui
|
|||||||
double headingRad = sa.getHeading().value(CAngleUnit::rad());
|
double headingRad = sa.getHeading().value(CAngleUnit::rad());
|
||||||
QPen pen(Qt::green, 1);
|
QPen pen(Qt::green, 1);
|
||||||
pen.setCosmetic(true);
|
pen.setCosmetic(true);
|
||||||
QGraphicsLineItem *li = new QGraphicsLineItem(QLineF(0.0, 0.0, 20.0 * qSin(headingRad), -20.0 * qCos(headingRad)), dot);
|
QGraphicsLineItem *li = new QGraphicsLineItem(QLineF({ 0.0, 0.0 }, polarPoint(20.0, headingRad)), dot);
|
||||||
li->setFlags(QGraphicsItem::ItemIgnoresTransformations);
|
li->setFlags(QGraphicsItem::ItemIgnoresTransformations);
|
||||||
li->setPen(pen);
|
li->setPen(pen);
|
||||||
}
|
}
|
||||||
@@ -282,7 +282,11 @@ namespace BlackGui
|
|||||||
if (!myself) { return; }
|
if (!myself) { return; }
|
||||||
myself->refreshTargets();
|
myself->refreshTargets();
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
QPointF CRadarComponent::polarPoint(double distance, double angleRadians)
|
||||||
|
{
|
||||||
|
return { distance * qSin(angleRadians), -distance * qCos(angleRadians) };
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|||||||
@@ -57,6 +57,8 @@ namespace BlackGui
|
|||||||
void changeRangeInSteps(bool zoomIn);
|
void changeRangeInSteps(bool zoomIn);
|
||||||
void changeRangeFromUserSelection(int index);
|
void changeRangeFromUserSelection(int index);
|
||||||
|
|
||||||
|
static QPointF polarPoint(double distance, double angleRadians);
|
||||||
|
|
||||||
//! Info area tab bar has changed
|
//! Info area tab bar has changed
|
||||||
void onInfoAreaTabBarChanged(int index);
|
void onInfoAreaTabBarChanged(int index);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user