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