Board index FlightGear Development Canvas

Auto protractor?

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.

Auto protractor?

Postby tridecagon » Sun Mar 23, 2014 10:37 pm

When I first got into flight simulators, I was annoyed by the lack of tools when planning a rout. For example, if I wanted to fly from my home airport, KLOZ, directly to KLEX, I basically had to guestimate the heading. Sometimes it was easy: from the LOZ VOR to KSME was directly west. But if I wanted to go from some random airport to another, I would look at the planned leg and imagine a compass around it. I was usually off by around five degrees. Over long distances, this could put the target airport well out of drawing range.

So I would like to request a feature that does the math for me. Basically, you place two dots on the map. Then a line connects these two dots. Somewhere near this line, you will see the headings between the two dots. For example, let's say your line is directly north-south. Beside the formed line, you get:
00.0 (N) / 180.0 (S)


If you do east-west:
90.0 (E) / 270.0 (W)
tridecagon
 
Posts: 10
Joined: Sun Mar 23, 2014 3:47 am
Location: London, KY
Version: 3.0.0
OS: Windows 7 64-Bit

Re: Auto protractor?

Postby Kabuki » Sun Mar 23, 2014 11:26 pm

A protractor and ruler on a map would indeed be nice. I use Google Earth a lot, and the 'ruler', which also gives heading, is handy at times.
This is a family-friendly saloon. No talk stink.
Kabuki
 
Posts: 587
Joined: Fri Oct 23, 2009 11:21 pm
Location: Usually on the ground, always in the sky, except when underwater.
Callsign: Kabuki
Version: 3.0.0
OS: Windows 7

Re: Auto protractor?

Postby sanhozay » Mon Mar 24, 2014 4:52 am

Doesn't skyvector.com do what you need?

For example:

http://skyvector.com/?ll=37.61684218015 ... :A.K5.KLEX
sanhozay
 
Posts: 1207
Joined: Thu Dec 26, 2013 11:57 am
Location: EGNM
Callsign: G-SHOZ
Version: Git
OS: Ubuntu 16.04

Re: Auto protractor?

Postby Hooray » Mon Mar 24, 2014 6:56 am

Hi & welcome!

That should be possible to do without touching any C++ code, and without rebuilding the binary.
You really just need to use Nasal/Canvas for this, and could make it a part of MapStructure:

http://wiki.flightgear.org/MapStructure
Image

Image

These images are created and animated entirely from scripting space (Nasal). You can simply load SVG or raster images and place them on the map, and animate/scale/transform them, and even respond to events (mouse clicks etc)
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: 11312
Joined: Tue Mar 25, 2008 8:40 am

Re: Auto protractor?

Postby tridecagon » Mon Mar 24, 2014 12:15 pm

sanhozay wrote in Mon Mar 24, 2014 4:52 am:Doesn't skyvector.com do what you need?

For example:

http://skyvector.com/?ll=37.61684218015 ... :A.K5.KLEX


That... I never heard of that. It looks as to be very helpful. But what if, let's say, you see a landmark you want to share. Let's say it's a terrain bug in the middle of the ocean. Then what?

Hooray wrote in Mon Mar 24, 2014 6:56 am:Hi & welcome!

That should be possible to do without touching any C++ code, and without rebuilding the binary.
You really just need to use Nasal/Canvas for this, and could make it a part of MapStructure:

http://wiki.flightgear.org/MapStructure
<snip>

These images are created and animated entirely from scripting space (Nasal). You can simply load SVG or raster images and place them on the map, and animate/scale/transform them, and even respond to events (mouse clicks etc)

I would love to get into Nasal and all that. But I don't even know where to begin.
I can make all your dreams come true... if your dreams involve a stranger entering your home and breaking things.
tridecagon
 
Posts: 10
Joined: Sun Mar 23, 2014 3:47 am
Location: London, KY
Version: 3.0.0
OS: Windows 7 64-Bit

Re: Auto protractor?

