FlightGear.dsp FlightGear.dsw
dist-hook:
- (cd $(top_srcdir); ../admin/am2dsp.pl)
+ (cd $(top_srcdir); $(HOME)/projects/FlightGear-0.7/admin/am2dsp.pl)
tar --exclude docs-mini/CVS --exclude hints/CVS -cf - docs-mini hints \
| (cd $(distdir); tar xvf -)
# tar cf - Simulator/FDM/JSBsim/aircraft Simulator/FDM/JSBsim/engine | (cd $(distdir); tar xvf -)
fgfs-base-tar:
(cd $(HOME); \
- tar --exclude=CVS -czvf fgfs-base-$(VERSION).tar.gz \
+ tar --exclude=CVS --exclude='*/Textures/Unused' \
+ -czvf fgfs-base-$(VERSION).tar.gz \
FlightGear/A[A-su-z]* \
FlightGear/[B-CE-R]* \
FlightGear/Scenery/w130n30/w123n37 \
FlightGear/Scenery/w130n30/w122n37 \
FlightGear/Sounds \
FlightGear/[T-Za]* FlightGear/[c-z]* \
- -x '*/CVS/*' )
+ -x '*/CVS/*' -x '*/Textures/Unused/*' )
fgfs-base-patch:
(cd $(HOME); \
fgfs-docs: fgfs-docs-tar fgfs-manual-zip
fgfs-docs-tar:
- ( cd ../.. ; \
+ ( cd $(HOME)/projects ; \
tar czvf fgfs-docs-$(VERSION).tar.gz FlightGear-0.7/docs )
# fgfs-docs-zip:
-# ( cd ../.. ; \
+# ( cd $(HOME)/projects ; \
# zip -r fgfs-docs-$(VERSION).zip FlightGear-0.7/docs )
fgfs-manual-zip:
- ( cd ../.. ; \
+ ( cd $(HOME)/projects ; \
zip -r fgfs-manual-$(VERSION).zip FlightGear-0.7/docs/InstallGuide )
# make the win32-bin distribution
* texture, x1=0.0, y1=0.0, x2=0.5, y2=0.5.
*/
static FGCroppedTexture
-readTexture (SGPropertyNode node)
+readTexture (const SGPropertyNode * node)
{
- FGCroppedTexture texture(node.getStringValue("path"),
- node.getFloatValue("x1"),
- node.getFloatValue("y1"),
- node.getFloatValue("x2", 1.0),
- node.getFloatValue("y2", 1.0));
- FG_LOG(FG_INPUT, FG_INFO, "Read texture " << node.getName());
+ FGCroppedTexture texture(node->getStringValue("path"),
+ node->getFloatValue("x1"),
+ node->getFloatValue("y1"),
+ node->getFloatValue("x2", 1.0),
+ node->getFloatValue("y2", 1.0));
+ FG_LOG(FG_INPUT, FG_INFO, "Read texture " << node->getName());
return texture;
}
* being drawn at its regular size.
*/
static FGPanelAction *
-readAction (SGPropertyNode node, float hscale, float vscale)
+readAction (const SGPropertyNode * node, float hscale, float vscale)
{
FGPanelAction * action = 0;
- string name = node.getStringValue("name");
- string type = node.getStringValue("type");
+ string name = node->getStringValue("name");
+ string type = node->getStringValue("type");
- int button = node.getIntValue("button");
- int x = int(node.getIntValue("x") * hscale);
- int y = int(node.getIntValue("y") * vscale);
- int w = int(node.getIntValue("w") * hscale);
- int h = int(node.getIntValue("h") * vscale);
+ int button = node->getIntValue("button");
+ int x = int(node->getIntValue("x") * hscale);
+ int y = int(node->getIntValue("y") * vscale);
+ int w = int(node->getIntValue("w") * hscale);
+ int h = int(node->getIntValue("h") * vscale);
if (type == "") {
FG_LOG(FG_INPUT, FG_ALERT,
// Adjust a property value
if (type == "adjust") {
- string propName = node.getStringValue("property");
- SGValue * value = current_properties.getValue(propName, true);
- float increment = node.getFloatValue("increment", 1.0);
- float min = node.getFloatValue("min", 0.0);
- float max = node.getFloatValue("max", 0.0);
- bool wrap = node.getBoolValue("wrap", false);
+ string propName = node->getStringValue("property");
+ SGValue * value = globals->get_props()->getValue(propName, true);
+ float increment = node->getFloatValue("increment", 1.0);
+ float min = node->getFloatValue("min", 0.0);
+ float max = node->getFloatValue("max", 0.0);
+ bool wrap = node->getBoolValue("wrap", false);
if (min == max)
- FG_LOG(FG_INPUT, FG_ALERT, "Action " << node.getName()
+ FG_LOG(FG_INPUT, FG_ALERT, "Action " << node->getName()
<< " has same min and max value");
action = new FGAdjustAction(button, x, y, w, h, value,
increment, min, max, wrap);
// Swap two property values
else if (type == "swap") {
- string propName1 = node.getStringValue("property1");
- string propName2 = node.getStringValue("property2");
- SGValue * value1 = current_properties.getValue(propName1, true);
- SGValue * value2 = current_properties.getValue(propName2, true);
+ string propName1 = node->getStringValue("property1");
+ string propName2 = node->getStringValue("property2");
+ SGValue * value1 = globals->get_props()->getValue(propName1, true);
+ SGValue * value2 = globals->get_props()->getValue(propName2, true);
action = new FGSwapAction(button, x, y, w, h, value1, value2);
}
// Toggle a boolean value
else if (type == "toggle") {
- string propName = node.getStringValue("property");
- SGValue * value = current_properties.getValue(propName, true);
+ string propName = node->getStringValue("property");
+ SGValue * value = globals->get_props()->getValue(propName, true);
action = new FGToggleAction(button, x, y, w, h, value);
}
* appear to be applied backwards.
*/
static FGPanelTransformation *
-readTransformation (SGPropertyNode node, float hscale, float vscale)
+readTransformation (const SGPropertyNode * node, float hscale, float vscale)
{
FGPanelTransformation * t = new FGPanelTransformation;
- string name = node.getName();
- string type = node.getStringValue("type");
- string propName = node.getStringValue("property", "");
+ string name = node->getName();
+ string type = node->getStringValue("type");
+ string propName = node->getStringValue("property", "");
SGValue * value = 0;
if (type == "") {
}
if (propName != "") {
- value = current_properties.getValue(propName, true);
+ value = globals->get_props()->getValue(propName, true);
}
t->value = value;
- t->min = node.getFloatValue("min", -9999999);
- t->max = node.getFloatValue("max", 99999999);
- t->factor = node.getFloatValue("scale", 1.0);
- t->offset = node.getFloatValue("offset", 0.0);
+ t->min = node->getFloatValue("min", -9999999);
+ t->max = node->getFloatValue("max", 99999999);
+ t->factor = node->getFloatValue("scale", 1.0);
+ t->offset = node->getFloatValue("offset", 0.0);
// Move the layer horizontally.
if (type == "x-shift") {
* All three may also include a printf-style format string.
*/
FGTextLayer::Chunk *
-readTextChunk (SGPropertyNode node)
+readTextChunk (const SGPropertyNode * node)
{
FGTextLayer::Chunk * chunk;
- string name = node.getStringValue("name");
- string type = node.getStringValue("type");
- string format = node.getStringValue("format");
+ string name = node->getStringValue("name");
+ string type = node->getStringValue("type");
+ string format = node->getStringValue("format");
// Default to literal text.
if (type == "") {
// A literal text string.
if (type == "literal") {
- string text = node.getStringValue("text");
+ string text = node->getStringValue("text");
chunk = new FGTextLayer::Chunk(text, format);
}
// The value of a string property.
else if (type == "text-value") {
SGValue * value =
- current_properties.getValue(node.getStringValue("property"), true);
+ globals->get_props()->getValue(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 = current_properties.getValue(propName, true);
+ string propName = node->getStringValue("property");
+ float scale = node->getFloatValue("scale", 1.0);
+ SGValue * value = globals->get_props()->getValue(propName, true);
chunk = new FGTextLayer::Chunk(FGTextLayer::DOUBLE_VALUE, value,
format, scale);
}
* Currently, the only built-in layer class is "compass-ribbon".
*/
static FGInstrumentLayer *
-readLayer (SGPropertyNode node, float hscale, float vscale)
+readLayer (const SGPropertyNode * node, float hscale, float vscale)
{
FGInstrumentLayer * layer = NULL;
- string name = node.getStringValue("name");
- string type = node.getStringValue("type");
- int w = node.getIntValue("w", -1);
- int h = node.getIntValue("h", -1);
+ string name = node->getStringValue("name");
+ string type = node->getStringValue("type");
+ int w = node->getIntValue("w", -1);
+ int h = node->getIntValue("h", -1);
if (w != -1)
w = int(w * hscale);
if (h != -1)
// A textured instrument layer.
if (type == "texture") {
- FGCroppedTexture texture = readTexture(node.getSubNode("texture"));
+ FGCroppedTexture texture = readTexture(node->getNode("texture"));
layer = new FGTexturedLayer(texture, w, h);
}
FGTextLayer * tlayer = new FGTextLayer(w, h); // FIXME
// Set the text color.
- float red = node.getFloatValue("color/red", 0.0);
- float green = node.getFloatValue("color/green", 0.0);
- float blue = node.getFloatValue("color/blue", 0.0);
+ float red = node->getFloatValue("color/red", 0.0);
+ float green = node->getFloatValue("color/green", 0.0);
+ float blue = node->getFloatValue("color/blue", 0.0);
tlayer->setColor(red, green, blue);
// Set the point size.
- float pointSize = node.getFloatValue("point-size", 10.0) * hscale;
+ float pointSize = node->getFloatValue("point-size", 10.0) * hscale;
tlayer->setPointSize(pointSize);
// Set the font.
// TODO
- SGPropertyNode chunk_group = node.getSubNode("chunks");
- int nChunks = chunk_group.size();
- for (int i = 0; i < nChunks; i++) {
- FGTextLayer::Chunk * chunk = readTextChunk(chunk_group.getChild(i));
- if (chunk == 0) {
- delete layer;
- return 0;
+ const SGPropertyNode * chunk_group = node->getNode("chunks");
+ if (chunk_group != 0) {
+ int nChunks = chunk_group->nChildren();
+ for (int i = 0; i < nChunks; i++) {
+ FGTextLayer::Chunk * chunk = readTextChunk(chunk_group->getChild(i));
+ if (chunk == 0) {
+ delete layer;
+ return 0;
+ }
+ tlayer->addChunk(chunk);
}
- tlayer->addChunk(chunk);
+ layer = tlayer;
}
- layer = tlayer;
}
// A switch instrument layer.
else if (type == "switch") {
SGValue * value =
- current_properties.getValue(node.getStringValue("property"), true);
+ globals->get_props()->getValue(node->getStringValue("property"), true);
FGInstrumentLayer * layer1 =
- readLayer(node.getSubNode("layer1"), hscale, vscale);
+ readLayer(node->getNode("layer1"), hscale, vscale);
FGInstrumentLayer * layer2 =
- readLayer(node.getSubNode("layer2"), hscale, vscale);
+ readLayer(node->getNode("layer2"), hscale, vscale);
layer = new FGSwitchLayer(w, h, value, layer1, layer2);
}
// A built-in instrument layer.
else if (type == "built-in") {
- string layerclass = node.getStringValue("class");
+ string layerclass = node->getStringValue("class");
if (layerclass == "mag-ribbon") {
layer = new FGMagRibbon(w, h);
//
// Get the transformations for each layer.
//
- SGPropertyNode trans_group = node.getSubNode("transformations");
- int nTransformations = trans_group.size();
- for (int k = 0; k < nTransformations; k++) {
- FGPanelTransformation * t = readTransformation(trans_group.getChild(k),
- hscale, vscale);
- if (t == 0) {
- delete layer;
- return 0;
+ const SGPropertyNode * trans_group = node->getNode("transformations");
+ if (trans_group != 0) {
+ int nTransformations = trans_group->nChildren();
+ for (int i = 0; i < nTransformations; i++) {
+ FGPanelTransformation * t = readTransformation(trans_group->getChild(i),
+ hscale, vscale);
+ if (t == 0) {
+ delete layer;
+ return 0;
+ }
+ layer->addTransformation(t);
}
- layer->addTransformation(t);
}
FG_LOG(FG_INPUT, FG_INFO, "Read layer " << name);
* scaled automatically if the instrument is not at its preferred size.
*/
static FGPanelInstrument *
-readInstrument (SGPropertyNode node, int x, int y, int real_w, int real_h)
+readInstrument (const SGPropertyNode * node, int x, int y,
+ int real_w, int real_h)
{
- int w = node.getIntValue("w");
- int h = node.getIntValue("h");
- const string &name = node.getStringValue("name");
+ int w = node->getIntValue("w");
+ int h = node->getIntValue("h");
+ const string &name = node->getStringValue("name");
float hscale = 1.0;
float vscale = 1.0;
//
// Get the actions for the instrument.
//
- SGPropertyNode action_group = node.getSubNode("actions");
- int nActions = action_group.size();
- int j;
- for (j = 0; j < nActions; j++) {
- FGPanelAction * action = readAction(action_group.getChild(j),
- hscale, vscale);
- if (action == 0) {
- delete instrument;
- return new DefaultInstrument(x, y, w, h);
+ const SGPropertyNode * action_group = node->getNode("actions");
+ if (action_group != 0) {
+ int nActions = action_group->nChildren();
+ for (int i = 0; i < nActions; i++) {
+ FGPanelAction * action = readAction(action_group->getChild(i),
+ hscale, vscale);
+ if (action == 0) {
+ delete instrument;
+ return new DefaultInstrument(x, y, w, h);
+ }
+ instrument->addAction(action);
}
- instrument->addAction(action);
}
//
// Get the layers for the instrument.
//
- SGPropertyNode layer_group = node.getSubNode("layers");
- int nLayers = layer_group.size();
- for (j = 0; j < nLayers; j++) {
- FGInstrumentLayer * layer = readLayer(layer_group.getChild(j),
- hscale, vscale);
- if (layer == 0) {
- delete instrument;
- return new DefaultInstrument(x, y, w, h);
+ const SGPropertyNode * layer_group = node->getNode("layers");
+ if (layer_group != 0) {
+ int nLayers = layer_group->nChildren();
+ for (int i = 0; i < nLayers; i++) {
+ FGInstrumentLayer * layer = readLayer(layer_group->getChild(i),
+ hscale, vscale);
+ if (layer == 0) {
+ delete instrument;
+ return new DefaultInstrument(x, y, w, h);
+ }
+ instrument->addLayer(layer);
}
- instrument->addLayer(layer);
}
-
+
FG_LOG(FG_INPUT, FG_INFO, "Done reading instrument " << name);
return instrument;
}
FGPanel *
fgReadPanel (istream &input)
{
- SGPropertyList props;
+ SGPropertyNode root;
//
// Read the property list from disk.
//
- if (!readPropertyList(input, &props)) {
+ if (!readProperties(input, &root)) {
FG_LOG(FG_INPUT, FG_ALERT, "Malformed property list for panel.");
return 0;
}
FG_LOG(FG_INPUT, FG_INFO, "Read properties for panel " <<
- props.getStringValue("/name"));
+ root.getStringValue("name"));
//
// Construct a new, empty panel.
//
// Grab the panel's dimensions, default to 1024x443.
//
- int panel_w = (props.hasValue("/w") ? props.getIntValue("/w") : 1024);
- int panel_h = (props.hasValue("/h") ? props.getIntValue("/h") : 443);
+ int panel_w = (root.hasValue("w") ? root.getIntValue("w") : 1024);
+ int panel_h = (root.hasValue("h") ? root.getIntValue("h") : 443);
panel->setWidth(panel_w);
panel->setHeight(panel_h);
//
// Grab the visible external viewing area, default to
//
- panel->setViewHeight(props.hasValue("/view-height") ?
- props.getIntValue("/view-height") :
+ panel->setViewHeight(root.hasValue("view-height") ?
+ root.getIntValue("view-height") :
768 - panel_h + 2);
//
// Grab the panel's initial offsets, default to 0, 0.
//
- int xoffset = (props.hasValue("/x-offset") ?
- props.getIntValue("x-offset") :
+ int xoffset = (root.hasValue("x-offset") ?
+ root.getIntValue("x-offset") :
0);
- int yoffset = (props.hasValue("/y-offset") ?
- props.getIntValue("y-offset") :
+ int yoffset = (root.hasValue("y-offset") ?
+ root.getIntValue("y-offset") :
0);
panel->setXOffset(xoffset);
panel->setYOffset(yoffset);
//
// Assign the background texture, if any, or a bogus chequerboard.
//
- string bgTexture = props.getStringValue("/background");
+ string bgTexture = root.getStringValue("background");
if (bgTexture == "")
bgTexture = "FOO";
panel->setBackground(FGTextureManager::createTexture(bgTexture.c_str()));
// Create each instrument.
//
FG_LOG(FG_INPUT, FG_INFO, "Reading panel instruments");
- SGPropertyNode instrument_group("/instruments", &props);
- int nInstruments = instrument_group.size();
- for (int i = 0; i < nInstruments; i++) {
- SGPropertyList props2;
- SGPropertyNode node = instrument_group.getChild(i);
-
- FGPath path( globals->get_options()->get_fg_root() );
- path.append(node.getStringValue("path"));
-
- FG_LOG(FG_INPUT, FG_INFO, "Reading instrument "
- << node.getName()
- << " from "
- << path.str());
-
- int x = node.getIntValue("x", -1);
- int y = node.getIntValue("y", -1);
- int w = node.getIntValue("w", -1);
- int h = node.getIntValue("h", -1);
-
- if (x == -1 || y == -1) {
- FG_LOG(FG_INPUT, FG_ALERT, "x and y positions must be specified and >0");
- delete panel;
- return 0;
- }
-
-
- FGPanelInstrument * instrument = 0;
+ const SGPropertyNode * instrument_group = root.getChild("instruments");
+ if (instrument_group != 0) {
+ int nInstruments = instrument_group->nChildren();
+ for (int i = 0; i < nInstruments; i++) {
+ const SGPropertyNode * node = instrument_group->getChild(i);
+
+ FGPath path( globals->get_options()->get_fg_root() );
+ path.append(node->getStringValue("path"));
+
+ FG_LOG(FG_INPUT, FG_INFO, "Reading instrument "
+ << node->getName()
+ << " from "
+ << path.str());
+
+ int x = node->getIntValue("x", -1);
+ int y = node->getIntValue("y", -1);
+ int w = node->getIntValue("w", -1);
+ int h = node->getIntValue("h", -1);
+
+ if (x == -1 || y == -1) {
+ FG_LOG(FG_INPUT, FG_ALERT, "x and y positions must be specified and >0");
+ delete panel;
+ return 0;
+ }
- if (readPropertyList(path.str(), &props2)) {
- instrument = readInstrument(SGPropertyNode("/", &props2), x, y, w, h);
- }
- if (instrument == 0) {
- instrument = new DefaultInstrument(x, y, w, h);
+ // Read the instrument from
+ // a separate file.
+ FGPanelInstrument * instrument = 0;
+
+ SGPropertyNode root2;
+
+ if (readProperties(path.str(), &root2)) {
+ cerr << "Read " << root2.nChildren() << " top-level nodes from "
+ << path.c_str() << endl;
+ instrument = readInstrument(&root2, x, y, w, h);
+ }
+ if (instrument == 0)
+ instrument = new DefaultInstrument(x, y, w, h);
+ panel->addInstrument(instrument);
}
- panel->addInstrument(instrument);
}
FG_LOG(FG_INPUT, FG_INFO, "Done reading panel instruments");
int FGSteam::_UpdatesPending = 1000000; /* Forces filter to reset */
+ // FIXME: no need to use static
+ // functions any longer.
+#define DF1(getter) SGRawValueFunctions<double>(getter,0)
+#define DF2(getter, setter) SGRawValueFunctions<double>(getter,setter)
+
void FGSteam::update ( int timesteps )
{
if (!isTied) {
isTied = true;
- current_properties.tieDouble("/steam/airspeed",
- FGSteam::get_ASI_kias);
- current_properties.tieDouble("/steam/altitude",
- FGSteam::get_ALT_ft);
- current_properties.tieDouble("/steam/turn-rate",
- FGSteam::get_TC_std);
- current_properties.tieDouble("/steam/slip-skid",
- FGSteam::get_TC_rad);
- current_properties.tieDouble("/steam/vertical-speed",
- FGSteam::get_VSI_fps);
- current_properties.tieDouble("/steam/gyro-compass",
- FGSteam::get_DG_deg);
- current_properties.tieDouble("/steam/vor1",
- FGSteam::get_HackVOR1_deg);
- current_properties.tieDouble("/steam/vor2",
- FGSteam::get_HackVOR2_deg);
- current_properties.tieDouble("/steam/glidescope1",
- FGSteam::get_HackGS_deg);
- current_properties.tieDouble("/steam/adf",
- FGSteam::get_HackADF_deg);
- current_properties.tieDouble("/steam/gyro-compass-error",
- FGSteam::get_DG_err,
- FGSteam::set_DG_err);
- current_properties.tieDouble("/steam/mag-compass",
- FGSteam::get_MH_deg);
+ globals->get_props()->tie("/steam/airspeed",
+ DF1(FGSteam::get_ASI_kias));
+ globals->get_props()->tie("/steam/altitude",
+ DF1(FGSteam::get_ALT_ft));
+ globals->get_props()->tie("/steam/turn-rate",
+ DF1(FGSteam::get_TC_std));
+ globals->get_props()->tie("/steam/slip-skid",
+ DF1(FGSteam::get_TC_rad));
+ globals->get_props()->tie("/steam/vertical-speed",
+ DF1(FGSteam::get_VSI_fps));
+ globals->get_props()->tie("/steam/gyro-compass",
+ DF1(FGSteam::get_DG_deg));
+ globals->get_props()->tie("/steam/vor1",
+ DF1(FGSteam::get_HackVOR1_deg));
+ globals->get_props()->tie("/steam/vor2",
+ DF1(FGSteam::get_HackVOR2_deg));
+ globals->get_props()->tie("/steam/glidescope1",
+ DF1(FGSteam::get_HackGS_deg));
+ globals->get_props()->tie("/steam/adf",
+ DF1(FGSteam::get_HackADF_deg));
+ globals->get_props()->tie("/steam/gyro-compass-error",
+ DF2(FGSteam::get_DG_err,
+ FGSteam::set_DG_err));
+ globals->get_props()->tie("/steam/mag-compass",
+ DF1(FGSteam::get_MH_deg));
}
_UpdatesPending += timesteps;
}
+#undef DF1
+#undef DF2
+
void FGSteam::set_lowpass ( double *outthe, double inthe, double tc )
{
#include <string>
+#include <Main/globals.hxx>
+
#include <simgear/misc/props.hxx>
#include <simgear/debug/logstream.hxx>
#include <plib/js.h>
// Control property
string name = base;
name += "/control";
- SGValue * value = current_properties.getValue(name);
+ SGValue * value = globals->get_props()->getValue(name);
if (value == 0) {
FG_LOG(FG_INPUT, FG_INFO, " no control defined");
continue;
}
const string &control = value->getStringValue();
- a.value = current_properties.getValue(control, true);
+ a.value = globals->get_props()->getValue(control, true);
FG_LOG(FG_INPUT, FG_INFO, " using control " << control);
// Dead band
name = base;
name += "/dead-band";
- value = current_properties.getValue(name);
+ value = globals->get_props()->getValue(name);
if (value != 0)
js->setDeadBand(j, value->getDoubleValue());
FG_LOG(FG_INPUT, FG_INFO, " dead-band is " << js->getDeadBand(j));
// Offset
name = base;
name += "/offset";
- value = current_properties.getValue(name);
+ value = globals->get_props()->getValue(name);
if (value != 0)
a.offset = value->getDoubleValue();
FG_LOG(FG_INPUT, FG_INFO, " offset is " << a.offset);
// Factor
name = base;
name += "/factor";
- value = current_properties.getValue(name);
+ value = globals->get_props()->getValue(name);
if (value != 0)
a.factor = value->getDoubleValue();
FG_LOG(FG_INPUT, FG_INFO, " factor is " << a.factor);
// Tolerance
name = base;
name += "/tolerance";
- value = current_properties.getValue(name);
+ value = globals->get_props()->getValue(name);
if (value != 0)
a.tolerance = value->getDoubleValue();
FG_LOG(FG_INPUT, FG_INFO, " tolerance is " << a.tolerance);
// Saturation
name = base;
name += "/saturation";
- value = current_properties.getValue(name);
+ value = globals->get_props()->getValue(name);
if (value != 0)
js->setSaturation(j, value->getDoubleValue());
FG_LOG(FG_INPUT, FG_INFO, " saturation is " << js->getSaturation(j));
// Minimum range
name = base;
name += "/min-range";
- value = current_properties.getValue(name);
+ value = globals->get_props()->getValue(name);
if (value != 0)
minRange[j] = value->getDoubleValue();
FG_LOG(FG_INPUT, FG_INFO, " min-range is " << minRange[j]);
// Maximum range
name = base;
name += "/max-range";
- value = current_properties.getValue(name);
+ value = globals->get_props()->getValue(name);
if (value != 0)
maxRange[j] = value->getDoubleValue();
FG_LOG(FG_INPUT, FG_INFO, " max-range is " << maxRange[j]);
// Center
name = base;
name += "/center";
- value = current_properties.getValue(name);
+ value = globals->get_props()->getValue(name);
if (value != 0)
center[j] = value->getDoubleValue();
FG_LOG(FG_INPUT, FG_INFO, " center is " << center[j]);
string name = base;
name += "/control";
cout << "Trying name " << name << endl;
- SGValue * value = current_properties.getValue(name);
+ SGValue * value = globals->get_props()->getValue(name);
if (value == 0) {
FG_LOG(FG_INPUT, FG_INFO, " no control defined");
continue;
}
const string &control = value->getStringValue();
- b.value = current_properties.getValue(control, true);
+ b.value = globals->get_props()->getValue(control, true);
FG_LOG(FG_INPUT, FG_INFO, " using control " << control);
// Step
name = base;
name += "/step";
- value = current_properties.getValue(name);
+ value = globals->get_props()->getValue(name);
if (value != 0)
b.step = value->getDoubleValue();
FG_LOG(FG_INPUT, FG_INFO, " step is " << b.step);
// Type
name = base;
name += "/action";
- value = current_properties.getValue(name);
+ value = globals->get_props()->getValue(name);
string action = "adjust";
if (value != 0)
action = value->getStringValue();
// Repeatability.
name = base;
name += "/repeatable";
- value = current_properties.getValue(name);
+ value = globals->get_props()->getValue(name);
if (value != 0)
b.isRepeatable = value->getBoolValue();
FG_LOG(FG_INPUT, FG_INFO, (b.isRepeatable ?
// Local functions
////////////////////////////////////////////////////////////////////////
+static inline void
+TIE_BOOL(const char * name, bool (*getter)(), void (*setter)(bool)) {
+ globals->get_props()->tie(name, SGRawValueFunctions<bool>(getter, setter));
+}
+
+static inline void
+TIE_INT(const char * name, int (*getter)(), void (*setter)(int)) {
+ globals->get_props()->tie(name, SGRawValueFunctions<int>(getter, setter));
+}
+
+static inline void
+TIE_DOUBLE(const char * name, double (*getter)(), void (*setter)(double)) {
+ globals->get_props()->tie(name, SGRawValueFunctions<double>(getter, setter));
+}
+
+static inline void
+TIE_STRING(const char * name, string (*getter)(), void (*setter)(string)) {
+ globals->get_props()->tie(name, SGRawValueFunctions<string>(getter, setter));
+}
/**
* Initialize the BFI by binding its functions to properties.
{
FG_LOG(FG_GENERAL, FG_INFO, "Starting BFI init");
// Simulation
- current_properties.tieInt("/sim/flight-model",
- getFlightModel, setFlightModel);
- current_properties.tieString("/sim/aircraft",
- getAircraft, setAircraft);
- current_properties.tieString("/sim/aircraft-dir",
- getAircraftDir, setAircraftDir);
- // TODO: timeGMT
- current_properties.tieString("/sim/time/gmt",
- getDateString, setDateString);
- current_properties.tieString("/sim/time/gmt-string",
- getGMTString, 0);
- current_properties.tieBool("/sim/hud/visibility",
- getHUDVisible, setHUDVisible);
- current_properties.tieBool("/sim/panel/visibility",
- getPanelVisible, setPanelVisible);
- current_properties.tieInt("/sim/panel/x-offset",
- getPanelXOffset, setPanelXOffset);
- current_properties.tieInt("/sim/panel/y-offset",
- getPanelYOffset, setPanelYOffset);
+ TIE_INT("/sim/flight-model", getFlightModel, setFlightModel);
+ TIE_STRING("/sim/aircraft", getAircraft, setAircraft);
+ TIE_STRING("/sim/aircraft-dir", getAircraftDir, setAircraftDir);
+ TIE_STRING("/sim/time/gmt", getDateString, setDateString);
+ TIE_STRING("/sim/time/gmt-string", getGMTString, 0);
+ TIE_BOOL("/sim/hud/visibility", getHUDVisible, setHUDVisible);
+ TIE_BOOL("/sim/panel/visibility", getPanelVisible, setPanelVisible);
+ TIE_INT("/sim/panel/x-offset", getPanelXOffset, setPanelXOffset);
+ TIE_INT("/sim/panel/y-offset", getPanelYOffset, setPanelYOffset);
// Position
- current_properties.tieString("/position/airport-id",
- getTargetAirport, setTargetAirport);
- current_properties.tieDouble("/position/latitude",
- getLatitude, setLatitude);
- current_properties.tieDouble("/position/longitude",
- getLongitude, setLongitude);
- current_properties.tieDouble("/position/altitude",
- getAltitude, setAltitude);
-// getAltitude, setAltitude, false);
- current_properties.tieDouble("/position/altitude-agl",
- getAGL, 0);
+ TIE_STRING("/position/airport-id", getTargetAirport, setTargetAirport);
+ TIE_DOUBLE("/position/latitude", getLatitude, setLatitude);
+ TIE_DOUBLE("/position/longitude", getLongitude, setLongitude);
+ TIE_DOUBLE("/position/altitude", getAltitude, setAltitude);
+ TIE_DOUBLE("/position/altitude-agl", getAGL, 0);
// Orientation
- current_properties.tieDouble("/orientation/heading",
- getHeading, setHeading);
- current_properties.tieDouble("/orientation/heading-magnetic",
- getHeadingMag, 0);
- current_properties.tieDouble("/orientation/pitch",
- getPitch, setPitch);
- current_properties.tieDouble("/orientation/roll",
- getRoll, setRoll);
+ TIE_DOUBLE("/orientation/heading", getHeading, setHeading);
+ TIE_DOUBLE("/orientation/heading-magnetic", getHeadingMag, 0);
+ TIE_DOUBLE("/orientation/pitch", getPitch, setPitch);
+ TIE_DOUBLE("/orientation/roll", getRoll, setRoll);
// Engine
- current_properties.tieDouble("/engines/engine0/rpm",
- getRPM, 0);
- current_properties.tieDouble("/engines/engine0/egt",
- getEGT, 0);
- current_properties.tieDouble("/engines/engine0/cht",
- getCHT, 0);
- current_properties.tieDouble("/engines/engine0/mp",
- getMP, 0);
+ TIE_DOUBLE("/engines/engine0/rpm", getRPM, 0);
+ TIE_DOUBLE("/engines/engine0/egt", getEGT, 0);
+ TIE_DOUBLE("/engines/engine0/cht", getCHT, 0);
+ TIE_DOUBLE("/engines/engine0/mp", getMP, 0);
// Velocities
- current_properties.tieDouble("/velocities/airspeed",
- getAirspeed, setAirspeed);
- current_properties.tieDouble("/velocities/side-slip",
- getSideSlip, 0);
- current_properties.tieDouble("/velocities/vertical-speed",
- getVerticalSpeed, 0);
- current_properties.tieDouble("/velocities/speed-north",
- getSpeedNorth, 0);
- current_properties.tieDouble("/velocities/speed-east",
- getSpeedEast, 0);
- current_properties.tieDouble("/velocities/speed-down",
- getSpeedDown, 0);
+ TIE_DOUBLE("/velocities/airspeed", getAirspeed, setAirspeed);
+ TIE_DOUBLE("/velocities/side-slip", getSideSlip, 0);
+ TIE_DOUBLE("/velocities/vertical-speed", getVerticalSpeed, 0);
+ TIE_DOUBLE("/velocities/speed-north", getSpeedNorth, 0);
+ TIE_DOUBLE("/velocities/speed-east", getSpeedEast, 0);
+ TIE_DOUBLE("/velocities/speed-down", getSpeedDown, 0);
// Controls
- current_properties.tieDouble("/controls/throttle",
- getThrottle, setThrottle);
- current_properties.tieDouble("/controls/mixture",
- getMixture, setMixture);
- current_properties.tieDouble("/controls/propellor-pitch",
- getPropAdvance, setPropAdvance);
- current_properties.tieDouble("/controls/flaps",
- getFlaps, setFlaps);
- current_properties.tieDouble("/controls/aileron",
- getAileron, setAileron);
- current_properties.tieDouble("/controls/rudder",
- getRudder, setRudder);
- current_properties.tieDouble("/controls/elevator",
- getElevator, setElevator);
- current_properties.tieDouble("/controls/elevator-trim",
- getElevatorTrim, setElevatorTrim);
- current_properties.tieDouble("/controls/brakes/all",
- getBrakes, setBrakes);
- current_properties.tieDouble("/controls/brakes/left",
- getLeftBrake, setLeftBrake);
- current_properties.tieDouble("/controls/brakes/right",
- getRightBrake, setRightBrake);
- current_properties.tieDouble("/controls/brakes/center",
- getRightBrake, setCenterBrake);
+ TIE_DOUBLE("/controls/throttle", getThrottle, setThrottle);
+ TIE_DOUBLE("/controls/mixture", getMixture, setMixture);
+ TIE_DOUBLE("/controls/propellor-pitch", getPropAdvance, setPropAdvance);
+ TIE_DOUBLE("/controls/flaps", getFlaps, setFlaps);
+ TIE_DOUBLE("/controls/aileron", getAileron, setAileron);
+ TIE_DOUBLE("/controls/rudder", getRudder, setRudder);
+ TIE_DOUBLE("/controls/elevator", getElevator, setElevator);
+ TIE_DOUBLE("/controls/elevator-trim", getElevatorTrim, setElevatorTrim);
+ TIE_DOUBLE("/controls/brakes/all", getBrakes, setBrakes);
+ TIE_DOUBLE("/controls/brakes/left", getLeftBrake, setLeftBrake);
+ TIE_DOUBLE("/controls/brakes/right", getRightBrake, setRightBrake);
+ TIE_DOUBLE("/controls/brakes/center", getRightBrake, setCenterBrake);
// Autopilot
- current_properties.tieBool("/autopilot/locks/altitude",
- getAPAltitudeLock, setAPAltitudeLock);
- current_properties.tieDouble("/autopilot/settings/altitude",
- getAPAltitude, setAPAltitude);
- current_properties.tieBool("/autopilot/locks/heading",
- getAPHeadingLock, setAPHeadingLock);
- current_properties.tieDouble("/autopilot/settings/heading",
- getAPHeading, setAPHeading);
- current_properties.tieDouble("/autopilot/settings/heading-magnetic",
- getAPHeadingMag, setAPHeadingMag);
- current_properties.tieBool("/autopilot/locks/nav1",
- getAPNAV1Lock, setAPNAV1Lock);
+ TIE_BOOL("/autopilot/locks/altitude", getAPAltitudeLock, setAPAltitudeLock);
+ TIE_DOUBLE("/autopilot/settings/altitude", getAPAltitude, setAPAltitude);
+ TIE_BOOL("/autopilot/locks/heading", getAPHeadingLock, setAPHeadingLock);
+ TIE_DOUBLE("/autopilot/settings/heading", getAPHeading, setAPHeading);
+ TIE_DOUBLE("/autopilot/settings/heading-magnetic",
+ getAPHeadingMag, setAPHeadingMag);
+ TIE_BOOL("/autopilot/locks/nav1", getAPNAV1Lock, setAPNAV1Lock);
// Radio navigation
- current_properties.tieDouble("/radios/nav1/frequencies/selected",
- getNAV1Freq, setNAV1Freq);
- current_properties.tieDouble("/radios/nav1/frequencies/standby",
- getNAV1AltFreq, setNAV1AltFreq);
- current_properties.tieDouble("/radios/nav1/radials/actual",
- getNAV1Radial, 0);
- current_properties.tieDouble("/radios/nav1/radials/selected",
- getNAV1SelRadial, setNAV1SelRadial);
- current_properties.tieDouble("/radios/nav1/dme/distance",
- getNAV1DistDME, 0);
- current_properties.tieBool("/radios/nav1/to-flag",
- getNAV1TO, 0);
- current_properties.tieBool("/radios/nav1/from-flag",
- getNAV1FROM, 0);
- current_properties.tieBool("/radios/nav1/in-range",
- getNAV1InRange, 0);
- current_properties.tieBool("/radios/nav1/dme/in-range",
- getNAV1DMEInRange, 0);
+ TIE_DOUBLE("/radios/nav1/frequencies/selected", getNAV1Freq, setNAV1Freq);
+ TIE_DOUBLE("/radios/nav1/frequencies/standby", getNAV1AltFreq, setNAV1AltFreq);
+ TIE_DOUBLE("/radios/nav1/radials/actual", getNAV1Radial, 0);
+ TIE_DOUBLE("/radios/nav1/radials/selected",
+ getNAV1SelRadial, setNAV1SelRadial);
+ TIE_DOUBLE("/radios/nav1/dme/distance", getNAV1DistDME, 0);
+ TIE_BOOL("/radios/nav1/to-flag", getNAV1TO, 0);
+ TIE_BOOL("/radios/nav1/from-flag", getNAV1FROM, 0);
+ TIE_BOOL("/radios/nav1/in-range", getNAV1InRange, 0);
+ TIE_BOOL("/radios/nav1/dme/in-range", getNAV1DMEInRange, 0);
- current_properties.tieDouble("/radios/nav2/frequencies/selected",
- getNAV2Freq, setNAV2Freq);
- current_properties.tieDouble("/radios/nav2/frequencies/standby",
- getNAV2AltFreq, setNAV2AltFreq);
- current_properties.tieDouble("/radios/nav2/radials/actual",
- getNAV2Radial, 0);
- current_properties.tieDouble("/radios/nav2/radials/selected",
- getNAV2SelRadial, setNAV2SelRadial);
- current_properties.tieDouble("/radios/nav2/dme/distance",
- getNAV2DistDME, 0);
- current_properties.tieBool("/radios/nav2/to-flag",
- getNAV2TO, 0);
- current_properties.tieBool("/radios/nav2/from-flag",
- getNAV2FROM, 0);
- current_properties.tieBool("/radios/nav2/in-range",
- getNAV2InRange, 0);
- current_properties.tieBool("/radios/nav2/dme/in-range",
- getNAV2DMEInRange, 0);
-
- current_properties.tieDouble("/radios/adf/frequencies/selected",
- getADFFreq, setADFFreq);
- current_properties.tieDouble("/radios/adf/frequencies/standby",
- getADFAltFreq, setADFAltFreq);
- current_properties.tieDouble("/radios/adf/rotation",
- getADFRotation, setADFRotation);
-
- current_properties.tieDouble("/environment/visibility",
- getVisibility, setVisibility);
+ TIE_DOUBLE("/radios/nav2/frequencies/selected", getNAV2Freq, setNAV2Freq);
+ TIE_DOUBLE("/radios/nav2/frequencies/standby",
+ getNAV2AltFreq, setNAV2AltFreq);
+ TIE_DOUBLE("/radios/nav2/radials/actual", getNAV2Radial, 0);
+ TIE_DOUBLE("/radios/nav2/radials/selected",
+ getNAV2SelRadial, setNAV2SelRadial);
+ TIE_DOUBLE("/radios/nav2/dme/distance", getNAV2DistDME, 0);
+ TIE_BOOL("/radios/nav2/to-flag", getNAV2TO, 0);
+ TIE_BOOL("/radios/nav2/from-flag", getNAV2FROM, 0);
+ TIE_BOOL("/radios/nav2/in-range", getNAV2InRange, 0);
+ TIE_BOOL("/radios/nav2/dme/in-range", getNAV2DMEInRange, 0);
+
+ TIE_DOUBLE("/radios/adf/frequencies/selected", getADFFreq, setADFFreq);
+ TIE_DOUBLE("/radios/adf/frequencies/standby", getADFAltFreq, setADFAltFreq);
+ TIE_DOUBLE("/radios/adf/rotation", getADFRotation, setADFRotation);
+
+ TIE_DOUBLE("/environment/visibility", getVisibility, setVisibility);
_needReinit = false;
/**
* Return the current aircraft as a string.
*/
-const string &
+string
FGBFI::getAircraft ()
{
_temp = globals->get_options()->get_aircraft();
/**
* Return the current aircraft directory (UIUC) as a string.
*/
-const string &
+string
FGBFI::getAircraftDir ()
{
_temp = aircraft_dir;
* Set the current aircraft.
*/
void
-FGBFI::setAircraft (const string &aircraft)
+FGBFI::setAircraft (string aircraft)
{
if (getAircraft() != aircraft) {
globals->get_options()->set_aircraft(aircraft);
* Set the current aircraft directory (UIUC).
*/
void
-FGBFI::setAircraftDir (const string &dir)
+FGBFI::setAircraftDir (string dir)
{
if (getAircraftDir() != dir) {
aircraft_dir = dir;
/**
* Return the current Zulu time.
*/
-const string &
+string
FGBFI::getDateString ()
{
- static string out; // FIXME: not thread-safe
+ string out;
char buf[64];
struct tm * t = globals->get_time_params()->getGmt();
sprintf(buf, "%.4d-%.2d-%.2dT%.2d:%.2d:%.2d",
* Set the current Zulu time.
*/
void
-FGBFI::setDateString (const string &date_string)
+FGBFI::setDateString (string date_string)
// FGBFI::setTimeGMT (time_t time)
{
SGTime * st = globals->get_time_params();
/**
* Return the GMT as a string.
*/
-const string &
+string
FGBFI::getGMTString ()
{
- static string out; // FIXME: not thread-safe
+ string out;
char buf[16];
struct tm * t = globals->get_time_params()->getGmt();
sprintf(buf, " %.2d:%.2d:%.2d",
/**
* Get the GPS target airport code.
*/
-const string &
+string
FGBFI::getTargetAirport ()
{
// FIXME: not thread-safe
* Set the GPS target airport code.
*/
void
-FGBFI::setTargetAirport (const string &airportId)
+FGBFI::setTargetAirport (string airportId)
{
// cout << "setting target airport id = " << airportId << endl;
globals->get_options()->set_airport_id(airportId);
static int getFlightModel ();
static void setFlightModel (int flightModel);
- static const string &getAircraft ();
- static void setAircraft (const string &aircraft);
+ static string getAircraft ();
+ static void setAircraft (string aircraft);
- static const string &getAircraftDir ();
- static void setAircraftDir (const string &aircraftDir);
+ static string getAircraftDir ();
+ static void setAircraftDir (string aircraftDir);
// static time_t getTimeGMT ();
// static void setTimeGMT (time_t time);
- static const string &getDateString ();
- static void setDateString (const string &time_string);
+ static string getDateString ();
+ static void setDateString (string time_string);
// deprecated
- static const string &getGMTString ();
+ static string getGMTString ();
static bool getHUDVisible ();
static void setHUDVisible (bool hudVisible);
static void setADFRotation (double rot);
// GPS
- static const string &getTargetAirport ();
- static void setTargetAirport (const string &targetAirport);
+ static string getTargetAirport ();
+ static void setTargetAirport (string targetAirport);
static bool getGPSLock ();
static void setGPSLock (bool lock);
if ( fgFindAirportID( id, &a ) ) {
globals->get_options()->set_lon( a.longitude );
globals->get_options()->set_lat( a.latitude );
- current_properties.setDoubleValue("/position/longitude",
+ globals->get_props()->setDoubleValue("/position/longitude",
a.longitude);
- current_properties.setDoubleValue("/position/latitude",
+ globals->get_props()->setDoubleValue("/position/latitude",
a.latitude);
FG_LOG( FG_GENERAL, FG_INFO,
globals->get_options()->set_lon( lon2 );
globals->get_options()->set_lat( lat2 );
globals->get_options()->set_heading( heading );
- current_properties.setDoubleValue("/position/longitude", lon2);
- current_properties.setDoubleValue("/position/latitude", lat2);
- current_properties.setDoubleValue("/orientation/heading", heading);
+ globals->get_props()->setDoubleValue("/position/longitude", lon2);
+ globals->get_props()->setDoubleValue("/position/latitude", lat2);
+ globals->get_props()->setDoubleValue("/orientation/heading", heading);
FG_LOG( FG_GENERAL, FG_INFO,
"Position for " << id << " is ("
// f->get_Altitude() * FEET_TO_METER );
#if 0
- current_properties.setDoubleValue("/position/longitude",
+ globals->get_props()->setDoubleValue("/position/longitude",
f->get_Longitude() * RAD_TO_DEG);
- current_properties.setDoubleValue("/position/latitude",
+ globals->get_props()->setDoubleValue("/position/latitude",
f->get_Latitude() * RAD_TO_DEG);
- current_properties.setDoubleValue("/position/altitude",
+ globals->get_props()->setDoubleValue("/position/altitude",
f->get_Altitude() * RAD_TO_DEG);
#endif
// Initialize the 2D panel.
string panel_path =
- current_properties.getStringValue("/sim/panel/path",
- "Panels/Default/default.xml");
+ globals->get_props()->getStringValue("/sim/panel/path",
+ "Panels/Default/default.xml");
current_panel = fgReadPanel(panel_path);
if (current_panel == 0) {
FG_LOG( FG_INPUT, FG_ALERT,
#include <simgear/magvar/magvar.hxx>
#include <simgear/route/route.hxx>
#include <simgear/timing/sg_time.hxx>
+#include <simgear/misc/props.hxx>
#include "options.hxx"
#include "viewmgr.hxx"
FGViewMgr *viewmgr;
FGViewer *current_view;
+ // properties
+ SGPropertyNode *props;
+
public:
FGGlobals();
inline void set_viewmgr( FGViewMgr *vm ) { viewmgr = vm; }
inline FGViewer *get_current_view() const { return current_view; }
inline void set_current_view( FGViewer *v ) { current_view = v; }
+
+ inline SGPropertyNode *get_props () { return props; }
+ inline void set_props( SGPropertyNode *n ) { props = n; }
+ // inline const SGPropertyNode &get_props () const { return props; }
};
}
case GLUT_KEY_F3: {
string panel_path =
- current_properties.getStringValue("/sim/panel/path",
+ globals->get_props()->getStringValue("/sim/panel/path",
"Panels/Default/default.xml");
FGPanel * new_panel = fgReadPanel(panel_path);
if (new_panel == 0) {
FGPath props_path(globals->get_options()->get_fg_root());
props_path.append("preferences.xml");
FG_LOG(FG_INPUT, FG_INFO, "Rereading global preferences");
- if (!readPropertyList(props_path.str(), ¤t_properties)) {
+ if (!readProperties(props_path.str(), globals->get_props())) {
FG_LOG(FG_INPUT, FG_ALERT,
"Failed to reread global preferences from "
<< props_path.str());
// set current view to 0 (first) which is our main pilot view
globals->set_current_view( globals->get_viewmgr()->get_view( 0 ) );
+ SGPropertyNode *props = new SGPropertyNode;
+ globals->set_props( props );
+
// Scan the config file(s) and command line options to see if
// fg_root was specified (ignore all other options for now)
fgInitFGRoot(argc, argv);
FGPath props_path(globals->get_options()->get_fg_root());
props_path.append("preferences.xml");
FG_LOG(FG_INPUT, FG_INFO, "Reading global preferences");
- if (!readPropertyList(props_path.str(), ¤t_properties)) {
+ if (!readProperties(props_path.str(), globals->get_props())) {
FG_LOG(FG_INPUT, FG_ALERT, "Failed to read global preferences from "
<< props_path.str());
} else {
acmodel_pos = new ssgTransform;
string acmodel_path =
- current_properties.getStringValue("/sim/model/path",
+ globals->get_props()->getStringValue("/sim/model/path",
"Models/Geometry/glider.ac");
ssgEntity *acmodel_obj = ssgLoad((char *)(acmodel_path.c_str()));
sgMat4 off_matrix;
sgMat4 res_matrix;
float h_rot =
- current_properties.getFloatValue("/sim/model/h-rotation", 0.0);
+ globals->get_props()->getFloatValue("/sim/model/h-rotation", 0.0);
float p_rot =
- current_properties.getFloatValue("/sim/model/p-rotation", 0.0);
+ globals->get_props()->getFloatValue("/sim/model/p-rotation", 0.0);
float r_rot =
- current_properties.getFloatValue("/sim/model/r-rotation", 0.0);
+ globals->get_props()->getFloatValue("/sim/model/r-rotation", 0.0);
float x_off =
- current_properties.getFloatValue("/sim/model/x-offset", 0.0);
+ globals->get_props()->getFloatValue("/sim/model/x-offset", 0.0);
float y_off =
- current_properties.getFloatValue("/sim/model/y-offset", 0.0);
+ globals->get_props()->getFloatValue("/sim/model/y-offset", 0.0);
float z_off =
- current_properties.getFloatValue("/sim/model/z-offset", 0.0);
+ globals->get_props()->getFloatValue("/sim/model/z-offset", 0.0);
sgMakeRotMat4(rot_matrix, h_rot, p_rot, r_rot);
sgMakeTransMat4(off_matrix, x_off, y_off, z_off);
sgMultMat4(res_matrix, off_matrix, rot_matrix);
auto_coordination = FG_AUTO_COORD_ENABLED;
} else if ( arg == "--disable-hud" ) {
hud_status = false;
- current_properties.setBoolValue("/sim/hud/visibility", false);
+ globals->get_props()->setBoolValue("/sim/hud/visibility", false);
//$$$ begin - added Neetha
} else if ( arg == "--enable-default_hud" ) {
hud_status = true;
hud_flag = 1;
- current_properties.setBoolValue("/sim/hud/visibility", true);
+ globals->get_props()->setBoolValue("/sim/hud/visibility", true);
} else if ( arg == "--enable-ada_hud" ) {
hud_status = true;
hud_flag = 2;
- current_properties.setBoolValue("/sim/hud/visibility", true);
+ globals->get_props()->setBoolValue("/sim/hud/visibility", true);
//$$$ end - added Neetha
} else if ( arg == "--disable-panel" ) {
panel_status = false;
- current_properties.setBoolValue("/sim/panel/visibility", false);
+ globals->get_props()->setBoolValue("/sim/panel/visibility", false);
if ( current_panel != NULL )
current_panel->setVisibility(false);
} else if ( arg == "--enable-panel" ) {
panel_status = true;
- current_properties.setBoolValue("/sim/panel/visibility", true);
+ globals->get_props()->setBoolValue("/sim/panel/visibility", true);
if ( current_panel != NULL )
current_panel->setVisibility(true);
} else if ( arg == "--disable-sound" ) {
sound = true;
} else if ( arg.find( "--airport-id=") != string::npos ) {
airport_id = arg.substr( 13 );
- current_properties.setStringValue("/position/airport-id", airport_id);
+ globals->get_props()->setStringValue("/position/airport-id", airport_id);
} else if ( arg.find( "--lon=" ) != string::npos ) {
lon = parse_degree( arg.substr(6) );
airport_id = "";
- current_properties.setDoubleValue("/position/longitude", lon);
- current_properties.setStringValue("/position/airport-id", airport_id);
+ globals->get_props()->setDoubleValue("/position/longitude", lon);
+ globals->get_props()->setStringValue("/position/airport-id", airport_id);
} else if ( arg.find( "--lat=" ) != string::npos ) {
lat = parse_degree( arg.substr(6) );
airport_id = "";
- current_properties.setDoubleValue("/position/latitude", lat);
- current_properties.setStringValue("/position/airport-id", airport_id);
+ globals->get_props()->setDoubleValue("/position/latitude", lat);
+ globals->get_props()->setStringValue("/position/airport-id", airport_id);
} else if ( arg.find( "--altitude=" ) != string::npos ) {
if ( units == FG_UNITS_FEET ) {
altitude = atof( arg.substr(11) ) * FEET_TO_METER;
} else {
altitude = atof( arg.substr(11) );
}
- current_properties.setDoubleValue("/position/altitude", altitude);
+ globals->get_props()->setDoubleValue("/position/altitude", altitude);
} else if ( arg.find( "--uBody=" ) != string::npos ) {
speedset = FG_VTUVW;
if ( units == FG_UNITS_FEET ) {
} else {
uBody = atof( arg.substr(8) ) * FEET_TO_METER;
}
- //current_properties.setDoubleValue("/velocities/speed-north", uBody);
+ //globals->get_props()->setDoubleValue("/velocities/speed-north", uBody);
} else if ( arg.find( "--vBody=" ) != string::npos ) {
speedset = FG_VTUVW;
if ( units == FG_UNITS_FEET ) {
} else {
vBody = atof( arg.substr(8) ) * FEET_TO_METER;
}
- //current_properties.setDoubleValue("/velocities/speed-east", vBody);
+ //globals->get_props()->setDoubleValue("/velocities/speed-east", vBody);
} else if ( arg.find( "--wBody=" ) != string::npos ) {
speedset = FG_VTUVW;
if ( units == FG_UNITS_FEET ) {
} else {
vNorth = atof( arg.substr(9) ) * FEET_TO_METER;
}
- current_properties.setDoubleValue("/velocities/speed-north", vNorth);
+ globals->get_props()->setDoubleValue("/velocities/speed-north", vNorth);
} else if ( arg.find( "--vEast=" ) != string::npos ) {
speedset = FG_VTNED;
if ( units == FG_UNITS_FEET ) {
} else {
vEast = atof( arg.substr(8) ) * FEET_TO_METER;
}
- current_properties.setDoubleValue("/velocities/speed-east", vEast);
+ globals->get_props()->setDoubleValue("/velocities/speed-east", vEast);
} else if ( arg.find( "--vDown=" ) != string::npos ) {
speedset = FG_VTNED;
if ( units == FG_UNITS_FEET ) {
} else {
vDown = atof( arg.substr(8) ) * FEET_TO_METER;
}
- current_properties.setDoubleValue("/velocities/speed-down", vDown);
+ globals->get_props()->setDoubleValue("/velocities/speed-down", vDown);
} else if ( arg.find( "--vc=" ) != string::npos) {
speedset = FG_VC;
vkcas=atof( arg.substr(5) );
mach=atof( arg.substr(7) );
} else if ( arg.find( "--heading=" ) != string::npos ) {
heading = atof( arg.substr(10) );
- current_properties.setDoubleValue("/orientation/heading", heading);
+ globals->get_props()->setDoubleValue("/orientation/heading", heading);
} else if ( arg.find( "--roll=" ) != string::npos ) {
roll = atof( arg.substr(7) );
- current_properties.setDoubleValue("/orientation/roll", roll);
+ globals->get_props()->setDoubleValue("/orientation/roll", roll);
} else if ( arg.find( "--pitch=" ) != string::npos ) {
pitch = atof( arg.substr(8) );
- current_properties.setDoubleValue("/orientation/pitch", pitch);
+ globals->get_props()->setDoubleValue("/orientation/pitch", pitch);
} else if ( arg.find( "--fg-root=" ) != string::npos ) {
fg_root = arg.substr( 10 );
} else if ( arg.find( "--fg-scenery=" ) != string::npos ) {
fg_scenery = arg.substr( 13 );
} else if ( arg.find( "--fdm=" ) != string::npos ) {
flight_model = parse_fdm( arg.substr(6) );
- current_properties.setIntValue("/sim/flight-model", flight_model);
+ globals->get_props()->setIntValue("/sim/flight-model", flight_model);
if((flight_model == FGInterface::FG_JSBSIM) && (get_trim_mode() == 0)) {
set_trim_mode(1);
} else {
}
} else if ( arg.find( "--aircraft=" ) != string::npos ) {
aircraft = arg.substr(11);
- current_properties.setStringValue("/sim/aircraft", aircraft);
+ globals->get_props()->setStringValue("/sim/aircraft", aircraft);
} else if ( arg.find( "--aircraft-dir=" ) != string::npos ) {
aircraft_dir = arg.substr(15); // (UIUC)
} else if ( arg.find( "--model-hz=" ) != string::npos ) {
}
string name = assign.substr(0, pos);
string value = assign.substr(pos + 1);
- current_properties.setStringValue(name.c_str(), value);
+ globals->get_props()->setStringValue(name.c_str(), value);
FG_LOG(FG_GENERAL, FG_INFO, "Setting default value of property "
<< name << " to \"" << value << '"');
// $$$ begin - added VS Renganathan, 14 Oct 2K
bool
fgSaveFlight (ostream &output)
{
- return writePropertyList(output, ¤t_properties);
+ return writeProperties(output, globals->get_props());
}
bool
fgLoadFlight (istream &input)
{
- return readPropertyList(input, ¤t_properties);
+ return readProperties(input, globals->get_props());
}
// end of save.cxx
// $Id$
+#include <Main/globals.hxx>
+
#include <simgear/compiler.h>
#include <simgear/debug/logstream.hxx>
#include <simgear/io/iochannel.hxx>
string command = tokens[0];
- SGPropertyNode node( path, ¤t_properties );
- if ( node.getPath() == "" ) {
- node.setPath( "/" );
- }
+ SGPropertyNode * node = globals->get_props()->getNode(path);
if ( command == "ls" ) {
- for (int i = 0; i < (int)node.size(); i++) {
- SGPropertyNode child = node.getChild(i);
- string name = child.getName();
+ for (int i = 0; i < (int)node->nChildren(); i++) {
+ SGPropertyNode * child = node->getChild(i);
+ string name = child->getName();
string line = name;
- if ( child.size() > 0 ) {
+ if ( child->nChildren() > 0 ) {
line += "/\n";
} else {
- string value = node.getStringValue ( name, "" );
+ string value = node->getStringValue ( name, "" );
line += " =\t'" + value + "'\t(";
- line += getValueTypeString( node.getValue( name ) );
+ line += getValueTypeString( node->getValue( name ) );
line += ")\n";
}
io->writestring( line.c_str() );
// string tmp = "current path = " + node.getPath() + "\n";
// io->writestring( tmp.c_str() );
- if ( tokens.size() <= 1 ) {
- // do nothing
- } else if ( tokens[1] == "." ) {
+ if ( tokens.size() <= 1 ) {
// do nothing
- } else if ( tokens[1] == ".." ) {
- // go back one level
- string current = node.getPath();
- int pos = current.rfind("/");
- // cout << "path = " << current << endl;
- // cout << "new path = " << current.substr(0, pos) << endl;d
- string tmp = current.substr(0, pos);
- node.setPath( tmp );
- path = tmp;
} else {
- // decend to specified child
- string tmp = node.getPath();
- tmp += "/" + tokens[1];
- node.setPath( tmp );
- path = tmp;
+ node = node->getNode(tokens[1]);
+ path = node->getPath();
}
+ } else if ( command == "pwd" ) {
+ string ttt = node->getPath();
+ if ( ttt == "" ) {
+ ttt = "/";
+ }
+ ttt += "\n";
+ io->writestring( ttt.c_str() );
} else if ( command == "show" ) {
if ( tokens.size() <= 1 ) {
// do nothing
string ttt = "debug = '" + tokens[1] + "'\n";
io->writestring( ttt.c_str() );
- string value = node.getStringValue ( tokens[1], "" );
+ string value = node->getStringValue ( tokens[1], "" );
string tmp = tokens[1] + " = '" + value + "' (";
- tmp += getValueTypeString( node.getValue( tokens[1] ) );
+ tmp += getValueTypeString( node->getValue( tokens[1] ) );
tmp += ")\n";
io->writestring( tmp.c_str() );
}
} else if ( command == "set" ) {
- if ( tokens.size() <= 2 ) {
+ if ( tokens.size() <= 2 ) {
// do nothing
} else {
- SGValue *v = node.getValue( tokens[1] );
- if ( v != NULL ) {
- SGValue::Type type = v->getType();
- if ( type == SGValue::UNKNOWN ) {
- v->setUnknownValue( tokens[2] );
- } else if ( type == SGValue::BOOL ) {
- if ( tokens[2] == "true" ) {
- v->setBoolValue( true );
- } else if ( tokens[2] == "false" ) {
- v->setBoolValue( false );
- } else {
- v->setBoolValue( atoi( tokens[2].c_str() ) );
- }
- } else if ( type == SGValue::INT ) {
- v->setIntValue( atoi( tokens[2].c_str() ) );
- } else if ( type == SGValue::FLOAT ) {
- v->setFloatValue( atof( tokens[2].c_str() ) );
- } else if ( type == SGValue::DOUBLE ) {
- v->setDoubleValue( atof( tokens[2].c_str() ) );
- } else if ( type == SGValue::STRING ) {
- v->setStringValue( tokens[2] );
- }
-
- // now fetch and write out the new value as confirmation
- // of the change
- string value = node.getStringValue ( tokens[1], "" );
- string tmp = tokens[1] + " = '" + value + "' (";
- tmp += getValueTypeString( node.getValue( tokens[1] ) );
- tmp += ")\n";
-
- io->writestring( tmp.c_str() );
- } else {
- string tmp = tokens[1] + " is unknown.\n";
-
- io->writestring( tmp.c_str() );
- }
+ node->getValue( tokens[1], true )->setStringValue(tokens[2]);
+ // now fetch and write out the new value as confirmation
+ // of the change
+ string value = node->getStringValue ( tokens[1], "" );
+ string tmp = tokens[1] + " = '" + value + "' (";
+ tmp += getValueTypeString( node->getValue( tokens[1] ) );
+ tmp += ")\n";
+
+ io->writestring( tmp.c_str() );
}
} else if ( command == "quit" ) {
close();
io->writestring( "help show help message\n" );
io->writestring( "ls list current directory\n" );
io->writestring( "cd <dir> cd to a directory, '..' to move back\n" );
+ io->writestring( "pwd display your current path\n" );
io->writestring( "show <var> show the value of a parameter\n" );
io->writestring( "set <var> <val> set <var> to a new <val>\n" );
io->writestring( "quit terminate connection\n" );
io->writestring( "\n" );
}
- string prompt = node.getPath();
+ string prompt = node->getPath();
if ( prompt == "" ) {
prompt = "/";
}