From: James Turner Date: Tue, 3 Nov 2015 22:05:09 +0000 (-0600) Subject: ILS drawing in the airport diagram X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=addcc432fd79440d6a0dc45a1f5299448d9d3de0;p=flightgear.git ILS drawing in the airport diagram --- diff --git a/src/GUI/AirportDiagram.cxx b/src/GUI/AirportDiagram.cxx index 07cd4f91e..ab9236034 100644 --- a/src/GUI/AirportDiagram.cxx +++ b/src/GUI/AirportDiagram.cxx @@ -22,6 +22,8 @@ #include +#include + #include #include #include @@ -32,6 +34,8 @@ #include #include +#include + 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) diff --git a/src/GUI/AirportDiagram.hxx b/src/GUI/AirportDiagram.hxx index 61a015407..08898350e 100644 --- a/src/GUI/AirportDiagram.hxx +++ b/src/GUI/AirportDiagram.hxx @@ -92,6 +92,8 @@ private: double m_approachDistanceNm; FGRunwayRef m_selectedRunway; + + void drawILS(QPainter *painter, FGRunwayRef runway) const; }; #endif // of GUI_AIRPORT_DIAGRAM_HXX