]> git.mxchange.org Git - flightgear.git/blob - src/Instrumentation/KLN89/kln89_page_set.cxx
James Turner: Improved runway management code:
[flightgear.git] / src / Instrumentation / KLN89 / kln89_page_set.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_set.hxx"
29
30 #include <iostream>
31 using namespace std;
32
33 KLN89SetPage::KLN89SetPage(KLN89* parent) 
34 : KLN89Page(parent) {
35         _nSubPages = 11;
36         _subPage = 0;
37         _name = "SET";
38 }
39
40 KLN89SetPage::~KLN89SetPage() {
41 }
42
43 void KLN89SetPage::Update(double dt) {
44         string sBaro, sAlt, sVel;
45         switch(_subPage+1) {
46         case 1:
47                 _kln89->DrawText("INIT POS:", 2, 0, 3);
48                 break;
49         case 2:
50                 _kln89->DrawText("DATE", 2, 0, 3);
51                 _kln89->DrawText("TIME", 2, 0, 2);
52                 _kln89->DrawText("Cord", 2, 0, 1);
53                 _kln89->DrawText("Mag Var:", 2, 0, 0);
54                 break;
55         case 3:
56                 _kln89->DrawText("Update DB on", 2, 1, 3);
57                 _kln89->DrawText("ground only", 2, 1, 2);
58                 _kln89->DrawText("Key", 2, 0, 1);
59                 _kln89->DrawText("Update pub DB?", 2, 0, 0);
60                 break;
61         case 4:
62                 //cout << "_uLinePos = " << _uLinePos << '\n';
63                 _kln89->DrawText("TURN", 2, 5, 3);
64                 _kln89->DrawText("ANTICIPATION", 2, 1, 2);
65                 if(_kln89->_mode == KLN89_MODE_CRSR && _uLinePos == 1) {
66                         if(!_kln89->_blink) {
67                                 _kln89->DrawText((_kln89->GetTurnAnticipation() ? "ENABLED" : "DISABLED"), 2, 3, 1);
68                         }
69                         _kln89->Underline(2, 3, 1, 8);
70                 } else {
71                         _kln89->DrawText((_kln89->GetTurnAnticipation() ? "ENABLED" : "DISABLED"), 2, 3, 1);
72                 }
73                 break;
74         case 5:
75                 _kln89->DrawText("Default First", 2, 0, 3);
76                 _kln89->DrawText("Character of", 2, 1, 2);
77                 _kln89->DrawText("Wpt identifier", 2, 0, 1);
78                 _kln89->DrawText("Entry:", 2, 3, 0);
79                 break;
80         case 6:
81                 _kln89->DrawText("NEAREST APT", 2, 1, 3);
82                 _kln89->DrawText("CRITERIA", 2, 3, 2);
83                 _kln89->DrawText("Length:", 2, 0, 1);
84                 _kln89->DrawText("Surface:", 2, 0, 0);
85                 break;
86         case 7:
87                 _kln89->DrawText("SUA ALERT", 2, 3, 3);
88                 if(_kln89->_mode == KLN89_MODE_CRSR && _uLinePos == 1) {
89                         if(!_kln89->_blink) {
90                                 _kln89->DrawText((_kln89->GetSuaAlertEnabled() ? "ENABLED" : "DISABLED"), 2, 4, 2);
91                         }
92                         _kln89->Underline(2, 4, 2, 8);
93                 } else {
94                         _kln89->DrawText((_kln89->GetSuaAlertEnabled() ? "ENABLED" : "DISABLED"), 2, 4, 2);
95                 }
96                 if(_kln89->GetSuaAlertEnabled()) {
97                         _kln89->DrawText("Buffer:", 2, 0, 1);
98                         _kln89->DrawSpecialChar(5, 2, 7, 1);    // +- sign.
99                         if(_kln89->_mode == KLN89_MODE_CRSR && _uLinePos == 2) {
100                                 if(!_kln89->_blink) {
101                                         _kln89->DrawText("00300", 2, 8, 1);             // TODO - fix this hardwiring!!!!
102                                 }
103                                 _kln89->Underline(2, 8, 1, 5);
104                         } else {
105                                 _kln89->DrawText("00300", 2, 8, 1);             // TODO - fix this hardwiring!!!!
106                         }
107                         _kln89->DrawText("ft", 2, 13, 1);       // TODO - fix this hardwiring!!!!
108                 }
109                 break;
110         case 8:
111                 _kln89->DrawText("SET UNITS:", 2, 3, 3);
112                 _kln89->DrawText("Baro    :", 2, 0, 2);
113                 _kln89->DrawText("Alt-APT :", 2, 0, 1);
114                 _kln89->DrawText("Dist-Vel:", 2, 0, 0);
115                 switch(_kln89->_baroUnits) {
116                 case GPS_PRES_UNITS_IN:
117                         sBaro = "\"";
118                         break;
119                 case GPS_PRES_UNITS_MB:
120                         sBaro = "mB";
121                         break;
122                 case GPS_PRES_UNITS_HP:
123                         sBaro = "hP";
124                         break;
125                 }
126                 if(_kln89->_altUnits == GPS_ALT_UNITS_FT) sAlt = "ft";
127                 else sAlt = "m";
128                 if(_kln89->_distUnits == GPS_DIST_UNITS_NM) sVel = "nm-kt";
129                 else sVel = "km-";
130                         
131                 if(_kln89->_mode == KLN89_MODE_CRSR && _uLinePos == 1) {
132                         if(!_kln89->_blink) {
133                                 _kln89->DrawText(sBaro, 2, 10, 2);
134                         }
135                         _kln89->Underline(2, 10, 2, 2);
136                 } else {
137                         _kln89->DrawText(sBaro, 2, 10, 2);
138                 }
139                 if(_kln89->_mode == KLN89_MODE_CRSR && _uLinePos == 2) {
140                         if(!_kln89->_blink) {
141                                 _kln89->DrawText(sAlt, 2, 10, 1);
142                         }
143                         _kln89->Underline(2, 10, 1, 2);
144                 } else {
145                         _kln89->DrawText(sAlt, 2, 10, 1);
146                 }
147                 if(_kln89->_mode == KLN89_MODE_CRSR && _uLinePos == 3) {
148                         if(!_kln89->_blink) {
149                                 _kln89->DrawText(sVel, 2, 10, 0);
150                                 if(_kln89->_distUnits != GPS_DIST_UNITS_NM) _kln89->DrawKPH(2, 13, 0);
151                         }
152                         _kln89->Underline(2, 10, 0, 5);
153                 } else {
154                         _kln89->DrawText(sVel, 2, 10, 0);
155                         if(_kln89->_distUnits != GPS_DIST_UNITS_NM) _kln89->DrawKPH(2, 13, 0);
156                 }
157                 break;
158         case 9:
159                 _kln89->DrawText("Altitude", 2, 3, 3);
160                 _kln89->DrawText("Alert:", 2, 1, 2);
161                 break;
162         case 10:
163                 _kln89->DrawText("BUS MONITOR", 2, 2, 3);
164                 _kln89->DrawText("Bus Volt", 2, 0, 2);
165                 _kln89->DrawText("Alert Volt", 2, 0, 1);
166                 _kln89->DrawText("Alert Delay", 2, 0, 0);
167                 break;
168         case 11:
169                 _kln89->DrawText("MIN DISPLAY", 2, 2, 3);
170                 _kln89->DrawText("BRIGHTNESS ADJ", 2, 1, 2);
171                 break;
172         }
173         
174         KLN89Page::Update(dt);
175 }
176
177 void KLN89SetPage::CrsrPressed() {
178         if(_kln89->_mode == KLN89_MODE_DISP) return;
179         if(_kln89->_obsMode) {
180                 _uLinePos = 0;
181         } else {
182                 _uLinePos = 1;
183         }
184         switch(_subPage+1) {
185         case 1:
186                 break;
187         case 2:
188                 break;
189         case 3:
190                 break;
191         case 4:
192                 _maxULinePos = 1;
193                 break;
194         case 5:
195                 break;
196         case 6:
197                 _maxULinePos = 2;
198                 break;
199         case 7:
200                 if(_kln89->GetSuaAlertEnabled()) _maxULinePos = 2;
201                 else _maxULinePos = 1;
202                 break;
203         case 8:
204                 _maxULinePos = 3;
205                 break;
206         case 9:
207                 break;
208         case 10:
209                 break;
210         case 11:
211                 break;
212         }
213 }
214
215 void KLN89SetPage::Knob2Left1() {
216         if(_kln89->_mode != KLN89_MODE_CRSR || _uLinePos == 0) {
217                 KLN89Page::Knob2Left1();
218         } else {
219                 switch(_subPage+1) {
220                 case 1:
221                         break;
222                 case 2:
223                         break;
224                 case 3:
225                         break;
226                 case 4:
227                         if(_uLinePos == 1) {
228                                 _kln89->SetTurnAnticipation(!_kln89->GetTurnAnticipation());
229                         }
230                         break;
231                 case 5:
232                         break;
233                 case 6:
234                         break;
235                 case 7:
236                         if(_uLinePos == 1) {
237                                 _kln89->SetSuaAlertEnabled(!_kln89->GetSuaAlertEnabled());
238                                 _maxULinePos = (_kln89->GetSuaAlertEnabled() ? 2 : 1);
239                         } else if(_uLinePos == 2) {
240                                 // TODO - implement variable sua alert buffer
241                         }
242                         break;
243                 case 8:
244                         if(_uLinePos == 1) {  // baro units
245                                 _kln89->SetBaroUnits(_kln89->GetBaroUnits() - 1, true);
246                         } else if(_uLinePos == 2) {
247                                 _kln89->SetAltUnitsSI(!_kln89->GetAltUnitsSI());
248                         } else if(_uLinePos == 3) {
249                                 _kln89->SetDistVelUnitsSI(!_kln89->GetDistVelUnitsSI());
250                         }
251                         break;
252                 }
253         }
254 }
255
256 void KLN89SetPage::Knob2Right1() {
257         if(_kln89->_mode != KLN89_MODE_CRSR || _uLinePos == 0) {
258                 KLN89Page::Knob2Right1();
259         } else {
260                 switch(_subPage+1) {
261                 case 1:
262                         break;
263                 case 2:
264                         break;
265                 case 3:
266                         break;
267                 case 4:
268                         if(_uLinePos == 1) {   // Which it should be!
269                                 _kln89->SetTurnAnticipation(!_kln89->GetTurnAnticipation());
270                         }
271                         break;
272                 case 5:
273                         break;
274                 case 6:
275                         break;
276                 case 7:
277                         if(_uLinePos == 1) {
278                                 _kln89->SetSuaAlertEnabled(!_kln89->GetSuaAlertEnabled());
279                                 _maxULinePos = (_kln89->GetSuaAlertEnabled() ? 2 : 1);
280                         } else if(_uLinePos == 2) {
281                                 // TODO - implement variable sua alert buffer
282                         }
283                         break;
284                 case 8:
285                         if(_uLinePos == 1) {  // baro units
286                                 _kln89->SetBaroUnits(_kln89->GetBaroUnits() + 1, true);
287                         } else if(_uLinePos == 2) {
288                                 _kln89->SetAltUnitsSI(!_kln89->GetAltUnitsSI());
289                         } else if(_uLinePos == 3) {
290                                 _kln89->SetDistVelUnitsSI(!_kln89->GetDistVelUnitsSI());
291                         }
292                         break;
293                 }
294         }
295 }