]> git.mxchange.org Git - flightgear.git/blobdiff - src/GUI/MapWidget.cxx
Expose more runway methods to Nasal
[flightgear.git] / src / GUI / MapWidget.cxx
index 41525cde25059a85facca8b132e48f7e95951a63..249605c6bfe7f9ac9859cf76c71e0e49a51ac5ed 100644 (file)
@@ -21,7 +21,7 @@
 #include <Navaids/navrecord.hxx>
 #include <Navaids/navlist.hxx>
 #include <Navaids/fix.hxx>
-#include <Airports/simple.hxx>
+#include <Airports/airport.hxx>
 #include <Airports/runways.hxx>
 #include <Main/fg_os.hxx>      // fgGetKeyModifiers()
 #include <Navaids/routePath.hxx>
@@ -537,8 +537,7 @@ void MapWidget::zoomOut()
 
 void MapWidget::draw(int dx, int dy)
 {
-  _aircraft = SGGeod::fromDeg(fgGetDouble("/position/longitude-deg"),
-    fgGetDouble("/position/latitude-deg"));
+  _aircraft = globals->get_aircraft_position();
     
   bool mag = _root->getBoolValue("magnetic-headings");
   if (mag != _magneticHeadings) {
@@ -936,7 +935,8 @@ private:
 void MapWidget::drawAirports()
 {
   MapAirportFilter af(_root);
-  FGPositioned::List apts = FGPositioned::findWithinRange(_projectionCenter, _drawRangeNm, &af);
+  bool partial = false;
+  FGPositioned::List apts = FGPositioned::findWithinRangePartial(_projectionCenter, _drawRangeNm, &af, partial);
   for (unsigned int i=0; i<apts.size(); ++i) {
     drawAirport((FGAirport*) apts[i].get());
   }
@@ -1194,23 +1194,32 @@ void MapWidget::drawAirport(FGAirport* apt)
     return;
   }
 
-  for (unsigned int r=0; r<apt->numRunways(); ++r) {
-    FGRunway* rwy = apt->getRunwayByIndex(r);
-               if (!rwy->isReciprocal()) {
-                       drawRunwayPre(rwy);
-               }
+  FGRunwayList runways(apt->getRunwaysWithoutReciprocals());
+    
+  for (unsigned int r=0; r<runways.size(); ++r) {
+    drawRunwayPre(runways[r]);
   }
 
-       for (unsigned int r=0; r<apt->numRunways(); ++r) {
-               FGRunway* rwy = apt->getRunwayByIndex(r);
-               if (!rwy->isReciprocal()) {
-                       drawRunway(rwy);
-               }
+  for (unsigned int r=0; r<runways.size(); ++r) {
+    FGRunway* rwy = runways[r];
+    drawRunway(rwy);
 
-               if (rwy->ILS()) {
-                       drawILS(false, rwy);
-               }
-       } // of runway iteration
+    if (rwy->ILS()) {
+        drawILS(false, rwy);
+    }
+    
+    if (rwy->reciprocalRunway()) {
+      FGRunway* recip = rwy->reciprocalRunway();
+      if (recip->ILS()) {
+        drawILS(false, recip);
+      }
+    }
+  }
+
+  for (unsigned int r=0; r<apt->numHelipads(); ++r) {
+      FGHelipad* hp = apt->getHelipadByIndex(r);
+      drawHelipad(hp);
+  }  // of runway iteration
 
 }
 
@@ -1219,14 +1228,11 @@ int MapWidget::scoreAirportRunways(FGAirport* apt)
   bool needHardSurface = _root->getBoolValue("hard-surfaced-airports", true);
   double minLength = _root->getDoubleValue("min-runway-length-ft", 2000.0);
 
-  int score = 0;
-  unsigned int numRunways(apt->numRunways());
-  for (unsigned int r=0; r<numRunways; ++r) {
-    FGRunway* rwy = apt->getRunwayByIndex(r);
-    if (rwy->isReciprocal()) {
-      continue;
-    }
+  FGRunwayList runways(apt->getRunwaysWithoutReciprocals());
 
+  int score = 0;
+  for (unsigned int r=0; r<runways.size(); ++r) {
+    FGRunway* rwy = runways[r];
     if (needHardSurface && !rwy->isHardSurface()) {
       continue;
     }
@@ -1392,6 +1398,32 @@ void MapWidget::drawTraffic()
   } // of ai/models iteration
 }
 
+void MapWidget::drawHelipad(FGHelipad* hp)
+{
+  SGVec2d pos = project(hp->geod());
+  glLineWidth(1.0);
+  glColor3f(1.0, 1.0, 1.0);
+  circleAt(pos, 16, 5.0);
+
+  if (validDataForKey(hp)) {
+    setAnchorForKey(hp, pos);
+    return;
+  }
+
+  char buffer[1024];
+  ::snprintf(buffer, 1024, "%s\n%03d\n%.0f'",
+             hp->ident().c_str(),
+             displayHeading(hp->headingDeg()),
+             hp->lengthFt());
+
+  MapData* d = createDataForKey(hp);
+  d->setText(buffer);
+  d->setLabel(hp->ident());
+  d->setPriority(40);
+  d->setOffset(MapData::HALIGN_CENTER | MapData::VALIGN_BOTTOM, 8);
+  d->setAnchor(pos);
+}
+
 void MapWidget::drawAIAircraft(const SGPropertyNode* model, const SGGeod& pos, double hdg)
 {