1
0
Fork 0

ILS drawing in the airport diagram

This commit is contained in:
James Turner 2015-11-03 16:05:09 -06:00
parent 09cac14089
commit addcc432fd
2 changed files with 47 additions and 1 deletions

View file

@ -22,6 +22,8 @@
#include <limits>
#include <simgear/sg_inlines.h>
#include <QPainter>
#include <QDebug>
#include <QVector2D>
@ -32,6 +34,8 @@
#include <Airports/parking.hxx>
#include <Airports/pavement.hxx>
#include <Navaids/navrecord.hxx>
static double distanceToLineSegment(const QVector2D& p, const QVector2D& a,
const QVector2D& b, double* outT = NULL)
{
@ -206,7 +210,19 @@ void AirportDiagram::paintContents(QPainter* p)
f.setPixelSize(14);
p->setFont(f);
// draw ILS first so underneath all runways
QPen pen(Qt::magenta);
pen.setWidth(1.0 / m_scale);
p->setPen(pen);
Q_FOREACH(const RunwayData& r, m_runways) {
drawILS(p, r.runway);
drawILS(p, r.runway->reciprocalRunway());
}
// now draw the runways for real
Q_FOREACH(const RunwayData& r, m_runways) {
QColor color(Qt::magenta);
if ((r.runway == m_selectedRunway) || (r.runway->reciprocalRunway() == m_selectedRunway)) {
color = Qt::yellow;
@ -249,12 +265,40 @@ void AirportDiagram::paintContents(QPainter* p)
double d = SG_NM_TO_METER * m_approachDistanceNm;
QPointF pt = project(m_selectedRunway->pointOnCenterline(-d));
QPointF pt2 = project(m_selectedRunway->geod());
QPen pen(Qt::yellow, 10);
QPen pen(Qt::yellow);
pen.setWidth(2.0 / m_scale);
p->setPen(pen);
p->drawLine(pt, pt2);
}
}
void AirportDiagram::drawILS(QPainter* painter, FGRunwayRef runway) const
{
if (!runway)
return;
FGNavRecord* loc = runway->ILS();
if (!loc)
return;
double halfBeamWidth = loc->localizerWidth() * 0.5;
QPointF threshold = project(runway->threshold());
double rangeM = loc->get_range() * SG_NM_TO_METER;
double radial = loc->get_multiuse();
SG_NORMALIZE_RANGE(radial, 0.0, 360.0);
// compute the three end points at the wide end of the arrow
QPointF endCentre = project(SGGeodesy::direct(loc->geod(), radial, -rangeM));
QPointF endR = project(SGGeodesy::direct(loc->geod(), radial + halfBeamWidth, -rangeM * 1.1));
QPointF endL = project(SGGeodesy::direct(loc->geod(), radial - halfBeamWidth, -rangeM * 1.1));
painter->drawLine(threshold, endCentre);
painter->drawLine(threshold, endL);
painter->drawLine(threshold, endR);
painter->drawLine(endL, endCentre);
painter->drawLine(endR, endCentre);
}
void AirportDiagram::mouseReleaseEvent(QMouseEvent* me)
{
if (m_didPan)

View file

@ -92,6 +92,8 @@ private:
double m_approachDistanceNm;
FGRunwayRef m_selectedRunway;
void drawILS(QPainter *painter, FGRunwayRef runway) const;
};
#endif // of GUI_AIRPORT_DIAGRAM_HXX