]> git.mxchange.org Git - flightgear.git/blobdiff - src/ATCDCL/ATCDialog.cxx
Initial commit of the new sound system, expect more updates to follow
[flightgear.git] / src / ATCDCL / ATCDialog.cxx
index 4902947bc995b01a924fc54381ee70215dec0f33..f094b1170cc82893a419028af4a11e132cd890ce 100644 (file)
@@ -66,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]);
        }
@@ -239,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)
@@ -266,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];
@@ -318,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>)
@@ -341,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());
                }
@@ -349,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);
 }
@@ -383,7 +380,7 @@ 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();
@@ -397,7 +394,7 @@ 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);
 
                        ostr << itr->type;
                        entry->setStringValue("text[0]/label", ostr.str().c_str());