Board index FlightGear Development Canvas

Using Canvas to create a weather editor ? (split)

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.

Using Canvas to create a weather editor ? (split)

Postby Thorsten » Tue Sep 18, 2012 7:25 am

Could we use something like that in the farther future to edit the large-scale weather situation?

Say, we get a map displayed, and there are drag-and-drop symbols of low pressure areas, fronts,... to the right, we drag them to the map, edit pressure values and so on, and the weather engine then converts this into winds, cloud configs etc.

It'd be rather easy to modify the weather engine to do that, just the GUI scared me quite a bit, but this seems entirely capable of handling the problem.
Thorsten
 
Posts: 8656
Joined: Mon Nov 02, 2009 8:33 am

Re: Using a canvas map in the GUI

Postby Hooray » Tue Sep 18, 2012 8:10 am

Yes, technically that should be possible - but it would probably make sense to wait for Tom's latest work, so that GUI handling (drag/drop, mouse events etc) can be better supported. But overall, it should definitely be possible to implement a simple "GUI editor" with the canvas system.

For the LW/AW side of things, it would probably make sense to provide an abstract interface, either as a Nasal class/hash with setters/getters, or even just a bunch of properties with registered listeners that can be invoked by the GUI to instantiate objects and/or change settings - similar to your "compat layer", just specific to GUI needs - so that people working on the GUI, only need to look at a single Nasal file and can ignore all the other code.

PS: For such a visual "weather editor", having an additional "vertical" projection mode could also come in handy, so that weather patterns could be easily visualized just by setting their lat/lon/alt - and the canvas/map would automatically show everything in the right place.
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: 10587
Joined: Tue Mar 25, 2008 8:40 am

Re: Using Canvas to create a weather editor ? (split)

Postby Hooray » Thu Jun 05, 2014 10:18 am

Subject: Wiki's "Weather" page rewritten
Michat wrote in Thu Jun 05, 2014 3:46 am:Is there a way to represent ISOBARS in some WX MAP ?


As long as we can obtain the corresponding pressure info in some way from AW (Nasal functions and/or properties), we can probably use those to render a few OpenVG paths for contour lines procedurally like this: Image

On the MapStructure side I would prefer this to be about contour lines in general, so that we cannot only draw isobars, but also use the same code for elevations for example.
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: 10587
Joined: Tue Mar 25, 2008 8:40 am

Re: Using Canvas to create a weather editor ? (split)

Postby Michat » Fri Jun 27, 2014 3:08 am

The idea to have a GUI weather editor is really good for better understanding using the weather engine.
@Thorsten If the GUI scares to "you a bit" I could imagine the high level of difficulty ahead, due to the huge amount of data and the interactions between weather phenomena, fginternals and users.
Count with my help if you need some symbols like wind barbs or things like that.

About isobars is really great to have them in FG, what I don't know is if the METAR data is enough to have more or less accurate isobars or maybe is better to connect to a weather service.

About to have elevation contour lines with almost same code, that's a big lol.

A weather station-operator in FG is a dream I have in FG for a long time. So I have a question:

With the canvas elements that nowadays we have, it is possible to recreate a little wind mini widget like those I have in the right column of this image? Image, or instead do we need new elements from TheTom user?, I would like to try coding simple canvas elements based on properties, but I supposed is not so simple, when I try to understand code I get stuck.

Cheers.
User avatar
Michat
 
Posts: 835
Joined: Mon Jan 25, 2010 6:24 pm
Location: Spain
Version: 191b
OS: GNewSense

Re: Using Canvas to create a weather editor ? (split)

Postby Thorsten » Fri Jun 27, 2014 6:31 am

Funnily enough, just yesterday I had the idea to look at how the aircraft center is made internally to see how a next generation weather GUI could be made. By my FG time is a bit scarce at the moment, so this will have to wait till matters clear up a bit.
Thorsten
 
Posts: 8656
Joined: Mon Nov 02, 2009 8:33 am

Re: Using Canvas to create a weather editor ? (split)

Postby TheTom » Fri Jun 27, 2014 8:45 am

It should be possible to create any type of widget/layouting. Currently there are two possiblities:

