From: Christian Schmitt Date: Sun, 3 Mar 2013 23:27:12 +0000 (+0100) Subject: MapWidget: make use of the new POI system and display cities on the map. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=6bf47cd248ed388e6a4dd3ffa2d00977b00b62fb;p=flightgear.git MapWidget: make use of the new POI system and display cities on the map. This is meant as a preview. --- diff --git a/src/GUI/MapWidget.cxx b/src/GUI/MapWidget.cxx index 249605c6b..af0d854c5 100644 --- a/src/GUI/MapWidget.cxx +++ b/src/GUI/MapWidget.cxx @@ -607,6 +607,7 @@ void MapWidget::draw(int dx, int dy) drawAirports(); drawNavaids(); + drawPOIs(); drawTraffic(); drawGPSData(); drawNavRadio(fgGetNode("/instrumentation/nav[0]", false)); @@ -995,6 +996,20 @@ void MapWidget::drawNavaids() } // of navaids || fixes are drawn test } +void MapWidget::drawPOIs() +{ + FGPositioned::TypeFilter f(FGPositioned::CITY); + FGPositioned::List poi = FGPositioned::findWithinRange(_projectionCenter, _drawRangeNm, &f); + + glLineWidth(1.0); + for (unsigned int i=0; itype(); + if (ty == FGPositioned::CITY) { + drawCities((FGNavRecord*) poi[i].get()); + } + } // of navaid iteration +} + void MapWidget::drawNDB(bool tuned, FGNavRecord* ndb) { SGVec2d pos = project(ndb->geod()); @@ -1149,6 +1164,31 @@ void MapWidget::drawTunedLocalizer(SGPropertyNode_ptr radio) } } +void MapWidget::drawCities(FGNavRecord* rec) +{ + SGVec2d pos = project(rec->geod()); + glColor3f(1.0, 1.0, 1.0); + + circleAt(pos, 4, 8); + + if (validDataForKey(rec)) { + setAnchorForKey(rec, pos); + return; + } + + char buffer[1024]; + ::snprintf(buffer, 1024, "%s", + rec->name().c_str()); + + MapData* d = createDataForKey(rec); + d->setPriority(40); + d->setLabel(rec->ident()); + d->setText(buffer); + d->setOffset(MapData::HALIGN_CENTER | MapData::VALIGN_BOTTOM, 10); + d->setAnchor(pos); + +} + /* void MapWidget::drawObstacle(FGPositioned* obs) { diff --git a/src/GUI/MapWidget.hxx b/src/GUI/MapWidget.hxx index e855a2fce..73990f078 100644 --- a/src/GUI/MapWidget.hxx +++ b/src/GUI/MapWidget.hxx @@ -63,9 +63,12 @@ private: void drawILS(bool tuned, FGRunway* rwy); void drawNavaids(); + void drawPOIs(); void drawNDB(bool tuned, FGNavRecord* nav); void drawVOR(bool tuned, FGNavRecord* nav); void drawFix(FGFix* fix); + + void drawCities(FGNavRecord* rec); void drawTraffic(); void drawAIAircraft(const SGPropertyNode* model, const SGGeod& pos, double hdg);