From 45f3eb7f99b4eced8c95887c7a6fe9e3b2737bca Mon Sep 17 00:00:00 2001 From: david Date: Sun, 2 Mar 2003 14:19:24 +0000 Subject: [PATCH] Patch from Erik Hofman: I've updated the instrument modulator code to allow tricks like the one described by Andy. It is now possible to define , and in one layer and if and/or ore within the range of the tag, their value will be honoured. So, if you define 0 50 100 The value will stay at 50, until the modulator forces it back to 0. --- src/Cockpit/panel.cxx | 4 ++++ src/Cockpit/panel.hxx | 3 +++ src/Cockpit/panel_io.cxx | 3 +++ 3 files changed, 10 insertions(+) diff --git a/src/Cockpit/panel.cxx b/src/Cockpit/panel.cxx index dd5e83afd..b492c0bf4 100644 --- a/src/Cockpit/panel.cxx +++ b/src/Cockpit/panel.cxx @@ -847,11 +847,15 @@ FGInstrumentLayer::transform () const FGPanelTransformation *t = *it; if (t->test()) { float val = (t->node == 0 ? 0.0 : t->node->getFloatValue()); + + if (t->has_mod) + val = fmod(val, t->mod); if (val < t->min) { val = t->min; } else if (val > t->max) { val = t->max; } + if(t->table==0) { val = val * t->factor + t->offset; } else { diff --git a/src/Cockpit/panel.hxx b/src/Cockpit/panel.hxx index 595c5f8ee..af1c073ae 100644 --- a/src/Cockpit/panel.hxx +++ b/src/Cockpit/panel.hxx @@ -44,6 +44,7 @@ #include #include +#include #include #include #include @@ -303,6 +304,8 @@ public: const SGPropertyNode * node; float min; float max; + bool has_mod; + float mod; float factor; float offset; SGInterpTable * table; diff --git a/src/Cockpit/panel_io.cxx b/src/Cockpit/panel_io.cxx index 474ed4aa4..ef83c6b1a 100644 --- a/src/Cockpit/panel_io.cxx +++ b/src/Cockpit/panel_io.cxx @@ -251,6 +251,9 @@ readTransformation (const SGPropertyNode * node, float w_scale, float h_scale) t->node = target; t->min = node->getFloatValue("min", -9999999); t->max = node->getFloatValue("max", 99999999); + t->has_mod = node->hasChild("modulator"); + if (t->has_mod) + t->mod = node->getFloatValue("modulator"); t->factor = node->getFloatValue("scale", 1.0); t->offset = node->getFloatValue("offset", 0.0);