]> git.mxchange.org Git - flightgear.git/commitdiff
ILS drawing in the airport diagram
authorJames Turner <zakalawe@mac.com>
Tue, 3 Nov 2015 22:05:09 +0000 (16:05 -0600)
committerJames Turner <zakalawe@mac.com>
Mon, 23 Nov 2015 00:47:01 +0000 (00:47 +0000)
src/GUI/AirportDiagram.cxx
src/GUI/AirportDiagram.hxx

index 07cd4f91e1637ba9c3804b6950dc65d10c089175..ab923603487745b336688605bc4caa2d0faac5ad 100644 (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)
index 61a015407c03bbe13fec9388ddab3c690d535878..08898350e980f0f49dbb63155190a1a892848353 100644 (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