]> git.mxchange.org Git - flightgear.git/blobdiff - src/ATCDCL/ATCDialog.cxx
Update VS2008 projects : use Boost 1.44.0 available in last 3rd Party archive
[flightgear.git] / src / ATCDCL / ATCDialog.cxx
index 80d7edce0ca0dd371a5f41079282deb06069be05..f5f5ec935d3f337e7b1efe4ad1cb7b2e613d503b 100644 (file)
@@ -25,6 +25,7 @@
 #include <simgear/compiler.h>
 
 #include <simgear/structure/commands.hxx>
+#include <simgear/props/props_io.hxx>
 
 #include <Main/globals.hxx>
 #include <GUI/gui.h>           // mkDialog
@@ -65,7 +66,7 @@ ATCMenuEntry::ATCMenuEntry() {
 ATCMenuEntry::~ATCMenuEntry() {
 }
 
-static void atcUppercase(string &s) {
+void atcUppercase(string &s) {
        for(unsigned int i=0; i<s.size(); ++i) {
                s[i] = toupper(s[i]);
        }
@@ -238,7 +239,7 @@ void FGATCDialog::PopupDialog() {
                // add transmission button (modified copy of <button-template>)
                SGPropertyNode *entry = button_group->getNode("button", n, true);
                copyProperties(button_group->getNode("button-template", true), entry);
-               entry->removeChildren("hide", false);
+               entry->removeChildren("enabled", true);
                entry->setStringValue("property", buf);
                entry->setIntValue("keynum", '1' + n);
                if (n == 0)
@@ -265,7 +266,7 @@ void FGATCDialog::PopupCallback(int num) {
                //cout << "TOWER " << endl;
                //cout << "ident is " << atcptr->get_ident() << endl;
                atcmentry_vec_type atcmlist = (available_dialog[TOWER])[atcptr->get_ident()];
-               unsigned int size = atcmlist.size();
+               int size = atcmlist.size();
                if(size && num < size) {
                        //cout << "Doing callback...\n";
                        ATCMenuEntry a = atcmlist[num];
@@ -317,22 +318,19 @@ void FGATCDialog::FreqDialog() {
        // Find the ATC stations within a reasonable range
        comm_list_type atc_stations;
        comm_list_iterator atc_stat_itr;
-       
-       double lon = fgGetDouble("/position/longitude-deg");
-       double lat = fgGetDouble("/position/latitude-deg");
-       double elev = fgGetDouble("/position/altitude-ft");
-       Point3D aircraft = sgGeodToCart(Point3D(lon * SGD_DEGREES_TO_RADIANS,
-               lat * SGD_DEGREES_TO_RADIANS, elev));
+
+  SGGeod geod(SGGeod::fromDegFt(fgGetDouble("/position/longitude-deg"),
+    fgGetDouble("/position/latitude-deg"), fgGetDouble("/position/altitude-ft")));
+       SGVec3d aircraft = SGVec3d::fromGeod(geod);
 
        // search stations in range
-       int num_stat = current_commlist->FindByPos(lon, lat, elev, 50.0, &atc_stations);
+       int num_stat = current_commlist->FindByPos(geod, 50.0, &atc_stations);
        if (num_stat != 0) {
                map<atcdata, bool> uniq;
                // fill map (sorts by distance and removes duplicates)
                comm_list_iterator itr = atc_stations.begin();
                for (; itr != atc_stations.end(); ++itr) {
-                       Point3D station = Point3D(itr->x, itr->y, itr->z);
-                       double distance = aircraft.distance3Dsquared(station);
+                       double distance = distSqr(aircraft, itr->cart);
                        uniq[atcdata(itr->ident, itr->name, distance)] = true;
                }
                // create button per map entry (modified copy of <button-template>)
@@ -340,7 +338,7 @@ void FGATCDialog::FreqDialog() {
                for (int n = 0; uit != uniq.end() && n < 6; ++uit, ++n) { // max 6 buttons
                        SGPropertyNode *entry = button_group->getNode("button", n, true);
                        copyProperties(button_group->getNode("button-template", true), entry);
-                       entry->removeChildren("hide", false);
+                       entry->removeChildren("enabled", true);
                        entry->setStringValue("legend", uit->first.id.c_str());
                        entry->setStringValue("binding[0]/value", uit->first.id.c_str());
                }
@@ -348,7 +346,7 @@ void FGATCDialog::FreqDialog() {
 
        // (un)hide message saying no things in range
        SGPropertyNode_ptr range_error = getNamedNode(dlg, "no-atc-in-range");
-       range_error->setBoolValue("hide", num_stat);
+       range_error->setBoolValue("enabled", !num_stat);
 
        _gui->showDialog(dialog_name);
 }
@@ -382,9 +380,8 @@ void FGATCDialog::FreqDisplay(string& ident) {
        int n = 0;      // Number of ATC frequencies at this airport
 
        comm_list_type stations;
-       int found = current_commlist->FindByPos(a->getLongitude(), a->getLatitude(), a->getElevation(), 20.0, &stations);
+       int found = current_commlist->FindByPos(a->geod(), 20.0, &stations);
        if(found) {
-               ostringstream ostr;
                comm_list_iterator itr = stations.begin();
                for (n = 0; itr != stations.end(); ++itr) {
                        if(itr->ident != ident)
@@ -396,10 +393,11 @@ void FGATCDialog::FreqDisplay(string& ident) {
                        // add frequency line (modified copy of <group-template>)
                        SGPropertyNode *entry = freq_group->getNode("group", n, true);
                        copyProperties(freq_group->getNode("group-template", true), entry);
-                       entry->removeChildren("hide", false);
+                       entry->removeChildren("enabled", true);
 
+                       ostringstream ostr;
                        ostr << itr->type;
-                       entry->setStringValue("text[0]/label", ostr.str().c_str());
+                       entry->setStringValue("text[0]/label", ostr.str());
 
                        char buf[8];
                        snprintf(buf, 8, "%.2f", (itr->freq / 100.0));  // Convert from KHz to MHz
@@ -408,8 +406,6 @@ void FGATCDialog::FreqDisplay(string& ident) {
                        buf[7] = '\0';
 
                        entry->setStringValue("text[1]/label", buf);
-
-                       ostr.seekp(0);
                        n++;
                }
        }