From a285ff5ea47e7951430e28a93b233a5ab59e49b2 Mon Sep 17 00:00:00 2001
From: david <david>
Date: Tue, 19 Feb 2002 23:54:47 +0000
Subject: [PATCH] Added a new 'squared' subproperty for axis bindings.

---
 src/Main/fg_commands.cxx | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/src/Main/fg_commands.cxx b/src/Main/fg_commands.cxx
index 67ec281de..2f52e91de 100644
--- a/src/Main/fg_commands.cxx
+++ b/src/Main/fg_commands.cxx
@@ -58,6 +58,8 @@ public:
     { return _wrap ? _wrap : &_dummy_0; }
   virtual const SGPropertyNode * getFactor () const 
     { return _factor ? _factor : &_dummy_1; }
+  virtual const SGPropertyNode * getSquared () const 
+    { return _squared ? _squared : &_dummy_1; }
   virtual const SGPropertyNode * getSetting () const 
     { return _setting ? _setting : &_dummy_0; }
   virtual const SGPropertyNode * getOffset () const
@@ -73,6 +75,7 @@ private:
   const SGPropertyNode * _max;
   const SGPropertyNode * _wrap;
   const SGPropertyNode * _factor;
+  const SGPropertyNode * _squared;
   const SGPropertyNode * _setting;
   const SGPropertyNode * _offset;
 };
@@ -90,6 +93,7 @@ PropertyCommandState::PropertyCommandState (const SGPropertyNode * arg)
     _max(arg->getNode("max")),
     _wrap(arg->getNode("wrap")),
     _factor(arg->getNode("factor")),
+    _squared(arg->getNode("squared")),
     _setting(arg->getNode("setting")),
     _offset(arg->getNode("offset"))
 {
@@ -536,8 +540,14 @@ do_property_scale (const SGPropertyNode * arg, SGCommandState ** state)
     ((PropertyCommandState *)(*state))->getOffset()->getDoubleValue();
   double factor =
     ((PropertyCommandState *)(*state))->getFactor()->getDoubleValue();
+  bool squared =
+    ((PropertyCommandState *)(*state))->getSquared()->getBoolValue();
 
-  return prop->setDoubleValue((setting + offset) * factor);
+  double result = (setting + offset) * factor;
+  if (squared)
+    result = (result < 0 ? -1 : 1) * result * result;
+
+  return prop->setDoubleValue(result);
 }