]> git.mxchange.org Git - flightgear.git/commitdiff
MapWidget: Show counties and towns as well, depending on the zoom.
authorChristian Schmitt <chris@ilovelinux.de>
Tue, 5 Mar 2013 17:24:44 +0000 (18:24 +0100)
committerChristian Schmitt <chris@ilovelinux.de>
Tue, 5 Mar 2013 17:26:01 +0000 (18:26 +0100)
Some colors added.

src/GUI/MapWidget.cxx
src/GUI/MapWidget.hxx
src/Navaids/positioned.cxx

index af0d854c5ea0fb0817c42f9315bbb221c20c75a0..c0d1c0376810e0c51ef9f474b6db09008344d2d2 100644 (file)
@@ -375,6 +375,7 @@ int MapData::_fontDescender = 0;
 
 const int MAX_ZOOM = 12;
 const int SHOW_DETAIL_ZOOM = 8;
+const int SHOW_DETAIL2_ZOOM = 5;
 const int CURSOR_PAN_STEP = 32;
 
 MapWidget::MapWidget(int x, int y, int maxX, int maxY) :
@@ -998,14 +999,20 @@ void MapWidget::drawNavaids()
 
 void MapWidget::drawPOIs()
 {
-  FGPositioned::TypeFilter f(FGPositioned::CITY);
+  FGPositioned::TypeFilter f(FGPositioned::COUNTRY);
+  f.addType(FGPositioned::CITY);
+  f.addType(FGPositioned::TOWN);
   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) {
+      if (ty == FGPositioned::COUNTRY) {
+        drawCountries((FGNavRecord*) poi[i].get());
+      } else if (ty == FGPositioned::CITY) {
         drawCities((FGNavRecord*) poi[i].get());
+      } else if (ty == FGPositioned::TOWN) {
+        drawTowns((FGNavRecord*) poi[i].get());
       }
     } // of navaid iteration
 }
@@ -1164,10 +1171,43 @@ void MapWidget::drawTunedLocalizer(SGPropertyNode_ptr radio)
   }
 }
 
+void MapWidget::drawCountries(FGNavRecord* rec)
+{
+  if (_cachedZoom < 9) {
+    return; // hide labels beyond a certain zoom level
+  }
+
+  SGVec2d pos = project(rec->geod());
+  glColor3f(1.0, 1.0, 0.0);
+
+  circleAt(pos, 4, 10);
+
+  if (validDataForKey(rec)) {
+    setAnchorForKey(rec, pos);
+    return;
+  }
+
+  char buffer[1024];
+        ::snprintf(buffer, 1024, "%s",
+                rec->name().c_str());
+
+  MapData* d = createDataForKey(rec);
+  d->setPriority(200);
+  d->setLabel(rec->ident());
+  d->setText(buffer);
+  d->setOffset(MapData::HALIGN_CENTER | MapData::VALIGN_BOTTOM, 10);
+  d->setAnchor(pos);
+
+}
+
 void MapWidget::drawCities(FGNavRecord* rec)
 {
+  if (_cachedZoom > SHOW_DETAIL_ZOOM) {
+    return; // hide labels beyond a certain zoom level
+  }
+
   SGVec2d pos = project(rec->geod());
-  glColor3f(1.0, 1.0, 1.0);
+  glColor3f(0.0, 1.0, 0.0);
 
   circleAt(pos, 4, 8);
 
@@ -1189,6 +1229,35 @@ void MapWidget::drawCities(FGNavRecord* rec)
 
 }
 
+void MapWidget::drawTowns(FGNavRecord* rec)
+{
+  if (_cachedZoom > SHOW_DETAIL2_ZOOM) {
+    return; // hide labels beyond a certain zoom level
+  }
+
+  SGVec2d pos = project(rec->geod());
+  glColor3f(0.2, 1.0, 0.0);
+
+  circleAt(pos, 4, 5);
+
+  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)
 {
@@ -1442,7 +1511,7 @@ void MapWidget::drawHelipad(FGHelipad* hp)
 {
   SGVec2d pos = project(hp->geod());
   glLineWidth(1.0);
-  glColor3f(1.0, 1.0, 1.0);
+  glColor3f(1.0, 0.0, 1.0);
   circleAt(pos, 16, 5.0);
 
   if (validDataForKey(hp)) {
index 73990f078900245622341eff0708a60221f181b6..780ff2e12ca633574617e0ccafa58e587660d27c 100644 (file)
@@ -68,7 +68,9 @@ private:
   void drawVOR(bool tuned, FGNavRecord* nav);
   void drawFix(FGFix* fix);
 
+  void drawCountries(FGNavRecord* rec);
   void drawCities(FGNavRecord* rec);
+  void drawTowns(FGNavRecord* rec);
   
   void drawTraffic();
   void drawAIAircraft(const SGPropertyNode* model, const SGGeod& pos, double hdg);
index f6b706fd38e233f5d49cd0459d58281692307019..29e0ee0a466ddf7af831380f0c368b7f3693aa7a 100644 (file)
@@ -360,7 +360,9 @@ FGPositioned::TypeFilter::pass(FGPositioned* aPos) const
     std::vector<Type>::const_iterator it = types.begin(),
         end = types.end();
     for (; it != end; ++it) {
-        return aPos->type() == *it;
+        if (aPos->type() == *it) {
+            return true;
+        }
     }
     
     return false;