Board index FlightGear Development Canvas

How to display Airport Chart?

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: How to display Airport Chart?

Postby Philosopher » Sun Dec 08, 2013 7:18 pm

Great! Excellent!

Also thanks for looking into the positioned object to Nasal ghost matter; that the same have equal pointers is useful to know :).
I'm sure Hooray would add add you as a contributor so you can push the changes to our dev branch if you want. (It's currently his FGData/topics/canvas-mapstructure.)
Thanks,
Philosopher
(inactive but lurking occasionally...)
Philosopher
 
Posts: 1590
Joined: Sun Aug 12, 2012 6:29 pm
Location: Stuck in my head...
Callsign: AFTI
Version: Git
OS: Mac OS X 10.7.5

Re: How to display Airport Chart?

Postby Hooray » Sun Dec 08, 2013 7:29 pm

sure, that's not a problem, but it would probably be better if we stopped juggling around with so many different branches, it's been confusing enough with Gijs' and Hyde's work as is :-)
MapStructure.nas shouldn't be heavily affected by this, it should be just 2-3 lines IIRC - and the prototype in geo.nas can then probably go away, P. ?

And yes Tom:, thank you VERY much for implementing this (and kudos, very dense code!).

@P.: if we now get the canvas/caching scheme working in time, most reported "performance" issues should be resolved because of the way MapStructure is "structured" :lol:

But if you want me to help with porting existing "layers", you should either carefully comment the code and document what's going in your .scontroller/lcontroller framework, or turn the design into a simple OOP class/interface that even people without any Nasal metaprogramming skills can understand ;-)
At the moment, I am getting segfaults when adding my own trivial (and valid!) code inside the Nasal/VM, which are basically impossible to troubleshoot currently, because of all the indirection via compile(), call() and bind() going on there
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: How to display Airport Chart?

Postby Philosopher » Sun Dec 08, 2013 7:38 pm

Actually, Tom, nevermind, I forgot that mapstrucutre got merged into master, so we can take your changes back from the master repo :D.
Thanks,
Philosopher
(inactive but lurking occasionally...)
Philosopher
 
Posts: 1590
Joined: Sun Aug 12, 2012 6:29 pm
Location: Stuck in my head...
Callsign: AFTI
Version: Git
OS: Mac OS X 10.7.5

Re: How to display Airport Chart?

Postby Hooray » Sun Dec 08, 2013 8:12 pm

It's indeed very fast, the only thing I noticed is that the first NavDB query seems to be much slower in comparison, possibly because of some initialization going on ? Maybe we should call some positioned API during start, to ensure that everything is up & running, and fast ? Subsequent calls seem to be much faster, arguably because certain data is already in cached by then.

EDIT: I just checked it, it really seems to be initialization overhead, because when I go to a completely different airport/country, subsequent calls are still much faster than the very first positioned query, maybe Zakalawe knows what's going on there.

I saw the removeAllChildren() commit: that's now automatically used, right ? Just wondering, because it may still take a while until we can use MapStructure to only remove what's needed ...

BTW, there's now a minor segfault during shutdown:
Code: Select all
(gdb) bt
#0  0x0000000000b78480 in FGRenderer::removeCamera(osg::Camera*) ()
#1  0x0000000000e8f048 in simgear::canvas::ODGauge::~ODGauge() ()
#2  0x00000000007a1282 in GroundRadar::~GroundRadar() ()
#3  0x0000000001088e76 in SGSubsystemGroup::Member::~Member() ()
#4  0x000000000108a1d0 in SGSubsystemGroup::~SGSubsystemGroup() ()
#5  0x000000000078cd30 in flightgear::CockpitDisplayManager::~CockpitDisplayManager() ()
#6  0x0000000001088e76 in SGSubsystemGroup::Member::~Member() ()
#7  0x000000000108a080 in SGSubsystemGroup::~SGSubsystemGroup() ()
#8  0x000000000108aba3 in SGSubsystemMgr::~SGSubsystemMgr() ()
#9  0x00000000006bc7cc in FGGlobals::~FGGlobals() ()
#10 0x00000000006c7a88 in fgMainInit(int, char**) ()
#11 0x000000000069c9fa in main ()


