]> git.mxchange.org Git - flightgear.git/blobdiff - src/ATCDCL/ATCDialogOld.cxx
ITM radio calculations are only considered valid
[flightgear.git] / src / ATCDCL / ATCDialogOld.cxx
index bb3cc1650fa46eefd11cb9f854e43d2fa61a72e1..8a6ced12811859b5b96fb0385c2354cf7867735f 100644 (file)
@@ -30,6 +30,7 @@
 #include <Main/globals.hxx>
 #include <GUI/gui.h>           // mkDialog
 #include <GUI/new_gui.hxx>
+#include <Main/fg_props.hxx>
 
 #include "ATCDialogOld.hxx"
 #include "ATC.hxx"
@@ -47,6 +48,7 @@ using std::endl;
 FGATCDialog *current_atcdialog;
 
 // For the command manager - maybe eventually this should go in the built in command list
+#if 0
 static bool do_ATC_dialog(const SGPropertyNode* arg) {
         cerr << "Running ATCDCL do_ATC_dialog" << endl;
        current_atcdialog->PopupDialog();
@@ -57,6 +59,7 @@ static bool do_ATC_freq_search(const SGPropertyNode* arg) {
        current_atcdialog->FreqDialog();
        return(true);
 }
+#endif
 
 ATCMenuEntry::ATCMenuEntry() {
   stationid    = "";
@@ -205,7 +208,13 @@ void FGATCDialog::PopupDialog() {
        button_group->removeChildren("button", false);
 
        string label;
-       FGATC* atcptr = globals->get_ATC_mgr()->GetComm1ATCPointer();   // Hardwired to comm1 at the moment
+       FGATCMgr* pAtcMgr = globals->get_ATC_mgr();
+       if (!pAtcMgr)
+       {
+           SG_LOG(SG_ATC, SG_ALERT, "ERROR! No ATC manager! Oops...");
+           return;
+       }
+       FGATC* atcptr = pAtcMgr->GetComm1ATCPointer();  // Hardwired to comm1 at the moment
 
        if (!atcptr) {
                label = "Not currently tuned to any ATC service";
@@ -260,7 +269,13 @@ void FGATCDialog::PopupDialog() {
 }
 
 void FGATCDialog::PopupCallback(int num) {
-       FGATC* atcptr = globals->get_ATC_mgr()->GetComm1ATCPointer();   // FIXME - Hardwired to comm1 at the moment
+    FGATCMgr* pAtcMgr = globals->get_ATC_mgr();
+    if (!pAtcMgr)
+    {
+        SG_LOG(SG_ATC, SG_ALERT, "ERROR! No ATC manager! Oops...");
+        return;
+    }
+       FGATC* atcptr = pAtcMgr->GetComm1ATCPointer();  // FIXME - Hardwired to comm1 at the moment
 
        if (!atcptr)
                return;
@@ -289,108 +304,5 @@ void FGATCDialog::PopupCallback(int num) {
        }
 }
 
-class AirportsWithATC : public FGAirport::AirportFilter
-{
-public:
-    virtual FGPositioned::Type maxType() const {
-      return FGPositioned::SEAPORT;
-    }
-  
-    virtual bool passAirport(FGAirport* aApt) const
-    {
-      return (!aApt->commStations().empty());
-    }
-};
-
-void FGATCDialog::FreqDialog() {
-       const char *dialog_name = "atc-freq-search";
-       SGPropertyNode_ptr dlg = _gui->getDialogProperties(dialog_name);
-       if (!dlg)
-               return;
-
-       _gui->closeDialog(dialog_name);
 
-       SGPropertyNode_ptr button_group = getNamedNode(dlg, "quick-buttons");
-       // remove all dynamic airport/ATC buttons
-       button_group->removeChildren("button", false);
-
-
-  SGGeod geod(SGGeod::fromDegFt(fgGetDouble("/position/longitude-deg"),
-    fgGetDouble("/position/latitude-deg"), fgGetDouble("/position/altitude-ft")));
-
-    AirportsWithATC filt;
-    FGPositioned::List results = FGPositioned::findWithinRange(geod, 50.0, &filt);
-    FGPositioned::sortByRange(results, geod);
-    for (unsigned int r=0; (r<results.size()) && (r < 6); ++r) {
-      
-        SGPropertyNode *entry = button_group->getNode("button", r, true);
-               copyProperties(button_group->getNode("button-template", true), entry);
-               entry->removeChildren("enabled", true);
-               entry->setStringValue("legend", results[r]->ident());
-               entry->setStringValue("binding[0]/value", results[r]->ident());
-    }
-    
-       // (un)hide message saying no things in range
-       SGPropertyNode_ptr range_error = getNamedNode(dlg, "no-atc-in-range");
-       range_error->setBoolValue("enabled", !results.empty());
-
-       _gui->showDialog(dialog_name);
-}
-
-void FGATCDialog::FreqDisplay(string& ident) {
-       const char *dialog_name = "atc-freq-display";
-       SGPropertyNode_ptr dlg = _gui->getDialogProperties(dialog_name);
-       if (!dlg)
-               return;
-
-       _gui->closeDialog(dialog_name);
-
-       SGPropertyNode_ptr freq_group = getNamedNode(dlg, "frequency-list");
-       // remove all frequency entries
-       freq_group->removeChildren("group", false);
-
-       atcUppercase(ident);
-       string label;
-
-       const FGAirport *a = fgFindAirportID(ident);
-       if (!a) {
-               label = "Airport " + ident + " not found in database.";
-               mkDialog(label.c_str());
-               return;
-       }
-
-       // set title
-       label = ident + " Frequencies";
-       dlg->setStringValue("text/label", label.c_str());
-
-    const flightgear::CommStationList& comms(a->commStations());
-    if (comms.empty()) {
-        label = "No frequencies found for airport " + ident;
-               mkDialog(label.c_str());
-               return;
-    }
-    
-    int n = 0;
-    for (unsigned int c=0; c < comms.size(); ++c) {
-        flightgear::CommStation* comm = comms[c];
-        
-        // 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("enabled", true);
-
-        entry->setStringValue("text[0]/label", comm->ident());
-
-               char buf[8];
-               snprintf(buf, 8, "%.2f", comm->freqMHz());
-               if(buf[5] == '3') buf[5] = '2';
-               if(buf[5] == '8') buf[5] = '7';
-               buf[7] = '\0';
-
-               entry->setStringValue("text[1]/label", buf);
-        ++n;
-    }
-
-       _gui->showDialog(dialog_name);
-}