]> git.mxchange.org Git - flightgear.git/blob - src/Cockpit/panel_io.cxx
initialize marker_xs.
[flightgear.git] / src / Cockpit / panel_io.cxx
1 //  panel_io.cxx - I/O for 2D panel.
2 //
3 //  Written by David Megginson, started January 2000.
4 //
5 //  This program is free software; you can redistribute it and/or
6 //  modify it under the terms of the GNU General Public License as
7 //  published by the Free Software Foundation; either version 2 of the
8 //  License, or (at your option) any later version.
9 // 
10 //  This program is distributed in the hope that it will be useful, but
11 //  WITHOUT ANY WARRANTY; without even the implied warranty of
12 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 //  General Public License for more details.
14 // 
15 //  You should have received a copy of the GNU General Public License
16 //  along with this program; if not, write to the Free Software
17 //  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 //
19 //  $Id$
20
21 #ifdef HAVE_CONFIG_H
22 #  include <config.h>
23 #endif
24
25 #ifdef HAVE_WINDOWS_H          
26 #  include <windows.h>
27 #endif
28
29 #include <simgear/compiler.h>
30 #include <simgear/misc/exception.hxx>
31
32 #include <simgear/misc/sg_path.hxx>
33 #include <simgear/debug/logstream.hxx>
34 #include <simgear/misc/props.hxx>
35
36 #include STL_IOSTREAM
37 #include STL_FSTREAM
38 #include STL_STRING
39
40 #include <Main/globals.hxx>
41 #include <Main/fg_props.hxx>
42
43 #include <GUI/gui.h>
44
45 #include "panel.hxx"
46 #include "steam.hxx"
47 #include "panel_io.hxx"
48
49 #if !defined (SG_HAVE_NATIVE_SGI_COMPILERS)
50 SG_USING_STD(istream);
51 SG_USING_STD(ifstream);
52 #endif
53 SG_USING_STD(string);
54
55
56 \f
57 ////////////////////////////////////////////////////////////////////////
58 // Built-in layer for the magnetic compass ribbon layer.
59 //
60 // TODO: move this out into a special directory for built-in
61 // layers of various sorts.
62 ////////////////////////////////////////////////////////////////////////
63
64 class FGMagRibbon : public FGTexturedLayer
65 {
66 public:
67   FGMagRibbon (int w, int h);
68   virtual ~FGMagRibbon () {}
69
70   virtual void draw ();
71 };
72
73 FGMagRibbon::FGMagRibbon (int w, int h)
74   : FGTexturedLayer(w, h)
75 {
76   FGCroppedTexture texture("Aircraft/c172/Instruments/Textures/compass-ribbon.rgb");
77   setTexture(texture);
78 }
79
80 void
81 FGMagRibbon::draw ()
82 {
83   double heading = FGSteam::get_MH_deg();
84   double xoffset, yoffset;
85
86   while (heading >= 360.0) {
87     heading -= 360.0;
88   }
89   while (heading < 0.0) {
90     heading += 360.0;
91   }
92
93   if (heading >= 60.0 && heading <= 180.0) {
94     xoffset = heading / 240.0;
95     yoffset = 0.75;
96   } else if (heading >= 150.0 && heading <= 270.0) {
97     xoffset = (heading - 90.0) / 240.0;
98     yoffset = 0.50;
99   } else if (heading >= 240.0 && heading <= 360.0) {
100     xoffset = (heading - 180.0) / 240.0;
101     yoffset = 0.25;
102   } else {
103     if (heading < 270.0)
104       heading += 360.0;
105     xoffset = (heading - 270.0) / 240.0;
106     yoffset = 0.0;
107   }
108
109   xoffset = 1.0 - xoffset;
110                                 // Adjust to put the number in the centre
111   xoffset -= 0.25;
112
113   FGCroppedTexture &t = getTexture();
114   t.setCrop(xoffset, yoffset, xoffset + 0.5, yoffset + 0.25);
115   FGTexturedLayer::draw();
116 }
117
118
119 \f
120 ////////////////////////////////////////////////////////////////////////
121 // Read and construct a panel.
122 //
123 // The panel is specified as a regular property list, and each of the
124 // instruments is its own, separate property list (and thus, a separate
125 // XML document).  The functions in this section read in the files
126 // as property lists, then extract properties to set up the panel
127 // itself.
128 //
129 // A panel contains zero or more instruments.
130 //
131 // An instrument contains one or more layers and zero or more actions.
132 //
133 // A layer contains zero or more transformations.
134 //
135 // Some special types of layers also contain other objects, such as 
136 // chunks of text or other layers.
137 //
138 // There are currently four types of layers:
139 //
140 // 1. Textured Layer (type="texture"), the default
141 // 2. Text Layer (type="text")
142 // 3. Switch Layer (type="switch")
143 // 4. Built-in Layer (type="built-in", must also specify class)
144 //
145 // The only built-in layer so far is the ribbon for the magnetic compass
146 // (class="compass-ribbon").
147 //
148 // There are three types of actions:
149 //
150 // 1. Adjust (type="adjust"), the default
151 // 2. Swap (type="swap")
152 // 3. Toggle (type="toggle")
153 //
154 // There are three types of transformations:
155 //
156 // 1. X shift (type="x-shift"), the default
157 // 2. Y shift (type="y-shift")
158 // 3. Rotation (type="rotation")
159 //
160 // Each of these may be associated with a property, so that a needle
161 // will rotate with the airspeed, for example, or may have a fixed
162 // floating-point value.
163 ////////////////////////////////////////////////////////////////////////
164
165
166 /**
167  * Read a cropped texture from the instrument's property list.
168  *
169  * The x1 and y1 properties give the starting position of the texture
170  * (between 0.0 and 1.0), and the the x2 and y2 properties give the
171  * ending position.  For example, to use the bottom-left quarter of a
172  * texture, x1=0.0, y1=0.0, x2=0.5, y2=0.5.
173  */
174 static FGCroppedTexture
175 readTexture (const SGPropertyNode * node)
176 {
177     FGCroppedTexture texture(node->getStringValue("path"),
178                              node->getFloatValue("x1"),
179                              node->getFloatValue("y1"),
180                              node->getFloatValue("x2", 1.0),
181                              node->getFloatValue("y2", 1.0));
182     SG_LOG(SG_COCKPIT, SG_DEBUG, "Read texture " << node->getName());
183     return texture;
184 }
185
186
187 /**
188  * Read an action from the instrument's property list.
189  *
190  * The action will be performed when the user clicks a mouse button
191  * within the specified region of the instrument.  Actions always work
192  * by modifying the value of a property (see the SGPropertyNode
193  * class).
194  *
195  * The following action types are defined:
196  *
197  * "adjust" - modify the value of a floating-point property by
198  *    the increment specified.  This is the default.
199  *
200  * "swap" - swap the values of two-floating-point properties.
201  *
202  * "toggle" - toggle the value of a boolean property between true and
203  *    false.
204  *
205  * For the adjust action, it is possible to specify an increment
206  * (use a negative number for a decrement), a minimum allowed value,
207  * a maximum allowed value, and a flag to indicate whether the value
208  * should freeze or wrap-around when it reachs the minimum or maximum.
209  *
210  * The action will be scaled automatically if the instrument is not
211  * being drawn at its regular size.
212  */
213 static FGPanelAction *
214 readAction (const SGPropertyNode * node, float w_scale, float h_scale)
215 {
216   string name = node->getStringValue("name");
217
218   int button = node->getIntValue("button");
219   int x = int(node->getIntValue("x") * w_scale);
220   int y = int(node->getIntValue("y") * h_scale);
221   int w = int(node->getIntValue("w") * w_scale);
222   int h = int(node->getIntValue("h") * h_scale);
223
224   FGPanelAction * action = new FGPanelAction(button, x, y, w, h);
225
226   vector<const SGPropertyNode *>bindings = node->getChildren("binding");
227   for (int i = 0; i < bindings.size(); i++) {
228     SG_LOG(SG_INPUT, SG_INFO, "Reading binding "
229            << bindings[i]->getStringValue("command"));
230     action->addBinding(FGBinding(bindings[i])); // TODO: allow modifiers
231   }
232
233   return action;
234 }
235
236
237 /**
238  * Read a transformation from the instrument's property list.
239  *
240  * The panel module uses the transformations to slide or spin needles,
241  * knobs, and other indicators, and to place layers in the correct
242  * positions.  Every layer starts centered exactly on the x,y co-ordinate,
243  * and many layers need to be moved or rotated simply to display the
244  * instrument correctly.
245  *
246  * There are three types of transformations:
247  *
248  * "x-shift" - move the layer horizontally.
249  *
250  * "y-shift" - move the layer vertically.
251  *
252  * "rotation" - rotate the layer.
253  *
254  * Each transformation may have a fixed offset, and may also have
255  * a floating-point property value to add to the offset.  The
256  * floating-point property may be clamped to a minimum and/or
257  * maximum range and scaled (after clamping).
258  *
259  * Note that because of the way OpenGL works, transformations will
260  * appear to be applied backwards.
261  */
262 static FGPanelTransformation *
263 readTransformation (const SGPropertyNode * node, float w_scale, float h_scale)
264 {
265   FGPanelTransformation * t = new FGPanelTransformation;
266
267   string name = node->getName();
268   string type = node->getStringValue("type");
269   string propName = node->getStringValue("property", "");
270   SGPropertyNode * target = 0;
271
272   if (type == "") {
273     SG_LOG( SG_COCKPIT, SG_ALERT,
274             "No type supplied for transformation " << name
275             << " assuming \"rotation\"" );
276     type = "rotation";
277   }
278
279   if (propName != (string)"") {
280     target = fgGetNode(propName, true);
281   }
282
283   t->node = target;
284   t->min = node->getFloatValue("min", -9999999);
285   t->max = node->getFloatValue("max", 99999999);
286   t->factor = node->getFloatValue("scale", 1.0);
287   t->offset = node->getFloatValue("offset", 0.0);
288
289                                 // Check for an interpolation table
290   const SGPropertyNode * trans_table = node->getNode("interpolation");
291   if (trans_table != 0) {
292     SG_LOG( SG_COCKPIT, SG_INFO, "Found interpolation table with "
293             << trans_table->nChildren() << "children" );
294     t->table = new SGInterpTable();
295     for(int i = 0; i < trans_table->nChildren(); i++) {
296       const SGPropertyNode * node = trans_table->getChild(i);
297       if (node->getName() == "entry") {
298         double ind = node->getDoubleValue("ind", 0.0);
299         double dep = node->getDoubleValue("dep", 0.0);
300         SG_LOG( SG_COCKPIT, SG_INFO, "Adding interpolation entry "
301                 << ind << "==>" << dep );
302         t->table->addEntry(ind, dep);
303       } else {
304         SG_LOG( SG_COCKPIT, SG_INFO, "Skipping " << node->getName()
305                 << " in interpolation" );
306       }
307     }
308   } else {
309     t->table = 0;
310   }
311   
312                                 // Move the layer horizontally.
313   if (type == "x-shift") {
314     t->type = FGPanelTransformation::XSHIFT;
315 //     t->min *= w_scale; //removed by Martin Dressler
316 //     t->max *= w_scale; //removed by Martin Dressler
317     t->offset *= w_scale;
318     t->factor *= w_scale; //Added by Martin Dressler
319   } 
320
321                                 // Move the layer vertically.
322   else if (type == "y-shift") {
323     t->type = FGPanelTransformation::YSHIFT;
324     //t->min *= h_scale; //removed
325     //t->max *= h_scale; //removed
326     t->offset *= h_scale;
327     t->factor *= h_scale; //Added
328   } 
329
330                                 // Rotate the layer.  The rotation
331                                 // is in degrees, and does not need
332                                 // to scale with the instrument size.
333   else if (type == "rotation") {
334     t->type = FGPanelTransformation::ROTATION;
335   } 
336
337   else {
338     SG_LOG( SG_COCKPIT, SG_ALERT, "Unrecognized transformation type " << type );
339     delete t;
340     return 0;
341   }
342
343   SG_LOG( SG_COCKPIT, SG_DEBUG, "Read transformation " << name );
344   return t;
345 }
346
347
348 /**
349  * Read a chunk of text from the instrument's property list.
350  *
351  * A text layer consists of one or more chunks of text.  All chunks
352  * share the same font size and color (and eventually, font), but
353  * each can come from a different source.  There are three types of
354  * text chunks:
355  *
356  * "literal" - a literal text string (the default)
357  *
358  * "text-value" - the current value of a string property
359  *
360  * "number-value" - the current value of a floating-point property.
361  *
362  * All three may also include a printf-style format string.
363  */
364 FGTextLayer::Chunk *
365 readTextChunk (const SGPropertyNode * node)
366 {
367   FGTextLayer::Chunk * chunk;
368   string name = node->getStringValue("name");
369   string type = node->getStringValue("type");
370   string format = node->getStringValue("format");
371
372                                 // Default to literal text.
373   if (type == "") {
374     SG_LOG( SG_COCKPIT, SG_INFO, "No type provided for text chunk " << name
375             << " assuming \"literal\"");
376     type = "literal";
377   }
378
379                                 // A literal text string.
380   if (type == "literal") {
381     string text = node->getStringValue("text");
382     chunk = new FGTextLayer::Chunk(text, format);
383   }
384
385                                 // The value of a string property.
386   else if (type == "text-value") {
387     SGPropertyNode * target =
388       fgGetNode(node->getStringValue("property"), true);
389     chunk = new FGTextLayer::Chunk(FGTextLayer::TEXT_VALUE, target, format);
390   }
391
392                                 // The value of a float property.
393   else if (type == "number-value") {
394     string propName = node->getStringValue("property");
395     float scale = node->getFloatValue("scale", 1.0);
396     SGPropertyNode * target = fgGetNode(propName, true);
397     chunk = new FGTextLayer::Chunk(FGTextLayer::DOUBLE_VALUE, target,
398                                    format, scale);
399   }
400
401                                 // Unknown type.
402   else {
403     SG_LOG( SG_COCKPIT, SG_ALERT, "Unrecognized type " << type
404             << " for text chunk " << name );
405     return 0;
406   }
407
408   return chunk;
409 }
410
411
412 /**
413  * Read a single layer from an instrument's property list.
414  *
415  * Each instrument consists of one or more layers stacked on top
416  * of each other; the lower layers show through only where the upper
417  * layers contain an alpha component.  Each layer can be moved
418  * horizontally and vertically and rotated using transformations.
419  *
420  * This module currently recognizes four kinds of layers:
421  *
422  * "texture" - a layer containing a texture (the default)
423  *
424  * "text" - a layer containing text
425  *
426  * "switch" - a layer that switches between two other layers
427  *   based on the current value of a boolean property.
428  *
429  * "built-in" - a hard-coded layer supported by C++ code in FlightGear.
430  *
431  * Currently, the only built-in layer class is "compass-ribbon".
432  */
433 static FGInstrumentLayer *
434 readLayer (const SGPropertyNode * node, float w_scale, float h_scale)
435 {
436   FGInstrumentLayer * layer = NULL;
437   string name = node->getStringValue("name");
438   string type = node->getStringValue("type");
439   int w = node->getIntValue("w", -1);
440   int h = node->getIntValue("h", -1);
441   if (w != -1)
442     w = int(w * w_scale);
443   if (h != -1)
444     h = int(h * h_scale);
445
446
447   if (type == "") {
448     SG_LOG( SG_COCKPIT, SG_ALERT,
449             "No type supplied for layer " << name
450             << " assuming \"texture\"" );
451     type = "texture";
452   }
453
454
455                                 // A textured instrument layer.
456   if (type == "texture") {
457     FGCroppedTexture texture = readTexture(node->getNode("texture"));
458     layer = new FGTexturedLayer(texture, w, h);
459   }
460
461
462                                 // A textual instrument layer.
463   else if (type == "text") {
464     FGTextLayer * tlayer = new FGTextLayer(w, h); // FIXME
465
466                                 // Set the text color.
467     float red = node->getFloatValue("color/red", 0.0);
468     float green = node->getFloatValue("color/green", 0.0);
469     float blue = node->getFloatValue("color/blue", 0.0);
470     tlayer->setColor(red, green, blue);
471
472                                 // Set the point size.
473     float pointSize = node->getFloatValue("point-size", 10.0) * w_scale;
474     tlayer->setPointSize(pointSize);
475
476                                 // Set the font.
477     // TODO
478
479     const SGPropertyNode * chunk_group = node->getNode("chunks");
480     if (chunk_group != 0) {
481       int nChunks = chunk_group->nChildren();
482       for (int i = 0; i < nChunks; i++) {
483         const SGPropertyNode * node = chunk_group->getChild(i);
484         if (node->getName() == "chunk") {
485           FGTextLayer::Chunk * chunk = readTextChunk(node);
486           if (chunk != 0)
487             tlayer->addChunk(chunk);
488         } else {
489           SG_LOG( SG_COCKPIT, SG_INFO, "Skipping " << node->getName()
490                   << " in chunks" );
491         }
492       }
493       layer = tlayer;
494     }
495   }
496
497                                 // A switch instrument layer.
498   else if (type == "switch") {
499     SGPropertyNode * target =
500       fgGetNode(node->getStringValue("property"), true);
501     FGInstrumentLayer * layer1 =
502       readLayer(node->getNode("layer[0]"), w_scale, h_scale);
503     FGInstrumentLayer * layer2 =
504       readLayer(node->getNode("layer[1]"), w_scale, h_scale);
505     layer = new FGSwitchLayer(w, h, target, layer1, layer2);
506   }
507
508                                 // A built-in instrument layer.
509   else if (type == "built-in") {
510     string layerclass = node->getStringValue("class");
511
512     if (layerclass == "mag-ribbon") {
513       layer = new FGMagRibbon(w, h);
514     }
515
516     else if (layerclass == "") {
517       SG_LOG( SG_COCKPIT, SG_ALERT, "No class provided for built-in layer "
518               << name );
519       return 0;
520     }
521
522     else {
523       SG_LOG( SG_COCKPIT, SG_ALERT, "Unknown built-in layer class "
524               << layerclass);
525       return 0;
526     }
527   }
528
529                                 // An unknown type.
530   else {
531     SG_LOG( SG_COCKPIT, SG_ALERT, "Unrecognized layer type " << type );
532     delete layer;
533     return 0;
534   }
535   
536   //
537   // Get the transformations for each layer.
538   //
539   const SGPropertyNode * trans_group = node->getNode("transformations");
540   if (trans_group != 0) {
541     int nTransformations = trans_group->nChildren();
542     for (int i = 0; i < nTransformations; i++) {
543       const SGPropertyNode * node = trans_group->getChild(i);
544       if (node->getName() == "transformation") {
545         FGPanelTransformation * t = readTransformation(node, w_scale, h_scale);
546         if (t != 0)
547           layer->addTransformation(t);
548       } else {
549         SG_LOG( SG_COCKPIT, SG_INFO, "Skipping " << node->getName()
550                 << " in transformations" );
551       }
552     }
553   }
554   
555   SG_LOG( SG_COCKPIT, SG_DEBUG, "Read layer " << name );
556   return layer;
557 }
558
559
560 /**
561  * Read an instrument from a property list.
562  *
563  * The instrument consists of a preferred width and height
564  * (the panel may override these), together with a list of layers
565  * and a list of actions to be performed when the user clicks 
566  * the mouse over the instrument.  All co-ordinates are relative
567  * to the instrument's position, so instruments are fully relocatable;
568  * likewise, co-ordinates for actions and transformations will be
569  * scaled automatically if the instrument is not at its preferred size.
570  */
571 static FGPanelInstrument *
572 readInstrument (const SGPropertyNode * node)
573 {
574   const string &name = node->getStringValue("name");
575   int x = node->getIntValue("x", -1);
576   int y = node->getIntValue("y", -1);
577   int real_w = node->getIntValue("w", -1);
578   int real_h = node->getIntValue("h", -1);
579   int w = node->getIntValue("w-base", -1);
580   int h = node->getIntValue("h-base", -1);
581
582   if (x == -1 || y == -1) {
583     SG_LOG( SG_COCKPIT, SG_ALERT,
584             "x and y positions must be specified and > 0" );
585     return 0;
586   }
587
588   float w_scale = 1.0;
589   float h_scale = 1.0;
590   if (real_w != -1) {
591     w_scale = float(real_w) / float(w);
592     w = real_w;
593   }
594   if (real_h != -1) {
595     h_scale = float(real_h) / float(h);
596     h = real_h;
597   }
598
599   SG_LOG( SG_COCKPIT, SG_DEBUG, "Reading instrument " << name );
600
601   FGLayeredInstrument * instrument =
602     new FGLayeredInstrument(x, y, w, h);
603
604   //
605   // Get the actions for the instrument.
606   //
607   const SGPropertyNode * action_group = node->getNode("actions");
608   if (action_group != 0) {
609     int nActions = action_group->nChildren();
610     for (int i = 0; i < nActions; i++) {
611       const SGPropertyNode * node = action_group->getChild(i);
612       if (node->getName() == "action") {
613         FGPanelAction * action = readAction(node, w_scale, h_scale);
614         if (action != 0)
615           instrument->addAction(action);
616       } else {
617         SG_LOG( SG_COCKPIT, SG_INFO, "Skipping " << node->getName()
618                 << " in actions" );
619       }
620     }
621   }
622
623   //
624   // Get the layers for the instrument.
625   //
626   const SGPropertyNode * layer_group = node->getNode("layers");
627   if (layer_group != 0) {
628     int nLayers = layer_group->nChildren();
629     for (int i = 0; i < nLayers; i++) {
630       const SGPropertyNode * node = layer_group->getChild(i);
631       if (node->getName() == "layer") {
632         FGInstrumentLayer * layer = readLayer(node, w_scale, h_scale);
633         if (layer != 0)
634           instrument->addLayer(layer);
635       } else {
636         SG_LOG( SG_COCKPIT, SG_INFO, "Skipping " << node->getName()
637                 << " in layers" );
638       }
639     }
640   }
641     
642   SG_LOG( SG_COCKPIT, SG_DEBUG, "Done reading instrument " << name );
643   return instrument;
644 }
645
646
647 /**
648  * Construct the panel from a property tree.
649  */
650 FGPanel *
651 readPanel (const SGPropertyNode * root)
652 {
653   SG_LOG( SG_COCKPIT, SG_INFO, "Reading properties for panel " <<
654           root->getStringValue("name", "[Unnamed Panel]") );
655
656   FGPanel * panel = new FGPanel();
657   panel->setWidth(root->getIntValue("w", 1024));
658   panel->setHeight(root->getIntValue("h", 443));
659
660   //
661   // Grab the visible external viewing area, default to 
662   //
663   panel->setViewHeight(root->getIntValue("view-height",
664                                          768 - panel->getHeight() + 2));
665
666   //
667   // Grab the panel's initial offsets, default to 0, 0.
668   //
669   if (!fgHasNode("/sim/panel/x-offset"))
670     fgSetInt("/sim/panel/x-offset", root->getIntValue("x-offset", 0));
671
672   if (!fgHasNode("/sim/panel/y-offset"))
673     fgSetInt("/sim/panel/y-offset", root->getIntValue("y-offset", 0));
674
675   //
676   // Assign the background texture, if any, or a bogus chequerboard.
677   //
678   string bgTexture = root->getStringValue("background");
679   if (bgTexture == "")
680     bgTexture = "FOO";
681   panel->setBackground(FGTextureManager::createTexture(bgTexture.c_str()));
682   SG_LOG( SG_COCKPIT, SG_INFO, "Set background texture to " << bgTexture );
683
684
685   //
686   // Create each instrument.
687   //
688   SG_LOG( SG_COCKPIT, SG_INFO, "Reading panel instruments" );
689   const SGPropertyNode * instrument_group = root->getChild("instruments");
690   if (instrument_group != 0) {
691     int nInstruments = instrument_group->nChildren();
692     for (int i = 0; i < nInstruments; i++) {
693       const SGPropertyNode * node = instrument_group->getChild(i);
694       if (node->getName() == "instrument") {
695         FGPanelInstrument * instrument = readInstrument(node);
696         if (instrument != 0)
697           panel->addInstrument(instrument);
698       } else {
699         SG_LOG( SG_COCKPIT, SG_INFO, "Skipping " << node->getName()
700                 << " in instruments section" );
701       }
702     }
703   }
704   SG_LOG( SG_COCKPIT, SG_INFO, "Done reading panel instruments" );
705
706
707   //
708   // Return the new panel.
709   //
710   return panel;
711 }
712
713
714 /**
715  * Read a panel from a property list.
716  *
717  * Each panel instrument will appear in its own, separate
718  * property list.  The top level simply names the panel and
719  * places the instruments in their appropriate locations (and
720  * optionally resizes them if necessary).
721  *
722  * Returns 0 if the read fails for any reason.
723  */
724 FGPanel *
725 fgReadPanel (istream &input)
726 {
727   SGPropertyNode root;
728
729   try {
730     readProperties(input, &root);
731   } catch (const sg_exception &e) {
732     guiErrorMessage("Error reading panel: ", e);
733     return 0;
734   }
735   return readPanel(&root);
736 }
737
738
739 /**
740  * Read a panel from a property list.
741  *
742  * This function opens a stream to a file, then invokes the
743  * main fgReadPanel() function.
744  */
745 FGPanel *
746 fgReadPanel (const string &relative_path)
747 {
748   SGPath path(globals->get_fg_root());
749   path.append(relative_path);
750   SGPropertyNode root;
751
752   try {
753     readProperties(path.str(), &root);
754   } catch (const sg_exception &e) {
755     guiErrorMessage("Error reading panel: ", e);
756     return 0;
757   }
758   return readPanel(&root);
759 }
760
761
762
763 // end of panel_io.cxx