It seems related to Zakalawe's last ODGauge commit ?
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: How to display Airport Chart?

Postby Hooray » Mon Dec 16, 2013 10:24 am

Hooray wrote in Sat Nov 09, 2013 2:08 am:
zakalawe wrote in Sat Nov 09, 2013 1:51 am:Looking good, can you get this working so we can replace the map-widget for 3.0?


We need to check what's missing, or rather, what would be useful to replace the map widget completely/properly. For example, as far as I know, we don't currently have any hooks into the replay/flight recorder subsystem, which is however what's used to show flight path history,right ? So the poor-man's approach would be using a timer and sampling the position separately, but having access to the replay/recorder system would be great for many other reasons, so exposing it via cppbind would be awesome.


well, it probably took longer to discuss this than implement it - this turned out to be just 5 lines of Nasal code (even though we may want to use a better name for the API and maybe use cppbind for argument validation):
Code: Select all
--- a/src/Scripting/NasalSys.cxx
+++ b/src/Scripting/NasalSys.cxx
@@ -43,6 +43,8 @@
 #include "NasalHTTP.hxx"
 #include "NasalString.hxx"
 
+#include <Aircraft/FlightHistory.hxx> // for Nasal-space Map dialogs (Canvas)
+
 #include <Main/globals.hxx>
 #include <Main/util.hxx>
 #include <Main/fg_props.hxx>
@@ -701,6 +703,23 @@ static naRef f_systime(naContext c, naRef me, int argc, naRef* args)
 #endif
 }
 
+static naRef f_history(naContext c, naRef me, int argc, naRef* args) {
+nasal::CallContext ctx(c, argc, args);
+if(!argc || argc !=1 || !naIsNum(args[0]) )
+ naRuntimeError(c, "history() wrong argument type or count (expcecting double: edgeLengthM)");
+
+SGGeodVec samples;
+ try {
+ samples = static_cast<FGFlightHistory*> (globals->get_subsystem("history"))->pathForHistory( args[0].num );
+ }
+ catch(...) {
+  SG_LOG(SG_NASAL, SG_ALERT, "Could not access FGFlightHistory subsystem!"<<std::endl);
+  return naNil();
+ }
+
+return ctx.to_nasal(samples);
+}
+
 // Table of extension functions.  Terminate with zeros.
 static struct { const char* name; naCFunction func; } funcs[] = {
     { "getprop",   f_getprop },
@@ -724,6 +743,7 @@ static struct { const char* name; naCFunction func; } funcs[] = {
     { "finddata", f_findDataDir },
     { "parsexml", f_parsexml },
     { "systime", f_systime },
+    { "history", f_history },
     { 0, 0 }
 };

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: How to display Airport Chart?

Postby Philosopher » Sat Jan 18, 2014 11:15 pm

Hey, since you're taking time to post C++ code, I would like to point out that this works as well, if not better ;):

Code: Select all
static naRef f_history(nasal::CallContext ctx) {...}


But that looks great, I'll see what we can do with it!
Thanks,
Philosopher
(inactive but lurking occasionally...)
Philosopher
 
Posts: 1590
Joined: Sun Aug 12, 2012 6:29 pm
Location: Stuck in my head...
Callsign: AFTI
Version: Git
OS: Mac OS X 10.7.5

Re: How to display Airport Chart?

Postby Hooray » Sun Jan 19, 2014 7:51 am

right, that would work too - I the code originally was a "standard" (legacy) Nasal extension function - but when I had to return SGGeod() objects, I ended up using Tom's cppbind helper instead to save some typing - so that's why the code is a bit inconsistent here.

Technically, there should be no difference here - because it's just a simple extension function, so not sure why it would work "better" - internally, it will do the same thing. The code just didn't use cppbind originally.
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

Previous

Return to Canvas

Who is online

Users browsing this forum: No registered users and 6 guests