]> git.mxchange.org Git - flightgear.git/blob - src/FDM/UIUCModel/uiuc_menu_mass.cpp
- rename fgcommand "set-mouse" to "set-cursor"
[flightgear.git] / src / FDM / UIUCModel / uiuc_menu_mass.cpp
1 /**********************************************************************
2                                                                        
3  FILENAME:     uiuc_menu_mass.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_mass.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_mass( 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(mass_map[linetoken2])
112       {
113       case Weight_flag:
114         {
115           if (check_float(linetoken3))
116             token3 >> token_value;
117           else
118             uiuc_warnings_errors(1, *command_line);
119           
120           Weight = token_value;
121           Mass = Weight * INVG;
122           massParts -> storeCommands (*command_line);
123           break;
124         }
125       case Mass_flag:
126         {
127           if (check_float(linetoken3))
128             token3 >> token_value;
129           else
130             uiuc_warnings_errors(1, *command_line);
131           
132           Mass = token_value;
133           massParts -> storeCommands (*command_line);
134           break;
135         }
136       case I_xx_flag:
137         {
138           if (check_float(linetoken3))
139             token3 >> token_value;
140           else
141             uiuc_warnings_errors(1, *command_line);
142           
143           I_xx = token_value;
144           massParts -> storeCommands (*command_line);
145           break;
146         }
147       case I_yy_flag:
148         {
149           if (check_float(linetoken3))
150             token3 >> token_value;
151           else
152             uiuc_warnings_errors(1, *command_line);
153           
154           I_yy = token_value;
155           massParts -> storeCommands (*command_line);
156           break;
157         }
158       case I_zz_flag:
159         {
160           if (check_float(linetoken3))
161             token3 >> token_value;
162           else
163             uiuc_warnings_errors(1, *command_line);
164           
165           I_zz = token_value;
166           massParts -> storeCommands (*command_line);
167           break;
168         }
169       case I_xz_flag:
170         {
171           if (check_float(linetoken3))
172             token3 >> token_value;
173           else
174             uiuc_warnings_errors(1, *command_line);
175           
176           I_xz = token_value;
177           massParts -> storeCommands (*command_line);
178           break;
179         }
180       case Mass_appMass_ratio_flag:
181         {
182           if (check_float(linetoken3))
183             token3 >> token_value;
184           else
185             uiuc_warnings_errors(1, *command_line);
186           
187           Mass_appMass_ratio = token_value;
188           massParts -> storeCommands (*command_line);
189           break;
190         }
191       case I_xx_appMass_ratio_flag:
192         {
193           if (check_float(linetoken3))
194             token3 >> token_value;
195           else
196             uiuc_warnings_errors(1, *command_line);
197           
198           I_xx_appMass_ratio = token_value;
199           massParts -> storeCommands (*command_line);
200           break;
201         }
202       case I_yy_appMass_ratio_flag:
203         {
204           if (check_float(linetoken3))
205             token3 >> token_value;
206           else
207             uiuc_warnings_errors(1, *command_line);
208           
209           I_yy_appMass_ratio = token_value;
210           massParts -> storeCommands (*command_line);
211           break;
212         }
213       case I_zz_appMass_ratio_flag:
214         {
215           if (check_float(linetoken3))
216             token3 >> token_value;
217           else
218             uiuc_warnings_errors(1, *command_line);
219           
220           I_zz_appMass_ratio = token_value;
221           massParts -> storeCommands (*command_line);
222           break;
223         }
224       case Mass_appMass_flag:
225         {
226           if (check_float(linetoken3))
227             token3 >> token_value;
228           else
229             uiuc_warnings_errors(1, *command_line);
230           
231           Mass_appMass = token_value;
232           massParts -> storeCommands (*command_line);
233           break;
234         }
235       case I_xx_appMass_flag:
236         {
237           if (check_float(linetoken3))
238             token3 >> token_value;
239           else
240             uiuc_warnings_errors(1, *command_line);
241           
242           I_xx_appMass = token_value;
243           massParts -> storeCommands (*command_line);
244           break;
245         }
246       case I_yy_appMass_flag:
247         {
248           if (check_float(linetoken3))
249             token3 >> token_value;
250           else
251             uiuc_warnings_errors(1, *command_line);
252           
253           I_yy_appMass = token_value;
254           massParts -> storeCommands (*command_line);
255           break;
256         }
257       case I_zz_appMass_flag:
258         {
259           if (check_float(linetoken3))
260             token3 >> token_value;
261           else
262             uiuc_warnings_errors(1, *command_line);
263           
264           I_zz_appMass = token_value;
265           massParts -> storeCommands (*command_line);
266           break;
267         }
268       default:
269         {
270           if (ignore_unknown_keywords) {
271             // do nothing
272           } else {
273             // print error message
274             uiuc_warnings_errors(2, *command_line);
275           }
276           break;
277         }
278       };
279 }