http://forum.flightgear.org/viewtopic.php?f=14&t=23736
The code was obviously too aircraft-specific, so, after talking with Hooray, I started to abstract the code in order to have a generic Airbus ND directly into the canvas framework, so that it can be used with many Airbus aircrafts.
Most of the Airbus aircraft share the same ND (A320, A330-200, A330-300,...) and other Airbus aircrafts only have little differences in their ND. So it's a good thing to have a common generic Airbus ND that can be customized with very little effort.
Technically, the ND implementation is based on a new hash declared into navdisplay.style file (having 'Airbus' as key). I've tried to use the same MapStructure files used for Boeing when possible (it means that many MapStructure layer/symbols are shared between the Boeing and the Airbus ND). In some other cases i had to duplicate these files and create an Airbus version (ie. WPT-airbus.symbol) because of too different logics.
The shared symbols/controllers use callbacks, options and styles in order to provide different graphics and sometimes different behaviors for Airbus and Boeing ND.
I had to make some little change to MapStructure and canvas API that i will document here:
- Options are now passed to layers/symbols if they're declared directly inside every layer declared in the navdisplay.style hash.
- Same for style, it can be passed in the layer hash defined in navdisplay.style
- New Symbol methods
- getOption(optname, default = nil) -> gets an option or a default value if passed (default is nil)
- getStyle(optname, default = nil) -> gets a style property value or a default value if passed (default is nil). If the property valueis a func, the func is executed and its return value is used as the property value
- canvas.Group methods
- setColor(color, types = [Path, Text]) -> sets the specified color to all children of the group element (recursively) that match with the types specified by the second argument
- SVGSymbol now checks for an optional svg_path passed in the options hash and uses it if found. This allows to define different SVG files for the same .symbol file so that different ND implementation can share the same .symbol file with different graphics.
- Many .symbol/.lcontroller files now check for optional settings and styles and often use callbacks in order to perform different behaviors or use different graphics for different ND implementations. This is not standardized yet and i have put this checks and callbacks only in the files I needed. But we could think to make this a default behavior for all type of Symbols and Layers.
The work is not yet done, and the code still needs to be documented and cleaned-up.
If you want to try this implementation into your Airbus I can give you some hint on how to do it.
During the next days I will write a more comprehensive documentation for both the new API and the configuration needed to implement the ND on your Airbus aircraft.
You can find this implementation on the fg-canvas-hackers repo (the branch is named topics/airbus_nd):
https://gitorious.org/fg/canvas-hackers-fgdata/source/f58601124ea509e4465191ad084bd15d27da11e7: