]> git.mxchange.org Git - flightgear.git/blob - src/Main/fg_props.cxx
f937887b8a398b109e9ea12312ba4bc05a711450
[flightgear.git] / src / Main / fg_props.cxx
1 // fg_props.cxx -- support for FlightGear properties.
2 //
3 // Written by David Megginson, started 2000.
4 //
5 // Copyright (C) 2000, 2001 David Megginson - david@megginson.com
6 //
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License as
9 // published by the Free Software Foundation; either version 2 of the
10 // License, or (at your option) any later version.
11 //
12 // This program is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 // General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 //
21 // $Id$
22
23 #ifdef HAVE_CONFIG_H
24 #  include <simgear/compiler.h>
25 #endif
26
27 #include <simgear/misc/exception.hxx>
28
29 #include STL_IOSTREAM
30
31 #include <ATC/ATCdisplay.hxx>
32 #include <Autopilot/newauto.hxx>
33 #include <Aircraft/aircraft.hxx>
34 #include <Time/tmp.hxx>
35 #include <FDM/UIUCModel/uiuc_aircraftdir.h>
36 #ifndef FG_OLD_WEATHER
37 #  include <WeatherCM/FGLocalWeatherDatabase.h>
38 #else
39 #  include <Weather/weather.hxx>
40 #endif
41 #include <Objects/matlib.hxx>
42
43 #include <GUI/gui.h>
44
45 #include "globals.hxx"
46 #include "fgfs.hxx"
47 #include "fg_props.hxx"
48 #include "viewmgr.hxx"
49
50 #if !defined(SG_HAVE_NATIVE_SGI_COMPILERS)
51 SG_USING_STD(istream);
52 SG_USING_STD(ostream);
53 #endif
54
55 static double getWindNorth ();
56 static double getWindEast ();
57 static double getWindDown ();
58
59 // Allow the view to be set from two axes (i.e. a joystick hat)
60 // This needs to be in FGViewer itself, somehow.
61 static double axisLong = 0.0;
62 static double axisLat = 0.0;
63
64 static bool winding_ccw = true; // FIXME: temporary
65
66 static bool fdm_data_logging = false; // FIXME: temporary
67
68
69 /**
70  * Utility function.
71  */
72 static inline void
73 _set_view_from_axes ()
74 {
75                                 // Take no action when hat is centered
76   if ( ( axisLong <  0.01 ) &&
77        ( axisLong > -0.01 ) &&
78        ( axisLat  <  0.01 ) &&
79        ( axisLat  > -0.01 )
80      )
81     return;
82
83   double viewDir = 999;
84
85   /* Do all the quick and easy cases */
86   if (axisLong < 0) {           // Longitudinal axis forward
87     if (axisLat == axisLong)
88       viewDir = 45;
89     else if (axisLat == - axisLong)
90       viewDir = 315;
91     else if (axisLat == 0)
92       viewDir = 0;
93   } else if (axisLong > 0) {    // Longitudinal axis backward
94     if (axisLat == - axisLong)
95       viewDir = 135;
96     else if (axisLat == axisLong)
97       viewDir = 225;
98     else if (axisLat == 0)
99       viewDir = 180;
100   } else if (axisLong == 0) {   // Longitudinal axis neutral
101     if (axisLat < 0)
102       viewDir = 90;
103     else if (axisLat > 0)
104       viewDir = 270;
105     else return; /* And assertion failure maybe? */
106   }
107
108   /* Do all the difficult cases */
109   if ( viewDir > 900 )
110     viewDir = SGD_RADIANS_TO_DEGREES * atan2 ( -axisLat, -axisLong );
111   if ( viewDir < -1 ) viewDir += 360;
112
113 //  SG_LOG(SG_INPUT, SG_ALERT, "Joystick Lat=" << axisLat << "   and Long="
114 //      << axisLong << "  gave angle=" << viewDir );
115
116   globals->get_current_view()->set_goal_view_offset(viewDir*SGD_DEGREES_TO_RADIANS);
117 //   globals->get_current_view()->set_view_offset(viewDir*SGD_DEGREES_TO_RADIANS);
118 }
119
120 \f
121 ////////////////////////////////////////////////////////////////////////
122 // Default property bindings (not yet handled by any module).
123 ////////////////////////////////////////////////////////////////////////
124
125 struct LogClassMapping {
126   sgDebugClass c;
127   string name;
128   LogClassMapping(sgDebugClass cc, string nname) { c = cc; name = nname; }
129 };
130
131 LogClassMapping log_class_mappings [] = {
132   LogClassMapping(SG_NONE, "none"),
133   LogClassMapping(SG_TERRAIN, "terrain"),
134   LogClassMapping(SG_ASTRO, "astro"),
135   LogClassMapping(SG_FLIGHT, "flight"),
136   LogClassMapping(SG_INPUT, "input"),
137   LogClassMapping(SG_GL, "gl"),
138   LogClassMapping(SG_VIEW, "view"),
139   LogClassMapping(SG_COCKPIT, "cockpit"),
140   LogClassMapping(SG_GENERAL, "general"),
141   LogClassMapping(SG_MATH, "math"),
142   LogClassMapping(SG_EVENT, "event"),
143   LogClassMapping(SG_AIRCRAFT, "aircraft"),
144   LogClassMapping(SG_AUTOPILOT, "autopilot"),
145   LogClassMapping(SG_IO, "io"),
146   LogClassMapping(SG_CLIPPER, "clipper"),
147   LogClassMapping(SG_NETWORK, "network"),
148   LogClassMapping(SG_UNDEFD, "")
149 };
150
151
152 /**
153  * Get the logging classes.
154  */
155 static string
156 getLoggingClasses ()
157 {
158   sgDebugClass classes = logbuf::get_log_classes();
159   string result = "";
160   for (int i = 0; log_class_mappings[i].c != SG_UNDEFD; i++) {
161     if ((classes&log_class_mappings[i].c) > 0) {
162       if (result != (string)"")
163         result += '|';
164       result += log_class_mappings[i].name;
165     }
166   }
167   return result;
168 }
169
170
171 static void addLoggingClass (const string &name)
172 {
173   sgDebugClass classes = logbuf::get_log_classes();
174   for (int i = 0; log_class_mappings[i].c != SG_UNDEFD; i++) {
175     if (name == log_class_mappings[i].name) {
176       logbuf::set_log_classes(sgDebugClass(classes|log_class_mappings[i].c));
177       return;
178     }
179   }
180   SG_LOG(SG_GENERAL, SG_ALERT, "Unknown logging class: " << name);
181 }
182
183
184 /**
185  * Set the logging classes.
186  */
187 static void
188 setLoggingClasses (string classes)
189 {
190   logbuf::set_log_classes(SG_NONE);
191
192   if (classes == "none") {
193     SG_LOG(SG_GENERAL, SG_INFO, "Disabled all logging classes");
194     return;
195   }
196
197   if (classes == "" || classes == "all") { // default
198     logbuf::set_log_classes(SG_ALL);
199     SG_LOG(SG_GENERAL, SG_INFO, "Enabled all logging classes: "
200            << getLoggingClasses());
201     return;
202   }
203
204   string rest = classes;
205   string name = "";
206   int sep = rest.find('|');
207   while (sep > 0) {
208     name = rest.substr(0, sep);
209     rest = rest.substr(sep+1);
210     addLoggingClass(name);
211     sep = rest.find('|');
212   }
213   addLoggingClass(rest);
214   SG_LOG(SG_GENERAL, SG_INFO, "Set logging classes to "
215          << getLoggingClasses());
216 }
217
218
219 /**
220  * Get the logging priority.
221  */
222 static string
223 getLoggingPriority ()
224 {
225   switch (logbuf::get_log_priority()) {
226   case SG_BULK:
227     return "bulk";
228   case SG_DEBUG:
229     return "debug";
230   case SG_INFO:
231     return "info";
232   case SG_WARN:
233     return "warn";
234   case SG_ALERT:
235     return "alert";
236   default:
237     SG_LOG(SG_GENERAL, SG_WARN, "Internal: Unknown logging priority number: "
238            << logbuf::get_log_priority());
239     return "unknown";
240   }
241 }
242
243
244 /**
245  * Set the logging priority.
246  */
247 static void
248 setLoggingPriority (string priority)
249 {
250   if (priority == "bulk") {
251     logbuf::set_log_priority(SG_BULK);
252   } else if (priority == "debug") {
253     logbuf::set_log_priority(SG_DEBUG);
254   } else if (priority == "" || priority == "info") { // default
255     logbuf::set_log_priority(SG_INFO);
256   } else if (priority == "warn") {
257     logbuf::set_log_priority(SG_WARN);
258   } else if (priority == "alert") {
259     logbuf::set_log_priority(SG_ALERT);
260   } else {
261     SG_LOG(SG_GENERAL, SG_WARN, "Unknown logging priority " << priority);
262   }
263   SG_LOG(SG_GENERAL, SG_INFO, "Logging priority is " << getLoggingPriority());
264 }
265
266
267 #if 0
268 /**
269  * Get the pause state of the sim.
270  */
271 static bool
272 getFreeze ()
273 {
274   return globals->get_freeze();
275 }
276
277
278 /**
279  * Set the pause state of the sim.
280  */
281 static void
282 setFreeze (bool freeze)
283 {
284     globals->set_freeze(freeze);
285     if ( freeze ) {
286         // BusyCursor( 0 );
287         current_atcdisplay->CancelRepeatingMessage();
288         current_atcdisplay->RegisterRepeatingMessage("****    SIM IS FROZEN    ****    SIM IS FROZEN    ****");
289     } else {
290         // BusyCursor( 1 );
291         current_atcdisplay->CancelRepeatingMessage();
292     }
293 }
294 #endif
295
296 /**
297  * Return the current aircraft directory (UIUC) as a string.
298  */
299 static string 
300 getAircraftDir ()
301 {
302   return aircraft_dir;
303 }
304
305
306 /**
307  * Set the current aircraft directory (UIUC).
308  */
309 static void
310 setAircraftDir (string dir)
311 {
312   if (getAircraftDir() != dir) {
313     aircraft_dir = dir;
314 //     needReinit(); FIXME!!
315   }
316 }
317
318
319 /**
320  * Get the current view offset in degrees.
321  */
322 static double
323 getViewOffset ()
324 {
325   return (globals->get_current_view()
326           ->get_view_offset() * SGD_RADIANS_TO_DEGREES);
327 }
328
329
330 static void
331 setViewOffset (double offset)
332 {
333   globals->get_current_view()->set_view_offset(offset * SGD_DEGREES_TO_RADIANS);
334 }
335
336 static double
337 getGoalViewOffset ()
338 {
339   return (globals->get_current_view()
340           ->get_goal_view_offset() * SGD_RADIANS_TO_DEGREES);
341 }
342
343 static void
344 setGoalViewOffset (double offset)
345 {
346     while ( offset < 0 ) {
347         offset += 360.0;
348     }
349     while ( offset > 360.0 ) {
350         offset -= 360.0;
351     }
352     // Snap to center if we are close
353     if ( fabs(offset) < 1.0 ||  fabs(offset) > 359.0 ) {
354         offset = 0.0;
355     }
356
357     globals->get_current_view()
358         ->set_goal_view_offset(offset * SGD_DEGREES_TO_RADIANS);
359 }
360
361 /**
362  * Get the current view tilt in degrees.
363  */
364 static double
365 getViewTilt ()
366 {
367   return (globals->get_current_view()
368           ->get_view_tilt() * SGD_RADIANS_TO_DEGREES);
369 }
370
371
372 static void
373 setViewTilt (double tilt)
374 {
375   globals->get_current_view()->set_view_tilt(tilt * SGD_DEGREES_TO_RADIANS);
376 }
377
378 static double
379 getGoalViewTilt ()
380 {
381   return (globals->get_current_view()
382           ->get_goal_view_tilt() * SGD_RADIANS_TO_DEGREES);
383 }
384
385 static void
386 setGoalViewTilt (double tilt)
387 {
388     while ( tilt < 0 ) {
389         tilt += 360.0;
390     }
391     while ( tilt > 360.0 ) {
392         tilt -= 360.0;
393     }
394     // Snap to center if we are close
395     if ( fabs(tilt) < 1.0 ||  fabs(tilt) > 359.0 ) {
396         tilt = 0.0;
397     }
398
399     globals->get_current_view()
400         ->set_goal_view_tilt(tilt * SGD_DEGREES_TO_RADIANS);
401 }
402
403
404 /**
405  * Pilot position offset from CG.
406  */
407 static float
408 getPilotPositionXOffset ()
409 {
410   FGViewer * pilot_view = globals->get_viewmgr()->get_view(0);
411   float * offset = pilot_view->get_pilot_offset();
412   return offset[0];
413 }
414
415 static void
416 setPilotPositionXOffset (float x)
417 {
418   FGViewer * pilot_view = globals->get_viewmgr()->get_view(0);
419   float * offset = pilot_view->get_pilot_offset();
420   pilot_view->set_pilot_offset(x, offset[1], offset[2]);
421 }
422
423 static float
424 getPilotPositionYOffset ()
425 {
426   FGViewer * pilot_view = globals->get_viewmgr()->get_view(0);
427   float * offset = pilot_view->get_pilot_offset();
428   return offset[1];
429 }
430
431 static void
432 setPilotPositionYOffset (float y)
433 {
434   FGViewer * pilot_view = globals->get_viewmgr()->get_view(0);
435   float * offset = pilot_view->get_pilot_offset();
436   pilot_view->set_pilot_offset(offset[0], y, offset[2]);
437 }
438
439 static float
440 getPilotPositionZOffset ()
441 {
442   FGViewer * pilot_view = globals->get_viewmgr()->get_view(0);
443   float * offset = pilot_view->get_pilot_offset();
444   return offset[2];
445 }
446
447 static void
448 setPilotPositionZOffset (float z)
449 {
450   FGViewer * pilot_view = globals->get_viewmgr()->get_view(0);
451   float * offset = pilot_view->get_pilot_offset();
452   pilot_view->set_pilot_offset(offset[0], offset[1], z);
453 }
454
455
456 /**
457  * Return the current Zulu time.
458  */
459 static string 
460 getDateString ()
461 {
462   string out;
463   char buf[64];
464   struct tm * t = globals->get_time_params()->getGmt();
465   sprintf(buf, "%.4d-%.2d-%.2dT%.2d:%.2d:%.2d",
466           t->tm_year + 1900, t->tm_mon + 1, t->tm_mday,
467           t->tm_hour, t->tm_min, t->tm_sec);
468   out = buf;
469   return out;
470 }
471
472
473 /**
474  * Set the current Zulu time.
475  */
476 static void
477 setDateString (string date_string)
478 {
479   static const SGPropertyNode *cur_time_override
480         = fgGetNode("/sim/time/cur-time-override", true);
481
482   SGTime * st = globals->get_time_params();
483   struct tm * current_time = st->getGmt();
484   struct tm new_time;
485
486                                 // Scan for basic ISO format
487                                 // YYYY-MM-DDTHH:MM:SS
488   int ret = sscanf(date_string.c_str(), "%d-%d-%dT%d:%d:%d",
489                    &(new_time.tm_year), &(new_time.tm_mon),
490                    &(new_time.tm_mday), &(new_time.tm_hour),
491                    &(new_time.tm_min), &(new_time.tm_sec));
492
493                                 // Be pretty picky about this, so
494                                 // that strange things don't happen
495                                 // if the save file has been edited
496                                 // by hand.
497   if (ret != 6) {
498     SG_LOG(SG_INPUT, SG_ALERT, "Date/time string " << date_string
499            << " not in YYYY-MM-DDTHH:MM:SS format; skipped");
500     return;
501   }
502
503                                 // OK, it looks like we got six
504                                 // values, one way or another.
505   new_time.tm_year -= 1900;
506   new_time.tm_mon -= 1;
507
508                                 // Now, tell flight gear to use
509                                 // the new time.  This was far
510                                 // too difficult, by the way.
511   long int warp =
512     mktime(&new_time) - mktime(current_time) + globals->get_warp();
513   double lon = current_aircraft.fdm_state->get_Longitude();
514   double lat = current_aircraft.fdm_state->get_Latitude();
515   globals->set_warp(warp);
516   st->update(lon, lat, cur_time_override->getLongValue(), warp);
517   fgUpdateSkyAndLightingParams();
518 }
519
520 /**
521  * Return the GMT as a string.
522  */
523 static string 
524 getGMTString ()
525 {
526   string out;
527   char buf[16];
528   struct tm *t = globals->get_time_params()->getGmt();
529   sprintf(buf, " %.2d:%.2d:%.2d",
530           t->tm_hour, t->tm_min, t->tm_sec);
531   // cout << t << " " << buf << endl;
532   out = buf;
533   return out;
534 }
535
536
537 /**
538  * Get the texture rendering state.
539  */
540 static bool
541 getTextures ()
542 {
543   return (material_lib.get_step() == 0);
544 }
545
546
547 /**
548  * Set the texture rendering state.
549  */
550 static void
551 setTextures (bool textures)
552 {
553   if (textures)
554     material_lib.set_step(0);
555   else
556     material_lib.set_step(1);
557 }
558
559
560 /**
561  * Return the magnetic variation
562  */
563 static double
564 getMagVar ()
565 {
566   return globals->get_mag()->get_magvar() * SGD_RADIANS_TO_DEGREES;
567 }
568
569
570 /**
571  * Return the magnetic dip
572  */
573 static double
574 getMagDip ()
575 {
576   return globals->get_mag()->get_magdip() * SGD_RADIANS_TO_DEGREES;
577 }
578
579
580 /**
581  * Return the current heading in degrees.
582  */
583 static double
584 getHeadingMag ()
585 {
586   return current_aircraft.fdm_state->get_Psi() * SGD_RADIANS_TO_DEGREES - getMagVar();
587 }
588
589
590 /**
591  * Get the autopilot altitude lock (true=on).
592  */
593 static bool
594 getAPAltitudeLock ()
595 {
596     return (current_autopilot->get_AltitudeEnabled() &&
597             current_autopilot->get_AltitudeMode()
598             == FGAutopilot::FG_ALTITUDE_LOCK);
599 }
600
601
602 /**
603  * Set the autopilot altitude lock (true=on).
604  */
605 static void
606 setAPAltitudeLock (bool lock)
607 {
608   if (lock)
609     current_autopilot->set_AltitudeMode(FGAutopilot::FG_ALTITUDE_LOCK);
610   if (current_autopilot->get_AltitudeMode() == FGAutopilot::FG_ALTITUDE_LOCK)
611     current_autopilot->set_AltitudeEnabled(lock);
612 }
613
614
615 /**
616  * Get the autopilot target altitude in feet.
617  */
618 static double
619 getAPAltitude ()
620 {
621   return current_autopilot->get_TargetAltitude() * SG_METER_TO_FEET;
622 }
623
624
625 /**
626  * Set the autopilot target altitude in feet.
627  */
628 static void
629 setAPAltitude (double altitude)
630 {
631   current_autopilot->set_TargetAltitude( altitude * SG_FEET_TO_METER );
632 }
633
634 /**
635  * Get the autopilot altitude lock (true=on).
636  */
637 static bool
638 getAPGSLock ()
639 {
640     return (current_autopilot->get_AltitudeEnabled() &&
641             (current_autopilot->get_AltitudeMode()
642              == FGAutopilot::FG_ALTITUDE_GS1));
643 }
644
645
646 /**
647  * Set the autopilot altitude lock (true=on).
648  */
649 static void
650 setAPGSLock (bool lock)
651 {
652   if (lock)
653     current_autopilot->set_AltitudeMode(FGAutopilot::FG_ALTITUDE_GS1);
654   if (current_autopilot->get_AltitudeMode() == FGAutopilot::FG_ALTITUDE_GS1)
655     current_autopilot->set_AltitudeEnabled(lock);
656 }
657
658
659 /**
660  * Get the autopilot terrain lock (true=on).
661  */
662 static bool
663 getAPTerrainLock ()
664 {
665     return (current_autopilot->get_AltitudeEnabled() &&
666             (current_autopilot->get_AltitudeMode()
667              == FGAutopilot::FG_ALTITUDE_TERRAIN));
668 }
669
670
671 /**
672  * Set the autopilot terrain lock (true=on).
673  */
674 static void
675 setAPTerrainLock (bool lock)
676 {
677   if (lock) {
678     current_autopilot->set_AltitudeMode(FGAutopilot::FG_ALTITUDE_TERRAIN);
679     current_autopilot
680       ->set_TargetAGL(current_aircraft.fdm_state->get_Altitude_AGL() *
681                       SG_FEET_TO_METER);
682     cout << "Target AGL = "
683          << current_aircraft.fdm_state->get_Altitude_AGL() * SG_FEET_TO_METER
684          << endl;
685   }
686   if (current_autopilot->get_AltitudeMode() == FGAutopilot::FG_ALTITUDE_TERRAIN)
687     current_autopilot->set_AltitudeEnabled(lock);
688 }
689
690
691 /**
692  * Get the autopilot target altitude in feet.
693  */
694 static double
695 getAPClimb ()
696 {
697   return current_autopilot->get_TargetClimbRate() * SG_METER_TO_FEET;
698 }
699
700
701 /**
702  * Set the autopilot target altitude in feet.
703  */
704 static void
705 setAPClimb (double rate)
706 {
707     current_autopilot->set_TargetClimbRate( rate * SG_FEET_TO_METER );
708 }
709
710
711 /**
712  * Get the autopilot heading lock (true=on).
713  */
714 static bool
715 getAPHeadingLock ()
716 {
717     return
718       (current_autopilot->get_HeadingEnabled() &&
719        current_autopilot->get_HeadingMode() == DEFAULT_AP_HEADING_LOCK);
720 }
721
722
723 /**
724  * Set the autopilot heading lock (true=on).
725  */
726 static void
727 setAPHeadingLock (bool lock)
728 {
729   if (lock)
730     current_autopilot->set_HeadingMode(DEFAULT_AP_HEADING_LOCK);
731   if (current_autopilot->get_HeadingMode() == DEFAULT_AP_HEADING_LOCK)
732     current_autopilot->set_HeadingEnabled(lock);
733 }
734
735
736 /**
737  * Get the autopilot heading bug in degrees.
738  */
739 static double
740 getAPHeadingBug ()
741 {
742   return current_autopilot->get_DGTargetHeading();
743 }
744
745
746 /**
747  * Set the autopilot heading bug in degrees.
748  */
749 static void
750 setAPHeadingBug (double heading)
751 {
752   current_autopilot->set_DGTargetHeading( heading );
753 }
754
755
756 /**
757  * Get the autopilot wing leveler lock (true=on).
758  */
759 static bool
760 getAPWingLeveler ()
761 {
762     return
763       (current_autopilot->get_HeadingEnabled() &&
764        current_autopilot->get_HeadingMode() == FGAutopilot::FG_TC_HEADING_LOCK);
765 }
766
767
768 /**
769  * Set the autopilot wing leveler lock (true=on).
770  */
771 static void
772 setAPWingLeveler (bool lock)
773 {
774     if (lock)
775         current_autopilot->set_HeadingMode(FGAutopilot::FG_TC_HEADING_LOCK);
776     if (current_autopilot->get_HeadingMode() == FGAutopilot::FG_TC_HEADING_LOCK)
777       current_autopilot->set_HeadingEnabled(lock);
778 }
779
780 /**
781  * Return true if the autopilot is locked to NAV1.
782  */
783 static bool
784 getAPNAV1Lock ()
785 {
786   return
787     (current_autopilot->get_HeadingEnabled() &&
788      current_autopilot->get_HeadingMode() == FGAutopilot::FG_HEADING_NAV1);
789 }
790
791
792 /**
793  * Set the autopilot NAV1 lock.
794  */
795 static void
796 setAPNAV1Lock (bool lock)
797 {
798   if (lock)
799     current_autopilot->set_HeadingMode(FGAutopilot::FG_HEADING_NAV1);
800   if (current_autopilot->get_HeadingMode() == FGAutopilot::FG_HEADING_NAV1)
801     current_autopilot->set_HeadingEnabled(lock);
802 }
803
804 /**
805  * Get the autopilot autothrottle lock.
806  */
807 static bool
808 getAPAutoThrottleLock ()
809 {
810   return current_autopilot->get_AutoThrottleEnabled();
811 }
812
813
814 /**
815  * Set the autothrottle lock.
816  */
817 static void
818 setAPAutoThrottleLock (bool lock)
819 {
820   current_autopilot->set_AutoThrottleEnabled(lock);
821 }
822
823
824 // kludge
825 static double
826 getAPRudderControl ()
827 {
828     if (getAPHeadingLock())
829         return current_autopilot->get_TargetHeading();
830     else
831         return globals->get_controls()->get_rudder();
832 }
833
834 // kludge
835 static void
836 setAPRudderControl (double value)
837 {
838     if (getAPHeadingLock()) {
839         SG_LOG(SG_GENERAL, SG_DEBUG, "setAPRudderControl " << value );
840         value -= current_autopilot->get_TargetHeading();
841         current_autopilot->HeadingAdjust(value < 0.0 ? -1.0 : 1.0);
842     } else {
843         globals->get_controls()->set_rudder(value);
844     }
845 }
846
847 // kludge
848 static double
849 getAPElevatorControl ()
850 {
851   if (getAPAltitudeLock())
852       return current_autopilot->get_TargetAltitude();
853   else
854     return globals->get_controls()->get_elevator();
855 }
856
857 // kludge
858 static void
859 setAPElevatorControl (double value)
860 {
861     if (value != 0 && getAPAltitudeLock()) {
862         SG_LOG(SG_GENERAL, SG_DEBUG, "setAPElevatorControl " << value );
863         value -= current_autopilot->get_TargetAltitude();
864         current_autopilot->AltitudeAdjust(value < 0.0 ? 100.0 : -100.0);
865     } else {
866         globals->get_controls()->set_elevator(value);
867     }
868 }
869
870 // kludge
871 static double
872 getAPThrottleControl ()
873 {
874   if (getAPAutoThrottleLock())
875     return 0.0;                 // always resets
876   else
877     return globals->get_controls()->get_throttle(0);
878 }
879
880 // kludge
881 static void
882 setAPThrottleControl (double value)
883 {
884   if (getAPAutoThrottleLock())
885     current_autopilot->AutoThrottleAdjust(value < 0.0 ? -0.01 : 0.01);
886   else
887     globals->get_controls()->set_throttle(FGControls::ALL_ENGINES, value);
888 }
889
890
891 /**
892  * Get the current visibility (meters).
893  */
894 static double
895 getVisibility ()
896 {
897 #ifndef FG_OLD_WEATHER
898   return WeatherDatabase->getWeatherVisibility();
899 #else
900   return current_weather.get_visibility();
901 #endif
902 }
903
904
905 /**
906  * Set the current visibility (meters).
907  */
908 static void
909 setVisibility (double visibility)
910 {
911 #ifndef FG_OLD_WEATHER
912   WeatherDatabase->setWeatherVisibility(visibility);
913 #else
914   current_weather.set_visibility(visibility);
915 #endif
916 }
917
918 /**
919  * Get the current wind north velocity (feet/second).
920  */
921 static double
922 getWindNorth ()
923 {
924   return current_aircraft.fdm_state->get_V_north_airmass();
925 }
926
927
928 /**
929  * Set the current wind north velocity (feet/second).
930  */
931 static void
932 setWindNorth (double speed)
933 {
934   current_aircraft.fdm_state
935     ->set_Velocities_Local_Airmass(speed, getWindEast(), getWindDown());
936 }
937
938
939 /**
940  * Get the current wind east velocity (feet/second).
941  */
942 static double
943 getWindEast ()
944 {
945   return current_aircraft.fdm_state->get_V_east_airmass();
946 }
947
948
949 /**
950  * Set the current wind east velocity (feet/second).
951  */
952 static void
953 setWindEast (double speed)
954 {
955   cout << "Set wind-east to " << speed << endl;
956   current_aircraft.fdm_state->set_Velocities_Local_Airmass(getWindNorth(),
957                                                            speed,
958                                                            getWindDown());
959 }
960
961
962 /**
963  * Get the current wind down velocity (feet/second).
964  */
965 static double
966 getWindDown ()
967 {
968   return current_aircraft.fdm_state->get_V_down_airmass();
969 }
970
971
972 /**
973  * Set the current wind down velocity (feet/second).
974  */
975 static void
976 setWindDown (double speed)
977 {
978   current_aircraft.fdm_state->set_Velocities_Local_Airmass(getWindNorth(),
979                                                            getWindEast(),
980                                                            speed);
981 }
982
983 static double
984 getFOV ()
985 {
986   return globals->get_current_view()->get_fov();
987 }
988
989 static void
990 setFOV (double fov)
991 {
992   if ( fov < 180 ) {
993       globals->get_current_view()->set_fov( fov );
994   }
995 }
996
997 static long
998 getWarp ()
999 {
1000   return globals->get_warp();
1001 }
1002
1003 static void
1004 setWarp (long warp)
1005 {
1006   globals->set_warp(warp);
1007 }
1008
1009 static long
1010 getWarpDelta ()
1011 {
1012   return globals->get_warp_delta();
1013 }
1014
1015 static void
1016 setWarpDelta (long delta)
1017 {
1018   globals->set_warp_delta(delta);
1019 }
1020
1021 static void
1022 setViewAxisLong (double axis)
1023 {
1024   axisLong = axis;
1025 }
1026
1027 static void
1028 setViewAxisLat (double axis)
1029 {
1030   axisLat = axis;
1031 }
1032
1033 static bool
1034 getWindingCCW ()
1035 {
1036   return winding_ccw;
1037 }
1038
1039 static void
1040 setWindingCCW (bool state)
1041 {
1042   winding_ccw = state;
1043   if ( winding_ccw )
1044     glFrontFace ( GL_CCW );
1045   else
1046     glFrontFace ( GL_CW );
1047 }
1048
1049 static bool
1050 getFullScreen ()
1051 {
1052 #if defined(FX) && !defined(WIN32)
1053   return globals->get_fullscreen();
1054 #else
1055   return false;
1056 #endif
1057 }
1058
1059 static void
1060 setFullScreen (bool state)
1061 {
1062 #if defined(FX) && !defined(WIN32)
1063   globals->set_fullscreen(state);
1064 #  if defined(XMESA_FX_FULLSCREEN) && defined(XMESA_FX_WINDOW)
1065   XMesaSetFXmode( state ? XMESA_FX_FULLSCREEN : XMESA_FX_WINDOW );
1066 #  endif
1067 #endif
1068 }
1069
1070 static bool
1071 getFDMDataLogging ()
1072 {
1073   return fdm_data_logging;
1074 }
1075
1076 static void
1077 setFDMDataLogging (bool state)
1078 {
1079                                 // kludge; no getter or setter available
1080   if (state != fdm_data_logging) {
1081     fgToggleFDMdataLogging();
1082     fdm_data_logging = state;
1083   }
1084 }
1085
1086 \f
1087 ////////////////////////////////////////////////////////////////////////
1088 // Tie the properties.
1089 ////////////////////////////////////////////////////////////////////////
1090
1091 void
1092 fgInitProps ()
1093 {
1094                                 // Simulation
1095   fgTie("/sim/logging/priority", getLoggingPriority, setLoggingPriority);
1096   fgTie("/sim/logging/classes", getLoggingClasses, setLoggingClasses);
1097   // fgTie("/sim/freeze", getFreeze, setFreeze);
1098   fgTie("/sim/aircraft-dir", getAircraftDir, setAircraftDir);
1099   fgTie("/sim/view/offset-deg", getViewOffset, setViewOffset, false);
1100   fgSetArchivable("/sim/view/offset-deg");
1101   fgTie("/sim/view/goal-offset-deg", getGoalViewOffset, setGoalViewOffset, false);
1102   fgTie("/sim/view/tilt-deg", getViewTilt, setViewTilt, false);
1103   fgSetArchivable("/sim/view/tilt-deg");
1104   fgTie("/sim/view/goal-tilt-deg", getGoalViewTilt, setGoalViewTilt, false);
1105   fgSetArchivable("/sim/view/goal-offset-deg");
1106   fgTie("/sim/view/pilot/x-offset-m",
1107         getPilotPositionXOffset, setPilotPositionXOffset);
1108   fgSetArchivable("/sim/view/pilot/x-offset-m");
1109   fgTie("/sim/view/pilot/y-offset-m",
1110         getPilotPositionYOffset, setPilotPositionYOffset);
1111   fgSetArchivable("/sim/view/pilot/y-offset-m");
1112   fgTie("/sim/view/pilot/z-offset-m",
1113         getPilotPositionZOffset, setPilotPositionZOffset);
1114   fgSetArchivable("/sim/view/pilot/z-offset-m");
1115   fgTie("/sim/time/gmt", getDateString, setDateString);
1116   fgSetArchivable("/sim/time/gmt");
1117   fgTie("/sim/time/gmt-string", getGMTString);
1118   fgTie("/sim/rendering/textures", getTextures, setTextures);
1119
1120                                 // Orientation
1121   fgTie("/orientation/heading-magnetic-deg", getHeadingMag);
1122
1123                                 // Autopilot
1124   fgTie("/autopilot/locks/altitude", getAPAltitudeLock, setAPAltitudeLock);
1125   fgSetArchivable("/autopilot/locks/altitude");
1126   fgTie("/autopilot/settings/altitude-ft", getAPAltitude, setAPAltitude);
1127   fgSetArchivable("/autopilot/settings/altitude-ft");
1128   fgTie("/autopilot/locks/glide-slope", getAPGSLock, setAPGSLock);
1129   fgSetArchivable("/autopilot/locks/glide-slope");
1130   fgTie("/autopilot/locks/terrain", getAPTerrainLock, setAPTerrainLock);
1131   fgSetArchivable("/autopilot/locks/terrain");
1132   fgTie("/autopilot/settings/climb-rate-fpm", getAPClimb, setAPClimb, false);
1133   fgSetArchivable("/autopilot/settings/climb-rate-fpm");
1134   fgTie("/autopilot/locks/heading", getAPHeadingLock, setAPHeadingLock);
1135   fgSetArchivable("/autopilot/locks/heading");
1136   fgTie("/autopilot/settings/heading-bug-deg",
1137         getAPHeadingBug, setAPHeadingBug);
1138   fgSetArchivable("/autopilot/settings/heading-bug-deg");
1139   fgTie("/autopilot/locks/wing-leveler", getAPWingLeveler, setAPWingLeveler);
1140   fgSetArchivable("/autopilot/locks/wing-leveler");
1141   fgTie("/autopilot/locks/nav[0]", getAPNAV1Lock, setAPNAV1Lock);
1142   fgSetArchivable("/autopilot/locks/nav[0]");
1143   fgTie("/autopilot/locks/auto-throttle",
1144         getAPAutoThrottleLock, setAPAutoThrottleLock);
1145   fgSetArchivable("/autopilot/locks/auto-throttle");
1146   fgTie("/autopilot/control-overrides/rudder",
1147         getAPRudderControl, setAPRudderControl);
1148   fgSetArchivable("/autopilot/control-overrides/rudder");
1149   fgTie("/autopilot/control-overrides/elevator",
1150         getAPElevatorControl, setAPElevatorControl);
1151   fgSetArchivable("/autopilot/control-overrides/elevator");
1152   fgTie("/autopilot/control-overrides/throttle",
1153         getAPThrottleControl, setAPThrottleControl);
1154   fgSetArchivable("/autopilot/control-overrides/throttle");
1155
1156                                 // Environment
1157   fgTie("/environment/visibility-m", getVisibility, setVisibility);
1158   fgSetArchivable("/environment/visibility-m");
1159   fgTie("/environment/wind-north-fps", getWindNorth, setWindNorth);
1160   fgSetArchivable("/environment/wind-north-fps");
1161   fgTie("/environment/wind-east-fps", getWindEast, setWindEast);
1162   fgSetArchivable("/environment/wind-east-fps");
1163   fgTie("/environment/wind-down-fps", getWindDown, setWindDown);
1164   fgSetArchivable("/environment/wind-down-fps");
1165
1166   fgTie("/environment/magnetic-variation-deg", getMagVar);
1167   fgTie("/environment/magnetic-dip-deg", getMagDip);
1168
1169                                 // View
1170   fgTie("/sim/field-of-view", getFOV, setFOV);
1171   fgSetArchivable("/sim/field-of-view");
1172   fgTie("/sim/time/warp", getWarp, setWarp, false);
1173   fgTie("/sim/time/warp-delta", getWarpDelta, setWarpDelta);
1174   fgTie("/sim/view/axes/long", (double(*)())0, setViewAxisLong);
1175   fgTie("/sim/view/axes/lat", (double(*)())0, setViewAxisLat);
1176
1177                                 // Misc. Temporary junk.
1178   fgTie("/sim/temp/winding-ccw", getWindingCCW, setWindingCCW, false);
1179   fgTie("/sim/temp/full-screen", getFullScreen, setFullScreen);
1180   fgTie("/sim/temp/fdm-data-logging", getFDMDataLogging, setFDMDataLogging);
1181         
1182 }
1183
1184
1185 void
1186 fgUpdateProps ()
1187 {
1188   _set_view_from_axes();
1189 }
1190
1191
1192 \f
1193 ////////////////////////////////////////////////////////////////////////
1194 // Save and restore.
1195 ////////////////////////////////////////////////////////////////////////
1196
1197
1198 /**
1199  * Save the current state of the simulator to a stream.
1200  */
1201 bool
1202 fgSaveFlight (ostream &output)
1203 {
1204   try {
1205     writeProperties(output, globals->get_props());
1206   } catch (const sg_exception &e) {
1207     guiErrorMessage("Error saving flight: ", e);
1208     return false;
1209   }
1210   return true;
1211 }
1212
1213
1214 /**
1215  * Restore the current state of the simulator from a stream.
1216  */
1217 bool
1218 fgLoadFlight (istream &input)
1219 {
1220   SGPropertyNode props;
1221   try {
1222     readProperties(input, &props);
1223   } catch (const sg_exception &e) {
1224     guiErrorMessage("Error reading saved flight: ", e);
1225     return false;
1226   }
1227   copyProperties(&props, globals->get_props());
1228   // When loading a flight, make it the
1229   // new initial state.
1230   globals->saveInitialState();
1231   return true;
1232 }
1233
1234
1235 \f
1236 ////////////////////////////////////////////////////////////////////////
1237 // Implementation of FGCondition.
1238 ////////////////////////////////////////////////////////////////////////
1239
1240 FGCondition::FGCondition ()
1241 {
1242 }
1243
1244 FGCondition::~FGCondition ()
1245 {
1246 }
1247
1248
1249 \f
1250 ////////////////////////////////////////////////////////////////////////
1251 // Implementation of FGPropertyCondition.
1252 ////////////////////////////////////////////////////////////////////////
1253
1254 FGPropertyCondition::FGPropertyCondition (const string &propname)
1255   : _node(fgGetNode(propname, true))
1256 {
1257 }
1258
1259 FGPropertyCondition::~FGPropertyCondition ()
1260 {
1261 }
1262
1263
1264 \f
1265 ////////////////////////////////////////////////////////////////////////
1266 // Implementation of FGNotCondition.
1267 ////////////////////////////////////////////////////////////////////////
1268
1269 FGNotCondition::FGNotCondition (FGCondition * condition)
1270   : _condition(condition)
1271 {
1272 }
1273
1274 FGNotCondition::~FGNotCondition ()
1275 {
1276   delete _condition;
1277 }
1278
1279 bool
1280 FGNotCondition::test () const
1281 {
1282   return !(_condition->test());
1283 }
1284
1285
1286 \f
1287 ////////////////////////////////////////////////////////////////////////
1288 // Implementation of FGAndCondition.
1289 ////////////////////////////////////////////////////////////////////////
1290
1291 FGAndCondition::FGAndCondition ()
1292 {
1293 }
1294
1295 FGAndCondition::~FGAndCondition ()
1296 {
1297   for (unsigned int i = 0; i < _conditions.size(); i++)
1298     delete _conditions[i];
1299 }
1300
1301 bool
1302 FGAndCondition::test () const
1303 {
1304   int nConditions = _conditions.size();
1305   for (int i = 0; i < nConditions; i++) {
1306     if (!_conditions[i]->test())
1307       return false;
1308   }
1309   return true;
1310 }
1311
1312 void
1313 FGAndCondition::addCondition (FGCondition * condition)
1314 {
1315   _conditions.push_back(condition);
1316 }
1317
1318
1319 \f
1320 ////////////////////////////////////////////////////////////////////////
1321 // Implementation of FGOrCondition.
1322 ////////////////////////////////////////////////////////////////////////
1323
1324 FGOrCondition::FGOrCondition ()
1325 {
1326 }
1327
1328 FGOrCondition::~FGOrCondition ()
1329 {
1330   for (unsigned int i = 0; i < _conditions.size(); i++)
1331     delete _conditions[i];
1332 }
1333
1334 bool
1335 FGOrCondition::test () const
1336 {
1337   int nConditions = _conditions.size();
1338   for (int i = 0; i < nConditions; i++) {
1339     if (_conditions[i]->test())
1340       return true;
1341   }
1342   return false;
1343 }
1344
1345 void
1346 FGOrCondition::addCondition (FGCondition * condition)
1347 {
1348   _conditions.push_back(condition);
1349 }
1350
1351
1352 \f
1353 ////////////////////////////////////////////////////////////////////////
1354 // Implementation of FGComparisonCondition.
1355 ////////////////////////////////////////////////////////////////////////
1356
1357 static int
1358 doComparison (const SGPropertyNode * left, const SGPropertyNode *right)
1359 {
1360   switch (left->getType()) {
1361   case SGPropertyNode::BOOL: {
1362     bool v1 = left->getBoolValue();
1363     bool v2 = right->getBoolValue();
1364     if (v1 < v2)
1365       return FGComparisonCondition::LESS_THAN;
1366     else if (v1 > v2)
1367       return FGComparisonCondition::GREATER_THAN;
1368     else
1369       return FGComparisonCondition::EQUALS;
1370     break;
1371   }
1372   case SGPropertyNode::INT: {
1373     int v1 = left->getIntValue();
1374     int v2 = right->getIntValue();
1375     if (v1 < v2)
1376       return FGComparisonCondition::LESS_THAN;
1377     else if (v1 > v2)
1378       return FGComparisonCondition::GREATER_THAN;
1379     else
1380       return FGComparisonCondition::EQUALS;
1381     break;
1382   }
1383   case SGPropertyNode::LONG: {
1384     long v1 = left->getLongValue();
1385     long v2 = right->getLongValue();
1386     if (v1 < v2)
1387       return FGComparisonCondition::LESS_THAN;
1388     else if (v1 > v2)
1389       return FGComparisonCondition::GREATER_THAN;
1390     else
1391       return FGComparisonCondition::EQUALS;
1392     break;
1393   }
1394   case SGPropertyNode::FLOAT: {
1395     float v1 = left->getFloatValue();
1396     float v2 = right->getFloatValue();
1397     if (v1 < v2)
1398       return FGComparisonCondition::LESS_THAN;
1399     else if (v1 > v2)
1400       return FGComparisonCondition::GREATER_THAN;
1401     else
1402       return FGComparisonCondition::EQUALS;
1403     break;
1404   }
1405   case SGPropertyNode::DOUBLE: {
1406     double v1 = left->getDoubleValue();
1407     double v2 = right->getDoubleValue();
1408     if (v1 < v2)
1409       return FGComparisonCondition::LESS_THAN;
1410     else if (v1 > v2)
1411       return FGComparisonCondition::GREATER_THAN;
1412     else
1413       return FGComparisonCondition::EQUALS;
1414     break;
1415   }
1416   case SGPropertyNode::STRING: 
1417   case SGPropertyNode::NONE:
1418   case SGPropertyNode::UNSPECIFIED: {
1419     string v1 = left->getStringValue();
1420     string v2 = right->getStringValue();
1421     if (v1 < v2)
1422       return FGComparisonCondition::LESS_THAN;
1423     else if (v1 > v2)
1424       return FGComparisonCondition::GREATER_THAN;
1425     else
1426       return FGComparisonCondition::EQUALS;
1427     break;
1428   }
1429   }
1430   throw sg_exception("Unrecognized node type");
1431   return 0;
1432 }
1433
1434
1435 FGComparisonCondition::FGComparisonCondition (Type type, bool reverse)
1436   : _type(type),
1437     _reverse(reverse),
1438     _left_property(0),
1439     _right_property(0),
1440     _right_value(0)
1441 {
1442 }
1443
1444 FGComparisonCondition::~FGComparisonCondition ()
1445 {
1446   delete _right_value;
1447 }
1448
1449 bool
1450 FGComparisonCondition::test () const
1451 {
1452                                 // Always fail if incompletely specified
1453   if (_left_property == 0 ||
1454       (_right_property == 0 && _right_value == 0))
1455     return false;
1456
1457                                 // Get LESS_THAN, EQUALS, or GREATER_THAN
1458   int cmp =
1459     doComparison(_left_property,
1460                  (_right_property != 0 ? _right_property : _right_value));
1461   if (!_reverse)
1462     return (cmp == _type);
1463   else
1464     return (cmp != _type);
1465 }
1466
1467 void
1468 FGComparisonCondition::setLeftProperty (const string &propname)
1469 {
1470   _left_property = fgGetNode(propname, true);
1471 }
1472
1473 void
1474 FGComparisonCondition::setRightProperty (const string &propname)
1475 {
1476   delete _right_value;
1477   _right_value = 0;
1478   _right_property = fgGetNode(propname, true);
1479 }
1480
1481 void
1482 FGComparisonCondition::setRightValue (const SGPropertyNode *node)
1483 {
1484   _right_property = 0;
1485   delete _right_value;
1486   _right_value = new SGPropertyNode(*node);
1487 }
1488
1489
1490 \f
1491 ////////////////////////////////////////////////////////////////////////
1492 // Read a condition and use it if necessary.
1493 ////////////////////////////////////////////////////////////////////////
1494
1495                                 // Forward declaration
1496 static FGCondition * readCondition (const SGPropertyNode * node);
1497
1498 static FGCondition *
1499 readPropertyCondition (const SGPropertyNode * node)
1500 {
1501   return new FGPropertyCondition(node->getStringValue());
1502 }
1503
1504 static FGCondition *
1505 readNotCondition (const SGPropertyNode * node)
1506 {
1507   int nChildren = node->nChildren();
1508   for (int i = 0; i < nChildren; i++) {
1509     const SGPropertyNode * child = node->getChild(i);
1510     FGCondition * condition = readCondition(child);
1511     if (condition != 0)
1512       return new FGNotCondition(condition);
1513   }
1514   SG_LOG(SG_COCKPIT, SG_ALERT, "Panel: empty 'not' condition");
1515   return 0;
1516 }
1517
1518 static FGCondition *
1519 readAndConditions (const SGPropertyNode * node)
1520 {
1521   FGAndCondition * andCondition = new FGAndCondition;
1522   int nChildren = node->nChildren();
1523   for (int i = 0; i < nChildren; i++) {
1524     const SGPropertyNode * child = node->getChild(i);
1525     FGCondition * condition = readCondition(child);
1526     if (condition != 0)
1527       andCondition->addCondition(condition);
1528   }
1529   return andCondition;
1530 }
1531
1532 static FGCondition *
1533 readOrConditions (const SGPropertyNode * node)
1534 {
1535   FGOrCondition * orCondition = new FGOrCondition;
1536   int nChildren = node->nChildren();
1537   for (int i = 0; i < nChildren; i++) {
1538     const SGPropertyNode * child = node->getChild(i);
1539     FGCondition * condition = readCondition(child);
1540     if (condition != 0)
1541       orCondition->addCondition(condition);
1542   }
1543   return orCondition;
1544 }
1545
1546 static FGCondition *
1547 readComparison (const SGPropertyNode * node,
1548                 FGComparisonCondition::Type type,
1549                 bool reverse)
1550 {
1551   FGComparisonCondition * condition = new FGComparisonCondition(type, reverse);
1552   condition->setLeftProperty(node->getStringValue("property[0]"));
1553   if (node->hasValue("property[1]"))
1554     condition->setRightProperty(node->getStringValue("property[1]"));
1555   else
1556     condition->setRightValue(node->getChild("value", 0));
1557
1558   return condition;
1559 }
1560
1561 static FGCondition *
1562 readCondition (const SGPropertyNode * node)
1563 {
1564   const string &name = node->getName();
1565   if (name == "property")
1566     return readPropertyCondition(node);
1567   else if (name == "not")
1568     return readNotCondition(node);
1569   else if (name == "and")
1570     return readAndConditions(node);
1571   else if (name == "or")
1572     return readOrConditions(node);
1573   else if (name == "less-than")
1574     return readComparison(node, FGComparisonCondition::LESS_THAN, false);
1575   else if (name == "less-than-equals")
1576     return readComparison(node, FGComparisonCondition::GREATER_THAN, true);
1577   else if (name == "greater-than")
1578     return readComparison(node, FGComparisonCondition::GREATER_THAN, false);
1579   else if (name == "greater-than-equals")
1580     return readComparison(node, FGComparisonCondition::LESS_THAN, true);
1581   else if (name == "equals")
1582     return readComparison(node, FGComparisonCondition::EQUALS, false);
1583   else if (name == "not-equals")
1584     return readComparison(node, FGComparisonCondition::EQUALS, true);
1585   else
1586     return 0;
1587 }
1588
1589
1590 \f
1591 ////////////////////////////////////////////////////////////////////////
1592 // Implementation of FGConditional.
1593 ////////////////////////////////////////////////////////////////////////
1594
1595 FGConditional::FGConditional ()
1596   : _condition (0)
1597 {
1598 }
1599
1600 FGConditional::~FGConditional ()
1601 {
1602   delete _condition;
1603 }
1604
1605 void
1606 FGConditional::setCondition (FGCondition * condition)
1607 {
1608   delete _condition;
1609   _condition = condition;
1610 }
1611
1612 bool
1613 FGConditional::test () const
1614 {
1615   return ((_condition == 0) || _condition->test());
1616 }
1617
1618
1619 \f
1620 // The top-level is always an implicit 'and' group
1621 FGCondition *
1622 fgReadCondition (const SGPropertyNode * node)
1623 {
1624   return readAndConditions(node);
1625 }
1626
1627
1628 // end of fg_props.cxx