]> git.mxchange.org Git - flightgear.git/commitdiff
MapWidget: make use of the new POI system and display cities on the map.
authorChristian Schmitt <chris@ilovelinux.de>
Sun, 3 Mar 2013 23:27:12 +0000 (00:27 +0100)
committerChristian Schmitt <chris@ilovelinux.de>
Sun, 3 Mar 2013 23:27:12 +0000 (00:27 +0100)
This is meant as a preview.

src/GUI/MapWidget.cxx
src/GUI/MapWidget.hxx

index 249605c6bfe7f9ac9859cf76c71e0e49a51ac5ed..af0d854c5ea0fb0817c42f9315bbb221c20c75a0 100644 (file)
@@ -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; i<poi.size(); ++i) {
+      FGPositioned::Type ty = poi[i]->type();
+      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)
 {
index e855a2fce16d891c341296a0f0fa74049602c3af..73990f078900245622341eff0708a60221f181b6 100644 (file)
@@ -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);