1. Fixed layouting: define the position and size of any element on your own. Eg. load an SVG representing your widget and modify text, icons, etc. according to windspeed, etc.
2. Automatic layouting: create different widgets and layouts, and let the layout engine distribute the available space according to some policies. It works nearly the same as layouts in Qt. Currently vertical and horizontal box layouts, stretch factor, spacers and some basic widgets (buttons, label/image, checkbox, scroll area) are supported.

If you don't know how to implement a certain type of widget/gui/dialog just tell me what you want to achieve and I will tell you what you need to too, or I will implement what is missing. Now it's a good point helping to shape the API :-)
TheTom
 
Posts: 319
Joined: Sun Oct 09, 2011 10:20 am

Re: Using Canvas to create a weather editor ? (split)

Postby Hooray » Fri Jun 27, 2014 6:49 pm

TheTom wrote:
Thorsten wrote:Say, we get a map displayed, and there are drag-and-drop symbols of low pressure areas, fronts,... to the right, we drag them to the map, edit pressure values and so on, and the weather engine then converts this into winds, cloud configs etc.

It'd be rather easy to modify the weather engine to do that, just the GUI scared me quite a bit, but this seems entirely capable of handling the problem.

If you don't know how to implement a certain type of widget/gui/dialog just tell me what you want to achieve and I will tell you what you need to too, or I will implement what is missing. Now it's a good point helping to shape the API


It would take us (i.e. the MapStructure guys) roughly 50-100 lines of code to allow "map" layers to be "dynamic" in the sense that tooltips can be registered and so that mouse events can be handled by each layer, i.e. to freely move symbols around on a map, and invoke callbacks once a mouse button is released, e.g. to call geo.put_model() and/or write stuff to XML or call some arbitrary Nasal/AW APIs (e.g. showing another dialog to edit settings). I played with this a while ago when Bomber came up with the whole "chain home" idea:
Image

Conceptually, this would not even have to be a hack or workaround, we really only need to add a few base classes that can be used by the lcontroller files to receive the corresponding notifications, so that each "interactive" layer would just implement the corresponding interface by providing 2-3 methods.

And as can be seen in the other thread, we've started turning MapStructure into a generic/reusable Canvas widget, too:
Image

Personally, I kinda prefer that approach because it would be pretty consistent and it would allow us to reuse the same code that is ultimately used by maps/MFDs.
However, the type of coding involved in Canvas/GUI is very different from the type of code used in Advanced Weather, i.e. pretty focused on OOP, data structures and events/callbacks, as well as OpenVG and SVGs. But if this is something that you'd be interested in, I can help and come up with a working prototype that you could extend over time.

Capabilities-wise, you'll probably feel right at home, because there's Canvas functionality that's overlapping with your GLSL/effects background, i.e. dealing with textures, overlays/layers, rendering masks, texture maps, clipping etc. Conceptually, you can consider a Canvas like a texture that has various bounding boxes for which listeners (Nasal callbacks) are registered, which is used to handle GUI events like click, double click, mouse move (hover) etc - the corresponding callback can then transform elements on the canvas, i.e. to animate something. Most Inkscape SVG files can be directly used by the Canvas system for all kinds of purposes - transformations are typically timer/listener based.

For the sake of completeness, the other possibility would be using TorstenD's mongoose work to provide a HTML5/JavaScript-based browser GUI that directly gets/set properties
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: 10587
Joined: Tue Mar 25, 2008 8:40 am

Re: Using Canvas to create a weather editor ? (split)

Postby Hooray » Sat Jun 28, 2014 9:47 pm

Hooray wrote:It would take us (i.e. the MapStructure guys) roughly 50-100 lines of code to allow "map" layers to be "dynamic" in the sense that tooltips can be registered and so that mouse events can be handled by each layer


Turns out this was actually an exaggeration - I played with this, and ran initially into an issue, because we haven't yet formalized z-index/ordering handling in MapStructure (which is required to affect event propagation), but otherwise it works pretty nicely and requires very little in terms of added code - even though it would obviously make sense to add at least one helper class so that lcontrollers would fill in the corresponding interface methods.
Image

