diff --git a/src/GUI/MapWidget.cxx b/src/GUI/MapWidget.cxx index 12686771b..b73bee8a8 100644 --- a/src/GUI/MapWidget.cxx +++ b/src/GUI/MapWidget.cxx @@ -388,23 +388,29 @@ namespace class MapAirportFilter : public FGAirport::AirportFilter { public: - MapAirportFilter(SGPropertyNode_ptr nd) + MapAirportFilter(SGPropertyNode_ptr nd) : + _heliports(nd->getBoolValue("draw-heliports", false)), + _hardRunwaysOnly( nd->getBoolValue("hard-surfaced-airports", true)), + _minLengthFt(fgGetDouble("/sim/navdb/min-runway-length-ft", 2000)) { - _heliports = nd->getBoolValue("show-heliports", false); - _hardRunwaysOnly = nd->getBoolValue("hard-surfaced-airports", true); - _minLengthFt = fgGetDouble("/sim/navdb/min-runway-length-ft", 2000); } - virtual FGPositioned::Type maxType() const { + FGPositioned::Type maxType() const override + { return _heliports ? FGPositioned::HELIPORT : FGPositioned::AIRPORT; } - virtual bool passAirport(FGAirport* aApt) const { - if (_hardRunwaysOnly) { + FGPositioned::Type minType() const override + { + return FGPositioned::AIRPORT; + } + + bool passAirport(FGAirport* aApt) const override + { + if (_hardRunwaysOnly && !aApt->isHeliport()) { return aApt->hasHardRunwayOfLengthFt(_minLengthFt); } - - return true; + return (aApt->type() <= maxType()) && (aApt->type() >= minType()); } void showAll() @@ -413,9 +419,9 @@ public: } private: - bool _heliports; + const bool _heliports; bool _hardRunwaysOnly; - double _minLengthFt; + const double _minLengthFt; }; class NavaidFilter : public FGPositioned::Filter @@ -1068,16 +1074,19 @@ void MapWidget::drawPositioned() FGPositionedRef p = _itemsToDraw[i]; switch (p->type()) { case FGPositioned::AIRPORT: - drawAirport((FGAirport*) p.get()); + drawAirport(fgpositioned_cast(p)); + break; + case FGPositioned::HELIPORT: + drawHeliport(fgpositioned_cast(p)); break; case FGPositioned::NDB: - drawNDB(false, (FGNavRecord*) p.get()); + drawNDB(false, fgpositioned_cast(p)); break; case FGPositioned::VOR: - drawVOR(false, (FGNavRecord*) p.get()); + drawVOR(false, fgpositioned_cast(p)); break; case FGPositioned::FIX: - drawFix((FGFix*) p.get()); + drawFix(fgpositioned_cast(p)); break; case FGPositioned::TOWN: case FGPositioned::CITY: @@ -1357,6 +1366,28 @@ void MapWidget::drawAirport(FGAirport* apt) } + +void MapWidget::drawHeliport(FGAirport* apt) +{ + SGVec2d pos = project(apt->geod()); + glLineWidth(1.0); + glColor3f(1.0, 0.0, 1.0); + circleAt(pos, 16, 5.0); + + if (validDataForKey(apt)) { + setAnchorForKey(apt, pos); + return; + } + + MapData* d = createDataForKey(apt); + d->setLabel(apt->ident()); + d->setPriority(40); + d->setOffset(MapData::VALIGN_CENTER | MapData::HALIGN_LEFT, 10); + d->setAnchor(pos); + +} + + int MapWidget::scoreAirportRunways(FGAirport* apt) { bool needHardSurface = _root->getBoolValue("hard-surfaced-airports", true); diff --git a/src/GUI/MapWidget.hxx b/src/GUI/MapWidget.hxx index 301789cc6..9a31cb298 100644 --- a/src/GUI/MapWidget.hxx +++ b/src/GUI/MapWidget.hxx @@ -70,6 +70,7 @@ private: bool drawLineClipped(const SGVec2d& a, const SGVec2d& b); void drawAirport(FGAirport* apt); + void drawHeliport(FGAirport* apt); int scoreAirportRunways(FGAirport* apt); void drawRunwayPre(FGRunway* rwy); void drawRunway(FGRunway* rwy);