]> git.mxchange.org Git - flightgear.git/blob - src/FDM/UIUCModel/uiuc_menu_gear.cpp
- rename fgcommand "set-mouse" to "set-cursor"
[flightgear.git] / src / FDM / UIUCModel / uiuc_menu_gear.cpp
1 /**********************************************************************
2                                                                        
3  FILENAME:     uiuc_menu_gear.cpp
4
5 ----------------------------------------------------------------------
6
7  DESCRIPTION:  reads input data for specified aircraft and creates 
8                approporiate data storage space
9
10 ----------------------------------------------------------------------
11
12  STATUS:       alpha version
13
14 ----------------------------------------------------------------------
15
16  REFERENCES:   based on "menu reader" format of Michael Selig
17
18 ----------------------------------------------------------------------
19
20  HISTORY:      04/04/2003   initial release
21                06/30/2003   (RD) replaced istrstream with istringstream
22                             to get rid of the annoying warning about
23                             using the strstream header
24
25 ----------------------------------------------------------------------
26
27  AUTHOR(S):    Robert Deters      <rdeters@uiuc.edu>
28                Michael Selig      <m-selig@uiuc.edu>
29
30 ----------------------------------------------------------------------
31
32  VARIABLES:
33
34 ----------------------------------------------------------------------
35
36  INPUTS:       n/a
37
38 ----------------------------------------------------------------------
39
40  OUTPUTS:      n/a
41
42 ----------------------------------------------------------------------
43
44  CALLED BY:    uiuc_menu()
45
46 ----------------------------------------------------------------------
47
48  CALLS TO:     check_float() if needed
49                d_2_to_3() if needed
50                d_1_to_2() if needed
51                i_1_to_2() if needed
52                d_1_to_1() if needed
53
54  ----------------------------------------------------------------------
55
56  COPYRIGHT:    (C) 2003 by Michael Selig
57
58  This program is free software; you can redistribute it and/or
59  modify it under the terms of the GNU General Public License
60  as published by the Free Software Foundation.
61
62  This program is distributed in the hope that it will be useful,
63  but WITHOUT ANY WARRANTY; without even the implied warranty of
64  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
65  GNU General Public License for more details.
66
67  You should have received a copy of the GNU General Public License
68  along with this program; if not, write to the Free Software
69  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
70
71 **********************************************************************/
72
73 #include <simgear/compiler.h>
74
75 #if defined( __MWERKS__ )
76 // -dw- optimizer chokes (big-time) trying to optimize humongous
77 // loop/switch statements
78 #pragma optimization_level 0
79 #endif
80
81 #include <cstdlib>
82 #include <string>
83 #include STL_IOSTREAM
84
85 #include "uiuc_menu_gear.h"
86
87 SG_USING_STD(cerr);
88 SG_USING_STD(cout);
89 SG_USING_STD(endl);
90
91 #ifndef _MSC_VER
92 SG_USING_STD(exit);
93 #endif
94
95 void parse_gear( const string& linetoken2, const string& linetoken3,
96                  const string& linetoken4, const string& linetoken5, 
97                  const string& linetoken6, const string& linetoken7, 
98                  const string& linetoken8, const string& linetoken9,
99                  const string& linetoken10, const string& aircraft_directory, 
100                  LIST command_line ) {
101     double token_value;
102     istringstream token3(linetoken3.c_str());
103     istringstream token4(linetoken4.c_str());
104     istringstream token5(linetoken5.c_str());
105     istringstream token6(linetoken6.c_str());
106     istringstream token7(linetoken7.c_str());
107     istringstream token8(linetoken8.c_str());
108     istringstream token9(linetoken9.c_str());
109     istringstream token10(linetoken10.c_str());
110
111     switch(gear_map[linetoken2])
112       {
113       case Dx_gear_flag:
114         {
115           int index;
116           token3 >> index;
117           if (index < 0 || index >= 16)
118             uiuc_warnings_errors(1, *command_line);
119           if (check_float(linetoken4))
120             token4 >> token_value;
121           else
122             uiuc_warnings_errors(1, *command_line);
123           D_gear_v[index][0] = token_value;
124           gear_model[index] = true;
125           break;
126         }
127       case Dy_gear_flag:
128         {
129           int index;
130           token3 >> index;
131           if (index < 0 || index >= 16)
132             uiuc_warnings_errors(1, *command_line);
133           if (check_float(linetoken4))
134             token4 >> token_value;
135           else
136             uiuc_warnings_errors(1, *command_line);
137           D_gear_v[index][1] = token_value;
138           gear_model[index] = true;
139           break;
140         }
141       case Dz_gear_flag:
142         {
143           int index;
144           token3 >> index;
145           if (index < 0 || index >= 16)
146             uiuc_warnings_errors(1, *command_line);
147           if (check_float(linetoken4))
148             token4 >> token_value;
149           else
150             uiuc_warnings_errors(1, *command_line);
151           D_gear_v[index][2] = token_value;
152           gear_model[index] = true;
153           break;
154         }
155       case cgear_flag:
156         {
157           int index;
158           token3 >> index;
159           if (index < 0 || index >= 16)
160             uiuc_warnings_errors(1, *command_line);
161           if (check_float(linetoken4))
162             token4 >> token_value;
163           else
164             uiuc_warnings_errors(1, *command_line);
165           cgear[index] = token_value;
166           gear_model[index] = true;
167           break;
168         }
169       case kgear_flag:
170         {
171           int index;
172           token3 >> index;
173           if (index < 0 || index >= 16)
174             uiuc_warnings_errors(1, *command_line);
175           if (check_float(linetoken4))
176             token4 >> token_value;
177           else
178             uiuc_warnings_errors(1, *command_line);
179           kgear[index] = token_value;
180           gear_model[index] = true;
181           break;
182         }
183       case muGear_flag:
184         {
185           int index;
186           token3 >> index;
187           if (index < 0 || index >= 16)
188             uiuc_warnings_errors(1, *command_line);
189           if (check_float(linetoken4))
190             token4 >> token_value;
191           else
192             uiuc_warnings_errors(1, *command_line);
193           muGear[index] = token_value;
194           gear_model[index] = true;
195           break;
196         }
197       case strutLength_flag:
198         {
199           int index;
200           token3 >> index;
201           if (index < 0 || index >= 16)
202             uiuc_warnings_errors(1, *command_line);
203           if (check_float(linetoken4))
204             token4 >> token_value;
205           else
206             uiuc_warnings_errors(1, *command_line);
207           strutLength[index] = token_value;
208           gear_model[index] = true;
209           break;
210         }
211       case gear_max_flag:
212         {
213           if (check_float(linetoken3))
214             token3 >> token_value;
215           else
216             uiuc_warnings_errors(1, *command_line);
217           
218           use_gear = true;
219           gear_max = token_value;
220           break;
221         }
222       case gear_rate_flag:
223         {
224           if (check_float(linetoken3))
225             token3 >> token_value;
226           else
227             uiuc_warnings_errors(1, *command_line);
228           
229           use_gear = true;
230           gear_rate = token_value;
231           break;
232         }
233       default:
234         {
235           if (ignore_unknown_keywords) {
236             // do nothing
237           } else {
238             // print error message
239             uiuc_warnings_errors(2, *command_line);
240           }
241           break;
242         }
243       };
244 }