1 // panel_io.cxx - I/O for 2D panel.
3 // Written by David Megginson, started January 2000.
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.
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.
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
25 #include <string.h> // for strcmp()
27 #include <simgear/compiler.h>
28 #include <simgear/structure/exception.hxx>
29 #include <simgear/debug/logstream.hxx>
30 #include <simgear/misc/sg_path.hxx>
31 #include <simgear/props/props.hxx>
37 #include <Main/globals.hxx>
38 #include <Main/fg_props.hxx>
42 // #include "panel.hxx"
43 #include "panel_io.hxx"
44 #include <Instrumentation/KLN89/kln89.hxx>
47 #include "built_in/FGMagRibbon.hxx"
55 ////////////////////////////////////////////////////////////////////////
56 // Read and construct a panel.
58 // The panel is specified as a regular property list, and each of the
59 // instruments is its own, separate property list (and thus, a separate
60 // XML document). The functions in this section read in the files
61 // as property lists, then extract properties to set up the panel
64 // A panel contains zero or more instruments.
66 // An instrument contains one or more layers and zero or more actions.
68 // A layer contains zero or more transformations.
70 // Some special types of layers also contain other objects, such as
71 // chunks of text or other layers.
73 // There are currently four types of layers:
75 // 1. Textured Layer (type="texture"), the default
76 // 2. Text Layer (type="text")
77 // 3. Switch Layer (type="switch")
78 // 4. Built-in Layer (type="built-in", must also specify class)
80 // The only built-in layer so far is the ribbon for the magnetic compass
81 // (class="compass-ribbon").
83 // There are three types of actions:
85 // 1. Adjust (type="adjust"), the default
86 // 2. Swap (type="swap")
87 // 3. Toggle (type="toggle")
89 // There are three types of transformations:
91 // 1. X shift (type="x-shift"), the default
92 // 2. Y shift (type="y-shift")
93 // 3. Rotation (type="rotation")
95 // Each of these may be associated with a property, so that a needle
96 // will rotate with the airspeed, for example, or may have a fixed
97 // floating-point value.
98 ////////////////////////////////////////////////////////////////////////
102 * Read a cropped texture from the instrument's property list.
104 * The x1 and y1 properties give the starting position of the texture
105 * (between 0.0 and 1.0), and the the x2 and y2 properties give the
106 * ending position. For example, to use the bottom-left quarter of a
107 * texture, x1=0.0, y1=0.0, x2=0.5, y2=0.5.
109 static FGCroppedTexture
110 readTexture (const SGPropertyNode * node)
112 FGCroppedTexture texture(node->getStringValue("path"),
113 node->getFloatValue("x1"),
114 node->getFloatValue("y1"),
115 node->getFloatValue("x2", 1.0),
116 node->getFloatValue("y2", 1.0));
117 SG_LOG(SG_COCKPIT, SG_DEBUG, "Read texture " << node->getName());
123 * Test for a condition in the current node.
126 ////////////////////////////////////////////////////////////////////////
127 // Read a condition and use it if necessary.
128 ////////////////////////////////////////////////////////////////////////
131 readConditions (SGConditional *component, const SGPropertyNode *node)
133 const SGPropertyNode * conditionNode = node->getChild("condition");
134 if (conditionNode != 0)
135 // The top level is implicitly AND
136 component->setCondition(sgReadCondition(globals->get_props(),
142 * Read an action from the instrument's property list.
144 * The action will be performed when the user clicks a mouse button
145 * within the specified region of the instrument. Actions always work
146 * by modifying the value of a property (see the SGPropertyNode
149 * The following action types are defined:
151 * "adjust" - modify the value of a floating-point property by
152 * the increment specified. This is the default.
154 * "swap" - swap the values of two-floating-point properties.
156 * "toggle" - toggle the value of a boolean property between true and
159 * For the adjust action, it is possible to specify an increment
160 * (use a negative number for a decrement), a minimum allowed value,
161 * a maximum allowed value, and a flag to indicate whether the value
162 * should freeze or wrap-around when it reachs the minimum or maximum.
164 * The action will be scaled automatically if the instrument is not
165 * being drawn at its regular size.
167 static FGPanelAction *
168 readAction (const SGPropertyNode * node, float w_scale, float h_scale)
171 SGPropertyNode *binding;
172 vector<SGPropertyNode_ptr>bindings = node->getChildren("binding");
174 // button-less actions are fired initially
175 if (!node->hasValue("w") || !node->hasValue("h")) {
176 for (i = 0; i < bindings.size(); i++) {
177 SGBinding b(bindings[i], globals->get_props());
183 string name = node->getStringValue("name");
185 int button = node->getIntValue("button");
186 int x = int(node->getIntValue("x") * w_scale);
187 int y = int(node->getIntValue("y") * h_scale);
188 int w = int(node->getIntValue("w") * w_scale);
189 int h = int(node->getIntValue("h") * h_scale);
190 bool repeatable = node->getBoolValue("repeatable", true);
192 FGPanelAction * action = new FGPanelAction(button, x, y, w, h, repeatable);
194 SGPropertyNode * dest = fgGetNode("/sim/bindings/panel", true);
196 for (i = 0; i < bindings.size(); i++) {
197 SG_LOG(SG_INPUT, SG_INFO, "Reading binding "
198 << bindings[i]->getStringValue("command"));
201 while (dest->getChild("binding", j))
204 binding = dest->getChild("binding", j, true);
205 copyProperties(bindings[i], binding);
206 action->addBinding(new SGBinding(binding, globals->get_props()), 0);
209 if (node->hasChild("mod-up")) {
210 bindings = node->getChild("mod-up")->getChildren("binding");
211 for (i = 0; i < bindings.size(); i++) {
213 while (dest->getChild("binding", j))
216 binding = dest->getChild("binding", j, true);
217 copyProperties(bindings[i], binding);
218 action->addBinding(new SGBinding(binding, globals->get_props()), 1);
222 readConditions(action, node);
228 * Read a transformation from the instrument's property list.
230 * The panel module uses the transformations to slide or spin needles,
231 * knobs, and other indicators, and to place layers in the correct
232 * positions. Every layer starts centered exactly on the x,y co-ordinate,
233 * and many layers need to be moved or rotated simply to display the
234 * instrument correctly.
236 * There are three types of transformations:
238 * "x-shift" - move the layer horizontally.
240 * "y-shift" - move the layer vertically.
242 * "rotation" - rotate the layer.
244 * Each transformation may have a fixed offset, and may also have
245 * a floating-point property value to add to the offset. The
246 * floating-point property may be clamped to a minimum and/or
247 * maximum range and scaled (after clamping).
249 * Note that because of the way OpenGL works, transformations will
250 * appear to be applied backwards.
252 static FGPanelTransformation *
253 readTransformation (const SGPropertyNode * node, float w_scale, float h_scale)
255 FGPanelTransformation * t = new FGPanelTransformation;
257 string name = node->getName();
258 string type = node->getStringValue("type");
259 string propName = node->getStringValue("property", "");
260 SGPropertyNode * target = 0;
263 SG_LOG( SG_COCKPIT, SG_INFO,
264 "No type supplied for transformation " << name
265 << " assuming \"rotation\"" );
269 if (!propName.empty()) {
270 target = fgGetNode(propName.c_str(), true);
274 t->min = node->getFloatValue("min", -9999999);
275 t->max = node->getFloatValue("max", 99999999);
276 t->has_mod = node->hasChild("modulator");
278 t->mod = node->getFloatValue("modulator");
279 t->factor = node->getFloatValue("scale", 1.0);
280 t->offset = node->getFloatValue("offset", 0.0);
282 // Check for an interpolation table
283 const SGPropertyNode * trans_table = node->getNode("interpolation");
284 if (trans_table != 0) {
285 SG_LOG( SG_COCKPIT, SG_INFO, "Found interpolation table with "
286 << trans_table->nChildren() << " children" );
287 t->table = new SGInterpTable(trans_table);
292 // Move the layer horizontally.
293 if (type == "x-shift") {
294 t->type = FGPanelTransformation::XSHIFT;
295 // t->min *= w_scale; //removed by Martin Dressler
296 // t->max *= w_scale; //removed by Martin Dressler
297 t->offset *= w_scale;
298 t->factor *= w_scale; //Added by Martin Dressler
301 // Move the layer vertically.
302 else if (type == "y-shift") {
303 t->type = FGPanelTransformation::YSHIFT;
304 //t->min *= h_scale; //removed
305 //t->max *= h_scale; //removed
306 t->offset *= h_scale;
307 t->factor *= h_scale; //Added
310 // Rotate the layer. The rotation
311 // is in degrees, and does not need
312 // to scale with the instrument size.
313 else if (type == "rotation") {
314 t->type = FGPanelTransformation::ROTATION;
318 SG_LOG( SG_COCKPIT, SG_ALERT, "Unrecognized transformation type " << type );
323 readConditions(t, node);
324 SG_LOG( SG_COCKPIT, SG_DEBUG, "Read transformation " << name );
330 * Read a chunk of text from the instrument's property list.
332 * A text layer consists of one or more chunks of text. All chunks
333 * share the same font size and color (and eventually, font), but
334 * each can come from a different source. There are three types of
337 * "literal" - a literal text string (the default)
339 * "text-value" - the current value of a string property
341 * "number-value" - the current value of a floating-point property.
343 * All three may also include a printf-style format string.
346 readTextChunk (const SGPropertyNode * node)
348 FGTextLayer::Chunk * chunk;
349 string name = node->getStringValue("name");
350 string type = node->getStringValue("type");
351 string format = node->getStringValue("format");
353 // Default to literal text.
355 SG_LOG( SG_COCKPIT, SG_INFO, "No type provided for text chunk " << name
356 << " assuming \"literal\"");
360 // A literal text string.
361 if (type == "literal") {
362 string text = node->getStringValue("text");
363 chunk = new FGTextLayer::Chunk(text, format);
366 // The value of a string property.
367 else if (type == "text-value") {
368 SGPropertyNode * target =
369 fgGetNode(node->getStringValue("property"), true);
370 chunk = new FGTextLayer::Chunk(FGTextLayer::TEXT_VALUE, target, format);
373 // The value of a float property.
374 else if (type == "number-value") {
375 string propName = node->getStringValue("property");
376 float scale = node->getFloatValue("scale", 1.0);
377 float offset = node->getFloatValue("offset", 0.0);
378 bool truncation = node->getBoolValue("truncate", false);
379 SGPropertyNode * target = fgGetNode(propName.c_str(), true);
380 chunk = new FGTextLayer::Chunk(FGTextLayer::DOUBLE_VALUE, target,
381 format, scale, offset, truncation);
386 SG_LOG( SG_COCKPIT, SG_ALERT, "Unrecognized type " << type
387 << " for text chunk " << name );
391 readConditions(chunk, node);
397 * Read a single layer from an instrument's property list.
399 * Each instrument consists of one or more layers stacked on top
400 * of each other; the lower layers show through only where the upper
401 * layers contain an alpha component. Each layer can be moved
402 * horizontally and vertically and rotated using transformations.
404 * This module currently recognizes four kinds of layers:
406 * "texture" - a layer containing a texture (the default)
408 * "text" - a layer containing text
410 * "switch" - a layer that switches between two other layers
411 * based on the current value of a boolean property.
413 * "built-in" - a hard-coded layer supported by C++ code in FlightGear.
415 * Currently, the only built-in layer class is "compass-ribbon".
417 static FGInstrumentLayer *
418 readLayer (const SGPropertyNode * node, float w_scale, float h_scale)
420 FGInstrumentLayer * layer = NULL;
421 string name = node->getStringValue("name");
422 string type = node->getStringValue("type");
423 int w = node->getIntValue("w", -1);
424 int h = node->getIntValue("h", -1);
425 bool emissive = node->getBoolValue("emissive", false);
427 w = int(w * w_scale);
429 h = int(h * h_scale);
433 SG_LOG( SG_COCKPIT, SG_INFO,
434 "No type supplied for layer " << name
435 << " assuming \"texture\"" );
440 // A textured instrument layer.
441 if (type == "texture") {
442 FGCroppedTexture texture = readTexture(node->getNode("texture"));
443 layer = new FGTexturedLayer(texture, w, h);
445 FGTexturedLayer *tl=(FGTexturedLayer*)layer;
446 tl->setEmissive(true);
451 // A group of sublayers.
452 else if (type == "group") {
453 layer = new FGGroupLayer();
454 for (int i = 0; i < node->nChildren(); i++) {
455 const SGPropertyNode * child = node->getChild(i);
456 if (!strcmp(child->getName(), "layer"))
457 ((FGGroupLayer *)layer)->addLayer(readLayer(child, w_scale, h_scale));
462 // A textual instrument layer.
463 else if (type == "text") {
464 FGTextLayer * tlayer = new FGTextLayer(w, h); // FIXME
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);
472 // Set the point size.
473 float pointSize = node->getFloatValue("point-size", 10.0) * w_scale;
474 tlayer->setPointSize(pointSize);
477 string fontName = node->getStringValue("font", "Helvetica");
478 tlayer->setFontName(fontName);
480 const SGPropertyNode * chunk_group = node->getNode("chunks");
481 if (chunk_group != 0) {
482 int nChunks = chunk_group->nChildren();
483 for (int i = 0; i < nChunks; i++) {
484 const SGPropertyNode * node = chunk_group->getChild(i);
485 if (!strcmp(node->getName(), "chunk")) {
486 FGTextLayer::Chunk * chunk = readTextChunk(node);
488 tlayer->addChunk(chunk);
490 SG_LOG( SG_COCKPIT, SG_INFO, "Skipping " << node->getName()
498 // A switch instrument layer.
499 else if (type == "switch") {
500 layer = new FGSwitchLayer();
501 for (int i = 0; i < node->nChildren(); i++) {
502 const SGPropertyNode * child = node->getChild(i);
503 if (!strcmp(child->getName(), "layer"))
504 ((FGGroupLayer *)layer)->addLayer(readLayer(child, w_scale, h_scale));
508 // A built-in instrument layer.
509 else if (type == "built-in") {
510 string layerclass = node->getStringValue("class");
512 if (layerclass == "mag-ribbon") {
513 layer = new FGMagRibbon(w, h);
516 else if (layerclass.empty()) {
517 SG_LOG( SG_COCKPIT, SG_ALERT, "No class provided for built-in layer "
523 SG_LOG( SG_COCKPIT, SG_ALERT, "Unknown built-in layer class "
531 SG_LOG( SG_COCKPIT, SG_ALERT, "Unrecognized layer type " << type );
537 // Get the transformations for each layer.
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 (!strcmp(node->getName(), "transformation")) {
545 FGPanelTransformation * t = readTransformation(node, w_scale, h_scale);
547 layer->addTransformation(t);
549 SG_LOG( SG_COCKPIT, SG_INFO, "Skipping " << node->getName()
550 << " in transformations" );
555 readConditions(layer, node);
556 SG_LOG( SG_COCKPIT, SG_DEBUG, "Read layer " << name );
562 * Read an instrument from a property list.
564 * The instrument consists of a preferred width and height
565 * (the panel may override these), together with a list of layers
566 * and a list of actions to be performed when the user clicks
567 * the mouse over the instrument. All co-ordinates are relative
568 * to the instrument's position, so instruments are fully relocatable;
569 * likewise, co-ordinates for actions and transformations will be
570 * scaled automatically if the instrument is not at its preferred size.
572 static FGPanelInstrument *
573 readInstrument (const SGPropertyNode * node)
575 const string name = node->getStringValue("name");
576 int x = node->getIntValue("x", -1);
577 int y = node->getIntValue("y", -1);
578 int real_w = node->getIntValue("w", -1);
579 int real_h = node->getIntValue("h", -1);
580 int w = node->getIntValue("w-base", -1);
581 int h = node->getIntValue("h-base", -1);
583 if (x == -1 || y == -1) {
584 SG_LOG( SG_COCKPIT, SG_ALERT,
585 "x and y positions must be specified and > 0" );
592 w_scale = float(real_w) / float(w);
596 h_scale = float(real_h) / float(h);
600 SG_LOG( SG_COCKPIT, SG_DEBUG, "Reading instrument " << name );
602 FGLayeredInstrument * instrument =
603 new FGLayeredInstrument(x, y, w, h);
606 // Get the actions for the instrument.
608 const SGPropertyNode * action_group = node->getNode("actions");
609 if (action_group != 0) {
610 int nActions = action_group->nChildren();
611 for (int i = 0; i < nActions; i++) {
612 const SGPropertyNode * node = action_group->getChild(i);
613 if (!strcmp(node->getName(), "action")) {
614 FGPanelAction * action = readAction(node, w_scale, h_scale);
616 instrument->addAction(action);
618 SG_LOG( SG_COCKPIT, SG_INFO, "Skipping " << node->getName()
625 // Get the layers for the instrument.
627 const SGPropertyNode * layer_group = node->getNode("layers");
628 if (layer_group != 0) {
629 int nLayers = layer_group->nChildren();
630 for (int i = 0; i < nLayers; i++) {
631 const SGPropertyNode * node = layer_group->getChild(i);
632 if (!strcmp(node->getName(), "layer")) {
633 FGInstrumentLayer * layer = readLayer(node, w_scale, h_scale);
635 instrument->addLayer(layer);
637 SG_LOG( SG_COCKPIT, SG_INFO, "Skipping " << node->getName()
643 readConditions(instrument, node);
644 SG_LOG( SG_COCKPIT, SG_DEBUG, "Done reading instrument " << name );
650 * Construct the panel from a property tree.
653 readPanel (const SGPropertyNode * root)
655 SG_LOG( SG_COCKPIT, SG_INFO, "Reading properties for panel " <<
656 root->getStringValue("name", "[Unnamed Panel]") );
658 FGPanel * panel = new FGPanel();
659 panel->setWidth(root->getIntValue("w", 1024));
660 panel->setHeight(root->getIntValue("h", 443));
663 // Grab the visible external viewing area, default to
665 panel->setViewHeight(root->getIntValue("view-height",
666 768 - panel->getHeight() + 2));
669 // Grab the panel's initial offsets, default to 0, 0.
671 if (!fgHasNode("/sim/panel/x-offset"))
672 fgSetInt("/sim/panel/x-offset", root->getIntValue("x-offset", 0));
674 // conditional removed by jim wilson to allow panel xml code
675 // with y-offset defined to work...
676 if (!fgHasNode("/sim/panel/y-offset"))
677 fgSetInt("/sim/panel/y-offset", root->getIntValue("y-offset", 0));
679 panel->setAutohide(root->getBoolValue("autohide", true));
682 // Assign the background texture, if any, or a bogus chequerboard.
684 string bgTexture = root->getStringValue("background");
685 if (bgTexture.empty())
687 panel->setBackground(FGTextureManager::createTexture(bgTexture.c_str()));
688 SG_LOG( SG_COCKPIT, SG_INFO, "Set background texture to " << bgTexture );
691 // Get multibackground if any...
693 string mbgTexture = root->getStringValue("multibackground[0]");
694 if (!mbgTexture.empty()) {
695 panel->setMultiBackground(FGTextureManager::createTexture(mbgTexture.c_str()), 0);
696 SG_LOG( SG_COCKPIT, SG_INFO, "Set background texture to " << mbgTexture );
698 mbgTexture = root->getStringValue("multibackground[1]");
699 if (mbgTexture.empty())
701 panel->setMultiBackground(FGTextureManager::createTexture(mbgTexture.c_str()), 1);
702 SG_LOG( SG_COCKPIT, SG_INFO, "Set background texture to " << mbgTexture );
704 mbgTexture = root->getStringValue("multibackground[2]");
705 if (mbgTexture.empty())
707 panel->setMultiBackground(FGTextureManager::createTexture(mbgTexture.c_str()), 2);
708 SG_LOG( SG_COCKPIT, SG_INFO, "Set background texture to " << mbgTexture );
710 mbgTexture = root->getStringValue("multibackground[3]");
711 if (mbgTexture.empty())
713 panel->setMultiBackground(FGTextureManager::createTexture(mbgTexture.c_str()), 3);
714 SG_LOG( SG_COCKPIT, SG_INFO, "Set background texture to " << mbgTexture );
716 mbgTexture = root->getStringValue("multibackground[4]");
717 if (mbgTexture.empty())
719 panel->setMultiBackground(FGTextureManager::createTexture(mbgTexture.c_str()), 4);
720 SG_LOG( SG_COCKPIT, SG_INFO, "Set background texture to " << mbgTexture );
722 mbgTexture = root->getStringValue("multibackground[5]");
723 if (mbgTexture.empty())
725 panel->setMultiBackground(FGTextureManager::createTexture(mbgTexture.c_str()), 5);
726 SG_LOG( SG_COCKPIT, SG_INFO, "Set background texture to " << mbgTexture );
728 mbgTexture = root->getStringValue("multibackground[6]");
729 if (mbgTexture.empty())
731 panel->setMultiBackground(FGTextureManager::createTexture(mbgTexture.c_str()), 6);
732 SG_LOG( SG_COCKPIT, SG_INFO, "Set background texture to " << mbgTexture );
734 mbgTexture = root->getStringValue("multibackground[7]");
735 if (mbgTexture.empty())
737 panel->setMultiBackground(FGTextureManager::createTexture(mbgTexture.c_str()), 7);
738 SG_LOG( SG_COCKPIT, SG_INFO, "Set background texture to " << mbgTexture );
745 // Create each instrument.
747 SG_LOG( SG_COCKPIT, SG_INFO, "Reading panel instruments" );
748 const SGPropertyNode * instrument_group = root->getChild("instruments");
749 if (instrument_group != 0) {
750 int nInstruments = instrument_group->nChildren();
751 for (int i = 0; i < nInstruments; i++) {
752 const SGPropertyNode * node = instrument_group->getChild(i);
753 if (!strcmp(node->getName(), "instrument")) {
754 FGPanelInstrument * instrument = readInstrument(node);
756 panel->addInstrument(instrument);
757 } else if (!strcmp(node->getName(), "special-instrument")) {
758 //cout << "Special instrument found in instruments section!\n";
759 const string name = node->getStringValue("name");
760 if (name == "KLN89 GPS") {
761 //cout << "Special instrument is KLN89\n";
763 int x = node->getIntValue("x", -1);
764 int y = node->getIntValue("y", -1);
765 int real_w = node->getIntValue("w", -1);
766 int real_h = node->getIntValue("h", -1);
767 int w = node->getIntValue("w-base", -1);
768 int h = node->getIntValue("h-base", -1);
770 if (x == -1 || y == -1) {
771 SG_LOG( SG_COCKPIT, SG_ALERT,
772 "x and y positions must be specified and > 0" );
779 w_scale = float(real_w) / float(w);
783 h_scale = float(real_h) / float(h);
787 SG_LOG( SG_COCKPIT, SG_DEBUG, "Reading instrument " << name );
789 // Warning - hardwired size!!!
790 RenderArea2D* instrument = new RenderArea2D(158, 40, 158, 40, x, y);
791 KLN89* gps = (KLN89*)globals->get_subsystem("kln89");
793 gps = new KLN89(instrument);
794 globals->add_subsystem("kln89", gps);
796 //gps->init(); // init seems to get called automagically.
797 FGSpecialInstrument* gpsinst = new FGSpecialInstrument(gps);
798 panel->addInstrument(gpsinst);
800 SG_LOG( SG_COCKPIT, SG_WARN, "Unknown special instrument found" );
803 SG_LOG( SG_COCKPIT, SG_INFO, "Skipping " << node->getName()
804 << " in instruments section" );
808 SG_LOG( SG_COCKPIT, SG_INFO, "Done reading panel instruments" );
812 // Return the new panel.
819 * Read a panel from a property list.
821 * Each panel instrument will appear in its own, separate
822 * property list. The top level simply names the panel and
823 * places the instruments in their appropriate locations (and
824 * optionally resizes them if necessary).
826 * Returns 0 if the read fails for any reason.
829 fgReadPanel (istream &input)
834 readProperties(input, &root);
835 } catch (const sg_exception &e) {
836 guiErrorMessage("Error reading panel: ", e);
839 return readPanel(&root);
844 * Read a panel from a property list.
846 * This function opens a stream to a file, then invokes the
847 * main fgReadPanel() function.
850 fgReadPanel (const string &relative_path)
852 SGPath path(globals->get_fg_root());
853 path.append(relative_path);
857 readProperties(path.str(), &root);
858 } catch (const sg_exception &e) {
859 guiErrorMessage("Error reading panel: ", e);
862 return readPanel(&root);
867 // end of panel_io.cxx