]> git.mxchange.org Git - flightgear.git/blob - src/Instrumentation/KLN89/kln89_page_dir.cxx
Make hardcoded error values configurable.
[flightgear.git] / src / Instrumentation / KLN89 / kln89_page_dir.cxx
1 // kln89_page_*.[ch]xx - this file is one of the "pages" that
2 //                       are used in the KLN89 GPS unit simulation. 
3 //
4 // Written by David Luff, started 2005.
5 //
6 // Copyright (C) 2005 - David C Luff - david.luff@nottingham.ac.uk
7 //
8 // This program is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU General Public License as
10 // published by the Free Software Foundation; either version 2 of the
11 // License, or (at your option) any later version.
12 //
13 // This program is distributed in the hope that it will be useful, but
14 // WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16 // General Public License for more details.
17 //
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the Free Software
20 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21 //
22 // $Id$
23
24 #ifdef HAVE_CONFIG_H
25 #  include "config.h"
26 #endif
27
28 #include "kln89_page_dir.hxx"
29
30 KLN89DirPage::KLN89DirPage(KLN89* parent)
31 : KLN89Page(parent) {
32         _nSubPages = 1;
33         _subPage = 0;
34         _name = "DIR";
35         _DToWpDispMode = 2;
36 }
37
38 KLN89DirPage::~KLN89DirPage() {
39 }
40
41 void KLN89DirPage::Update(double dt) {
42         // TODO - this can apparently be "ACTIVATE:" under some circumstances
43         _kln89->DrawText("DIRECT TO:", 2, 2, 3);
44         
45         if(_kln89->_mode == KLN89_MODE_CRSR) {
46                 if(_DToWpDispMode == 0) {
47                         string s = _id;
48                         while(s.size() < 5) s += ' ';
49                         if(!_kln89->_blink) {
50                                 _kln89->DrawText(s, 2, 4, 1, false, 99);
51                                 _kln89->DrawEnt(1, 0, 1);
52                         }
53                 } else if(_DToWpDispMode == 1) {
54                         if(!_kln89->_blink) {
55                                 // TODO
56                                 _kln89->DrawEnt(1, 0, 1);
57                         }
58                         _kln89->Underline(2, 4, 1, 5);
59                 } else {
60                         if(!_kln89->_blink) _kln89->DrawText("_____", 2, 4, 1);
61                         _kln89->Underline(2, 4, 1, 5);
62                 }
63         } else {
64                 _kln89->DrawText("_____", 2, 4, 1);
65         }
66         
67         KLN89Page::Update(dt);
68 }
69
70 void KLN89DirPage::SetId(const string& s) {
71         if(s.size()) {
72                 _id = s;
73                 // TODO - fill in lat, lon, type
74                 // or just pass in waypoints (probably better!)
75                 _DToWpDispMode = 0;
76                 // TODO - this (above) should probably be dependent on whether s is a *valid* waypoint!
77         } else {
78                 _DToWpDispMode = 2;
79         }
80         _saveMasterMode = _kln89->_mode;
81         _uLinePos = 1;  // Needed to stop Leg flashing
82 }
83
84 void KLN89DirPage::ClrPressed() {
85         if(_kln89->_mode == KLN89_MODE_CRSR) {
86                 if(_DToWpDispMode <= 1) {
87                         _DToWpDispMode = 2;
88                         _id.clear();
89                 } else {
90                         // Restore the original master mode
91                         _kln89->_mode = _saveMasterMode;
92                         // Stop displaying dir page
93                         _kln89->_activePage = _kln89->_pages[_kln89->_curPage];
94                 }
95         } else {
96                 // TODO
97         }
98 }
99
100 void KLN89DirPage::EntPressed() {
101         //cout << "DTO ENT Pressed()\n";
102         if(_id.empty()) {
103                 _kln89->DtoCancel();
104         } else {
105                 _kln89->DtoInitiate(_id);
106         }
107 }