diff --git a/src/Cockpit/NavDisplay.cxx b/src/Cockpit/NavDisplay.cxx index caf70b0ff..6c344aa9d 100644 --- a/src/Cockpit/NavDisplay.cxx +++ b/src/Cockpit/NavDisplay.cxx @@ -566,6 +566,8 @@ NavDisplay::init () _userLonNode = _Instrument->getChild("user-longitude-deg", 0, true); _userPositionEnable = _Instrument->getChild("user-position", 0, true); + _customSymbols = _Instrument->getChild("symbols", 0, true); + // OSG geometry setup _radarGeode = new osg::Geode; @@ -745,6 +747,7 @@ NavDisplay::update (double delta_time_sec) processRoute(); processNavRadios(); processAI(); + processCustomSymbols(); findItems(); limitDisplayedSymbols(); } @@ -1439,3 +1442,39 @@ void NavDisplay::addRule(SymbolRule* r) _rules.push_back(r); } +void NavDisplay::computeCustomSymbolStates(const SGPropertyNode* sym, string_set& states) +{ + BOOST_FOREACH(SGPropertyNode* st, sym->getChildren("state")) { + states.insert(st->getStringValue()); + } +} + +void NavDisplay::processCustomSymbols() +{ + for (int i = _customSymbols->nChildren() - 1; i >= 0; i--) { + SGPropertyNode *symNode = _customSymbols->getChild(i); + if (!symNode->nChildren()) { + continue; + } + string_set ss; + computeCustomSymbolStates(symNode, ss); + SymbolRuleVector rules; + findRules(symNode->getName(), ss, rules); + if (rules.empty()) { + return; // no rules matched, we can skip this item + } + + double heading = symNode->getDoubleValue("true-heading-deg", 0.0); + SGGeod pos = SGGeod::fromDegFt(symNode->getDoubleValue("longitude-deg"), + symNode->getDoubleValue("latitude-deg"), + symNode->getDoubleValue("altitude-ft")); + + + osg::Vec2 projected = projectGeod(pos); + BOOST_FOREACH(SymbolRule* r, rules) { + addSymbolInstance(projected, heading, r->getDefinition(), symNode); + } + } // of custom symbols iteration +} + + diff --git a/src/Cockpit/NavDisplay.hxx b/src/Cockpit/NavDisplay.hxx index b45caed6c..62e9d45a7 100644 --- a/src/Cockpit/NavDisplay.hxx +++ b/src/Cockpit/NavDisplay.hxx @@ -121,6 +121,9 @@ private: void processAI(); void computeAIStates(const SGPropertyNode* ai, string_set& states); + void computeCustomSymbolStates(const SGPropertyNode* sym, string_set& states); + void processCustomSymbols(); + void findRules(const std::string& type, const string_set& states, SymbolRuleVector& rules); SymbolInstance* addSymbolInstance(const osg::Vec2& proj, double heading, SymbolDef* def, SGPropertyNode* vars); @@ -192,7 +195,8 @@ private: FGPositioned::List _itemsInRange; SGPropertyNode_ptr _excessDataNode; int _maxSymbols; - + SGPropertyNode_ptr _customSymbols; + class CacheListener; std::auto_ptr _cacheListener;