+ * Read a chunk of text from the instrument's property list.
+ *
+ * A text layer consists of one or more chunks of text. All chunks
+ * share the same font size and color (and eventually, font), but
+ * each can come from a different source. There are three types of
+ * text chunks:
+ *
+ * "literal" - a literal text string (the default)
+ *
+ * "text-value" - the current value of a string property
+ *
+ * "number-value" - the current value of a floating-point property.
+ *
+ * All three may also include a printf-style format string.
+ */
+FGTextLayer::Chunk *
+readTextChunk (const SGPropertyNode * node)
+{
+ FGTextLayer::Chunk * chunk;
+ string name = node->getStringValue("name");
+ string type = node->getStringValue("type");
+ string format = node->getStringValue("format");
+
+ // Default to literal text.
+ if (type == "") {
+ FG_LOG(FG_INPUT, FG_INFO, "No type provided for text chunk " << name
+ << " assuming \"literal\"");
+ type = "literal";
+ }
+
+ // A literal text string.
+ if (type == "literal") {
+ string text = node->getStringValue("text");
+ chunk = new FGTextLayer::Chunk(text, format);
+ }
+
+ // The value of a string property.
+ else if (type == "text-value") {
+ SGValue * value =
+ fgGetValue(node->getStringValue("property"), true);
+ chunk = new FGTextLayer::Chunk(FGTextLayer::TEXT_VALUE, value, format);
+ }
+
+ // The value of a float property.
+ else if (type == "number-value") {
+ string propName = node->getStringValue("property");
+ float scale = node->getFloatValue("scale", 1.0);
+ SGValue * value = fgGetValue(propName, true);
+ chunk = new FGTextLayer::Chunk(FGTextLayer::DOUBLE_VALUE, value,
+ format, scale);
+ }
+
+ // Unknown type.
+ else {
+ FG_LOG(FG_INPUT, FG_ALERT, "Unrecognized type " << type
+ << " for text chunk " << name);
+ return 0;
+ }
+
+ return chunk;
+}
+
+
+/**
+ * Read a single layer from an instrument's property list.
+ *
+ * Each instrument consists of one or more layers stacked on top
+ * of each other; the lower layers show through only where the upper
+ * layers contain an alpha component. Each layer can be moved
+ * horizontally and vertically and rotated using transformations.
+ *
+ * This module currently recognizes four kinds of layers:
+ *
+ * "texture" - a layer containing a texture (the default)
+ *
+ * "text" - a layer containing text
+ *
+ * "switch" - a layer that switches between two other layers
+ * based on the current value of a boolean property.
+ *
+ * "built-in" - a hard-coded layer supported by C++ code in FlightGear.
+ *
+ * Currently, the only built-in layer class is "compass-ribbon".