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 7: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 10: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: 269
Joined: Fri May 19, 2017 8:17 pm
Location: Uruguay - SUMU
Callsign: CX-BEX
Version: next
OS: Ubuntu 18.04.4

Re: Plot2D and graph helpers

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

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

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

Re: Plot2D and graph helpers

Postby Hooray » Sun Feb 18, 2018 2: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: 12707
Joined: Tue Mar 25, 2008 9:40 am
Pronouns: THOU

Re: Plot2D and graph helpers

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

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

Re: Plot2D and graph helpers

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

Thorsten wrote in Tue Feb 20, 2018 7: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: 269
Joined: Fri May 19, 2017 8:17 pm
Location: Uruguay - SUMU
Callsign: CX-BEX
Version: next
OS: Ubuntu 18.04.4

Re: Plot2D and graph helpers

Postby Thorsten » Tue Feb 20, 2018 5: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: 12490
Joined: Mon Nov 02, 2009 9:33 am

Re: Plot2D and graph helpers

Postby Hooray » Tue Feb 20, 2018 6: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: 12707
Joined: Tue Mar 25, 2008 9:40 am
Pronouns: THOU

Re: Plot2D and graph helpers

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

Thorsten wrote in Tue Feb 20, 2018 5: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: 269
Joined: Fri May 19, 2017 8:17 pm
Location: Uruguay - SUMU
Callsign: CX-BEX
Version: next
OS: Ubuntu 18.04.4

Re: Plot2D and graph helpers

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

rleibner wrote in Tue Feb 20, 2018 7:17 pm:
Thorsten wrote in Tue Feb 20, 2018 5: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: 12707
Joined: Tue Mar 25, 2008 9:40 am
Pronouns: THOU

Re: Plot2D and graph helpers

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

Hooray wrote in Tue Feb 20, 2018 7: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: 269
Joined: Fri May 19, 2017 8:17 pm
Location: Uruguay - SUMU
Callsign: CX-BEX
Version: next
OS: Ubuntu 18.04.4

Re: Plot2D and graph helpers

Postby Hooray » Tue Feb 20, 2018 9: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: 12707
Joined: Tue Mar 25, 2008 9:40 am
Pronouns: THOU

Re: Plot2D and graph helpers

Postby rleibner » Tue Feb 20, 2018 9: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: 269
Joined: Fri May 19, 2017 8:17 pm
Location: Uruguay - SUMU
Callsign: CX-BEX
Version: next
OS: Ubuntu 18.04.4

Re: Plot2D and graph helpers

Postby Hooray » Tue Feb 20, 2018 9: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: 12707
Joined: Tue Mar 25, 2008 9:40 am
Pronouns: THOU

Re: Plot2D and graph helpers

Postby Thorsten » Wed Feb 21, 2018 7: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: 12490
Joined: Mon Nov 02, 2009 9:33 am

Re: Plot2D and graph helpers

Postby rleibner » Thu Mar 08, 2018 5: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: 269
Joined: Fri May 19, 2017 8:17 pm
Location: Uruguay - SUMU
Callsign: CX-BEX
Version: next
OS: Ubuntu 18.04.4

PreviousNext

Return to Canvas

Who is online

Users browsing this forum: No registered users and 2 guests