Technically, people could then easily create edit-able map layers (i.e. for symbols with geographic positions) without having to understand much about Nasal/Canvas or even mapping. You would basically tell the system which mouse events are relevant (click, double click, drag & drop or mouseover), and for each type of event you'd provide a Nasal callback, i.e. for moving a symbol, changing it, showing a dialog to customize additional values (turbulence type, altitude, diameter, strengths) - the symbol itself could then also be animated/transformed or changed accordingly.

In other words, you don't even need to understand how the "Aircraft Center" works at all in order to make use of this :D

From a C++ standpoint, we'll have to look at adding "unproject" handling at some point, as per Zakalawe's comments at: https://code.google.com/p/flightgear-bu ... id=550#c13
But I think Gijs started already revamping the projection handling code, so extending the underlying base class to add a corresponding required method should be a good thing.

Now, regarding a GUI editor for weather patterns, I can help prototype something like that, but it would be great if someone could provide the corresponding artwork for the GUI - for example, here's a SVG image for different types of clouds, if I could get a single SVG with a handful of cloud types (using separate element IDs), I could easily turn that into a widget with buttons: http://upload.wikimedia.org/wikipedia/c ... pes_en.svg
Image

(I'm just using navaids here, because we're missing lcontroller files for individual weather elements, i.e. cloud types etc)


EDIT: Sorry, I forgot to include the actual tooltip in the screen shot :lol:
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: 10587
Joined: Tue Mar 25, 2008 8:40 am

Re: Using Canvas to create a weather editor ? (split)

Postby Michat » Sun Jun 29, 2014 3:34 pm

Good evening I have anticipate a set of clouds- phenomena composition few months ago while practicing with inkscape projecting ideas with mock-ups, that it is on sleep phase, but I think I can easily adapt new elements for a entire composition set. Here I show you what about:

Image

Looking at this FGComScanner screen you can see I'd managed to create a so call atmosphere/freq spectrum. If you like this style I can create a full set of clouds formations, and a background where to slice the entire composition. Here in this example also you can see some sideral objects high altitude phenomena and some clouds with a mist layers atmosphere, it just a mock up. Please share your opinions freely.

The only limitation is that 7 of July I'll leave Madrid home station for about month and a half. But I think I can resolve those cloud set on a few ours using that style .

About ID, is that an specific part of the Inkscape side what's you meant? I saw that we can ID symbols using right button click properties, I never work ID's, so if is the case that is inkscape side related... do I'll need some names conventions from you?.

Cheers
User avatar
Michat
 
Posts: 835
Joined: Mon Jan 25, 2010 6:24 pm
Location: Spain
Version: 191b
OS: GNewSense

Re: Using Canvas to create a weather editor ? (split)

Postby Hooray » Sun Jun 29, 2014 3:44 pm

The only limitation is that 7 of July I'll leave Madrid home station for about month and a half. But I think I can resolve those cloud set on a few ours using that style .

I'd suggest to wait then, there's no hurry needed - we're still having to make progress in a few related areas. BTW: That screen shot/mockup looks great - but we need to find a way to use such things, this seems to touch the area of GUI "skinning", so we better wait until Canvas GUI Widgets have evolved a little more, which may take another release cycle - we should have probably a dozen of widgets by then roughly.

Regarding those IDs, I think all elements will have an ID by default - but we want it to be "sane" and not some random number, so that people working out different styles/skinning merely have to assign the proper element IDs to their SVGs.
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: 10587
Joined: Tue Mar 25, 2008 8:40 am

Re: Using Canvas to create a weather editor ? (split)

Postby Michat » Sun Jun 29, 2014 4:02 pm

Understand, now I'm feeling light. So I'll expend this week ultimating preparatives for my trip.
I hope the best for you.... have a good FlightGear Summer of code.

Many thanks for your great efforts " FG'ers"
User avatar
Michat
 
Posts: 835
Joined: Mon Jan 25, 2010 6:24 pm
Location: Spain
Version: 191b
OS: GNewSense


Return to Canvas

Who is online

Users browsing this forum: No registered users and 2 guests