Board index FlightGear Development Canvas

any info about creating widgets for canvas instruments?

Canvas is FlightGear's new fully scriptable 2D drawing system that will allow you to easily create new instruments, HUDs and even GUI dialogs and custom GUI widgets, without having to write C++ code and without having to rebuild FlightGear.

any info about creating widgets for canvas instruments?

Postby www2 » Sat Jan 10, 2015 12:47 pm

Hi is there some info about creating widgets for canvas instruments like gauges?
www2
 
Posts: 261
Joined: Thu Apr 16, 2009 1:58 pm

Re: any info about creating widgets for canvas instruments?

Postby Hooray » Sat Jan 10, 2015 1:51 pm

could you be a little more specific ?
For instance, are you referring to modern instruments (MFDs) using GUI widgets (think Airbus A380/Boeing 787) or are you thinking in terms of of more conventional ("steam") gauges ?
Or is this about having gauges as GUI widgets ?

To answer in general, gauges will typically be SVG files (created via Inkscape) and animated via Nasal timers/listeners.
Depending on what you have in mind, we have a few howtos/tutorials on the wiki, including quite a few code snippets/examples in $FG_ROOT
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 11437
Joined: Tue Mar 25, 2008 8:40 am

Re: any info about creating widgets for canvas instruments?

Postby www2 » Sat Jan 10, 2015 2:40 pm

Hooray wrote in Sat Jan 10, 2015 1:51 pm:could you be a little more specific ?
For instance, are you referring to modern instruments (MFDs) using GUI widgets (think Airbus A380/Boeing 787) or are you thinking in terms of of more conventional ("steam") gauges ?
Or is this about having gauges as GUI widgets ?

He Hooray i work on a MFD style instruments for a series of Flight Deck solution for GA and small/medium size Business jets (1,2 engines).
Be site this i want to include support 3 and 4 engines aircraft in this project (this is not support/use in the real life instrument) for inclusion inside e.g. the Carreidas 160 (that i wand to use as a test platform in this project).
Hooray wrote in Sat Jan 10, 2015 1:51 pm:To answer in general, gauges will typically be SVG files (created via Inkscape) and animated via Nasal timers/listeners.
Depending on what you have in mind, we have a few howtos/tutorials on the wiki, including quite a few code snippets/examples in $FG_ROOT

That is basic my idea but my problem is more a where i find a basic template for the widgets.
www2
 
Posts: 261
Joined: Thu Apr 16, 2009 1:58 pm

Re: any info about creating widgets for canvas instruments?

Postby Hooray » Sat Jan 10, 2015 3:56 pm

Thank you for the additional background info.
The following is assuming that you're indeed looking for an integrated solution running within the FlightGear main loop using a combination of Nasal/Canvas:

For anything involving MFDs (glass cockpit/EFIS-type avionics), you'll usually want to use Inkscape SVG files that are animated using Nasal/Canvas.
For that, you should understand a few Nasal basics, especially object-oriented programming using Nasal (vectors, hashes, classes, objects, inheritance):

http://wiki.flightgear.org/Object_Orien ... with_Nasal
http://wiki.flightgear.org/Object_orien ... g_in_Nasal

Next, you need to understand how to load an Inkscape SVG file onto a Canvas, for prototyping purposes it make sense to use a GUI dialog during development (which can later on be trivially turned into an actual instrument) :
http://wiki.flightgear.org/Canvas_Snipp ... GUI_Window

To learn more about adding raster images (e.g. as background), see: http://wiki.flightgear.org/Canvas_Snipp ... ter_Images
http://wiki.flightgear.org/Howto:Using_ ... d_canvases

To see how Inkscape SVG files can be loaded, please refer to the examples/tutorial at: http://wiki.flightgear.org/Howto:Use_SV ... e_a_Canvas

Next, there's also the possibility to reuse FlightGear's existing gauges and render/animate those using Canvas: http://wiki.flightgear.org/Howto:Parsin ... the_Canvas
Image

The reference for Canvas/Image handling (raster images) can be found at: http://wiki.flightgear.org/Canvas_Image

Assuming that you're more interested in modern MFD avionics, the approach taken by the GPSMap196 would seem useful: http://wiki.flightgear.org/Garmin_GPSMap_196
Image
Image

Those screen shots are using wikimedia common SVG files.

For additional examples, you can refer to Gijs' PFD work (747-400).

If you're just getting started, you may also want to check out the advice on creating a simple Nasal framework: http://wiki.flightgear.org/Howto:Coding ... _Framework

For the time being, the most generic Canvas-based approach involving SVG instrument's is Torsten's RBAR EFIS: Subject: Mirage 2000-5
Hooray wrote:Any Nasal/Canvas code that is highly specific to a single aircraft/instrument or use-case or that only supports a single instance of a display/instrument, will sooner or later turn out to be a huge maintenance challenge unfortunately, no matter how sophisticated the code involved might be. Unfortunately, our ND/MapStructure code isn't necessarily as structured as some of the more recent examples, especially the Avidyne Entegra R9 code is freaking awesome in comparison, but not yet sufficiently generic to be useful outside the scope of the extra500/Avidyne R9 - equally, Torsten's RBAR EFIS is basically the most elegant, and most correct, approach towards implementing a Canvas/Nasal based animation framework, but isn't yet sufficiently unified and generalized to be usable elsewhere.

The other thing is that the ND/MapStructure code gets away without using any conventional design patterns - which makes it fairly accessible to less-experienced contributors, especially those new to coding in general - in fact, all those layers and SVG elements are animated using a declarative hash syntax, so there's very little explicit coding involved - at the cost of making things pretty verbose, and not as elegant obviously ... :)


Subject: FGWebPanel aka FGPanel 2.0 or: FGPanel goes html
Hooray wrote:Regarding the animation logic that you have created for the RBAR EFIS, it would be great to see that moved to a standalone Nasal module so that it can be reused by other aircraft/instruments, without being aircraft specific - your code is much more generic than any existing Nasal/Canvas code we currently have for doing this, and it could help generalize and unify other Canvas-based MFDs.


Subject: Boeing 707 VIP
Hooray wrote:I don't quite recall if that's even using Canvas or if it's sufficiently generic, I do remember that the 744 (by Gijs) does feature a Canvas-based PFD but last I checked, it was not yet sufficiently restructured to be easily integrated on other aircraft. You may want to get in touch with Hyde to learn more about the PFD used there. Overall, it would make sense to generalize Gijs' code - but Torsten's recent RBAR/PFD code is much more generic, but not yet aircraft-agnostic either ...


The Canvas/ND framework is using a simple hash-based syntax for animating SVG elements using Nasal callbacks: http://wiki.flightgear.org/Canvas_ND_Fr ... w_features
Code: Select all
{
 id:'planArcs',
 impl: {
  init: func(nd,symbol) {},
  predicate: func(nd) { nd.in_mode('toggle_display_mode', ['PLAN']) },
  is_true: func(nd) { nd.symbols.planArcs.show() },
  is_false: func(nd) { nd.symbols.planArcs.hide() },
 },
},


These are SVG elements taken from an actual SVG file that are animated using a combination of timers/listeners.
it's a fairly simple but flexible system, that doesn't require any significant coding background.



We're hoping to come up with a simple animation framework encapsulating all animation specific logic: http://wiki.flightgear.org/Canvas_Animation_Framework
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 11437
Joined: Tue Mar 25, 2008 8:40 am


Return to Canvas

Who is online

Users browsing this forum: No registered users and 2 guests