Postby Philosopher » Mon Mar 24, 2014 12:36 pm

Hi, here's a simple example that you can copy into the Nasal Console in FG (under the Debug menu), but it probably won't work quite yet - I need to fix it up first. But something like this:
Code: Select all
# Create/show a new dialog window
var dlg = canvas.Window.new([600,300], "test dialog", "default");
var cv = dlg.createCanvas();
var map = cv.createGroup().createChild("map")
    .setController("Aircraft position")
    .addLayer("VOR");
# A little hack to make sure _our_ resources get deleted when _it_ gets deleted
dlg.del = func {
    print("delete/destroy called!");
    # Add code here to close any loops, delete any listeners, and clean up any other resources
    map.del();
    delete(me, "del"); me.del(); # call the default delete
}


@Hooray: I'm a little concerned because we don't have a de-projection algorithm, but I suppose we could approximate it if needed... using bounding boxes :P. But point is, dragging points around might not work well.
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: Auto protractor?

Postby Hooray » Mon Mar 24, 2014 1:21 pm

I would love to get into Nasal and all that. But I don't even know where to begin.


https://en.wikipedia.org/wiki/File:Protractor.svg
http://commons.wikimedia.org/wiki/File:Protractor1.svg

==> http://wiki.flightgear.org/Howto:Use_SV ... e_a_Canvas

I would start with a simple Nasal/Canvas "hello world" example, such as a dialog where you load/place and animate/transform a vector/raster image.
There are several existing snippets and tutorials that could be adapted for this.
Once you have that working, the MapStructure article should be a good place - but it may be a bit too sophisticated if you haven't yet done any Nasal coding at all

Philosopher wrote in Mon Mar 24, 2014 12:36 pm:@Hooray: I'm a little concerned because we don't have a de-projection algorithm, but I suppose we could approximate it if needed... using bounding boxes :P. But point is, dragging points around might not work well.

There's a discussion in the tracker where Gijs mentioned that he's working on additional projections, and Zakalawe (or TheTom?) said that "de-projection" is currently hard-coded for mouse interaction (panning IIRC), so could just as well be exposed to Nasal, too. I don't think there's any "hard" problems. The code is already there, so exposing it is probably less than 20 lines of cppbind/C++ code.
And I think you could even work around this limitation in Nasal space, because we already know the 2D coordinates, the projections and the lat/lon mapping accordingly.
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: 11312
Joined: Tue Mar 25, 2008 8:40 am

Re: Auto protractor?

Postby tridecagon » Fri Mar 28, 2014 8:47 pm

