]> git.mxchange.org Git - flightgear.git/commitdiff
Implement some of the inner-knob-out scan functionality. The waypoints of the active...
authordaveluff <daveluff>
Fri, 10 Feb 2006 23:19:45 +0000 (23:19 +0000)
committerdaveluff <daveluff>
Fri, 10 Feb 2006 23:19:45 +0000 (23:19 +0000)
src/Instrumentation/KLN89/kln89.cxx
src/Instrumentation/KLN89/kln89_page.cxx
src/Instrumentation/KLN89/kln89_page_nav.cxx
src/Instrumentation/KLN89/kln89_page_nav.hxx

index b491bcc3170acf7a2f973e3e733225c9be3cfbbf..d54b084de954c4edc83cef794b8e65e21d014c40 100644 (file)
@@ -379,7 +379,10 @@ void KLN89::Knob2Right1() {
 
 void KLN89::CrsrPressed() {
        _dispMsg = false;
-       if(_activePage == _nrst_page) return;   // CRSR cannot be switched off on nrst page.
+       // CRSR cannot be switched off on nrst page.
+       if(_activePage == _nrst_page) { return; }
+       // CRSR is always off when inner-knob is out on nav4 page.
+       if(_curPage == 6 && _activePage->GetSubPage() == 3 && fgGetBool("/instrumentation/kln89/scan-pull")) { return; }
        if(_cleanUpPage >= 0) {
                _pages[(unsigned int)_cleanUpPage]->CleanUp();
                _cleanUpPage = -1;
@@ -432,10 +435,9 @@ void KLN89::DtoPressed() {
                        } else {
                                _dir_page->SetId(_activeWaypoint.id);
                        }
-               // } else if(_curPage == 6 && _nav_page->GetSubPage() == 3 && 0) {
+               } else if(_curPage == 6 && _activePage->GetSubPage() == 3 && fgGetBool("/instrumentation/kln89/scan-pull") && _activeFP->waypoints.size()) {
                        // NAV 4
-                       // TODO
-                       // The && 0 should be && outer knob is out.
+                       _dir_page->SetId(((KLN89NavPage*)_activePage)->GetNav4WpId());
                } else if(_curPage == 7 && _activePage->GetSubPage() == 0 && _mode == KLN89_MODE_CRSR) {
                        //cout << "Checking the fpl page!\n";
                        // FPL 0
@@ -449,7 +451,7 @@ void KLN89::DtoPressed() {
                } else {
                        _dir_page->SetId(_activeWaypoint.id);
                }
-               // This need to come after the bit before otherwise the FPL page clears it's current ID when it looses focus.
+               // This need to come after the bit before otherwise the FPL or NAV4 page clears their current ID when it looses focus.
                _activePage->LooseFocus();
                _activePage = _dir_page;
                _mode = KLN89_MODE_CRSR;
index 6924208d0389fd90e79a3bdeea3dd32bd97741be..ee4e65bcd6623aac689f43d081c622941357289b 100644 (file)
@@ -22,6 +22,7 @@
 // $Id$\r
 \r
 #include "kln89_page.hxx"\r
+#include <Main/fg_props.hxx>\r
 \r
 KLN89Page::KLN89Page(KLN89* parent) \r
 : GPSPage(parent) {\r
@@ -130,7 +131,7 @@ void KLN89Page::Knob1Right1() {
 }\r
 \r
 void KLN89Page::Knob2Left1() {\r
-       if(_kln89->_mode != KLN89_MODE_CRSR) {\r
+       if(_kln89->_mode != KLN89_MODE_CRSR && !fgGetBool("/instrumentation/kln89/scan-pull")) {\r
                GPSPage::Knob2Left1(); \r
        } else {\r
                if(_uLinePos == 0 && _kln89->_obsMode) {\r
@@ -144,7 +145,7 @@ void KLN89Page::Knob2Left1() {
 }\r
 \r
 void KLN89Page::Knob2Right1() {\r
-       if(_kln89->_mode != KLN89_MODE_CRSR) {\r
+       if(_kln89->_mode != KLN89_MODE_CRSR && !fgGetBool("/instrumentation/kln89/scan-pull")) {\r
                GPSPage::Knob2Right1(); \r
        } else {\r
                if(_uLinePos == 0 && _kln89->_obsMode) {\r
index 968c3bb4c31344a78e4d010ecbdc716d9cb36cca..fdddb39019308e19c494ece8b392f79ad38f808e 100644 (file)
@@ -36,6 +36,7 @@ KLN89NavPage::KLN89NavPage(KLN89* parent)
        _menuActive = false;
        _menuPos = 0;
        _suspendAVS = false;
+       _scanWpSet = false;
 }
 
 KLN89NavPage::~KLN89NavPage() {
@@ -44,11 +45,15 @@ KLN89NavPage::~KLN89NavPage() {
 void KLN89NavPage::Update(double dt) {
        GPSFlightPlan* fp = ((KLN89*)_parent)->_activeFP;
        GPSWaypoint* awp = _parent->GetActiveWaypoint();
+       // Scan-pull out on nav4 page switches off the cursor
+       if(3 == _subPage && fgGetBool("/instrumentation/kln89/scan-pull")) { _kln89->_mode = KLN89_MODE_DISP; }
        bool crsr = (_kln89->_mode == KLN89_MODE_CRSR);
        bool blink = _kln89->_blink;
        double lat = _kln89->_gpsLat * SG_RADIANS_TO_DEGREES;
        double lon = _kln89->_gpsLon * SG_RADIANS_TO_DEGREES;
        
+       if(_subPage != 3) { _scanWpSet = false; }
+       
        if(0 == _subPage) {
                if(_kln89->_navFlagged) {
                        _kln89->DrawText(">    F L A G", 2, 0, 2);
@@ -240,7 +245,9 @@ void KLN89NavPage::Update(double dt) {
                } else {
                        _kln89->DrawText("-:--", 2, 11, 0);
                }
-       } else {
+       } else {        // if(3 == _subPage)
+               // Switch the cursor off if scan-pull is out on this page.
+               if(fgGetBool("/instrumentation/kln89/scan-pull")) { _kln89->_mode = KLN89_MODE_DISP; } 
                // The moving map page the core KLN89 class draws this.
                if(_kln89->_mapOrientation == 2 && _kln89->_groundSpeed_kts < 2) {
                        // Don't draw it if in track up mode and groundspeed < 2kts, as per real-life unit.
@@ -298,6 +305,21 @@ void KLN89NavPage::Update(double dt) {
                        // Just draw the scale
                        _kln89->DrawMapText(scle_str, 1, 0, true);
                }
+               // If the scan-pull knob is out, draw one of the waypoints (if applicable).
+               if(fgGetBool("/instrumentation/kln89/scan-pull")) {
+                       if(_kln89->_activeFP->waypoints.size()) {
+                               //cout << "Need to draw a waypoint!\n";
+                               _kln89->DrawLine(70, 0, 111, 0);
+                               if(!_kln89->_blink) {
+                                       //_kln89->DrawMapQuad(45, 0, 97, 8, true);
+                                       if(!_scanWpSet) {
+                                               _scanWpIndex = _kln89->GetActiveWaypointIndex();
+                                               _scanWpSet = true;
+                                       }
+                                       _kln89->DrawMapText(_kln89->_activeFP->waypoints[_scanWpIndex]->id, 71, 0, true);
+                               }               
+                       }
+               }
                // And do part of the field 1 update, since NAV 4 is a special case for the last line.
                _kln89->DrawChar('>', 1, 0, 0);
                if(crsr && _uLinePos == 1) _kln89->Underline(1, 1, 0, 5);
@@ -357,8 +379,25 @@ void KLN89NavPage::Update(double dt) {
        KLN89Page::Update(dt);
 }
 
+// Returns the id string of the selected waypoint on NAV4 if valid, else returns an empty string.
+string KLN89NavPage::GetNav4WpId() {
+       if(3 == _subPage) {
+               if(fgGetBool("/instrumentation/kln89/scan-pull")) {
+                       if(_kln89->_activeFP->waypoints.size()) {
+                               if(!_scanWpSet) {
+                                       return(_kln89->_activeWaypoint.id);
+                               } else {
+                                       return(_kln89->_activeFP->waypoints[_scanWpIndex]->id);
+                               }               
+                       }
+               }
+       }
+       return("");
+}
+
 void KLN89NavPage::LooseFocus() {
        _suspendAVS = false;
+       _scanWpSet = false;
 }
 
 void KLN89NavPage::CrsrPressed() {
@@ -440,6 +479,23 @@ void KLN89NavPage::Knob1Right1() {
 }
 
 void KLN89NavPage::Knob2Left1() {
+       // If the inner-knob is out on the nav4 page, the only effect is to cycle the displayed waypoint.
+       if(3 == _subPage && fgGetBool("/instrumentation/kln89/scan-pull")) {
+               if(_kln89->_activeFP->waypoints.size()) {       // TODO - find out what happens when scan-pull is on on nav4 without an active FP.
+                       // It's unlikely that we could get here without _scanWpSet, but theoretically possible, so we need to cover it.
+                       if(!_scanWpSet) {
+                               _scanWpIndex = _kln89->GetActiveWaypointIndex();
+                               _scanWpSet = true;
+                       } else {
+                               if(0 == _scanWpIndex) {
+                                       _scanWpIndex = _kln89->_activeFP->waypoints.size() - 1;
+                               } else {
+                                       _scanWpIndex--;
+                               }
+                       }
+               }
+               return;
+       }
        if(_kln89->_mode != KLN89_MODE_CRSR || _uLinePos == 0) {
                KLN89Page::Knob2Left1();
                return;
@@ -477,6 +533,22 @@ void KLN89NavPage::Knob2Left1() {
 }
 
 void KLN89NavPage::Knob2Right1() {
+       // If the inner-knob is out on the nav4 page, the only effect is to cycle the displayed waypoint.
+       if(3 == _subPage && fgGetBool("/instrumentation/kln89/scan-pull")) {
+               if(_kln89->_activeFP->waypoints.size()) {       // TODO - find out what happens when scan-pull is on on nav4 without an active FP.
+                       // It's unlikely that we could get here without _scanWpSet, but theoretically possible, so we need to cover it.
+                       if(!_scanWpSet) {
+                               _scanWpIndex = _kln89->GetActiveWaypointIndex();
+                               _scanWpSet = true;
+                       } else {
+                               _scanWpIndex++;
+                               if(_scanWpIndex > _kln89->_activeFP->waypoints.size() - 1) {
+                                       _scanWpIndex = 0;
+                               }
+                       }
+               }
+               return;
+       }
        if(_kln89->_mode != KLN89_MODE_CRSR || _uLinePos == 0) {
                KLN89Page::Knob2Right1();
                return;
index 7b722e3351337afa2a0079753c6262d72e802bf7..031a719fa3ccfd7bd590571d80679fabcaa83844 100644 (file)
@@ -41,6 +41,9 @@ public:
        
        void LooseFocus();
        
+       // Returns the id string of the selected waypoint on NAV4 if valid, else returns an empty string.
+       string GetNav4WpId();
+       
 private:
        int _posFormat;         // 0 => lat,lon; 1 => ref to wp.
        
@@ -60,4 +63,8 @@ private:
        // NAV 4 menu stuff
        bool _menuActive;
        int _menuPos;
+       
+       // NAV 4 waypoint scan drawing housekeeping.
+       bool _scanWpSet;
+       int _scanWpIndex;
 };