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 rominet » Thu Feb 08, 2018 6:15 pm

Also:
Code: Select all
% svn log -l 20 --diff Oscilloscope/graph.nas

[...]

Index: Oscilloscope/graph.nas
===================================================================
--- Oscilloscope/graph.nas      (revision 3192)
+++ Oscilloscope/graph.nas      (revision 3193)
@@ -33,8 +33,8 @@
  return d;
 },
 
-setPlotProperty: func(timeDivs, valueDivs, timePerDiv, propNode='', color="#0"){
- var plot = plotProperty.new(me.group,me.view,propNode,timeDivs,valueDivs,timePerDiv,color);
+setPlotProperty: func(timeDivs, valueDivs, timePerDiv, source='', color="#0", resolution=5){
+ var plot = plotProperty.new(me.group,me.view,source,timeDivs,valueDivs,timePerDiv,color,resolution);
 },

[...]

-> There used to be a propNode argument for setPlotProperty() before revision 3193. This suggests that clm76 isn't using the latest version of the add-on (maybe several ones have been downloaded and an old one is being loaded...).
rominet
 
Posts: 605
Joined: Sat Nov 01, 2014 2:33 pm
Callsign: F-KATS
Version: Git next
OS: Debian GNU/Linux

Re: Plot2D and graph helpers

Postby clm76 » Thu Feb 08, 2018 6:55 pm

@ rleibner
I’ve the same code as you, except for main.nas which is :
Code: Select all
 if (!canvas['graph'])  io.load_nasal( root ~ '/graph.nas', "canvas" );

But if i change by your code, it’s the same error.

@ rominet
I’ve only one version in fgaddon, the latest from svn with "oscilloscope.nas" and "graph.nas " corrected by the tar.gz of rleibner.

I updated my fg 2017.4.0 version this afternoon but the error is the same.
However, there is something strange : With the CitationX (the plane I’m developping with many canvas functions), I get the error :
Code: Select all
Nasal runtime error: Missing arg: propNode
  at /home/chris/.fgfs/fgaddon/Oscilloscope/oscilloscope.nas, line 18
  called from: /input/keyboard/key[111]/binding, line 1

while with other planes this error occurs :
Code: Select all
Nasal runtime error: non-objects have no members
  at /home/chris/.fgfs/fgaddon/Oscilloscope/oscilloscope.nas, line 47
  called from: /home/chris/.fgfs/fgaddon/Oscilloscope/oscilloscope.nas, line 24
  called from: /input/keyboard/key[111]/binding, line 1


[EDIT] Problem found :)
I had integrated the "spoken GCA" as a module in the CitationX, so there is a conflict between the "graph.nas" of the oscilloscope and the one of spoken GCA : the functions have the same name but are different. Without "spoken GCA", the oscilloscope runs correctly.
So, I think it should be better to give different names at the functions, between "Oscilloscope" and "Spoken GCA". What do you think ?
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 » Sat Feb 10, 2018 1:23 pm

Thanks for troubleshooting this and for reporting back here - I believe it would be best if the generic helpers could be committed to fgdata, with the addons getting a copy of the latest file that is included on demand (which is what the line you quoted is doing)

In the meantime, it might make sense to explicitly add a version attribute to the corresponding files to make sure that the latest version is included or show a corresponding error
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 » Sat Feb 10, 2018 4:41 pm

Hooray wrote in Sat Feb 10, 2018 1:23 pm:I believe it would be best if the generic helpers could be committed to fgdata, with the addons getting a copy of the latest file that is included on demand