For the life of me, I can't figure it out. I took the "Hello World" code and pasted it into NASAL. I edited it to use the protractor SVG image, but I see zero change. I tried editing the first line and the last line.
Code: Select all
new: func(x=300,y=200,file="/gui/dialogs/images/ndb_symbol.svg") {

to:
Code: Select all
new: func(x=300,y=200,file="/gui/dialogs/images/Protractor.svg") {

Yes, I put Protractor.svg in /gui/dialogs/images. It did nothing.

Then I did:
Code: Select all
var preview= SVGMapPreview.new(x:400, y:400, svg:"Nasal/canvas/map/boeingND.svg");

to:
Code: Select all
var preview= SVGMapPreview.new(x:400, y:400, svg:"/gui/dialogs/images/Protractor.svg");

and the preview screen went all black (but I kind of expected it to).

I was successful, however, to change the background color to white and to make the image smaller. It may not be much of a step, but a step nonetheless.
I can make all your dreams come true... if your dreams involve a stranger entering your home and breaking things.
tridecagon
 
Posts: 10
Joined: Sun Mar 23, 2014 3:47 am
Location: London, KY
Version: 3.0.0
OS: Windows 7 64-Bit

Re: Auto protractor?

Postby Hooray » Sat May 10, 2014 11:07 am

is this something you're still working on ?
Sorry for not getting back to this earlier, I somehow missed your response - we're all kinda busy with other projects.
But if you need a little help please post what you've got (or even just the image), and I'll turn it into a little tutorial for the wiki so that you can work through it and extend it.
Keep in mind though that our SVG parser doesn't support all SVG elements, so watch out for any errors (and report them here).
Overall, this should be a fairly straightforward little project for someone interested in scripting.
If the image doesn't show up, it's probably some SVG incompatibility on our side - to see for yourself if that's the case, use photoshop or gimp to convert it into a raster image, and load it as a raster image: http://wiki.flightgear.org/Howto:Using_ ... d_canvases

We also have a few folks interested in adding an E6B to FG, so this may be a good project to get such useful tools integrated.
Scripting-wise this should require less than 100 lines of code, and most things are covered in a handful of tutorials.

I am currently looking into extending MapStructure to support "interactive layers" that respond to GUI events (zooming/panning, mouse clicks etc). Canvas already supports everything that's needed here, so it's just a matter of integrating things. A protractor tool could be a cool utility for MapStructure, and especially the new Map dialog, so I would be willing to help with this if you're still interested.

EDIT: Just checked it: the protractor file gets loaded without errors, but only parts of it show up because our svg.nas parser doesn't handle certain constructs at all (and no errors shown either), and the supported stuff is drawn black on black here - so turning it into a raster image would be a simple fix, the other option would be extending svg.nas to support 2-3 additional primitives. Even just mapping line properly should get us pretty far :D

https://gitorious.org/fg/fgdata/source/ ... g.nas#L158
https://gitorious.org/fg/fgdata/source/ ... i.nas#L628
Image
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: 11312
Joined: Tue Mar 25, 2008 8:40 am

Re: Auto protractor?

Postby Johan G » Sat May 10, 2014 9:43 pm

What shape of protractor would be interesting? Semicircular, triangular or the good old Weems plotter?

Note that any distance scales probably should be avoided though (due to zooming map with non-fixed scales etc.).

I could make something in Inkscape. :wink:

As for an E6B (proper) that is a lot, and I mean a lot of work, but can be done even to mil spec.

If you ask me Philip Van Horn Weems is one of the unsung heroes of aerial navigation.
Low-level flying — It's all fun and games till someone looses an engine. (Paraphrased from a YouTube video)
Improving the Dassault Mirage F1 (Wiki, Forum, GitLab. Work in slow progress)
Johan G
Moderator
 
Posts: 5405
Joined: Fri Aug 06, 2010 5:33 pm
Location: Sweden
Callsign: SE-JG
IRC name: Johan_G
Version: 3.0.0
OS: Windows 7, 32 bit

Re: Auto protractor?

Postby tridecagon » Fri May 23, 2014 2:36 am

Actually, I was going to use this one:
Image

I'm still interested, but I kind of just gave up. I became preoccupied with building missiles in KSP. And then I moved to space stations. And then when I remembered this topic, it was getting close to finals week. And now I'm just back and fourth between random stuff.
I can make all your dreams come true... if your dreams involve a stranger entering your home and breaking things.
tridecagon
 
Posts: 10
Joined: Sun Mar 23, 2014 3:47 am
Location: London, KY
Version: 3.0.0
OS: Windows 7 64-Bit

Re: Auto protractor?

Postby Hooray » Fri May 23, 2014 9:15 am

the first question is if our SVG parser can process the file as is, or if it needs to be extended.
But like I mentioned earlier, to get this started, it would be easier to convert this into a raster image (PNG) and simply take it from there.
There's really only 5-10 lines of code needed to animate such a raster image, see: viewtopic.php?f=6&t=22143&p=201272&hilit=#p201272

Once that works, it's about 20-30 lines to turn this into a MapStructure layer, so that it can be shown on the new map, and another ~20 lines to make it interactive, i.e. respond to GUI events
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: 11312
Joined: Tue Mar 25, 2008 8:40 am


Return to Canvas

Who is online

Users browsing this forum: No registered users and 1 guest