#include <simgear/compiler.h>
#include <simgear/structure/commands.hxx>
+#include <simgear/props/props_io.hxx>
#include <Main/globals.hxx>
#include <GUI/gui.h> // mkDialog
#include <sstream>
-SG_USING_STD(ostringstream);
+using std::ostringstream;
FGATCDialog *current_atcdialog;
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]);
}
// 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)
//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];
// 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>)
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());
}
// (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);
}
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)
// 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
buf[7] = '\0';
entry->setStringValue("text[1]/label", buf);
-
- ostr.seekp(0);
n++;
}
}