If I'm understanding,
* an unique version of each generic helper should be committed to fgdata. (to //sourceforge.net/p/flightgear/fgdata/ci/next/tree/Nasal/canvas/ ?)
* each addon must get a copy of those helpers. At its main() ? how ?

I mean, while the user has not yet the helpers under his fgdata/Nasal/canvas, can the main() func "force" a downloading ?
Please confirm, cause I'm a bit confused here.
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 » Sat Feb 10, 2018 4:56 pm

the generic helper files (graph.nas) would be committed to $FG_ROOT/Nasal/canvas, and loaded into the global canvas namespace
Your existing code will check if the corresponding module is loaded or not (older fg versions), and if it isn't, load the local copy from the addon directory.
Once a new release is out, you can safely remove the local copies from your addons and simply raise the required fg version number to enforce that the oscillscope addon requires FG version >= 2018.2

That way, your addons are backwards compatible - i.e. ensuring that an exact copy if the required helpers is part of the addon, and can be loaded on demand.
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 clm76 » Sat Feb 10, 2018 7:38 pm

Hi,

The oscilloscope is a very nice tool to adjust parameters of an autopilot. Here, 2 oscilloscopes for the 2 stages of a Vertical altitude control.

Image

For information, a nasal error occurs every time we set a property to be checked, but without any visible consequence.
Nasal runtime error: non-objects have no members
at /home/chris/fg2017_4_1/install/flightgear/fgdata/Nasal/canvas/gui/Widget.nas, line 125
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 » Sat Feb 10, 2018 7:43 pm

It might be a good idea to either display the property paths in the UI or at least change the title of the oscilloscope window using a configurable name for the values/properties that are shown to make it easier for people to tell what is being displayed by a certain window without having to remember any setup details
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 » Sat Feb 10, 2018 9:10 pm

clm76 wrote in Sat Feb 10, 2018 7:38 pm:For information, a nasal error occurs every time we set a property to be checked, but without any visible consequence.
Yes, I saw that. It has no consequences, but is not nice. I think it's because I'm calling canvas.InputDialog.getText() without previously instancing canvas.InputDialog.new().
Hooray wrote in Sat Feb 10, 2018 7:43 pm:It might be a good idea to either display the property paths in the UI ...
It's implemented yet: clicking the channel connector the InputDialog shows by default the property path being currently used.
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 » Sat Feb 10, 2018 9:22 pm

I think, this is how it's supposed to be used: http://wiki.flightgear.org/Canvas_Snipp ... put_Dialog
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 » Sat Feb 10, 2018 9:29 pm

It's what i did.
From oscilloscope.nas:
Code: Select all
...
   var defTxt = typeof(plot.source)=='func'? '(function)' : plot.source;
   var instruc = "Enter a valid propNode address or a nasal expression:";
   canvas.InputDialog.getText(sprintf('Channel %i source',parms),
   instruc, func(btn,value) {
   if(btn==1) call(me.setChannelInput,[parms,value],me);
   }, defTxt);
...
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 » Sat Feb 10, 2018 10:12 pm

the following is probably unrelated, but like I said previously elsewhere - to pass a method around like this, the me part has to be wrapped in a closure, or simply use the underlying class/hash directly: call(class.method, [arguments], me);
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 rominet » Sat Feb 10, 2018 10:33 pm

Hi,

I made a little change[1][2][3] to the add-on API. The add-on framework now works with addon-config.xml instead of config.xml and addon-main.nas instead of main.nas. I already applied the renaming to all add-ons in FGAddon, so all you have to do is to update your FlightGear, FGData repositories and FGAddon add-ons at the same time (quite possibly also SimGear, but for unrelated reasons) and work with the new names.

Sorry for the inconvenience.

[1] announcement on flightgear-devel
[2] FlightGear commit da961b97f
[3] FGData commit c17d9377f
rominet
 
Posts: 605
Joined: Sat Nov 01, 2014 2:33 pm
Callsign: F-KATS
Version: Git next
OS: Debian GNU/Linux

Re: Plot2D and graph helpers

Postby Hooray » 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
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 » Sat Feb 10, 2018 10:38 pm

Was not that.
I've tried with:
Code: Select all
...
   call(canvas.InputDialog.getText,[sprintf('Channel %i source',parms),
   instruc, func(btn,value) {
   if(btn==1) call(me.setChannelInput,[parms,value],me);
   }, defTxt],me);
and still got
Code: Select all
Nasal runtime error: non-objects have no members
  at /home/rodolfo/fgfs/next/install/flightgear/fgdata/Nasal/canvas/gui/Widget.nas, line 125
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 » Sat Feb 10, 2018 10:42 pm

Like I said, I expect this to be unrelated - but I also specifically referred to your way of calling setChannelInput without referencing the underlying class/hash
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

PreviousNext

Return to Canvas

Who is online

Users browsing this forum: No registered users and 2 guests