Board index FlightGear Development Canvas

Plot2D and graph helpers

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.

Re: Plot2D and graph helpers

Postby rleibner » Tue Feb 13, 2018 6:19 pm

I've removed graph.nas from SpokenGCA (it's not used there) and unified the plot2D versions.
@clm76: You can now load both (SpokenGCA and Oscilloscope addons) without collision.

Hooray wrote in Sat Feb 10, 2018 9:36 pm:the "load foo.nas into namespace if namespace == nil" heuristics could actually be moved right into the addon framework to handle backward compatibility in a sane fashion
Do you mean to remove those lines from the addon-main and include them into the scripts that need them?
OK, if it's better.
Rodolfo
*************************
Non-shared knowledge is lost knowledge
User avatar
rleibner
 
Posts: 246
Joined: Fri May 19, 2017 7:17 pm
Location: Uruguay - SUMU
Callsign: CX-BEX
Version: 2180.4.0
OS: Ubuntu 18.04

Re: Plot2D and graph helpers

Postby clm76 » Sun Feb 18, 2018 10:45 am

@clm76: You can now load both (SpokenGCA and Oscilloscope addons) without collision.

Yesss !... It's ok now. Thanks. :)
clm76
 
Posts: 149
Joined: Tue Oct 30, 2012 8:18 pm
Location: France - LFOH
Callsign: F-GCLM
Version: 2018.3.0
OS: Linux Mint 18.3

Re: Plot2D and graph helpers

Postby Hooray » Sun Feb 18, 2018 1:59 pm

my suggestion would be to ask one of the fgdata committers familiar with Nasal/Canvas to add your generic modules to $FG_ROOT/Nasal/canvas and load them into a separate sub-namespace there.

That way, your addons can simply raise the required flightgear version number after the next release cycle, and stop shipping their own copy of the file - which means less work for you, because you don't have to keep two separate files in sync.
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: 11329
Joined: Tue Mar 25, 2008 8:40 am

Re: Plot2D and graph helpers

Postby Thorsten » Tue Feb 20, 2018 6:56 am

I'm happy to do a review/commit - this seems very useful work. Let me know.
Thorsten
 
Posts: 10939
Joined: Mon Nov 02, 2009 8:33 am

Re: Plot2D and graph helpers

Postby rleibner » Tue Feb 20, 2018 1:15 pm

Thorsten wrote in Tue Feb 20, 2018 6:56 am:I'm happy to do a review/commit - this seems very useful work. Let me know.

Thanks, Thorsten.
I'm working on a new PA_Radar addon, and having those helpers under $FG_ROOT/Nasal/canvas will make things much easier and safer.
Rodolfo
*************************
Non-shared knowledge is lost knowledge
User avatar
rleibner
 
Posts: 246
Joined: Fri May 19, 2017 7:17 pm
Location: Uruguay - SUMU
Callsign: CX-BEX
Version: 2180.4.0
OS: Ubuntu 18.04

Re: Plot2D and graph helpers

Postby Thorsten » Tue Feb 20, 2018 4:00 pm

Okay, could you assemble a package with the files you want there for me? Or give me download links? I might take a few days to look over the code myself, but you should be good to go before your addon is ready.
Thorsten
 
Posts: 10939
Joined: Mon Nov 02, 2009 8:33 am

Re: Plot2D and graph helpers

Postby Hooray » Tue Feb 20, 2018 5:32 pm

my suggestion would be to load the corresponding helpers into a suitable sub-namespace under "canvas", i.e. according to the purpose (e.g. "canvas.plot2D" or "canvas.plotting")
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: 11329
Joined: Tue Mar 25, 2008 8:40 am

Re: Plot2D and graph helpers

Postby rleibner » Tue Feb 20, 2018 6:17 pm

Thorsten wrote in Tue Feb 20, 2018 4:00 pm:Okay, could you assemble a package with the files you want there for me? Or give me download links? I might take a few days to look over the code myself, but you should be good to go before your addon is ready.

These are the latest versions: canvas_helpers
Rodolfo
*************************
Non-shared knowledge is lost knowledge
User avatar
rleibner
 
Posts: 246
Joined: Fri May 19, 2017 7:17 pm
Location: Uruguay - SUMU
Callsign: CX-BEX
Version: 2180.4.0
OS: Ubuntu 18.04

Re: Plot2D and graph helpers

Postby Hooray » Tue Feb 20, 2018 6:42 pm

rleibner wrote in Tue Feb 20, 2018 6:17 pm:
Thorsten wrote in Tue Feb 20, 2018 4:00 pm:Okay, could you assemble a package with the files you want there for me? Or give me download links? I might take a few days to look over the code myself, but you should be good to go before your addon is ready.

These are the latest versions: canvas_helpers



