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., 675 Mass Ave, Cambridge, MA 02139, USA.
29 #include <string.h> // for strcmp()
31 #include <simgear/compiler.h>
32 #include <simgear/structure/exception.hxx>
33 #include <simgear/debug/logstream.hxx>
34 #include <simgear/misc/sg_path.hxx>
35 #include <simgear/props/props.hxx>
41 #include <Main/globals.hxx>
42 #include <Main/fg_props.hxx>
46 // #include "panel.hxx"
47 #include "panel_io.hxx"
48 #include <Instrumentation/KLN89/kln89.hxx>
51 #include "built_in/FGMagRibbon.hxx"
53 SG_USING_STD(istream);
54 SG_USING_STD(ifstream);
59 ////////////////////////////////////////////////////////////////////////
60 // Read and construct a panel.
62 // The panel is specified as a regular property list, and each of the
63 // instruments is its own, separate property list (and thus, a separate
64 // XML document). The functions in this section read in the files
65 // as property lists, then extract properties to set up the panel
68 // A panel contains zero or more instruments.
70 // An instrument contains one or more layers and zero or more actions.
72 // A layer contains zero or more transformations.
74 // Some special types of layers also contain other objects, such as
75 // chunks of text or other layers.
77 // There are currently four types of layers:
79 // 1. Textured Layer (type="texture"), the default
80 // 2. Text Layer (type="text")
81 // 3. Switch Layer (type="switch")
82 // 4. Built-in Layer (type="built-in", must also specify class)
84 // The only built-in layer so far is the ribbon for the magnetic compass
85 // (class="compass-ribbon").
87 // There are three types of actions:
89 // 1. Adjust (type="adjust"), the default
90 // 2. Swap (type="swap")
91 // 3. Toggle (type="toggle")
93 // There are three types of transformations:
95 // 1. X shift (type="x-shift"), the default
96 // 2. Y shift (type="y-shift")
97 // 3. Rotation (type="rotation")
99 // Each of these may be associated with a property, so that a needle
100 // will rotate with the airspeed, for example, or may have a fixed
101 // floating-point value.
102 ////////////////////////////////////////////////////////////////////////
106 * Read a cropped texture from the instrument's property list.
108 * The x1 and y1 properties give the starting position of the texture
109 * (between 0.0 and 1.0), and the the x2 and y2 properties give the
110 * ending position. For example, to use the bottom-left quarter of a
111 * texture, x1=0.0, y1=0.0, x2=0.5, y2=0.5.
113 static FGCroppedTexture
114 readTexture (const SGPropertyNode * node)
116 FGCroppedTexture texture(node->getStringValue("path"),
117 node->getFloatValue("x1"),
118 node->getFloatValue("y1"),
119 node->getFloatValue("x2", 1.0),
120 node->getFloatValue("y2", 1.0));
121 SG_LOG(SG_COCKPIT, SG_DEBUG, "Read texture " << node->getName());
127 * Test for a condition in the current node.
130 ////////////////////////////////////////////////////////////////////////
131 // Read a condition and use it if necessary.
132 ////////////////////////////////////////////////////////////////////////
135 readConditions (SGConditional *component, const SGPropertyNode *node)
137 const SGPropertyNode * conditionNode = node->getChild("condition");
138 if (conditionNode != 0)
139 // The top level is implicitly AND
140 component->setCondition(sgReadCondition(globals->get_props(),
146 * Read an action from the instrument's property list.
148 * The action will be performed when the user clicks a mouse button
149 * within the specified region of the instrument. Actions always work
150 * by modifying the value of a property (see the SGPropertyNode
153 * The following action types are defined:
155 * "adjust" - modify the value of a floating-point property by
156 * the increment specified. This is the default.
158 * "swap" - swap the values of two-floating-point properties.
160 * "toggle" - toggle the value of a boolean property between true and
163 * For the adjust action, it is possible to specify an increment
164 * (use a negative number for a decrement), a minimum allowed value,
165 * a maximum allowed value, and a flag to indicate whether the value
166 * should freeze or wrap-around when it reachs the minimum or maximum.
168 * The action will be scaled automatically if the instrument is not
169 * being drawn at its regular size.
171 static FGPanelAction *
172 readAction (const SGPropertyNode * node, float w_scale, float h_scale)
175 SGPropertyNode *binding;
176 vector<SGPropertyNode_ptr>bindings = node->getChildren("binding");
178 // button-less actions are fired initially
179 if (!node->hasValue("w") || !node->hasValue("h")) {
180 for (i = 0; i < bindings.size(); i++) {
181 FGBinding b(bindings[i]);
187 string name = node->getStringValue("name");
189 int button = node->getIntValue("button");
190 int x = int(node->getIntValue("x") * w_scale);
191 int y = int(node->getIntValue("y") * h_scale);
192 int w = int(node->getIntValue("w") * w_scale);
193 int h = int(node->getIntValue("h") * h_scale);
194 bool repeatable = node->getBoolValue("repeatable", true);
196 FGPanelAction * action = new FGPanelAction(button, x, y, w, h, repeatable);
198 SGPropertyNode * dest = fgGetNode("/sim/bindings/panel", true);
200 for (i = 0; i < bindings.size(); i++) {
201 SG_LOG(SG_INPUT, SG_INFO, "Reading binding "
202 << bindings[i]->getStringValue("command"));
205 while (dest->getChild("binding", j))
208 binding = dest->getChild("binding", j, true);
209 copyProperties(bindings[i], binding);
210 action->addBinding(new FGBinding(binding), 0);
213 if (node->hasChild("mod-up")) {
214 bindings = node->getChild("mod-up")->getChildren("binding");
215 for (i = 0; i < bindings.size(); i++) {
217 while (dest->getChild("binding", j))
220 binding = dest->getChild("binding", j, true);
221 copyProperties(bindings[i], binding);
222 action->addBinding(new FGBinding(binding), 1);
226 readConditions(action, node);
232 * Read a transformation from the instrument's property list.
234 * The panel module uses the transformations to slide or spin needles,
235 * knobs, and other indicators, and to place layers in the correct
236 * positions. Every layer starts centered exactly on the x,y co-ordinate,
237 * and many layers need to be moved or rotated simply to display the
238 * instrument correctly.
240 * There are three types of transformations:
242 * "x-shift" - move the layer horizontally.
244 * "y-shift" - move the layer vertically.
246 * "rotation" - rotate the layer.
248 * Each transformation may have a fixed offset, and may also have
249 * a floating-point property value to add to the offset. The
250 * floating-point property may be clamped to a minimum and/or
251 * maximum range and scaled (after clamping).
253 * Note that because of the way OpenGL works, transformations will
254 * appear to be applied backwards.
256 static FGPanelTransformation *
257 readTransformation (const SGPropertyNode * node, float w_scale, float h_scale)
259 FGPanelTransformation * t = new FGPanelTransformation;
261 string name = node->getName();
262 string type = node->getStringValue("type");
263 string propName = node->getStringValue("property", "");
264 SGPropertyNode * target = 0;
267 SG_LOG( SG_COCKPIT, SG_INFO,
268 "No type supplied for transformation " << name
269 << " assuming \"rotation\"" );
273 if (!propName.empty()) {
274 target = fgGetNode(propName.c_str(), true);
278 t->min = node->getFloatValue("min", -9999999);
279 t->max = node->getFloatValue("max", 99999999);
280 t->has_mod = node->hasChild("modulator");
282 t->mod = node->getFloatValue("modulator");
283 t->factor = node->getFloatValue("scale", 1.0);
284 t->offset = node->getFloatValue("offset", 0.0);
286 // Check for an interpolation table
287 const SGPropertyNode * trans_table = node->getNode("interpolation");
288 if (trans_table != 0) {
289 SG_LOG( SG_COCKPIT, SG_INFO, "Found interpolation table with "
290 << trans_table->nChildren() << "children" );
291 t->table = new SGInterpTable();
292 for(int i = 0; i < trans_table->nChildren(); i++) {
293 const SGPropertyNode * node = trans_table->getChild(i);
294 if (!strcmp(node->getName(), "entry")) {
295 double ind = node->getDoubleValue("ind", 0.0);
296 double dep = node->getDoubleValue("dep", 0.0);
297 SG_LOG( SG_COCKPIT, SG_INFO, "Adding interpolation entry "
298 << ind << "==>" << dep );
299 t->table->addEntry(ind, dep);
301 SG_LOG( SG_COCKPIT, SG_INFO, "Skipping " << node->getName()
302 << " in interpolation" );
309 // Move the layer horizontally.
310 if (type == "x-shift") {
311 t->type = FGPanelTransformation::XSHIFT;
312 // t->min *= w_scale; //removed by Martin Dressler
313 // t->max *= w_scale; //removed by Martin Dressler
314 t->offset *= w_scale;
315 t->factor *= w_scale; //Added by Martin Dressler
318 // Move the layer vertically.
319 else if (type == "y-shift") {
320 t->type = FGPanelTransformation::YSHIFT;
321 //t->min *= h_scale; //removed
322 //t->max *= h_scale; //removed
323 t->offset *= h_scale;
324 t->factor *= h_scale; //Added
327 // Rotate the layer. The rotation
328 // is in degrees, and does not need
329 // to scale with the instrument size.
330 else if (type == "rotation") {
331 t->type = FGPanelTransformation::ROTATION;
335 SG_LOG( SG_COCKPIT, SG_ALERT, "Unrecognized transformation type " << type );
340 readConditions(t, node);
341 SG_LOG( SG_COCKPIT, SG_DEBUG, "Read transformation " << name );
347 * Read a chunk of text from the instrument's property list.
349 * A text layer consists of one or more chunks of text. All chunks
350 * share the same font size and color (and eventually, font), but
351 * each can come from a different source. There are three types of
354 * "literal" - a literal text string (the default)
356 * "text-value" - the current value of a string property
358 * "number-value" - the current value of a floating-point property.
360 * All three may also include a printf-style format string.
363 readTextChunk (const SGPropertyNode * node)
365 FGTextLayer::Chunk * chunk;
366 string name = node->getStringValue("name");
367 string type = node->getStringValue("type");
368 string format = node->getStringValue("format");
370 // Default to literal text.
372 SG_LOG( SG_COCKPIT, SG_INFO, "No type provided for text chunk " << name
373 << " assuming \"literal\"");
377 // A literal text string.
378 if (type == "literal") {
379 string text = node->getStringValue("text");
380 chunk = new FGTextLayer::Chunk(text, format);
383 // The value of a string property.
384 else if (type == "text-value") {
385 SGPropertyNode * target =
386 fgGetNode(node->getStringValue("property"), true);
387 chunk = new FGTextLayer::Chunk(FGTextLayer::TEXT_VALUE, target, format);
390 // The value of a float property.
391 else if (type == "number-value") {
392 string propName = node->getStringValue("property");
393 float scale = node->getFloatValue("scale", 1.0);
394 float offset = node->getFloatValue("offset", 0.0);
395 bool truncation = node->getBoolValue("truncate", false);
396 SGPropertyNode * target = fgGetNode(propName.c_str(), true);
397 chunk = new FGTextLayer::Chunk(FGTextLayer::DOUBLE_VALUE, target,
398 format, scale, offset, truncation);
403 SG_LOG( SG_COCKPIT, SG_ALERT, "Unrecognized type " << type
404 << " for text chunk " << name );
408 readConditions(chunk, node);
414 * Read a single layer from an instrument's property list.
416 * Each instrument consists of one or more layers stacked on top
417 * of each other; the lower layers show through only where the upper
418 * layers contain an alpha component. Each layer can be moved
419 * horizontally and vertically and rotated using transformations.
421 * This module currently recognizes four kinds of layers:
423 * "texture" - a layer containing a texture (the default)
425 * "text" - a layer containing text
427 * "switch" - a layer that switches between two other layers
428 * based on the current value of a boolean property.
430 * "built-in" - a hard-coded layer supported by C++ code in FlightGear.
432 * Currently, the only built-in layer class is "compass-ribbon".
434 static FGInstrumentLayer *
435 readLayer (const SGPropertyNode * node, float w_scale, float h_scale)
437 FGInstrumentLayer * layer = NULL;
438 string name = node->getStringValue("name");
439 string type = node->getStringValue("type");
440 int w = node->getIntValue("w", -1);
441 int h = node->getIntValue("h", -1);
443 w = int(w * w_scale);
445 h = int(h * h_scale);
449 SG_LOG( SG_COCKPIT, SG_INFO,
450 "No type supplied for layer " << name
451 << " assuming \"texture\"" );
456 // A textured instrument layer.
457 if (type == "texture") {
458 FGCroppedTexture texture = readTexture(node->getNode("texture"));
459 layer = new FGTexturedLayer(texture, w, h);
462 // A group of sublayers.
463 else if (type == "group") {
464 layer = new FGGroupLayer();
465 for (int i = 0; i < node->nChildren(); i++) {
466 const SGPropertyNode * child = node->getChild(i);
467 if (!strcmp(child->getName(), "layer"))
468 ((FGGroupLayer *)layer)->addLayer(readLayer(child, w_scale, h_scale));
473 // A textual instrument layer.
474 else if (type == "text") {
475 FGTextLayer * tlayer = new FGTextLayer(w, h); // FIXME
477 // Set the text color.
478 float red = node->getFloatValue("color/red", 0.0);
479 float green = node->getFloatValue("color/green", 0.0);
480 float blue = node->getFloatValue("color/blue", 0.0);
481 tlayer->setColor(red, green, blue);
483 // Set the point size.
484 float pointSize = node->getFloatValue("point-size", 10.0) * w_scale;
485 tlayer->setPointSize(pointSize);
488 string fontName = node->getStringValue("font", "default");
489 tlayer->setFontName(fontName);
491 const SGPropertyNode * chunk_group = node->getNode("chunks");
492 if (chunk_group != 0) {
493 int nChunks = chunk_group->nChildren();
494 for (int i = 0; i < nChunks; i++) {
495 const SGPropertyNode * node = chunk_group->getChild(i);
496 if (!strcmp(node->getName(), "chunk")) {
497 FGTextLayer::Chunk * chunk = readTextChunk(node);
499 tlayer->addChunk(chunk);
501 SG_LOG( SG_COCKPIT, SG_INFO, "Skipping " << node->getName()
509 // A switch instrument layer.
510 else if (type == "switch") {
511 layer = new FGSwitchLayer();
512 for (int i = 0; i < node->nChildren(); i++) {
513 const SGPropertyNode * child = node->getChild(i);
514 if (!strcmp(child->getName(), "layer"))
515 ((FGGroupLayer *)layer)->addLayer(readLayer(child, w_scale, h_scale));
519 // A built-in instrument layer.
520 else if (type == "built-in") {
521 string layerclass = node->getStringValue("class");
523 if (layerclass == "mag-ribbon") {
524 layer = new FGMagRibbon(w, h);
527 else if (layerclass.empty()) {
528 SG_LOG( SG_COCKPIT, SG_ALERT, "No class provided for built-in layer "
534 SG_LOG( SG_COCKPIT, SG_ALERT, "Unknown built-in layer class "
542 SG_LOG( SG_COCKPIT, SG_ALERT, "Unrecognized layer type " << type );
548 // Get the transformations for each layer.
550 const SGPropertyNode * trans_group = node->getNode("transformations");
551 if (trans_group != 0) {
552 int nTransformations = trans_group->nChildren();
553 for (int i = 0; i < nTransformations; i++) {
554 const SGPropertyNode * node = trans_group->getChild(i);
555 if (!strcmp(node->getName(), "transformation")) {
556 FGPanelTransformation * t = readTransformation(node, w_scale, h_scale);
558 layer->addTransformation(t);
560 SG_LOG( SG_COCKPIT, SG_INFO, "Skipping " << node->getName()
561 << " in transformations" );
566 readConditions(layer, node);
567 SG_LOG( SG_COCKPIT, SG_DEBUG, "Read layer " << name );
573 * Read an instrument from a property list.
575 * The instrument consists of a preferred width and height
576 * (the panel may override these), together with a list of layers
577 * and a list of actions to be performed when the user clicks
578 * the mouse over the instrument. All co-ordinates are relative
579 * to the instrument's position, so instruments are fully relocatable;
580 * likewise, co-ordinates for actions and transformations will be
581 * scaled automatically if the instrument is not at its preferred size.
583 static FGPanelInstrument *
584 readInstrument (const SGPropertyNode * node)
586 const string name = node->getStringValue("name");
587 int x = node->getIntValue("x", -1);
588 int y = node->getIntValue("y", -1);
589 int real_w = node->getIntValue("w", -1);
590 int real_h = node->getIntValue("h", -1);
591 int w = node->getIntValue("w-base", -1);
592 int h = node->getIntValue("h-base", -1);
594 if (x == -1 || y == -1) {
595 SG_LOG( SG_COCKPIT, SG_ALERT,
596 "x and y positions must be specified and > 0" );
603 w_scale = float(real_w) / float(w);
607 h_scale = float(real_h) / float(h);
611 SG_LOG( SG_COCKPIT, SG_DEBUG, "Reading instrument " << name );
613 FGLayeredInstrument * instrument =
614 new FGLayeredInstrument(x, y, w, h);
617 // Get the actions for the instrument.
619 const SGPropertyNode * action_group = node->getNode("actions");
620 if (action_group != 0) {
621 int nActions = action_group->nChildren();
622 for (int i = 0; i < nActions; i++) {
623 const SGPropertyNode * node = action_group->getChild(i);
624 if (!strcmp(node->getName(), "action")) {
625 FGPanelAction * action = readAction(node, w_scale, h_scale);
627 instrument->addAction(action);
629 SG_LOG( SG_COCKPIT, SG_INFO, "Skipping " << node->getName()
636 // Get the layers for the instrument.
638 const SGPropertyNode * layer_group = node->getNode("layers");
639 if (layer_group != 0) {
640 int nLayers = layer_group->nChildren();
641 for (int i = 0; i < nLayers; i++) {
642 const SGPropertyNode * node = layer_group->getChild(i);
643 if (!strcmp(node->getName(), "layer")) {
644 FGInstrumentLayer * layer = readLayer(node, w_scale, h_scale);
646 instrument->addLayer(layer);
648 SG_LOG( SG_COCKPIT, SG_INFO, "Skipping " << node->getName()
654 readConditions(instrument, node);
655 SG_LOG( SG_COCKPIT, SG_DEBUG, "Done reading instrument " << name );
661 * Construct the panel from a property tree.
664 readPanel (const SGPropertyNode * root)
666 SG_LOG( SG_COCKPIT, SG_INFO, "Reading properties for panel " <<
667 root->getStringValue("name", "[Unnamed Panel]") );
669 FGPanel * panel = new FGPanel();
670 panel->setWidth(root->getIntValue("w", 1024));
671 panel->setHeight(root->getIntValue("h", 443));
674 // Grab the visible external viewing area, default to
676 panel->setViewHeight(root->getIntValue("view-height",
677 768 - panel->getHeight() + 2));
680 // Grab the panel's initial offsets, default to 0, 0.
682 if (!fgHasNode("/sim/panel/x-offset"))
683 fgSetInt("/sim/panel/x-offset", root->getIntValue("x-offset", 0));
685 // conditional removed by jim wilson to allow panel xml code
686 // with y-offset defined to work...
687 if (!fgHasNode("/sim/panel/y-offset"))
688 fgSetInt("/sim/panel/y-offset", root->getIntValue("y-offset", 0));
691 // Assign the background texture, if any, or a bogus chequerboard.
693 string bgTexture = root->getStringValue("background");
694 if (bgTexture.empty())
696 panel->setBackground(FGTextureManager::createTexture(bgTexture.c_str()));
697 SG_LOG( SG_COCKPIT, SG_INFO, "Set background texture to " << bgTexture );
700 // Get multibackground if any...
702 string mbgTexture = root->getStringValue("multibackground[0]");
703 if (!mbgTexture.empty()) {
704 panel->setMultiBackground(FGTextureManager::createTexture(mbgTexture.c_str()), 0);
705 SG_LOG( SG_COCKPIT, SG_INFO, "Set background texture to " << mbgTexture );
707 mbgTexture = root->getStringValue("multibackground[1]");
708 if (mbgTexture.empty())
710 panel->setMultiBackground(FGTextureManager::createTexture(mbgTexture.c_str()), 1);
711 SG_LOG( SG_COCKPIT, SG_INFO, "Set background texture to " << mbgTexture );
713 mbgTexture = root->getStringValue("multibackground[2]");
714 if (mbgTexture.empty())
716 panel->setMultiBackground(FGTextureManager::createTexture(mbgTexture.c_str()), 2);
717 SG_LOG( SG_COCKPIT, SG_INFO, "Set background texture to " << mbgTexture );
719 mbgTexture = root->getStringValue("multibackground[3]");
720 if (mbgTexture.empty())
722 panel->setMultiBackground(FGTextureManager::createTexture(mbgTexture.c_str()), 3);
723 SG_LOG( SG_COCKPIT, SG_INFO, "Set background texture to " << mbgTexture );
725 mbgTexture = root->getStringValue("multibackground[4]");
726 if (mbgTexture.empty())
728 panel->setMultiBackground(FGTextureManager::createTexture(mbgTexture.c_str()), 4);
729 SG_LOG( SG_COCKPIT, SG_INFO, "Set background texture to " << mbgTexture );
731 mbgTexture = root->getStringValue("multibackground[5]");
732 if (mbgTexture.empty())
734 panel->setMultiBackground(FGTextureManager::createTexture(mbgTexture.c_str()), 5);
735 SG_LOG( SG_COCKPIT, SG_INFO, "Set background texture to " << mbgTexture );
737 mbgTexture = root->getStringValue("multibackground[6]");
738 if (mbgTexture.empty())
740 panel->setMultiBackground(FGTextureManager::createTexture(mbgTexture.c_str()), 6);
741 SG_LOG( SG_COCKPIT, SG_INFO, "Set background texture to " << mbgTexture );
743 mbgTexture = root->getStringValue("multibackground[7]");
744 if (mbgTexture.empty())
746 panel->setMultiBackground(FGTextureManager::createTexture(mbgTexture.c_str()), 7);
747 SG_LOG( SG_COCKPIT, SG_INFO, "Set background texture to " << mbgTexture );
754 // Create each instrument.
756 SG_LOG( SG_COCKPIT, SG_INFO, "Reading panel instruments" );
757 const SGPropertyNode * instrument_group = root->getChild("instruments");
758 if (instrument_group != 0) {
759 int nInstruments = instrument_group->nChildren();
760 for (int i = 0; i < nInstruments; i++) {
761 const SGPropertyNode * node = instrument_group->getChild(i);
762 if (!strcmp(node->getName(), "instrument")) {
763 FGPanelInstrument * instrument = readInstrument(node);
765 panel->addInstrument(instrument);
766 } else if(!strcmp(node->getName(), "special-instrument")) {
767 //cout << "Special instrument found in instruments section!\n";
768 const string name = node->getStringValue("name");
769 if(name == "KLN89 GPS") {
770 //cout << "Special instrument is KLN89\n";
772 int x = node->getIntValue("x", -1);
773 int y = node->getIntValue("y", -1);
774 int real_w = node->getIntValue("w", -1);
775 int real_h = node->getIntValue("h", -1);
776 int w = node->getIntValue("w-base", -1);
777 int h = node->getIntValue("h-base", -1);
779 if (x == -1 || y == -1) {
780 SG_LOG( SG_COCKPIT, SG_ALERT,
781 "x and y positions must be specified and > 0" );
788 w_scale = float(real_w) / float(w);
792 h_scale = float(real_h) / float(h);
796 SG_LOG( SG_COCKPIT, SG_DEBUG, "Reading instrument " << name );
798 // Warning - hardwired size!!!
799 RenderArea2D* instrument = new RenderArea2D(158, 40, 158, 40, x, y);
800 KLN89* gps = (KLN89*)globals->get_subsystem("kln89");
802 gps = new KLN89(instrument);
803 globals->add_subsystem("kln89", gps);
805 //gps->init(); // init seems to get called automagically.
806 FGSpecialInstrument* gpsinst = new FGSpecialInstrument(gps);
807 panel->addInstrument(gpsinst);
809 SG_LOG( SG_COCKPIT, SG_WARN, "Unknown special instrument found" );
812 SG_LOG( SG_COCKPIT, SG_INFO, "Skipping " << node->getName()
813 << " in instruments section" );
817 SG_LOG( SG_COCKPIT, SG_INFO, "Done reading panel instruments" );
821 // Return the new panel.
828 * Read a panel from a property list.
830 * Each panel instrument will appear in its own, separate
831 * property list. The top level simply names the panel and
832 * places the instruments in their appropriate locations (and
833 * optionally resizes them if necessary).
835 * Returns 0 if the read fails for any reason.
838 fgReadPanel (istream &input)
843 readProperties(input, &root);
844 } catch (const sg_exception &e) {
845 guiErrorMessage("Error reading panel: ", e);
848 return readPanel(&root);
853 * Read a panel from a property list.
855 * This function opens a stream to a file, then invokes the
856 * main fgReadPanel() function.
859 fgReadPanel (const string &relative_path)
861 SGPath path(globals->get_fg_root());
862 path.append(relative_path);
866 readProperties(path.str(), &root);
867 } catch (const sg_exception &e) {
868 guiErrorMessage("Error reading panel: ", e);
871 return readPanel(&root);
876 // end of panel_io.cxx