From ec0ed21b73d431ace353ebd1fcd943a909ba264a Mon Sep 17 00:00:00 2001 From: torsten Date: Mon, 18 May 2009 20:27:57 +0000 Subject: [PATCH] support true for input elements. If set to true, the input value is filtered thru fabs() function. Defaults to false if absent, so there is no impact for existing configurations --- src/Autopilot/xmlauto.cxx | 6 +++++- src/Autopilot/xmlauto.hxx | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Autopilot/xmlauto.cxx b/src/Autopilot/xmlauto.cxx index 640664140..1da364276 100644 --- a/src/Autopilot/xmlauto.cxx +++ b/src/Autopilot/xmlauto.cxx @@ -74,6 +74,10 @@ void FGXMLAutoInput::parse( SGPropertyNode_ptr node, double aValue, double aOffs min = new FGXMLAutoInput( n ); } + if( (n = node->getChild( "abs" )) != NULL ) { + abs = n->getBoolValue(); + } + SGPropertyNode *valueNode = node->getChild( "value" ); if ( valueNode != NULL ) { value = valueNode->getDoubleValue(); @@ -144,7 +148,7 @@ double FGXMLAutoInput::get_value() value = m; } - return value; + return abs ? fabs(value) : value; } FGXMLAutoComponent::FGXMLAutoComponent( SGPropertyNode * node ) : diff --git a/src/Autopilot/xmlauto.hxx b/src/Autopilot/xmlauto.hxx index 41946fb25..df2f9d95c 100644 --- a/src/Autopilot/xmlauto.hxx +++ b/src/Autopilot/xmlauto.hxx @@ -52,6 +52,7 @@ using std::deque; class FGXMLAutoInput : public SGReferenced { private: double value; // The value as a constant or initializer for the property + bool abs; // return absolute value SGPropertyNode_ptr property; // The name of the property containing the value SGSharedPtr offset; // A fixed offset, defaults to zero SGSharedPtr scale; // A constant scaling factor defaults to one @@ -63,6 +64,7 @@ public: FGXMLAutoInput( SGPropertyNode_ptr node = NULL, double value = 0.0, double offset = 0.0, double scale = 1.0 ) : property(NULL), value(0.0), + abs(false), offset(NULL), scale(NULL), min(NULL),