Board index FlightGear Development Canvas

Canvas placement / re-moving

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.

Canvas placement / re-moving

Postby jsb » Sat Dec 10, 2016 12:58 am

I am learning / playing around with canvas and I wonder what exactly a canvas addPlacement(...) does to the 3D model object.
    Obviously one can prepare a canvas texture and assign it to a 3D element by using addPlacement(...) - will show the texture on that element
    The same canvas can be added to different 3D element by calling addPlacement again with the name of that other 3D element - again, texture appears
However, after creating a second canvas I tried to addPlacement (same 3D element) but I could not replace the first canvas already assigned to that 3D element - no texture change visible. Why is this?
Can I "un-place" (e.g. remove) a canvas from a 3D element?
Maybe that is needed before I can place a different canvas to it - I guess it make no sense to assign more than one texture to a single 3D element at the same time?

Now, why do I ask this: After lerning the canvas basics I will want to implement the display control logic of the Collins Proline 4 EFIS used in the CRJ700 and this is mainly about swapping screens in case of one display unit fails (e.g. left display unit on pilot side fails so pilot want to display the PFD instead of MFD on the right display unit).

My first idea was to simply re-assign the PFD canvas to the 3D element of the right display. But in my first experiments the MFD canvas won't go away.
My second best (incomplete) idea would be: assign a canvas per display unit only once; swap displays by saving the root-groups of both canvas to nasal variables, delete all elements from canvas; re-add elements to other canvas L->R and R->L. But that seems to be much more work
jsb
 
Posts: 221
Joined: Sat Oct 25, 2014 8:17 pm
Location: Hamburg, Germany
Callsign: D-JSB
Version: next
OS: Win7/Linux

Re: Canvas placement / re-moving

Postby Thorsten » Sat Dec 10, 2016 7:32 am

I guess I really like Richard's MFD framework (which also underlies the Shuttle avionics, which is by some margin the most involved use case in FG).

* a canvas is assigned to each screen
* that canvas gets assigned all pages the screen can potentially display
* setVisible on the group is used to select the one which is shown right now, all others are set to not visible


If you really want to remove rather than show/hide, there's still no need to remove a canvas and assign a different one, because you can do this with all the groups the canvas contains (and all elements) - and your display will be one or more groups.
Thorsten
 
Posts: 11310
Joined: Mon Nov 02, 2009 8:33 am

Re: Canvas placement / re-moving

Postby jsb » Sat Dec 10, 2016 8:28 am

Thanks for that info, I will look into the framework how it handle things to learn more.

Digging around in the prop-browser I found
/canvas/by-index/texture(a)/playcement(i)/node
Changing the value of Node removes texture 'a' from the 3D element and possibly let appear a texture 'b' if it has a placement on that element.
jsb
 
Posts: 221
Joined: Sat Oct 25, 2014 8:17 pm
Location: Hamburg, Germany
Callsign: D-JSB
Version: next
OS: Win7/Linux

Re: Canvas placement / re-moving

Postby Hooray » Sat Dec 10, 2016 5:09 pm

Thorsten is right - however, note that the MFD framework does not really work in terms off screens and image generators (IGs) - we once covered that, but it's not much of an issue, because you can assign an arbitrary Canvas to a Canvas and treat it as a raster image.

Useful search terms for the forum might be "Canvas MFD Screens": search.php?st=0&sk=t&sd=d&sr=posts&keywords=canvas+MFD+screens
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: 11427
Joined: Tue Mar 25, 2008 8:40 am


Return to Canvas

Who is online

Users browsing this forum: No registered users and 1 guest