note that, once your helpers are added to $FG_ROOT/Nasal/Canvas, you can also add a simple Canvas wrapper to directly expose your helpers as a widget - e.g. a dedicated "Plot2D widget" - that would make it much easier for people to use your existing work, and add multiple widgets to a single dialog.

This would also mean that your widget's API would be in line with existing widgets (e.g. buttons, checkboxes).

See $FG_ROOT/Nasal/canvas/gui/widgets
and especially Widget.nas

Background at: http://wiki.flightgear.org/Howto:Creati ... GUI_Widget
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: 11329
Joined: Tue Mar 25, 2008 8:40 am

Re: Plot2D and graph helpers

Postby rleibner » Tue Feb 20, 2018 7:33 pm

Hooray wrote in Tue Feb 20, 2018 6:42 pm:note that, once your helpers are added to $FG_ROOT/Nasal/Canvas, you can also add a simple Canvas wrapper to directly expose your helpers as a widget - e.g. a dedicated "Plot2D widget" - that would make it much easier for people to use your existing work, and add multiple widgets to a single dialog.
Yes, Hooray, and this risks to be an endless way:
Canvas-API called by Plot2D called by graph called by Animated_button called by Skinnable called by Graphic_dialog . . . :lol: :lol:
Rodolfo
*************************
Non-shared knowledge is lost knowledge
User avatar
rleibner
 
Posts: 246
Joined: Fri May 19, 2017 7:17 pm
Location: Uruguay - SUMU
Callsign: CX-BEX
Version: 2180.4.0
OS: Ubuntu 18.04

Re: Plot2D and graph helpers

Postby Hooray » Tue Feb 20, 2018 8:03 pm

no, that is what Widgets are for - to support event-handling so that you can have an arbitrary number of widgets per dialog that work properly with layouting/styling primitives.
If you have ever used any of the existing widgets (buttons, checkboxes, line input), you probably already understand that this is basically the same code that you have already - it's just using a wrapper library to provide the interfacing mechanism (methods), so that layouts and styling work correctly.

See:

https://sourceforge.net/p/flightgear/fg ... Button.nas
https://sourceforge.net/p/flightgear/fg ... tStyle.nas

In other words, your current code would remain "as is" (unchanged) - it would just be used by a new class inheriting from Canvas.gui.Widget to provide the helper methods that dispatch the events to your helper routines to redraw/re-style the 2D graph
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: 11329
Joined: Tue Mar 25, 2008 8:40 am

Re: Plot2D and graph helpers

Postby rleibner » Tue Feb 20, 2018 8:21 pm

I see now ... Definitively I must study that.
But first I want to finish the PA_Radar addon. According my plan, the remaining tasks are:
    * To implement routines for the 'Flip' and 'Set' buttons.
    * To solve the uncharged-tiles issue.
Rodolfo
*************************
Non-shared knowledge is lost knowledge
User avatar
rleibner
 
Posts: 246
Joined: Fri May 19, 2017 7:17 pm
Location: Uruguay - SUMU
Callsign: CX-BEX
Version: 2180.4.0
OS: Ubuntu 18.04

Re: Plot2D and graph helpers

Postby Hooray » Tue Feb 20, 2018 8:33 pm

Yes sure, I just wanted to make you aware of the existing widget API and the benefits of using it - i.e. how existing widgets work via "events" and "actions" - but under the hood, it's the same kind of code that you have already written, there's just a wrapper class that sends triggers certain events/actions

Like I said before, it really only makes sense exploring this, once your code is part of fgdata - there's no point in adding widgets to the standard canvas library that depends on code that is part of some "addon".

Once your code is integrated with the widget API, people could easily instantiate graph objects using the the standard Widget.nas interface: https://sourceforge.net/p/flightgear/fg ... Widget.nas
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: 11329
Joined: Tue Mar 25, 2008 8:40 am

Re: Plot2D and graph helpers

Postby Thorsten » Wed Feb 21, 2018 6:35 pm

Quick update - I got the package, but I expect to be tied up with finding out why the Qt launcher in the release candidate keeps crashing on me and why its format looks off when it doesn't for the next few days...
Thorsten
 
Posts: 10939
Joined: Mon Nov 02, 2009 8:33 am

Re: Plot2D and graph helpers

Postby rleibner » Thu Mar 08, 2018 4:13 pm

@Thorsten,
I've improved the skinnable's code to make it more general and manage the events.
The new code is here and is documentated in the wiki.

Regards
Rodolfo
*************************
Non-shared knowledge is lost knowledge
User avatar
rleibner
 
Posts: 246
Joined: Fri May 19, 2017 7:17 pm
Location: Uruguay - SUMU
Callsign: CX-BEX
Version: 2180.4.0
OS: Ubuntu 18.04

PreviousNext

Return to Canvas

Who is online

Users browsing this forum: No registered users and 1 guest