1
0
Fork 0

Map dialog draws heliports now!

Patch from Daniel Wickstrom, with some style changes by James
This commit is contained in:
James Turner 2019-01-15 11:32:57 +00:00
parent 073e8927b9
commit 4deb61d0af
2 changed files with 47 additions and 15 deletions

View file

@ -388,23 +388,29 @@ namespace
class MapAirportFilter : public FGAirport::AirportFilter class MapAirportFilter : public FGAirport::AirportFilter
{ {
public: 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; return _heliports ? FGPositioned::HELIPORT : FGPositioned::AIRPORT;
} }
virtual bool passAirport(FGAirport* aApt) const { FGPositioned::Type minType() const override
if (_hardRunwaysOnly) { {
return FGPositioned::AIRPORT;
}
bool passAirport(FGAirport* aApt) const override
{
if (_hardRunwaysOnly && !aApt->isHeliport()) {
return aApt->hasHardRunwayOfLengthFt(_minLengthFt); return aApt->hasHardRunwayOfLengthFt(_minLengthFt);
} }
return (aApt->type() <= maxType()) && (aApt->type() >= minType());
return true;
} }
void showAll() void showAll()
@ -413,9 +419,9 @@ public:
} }
private: private:
bool _heliports; const bool _heliports;
bool _hardRunwaysOnly; bool _hardRunwaysOnly;
double _minLengthFt; const double _minLengthFt;
}; };
class NavaidFilter : public FGPositioned::Filter class NavaidFilter : public FGPositioned::Filter
@ -1068,16 +1074,19 @@ void MapWidget::drawPositioned()
FGPositionedRef p = _itemsToDraw[i]; FGPositionedRef p = _itemsToDraw[i];
switch (p->type()) { switch (p->type()) {
case FGPositioned::AIRPORT: case FGPositioned::AIRPORT:
drawAirport((FGAirport*) p.get()); drawAirport(fgpositioned_cast<FGAirport>(p));
break;
case FGPositioned::HELIPORT:
drawHeliport(fgpositioned_cast<FGAirport>(p));
break; break;
case FGPositioned::NDB: case FGPositioned::NDB:
drawNDB(false, (FGNavRecord*) p.get()); drawNDB(false, fgpositioned_cast<FGNavRecord>(p));
break; break;
case FGPositioned::VOR: case FGPositioned::VOR:
drawVOR(false, (FGNavRecord*) p.get()); drawVOR(false, fgpositioned_cast<FGNavRecord>(p));
break; break;
case FGPositioned::FIX: case FGPositioned::FIX:
drawFix((FGFix*) p.get()); drawFix(fgpositioned_cast<FGFix>(p));
break; break;
case FGPositioned::TOWN: case FGPositioned::TOWN:
case FGPositioned::CITY: 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) int MapWidget::scoreAirportRunways(FGAirport* apt)
{ {
bool needHardSurface = _root->getBoolValue("hard-surfaced-airports", true); bool needHardSurface = _root->getBoolValue("hard-surfaced-airports", true);

View file

@ -70,6 +70,7 @@ private:
bool drawLineClipped(const SGVec2d& a, const SGVec2d& b); bool drawLineClipped(const SGVec2d& a, const SGVec2d& b);
void drawAirport(FGAirport* apt); void drawAirport(FGAirport* apt);
void drawHeliport(FGAirport* apt);
int scoreAirportRunways(FGAirport* apt); int scoreAirportRunways(FGAirport* apt);
void drawRunwayPre(FGRunway* rwy); void drawRunwayPre(FGRunway* rwy);
void drawRunway(FGRunway* rwy); void drawRunway(FGRunway* rwy);