Board index FlightGear Development Canvas

Show information on the Simulator Main View

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.

Show information on the Simulator Main View

Postby acherpil » Mon Mar 02, 2015 5:33 pm

Hi,

I want to show some information such as pictures of right,left,... arrow as .png pictures during the simulation.
For example, if the plane is doing a right turn the right arrow will be displayed on the screen.

So far I can display such arrows, BUT the position of the canvas window is always at the top left of the view.
How can I chose the position of the window ?

Here is my code:
Code: Select all
var dlg  = canvas.Window.new([100,30]);
var my_canvas = dlg.createCanvas()
                     .setColorBackground(0,0,0,0.35);
var root = my_canvas.createGroup();

var show_arrow = func {
  print( "Arrow updated" );
  root.createChild("image")
                                      .setFile("Aircraft/fixedwing/Image/right.png")
                                      .setSize(100,30)
                                      .setTranslation(0,0);
}
acherpil
 
Posts: 3
Joined: Mon Mar 02, 2015 5:25 pm

Re: Show information on the Simulator Main View

Postby Hooray » Mon Mar 02, 2015 6:52 pm

Hi & welcome,

note that there's the notion of a transparent "desktop" window - so you would simply show a transparent window, without any decoration (titlebar etc) and add your images etc to that window.
for placement details, please refer to tooltip.nas - i.e. by checking how Canvas windows are handled there: https://gitorious.org/fg/fgdata/source/ ... ooltip.nas

In general, it makes sense to explore the simulator and look for similar features/functionality, so that you can take a look how the underlying implementation works.
As you'll notice, there are separate x/y nodes support for adjusting the position of a Canvas.
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: 11968
Joined: Tue Mar 25, 2008 8:40 am

Re: Show information on the Simulator Main View

Postby alexcherpi » Mon Mar 02, 2015 8:35 pm

Hi,

But the question is how to position the container which is the canvas and not the childs.

How would you write the code for that purpose?

Thanks
alexcherpi
 
Posts: 6
Joined: Wed Feb 04, 2015 1:53 pm

Re: Show information on the Simulator Main View

Postby alexcherpi » Fri Mar 13, 2015 1:06 pm

Hi,

My question is in fact the following.
During the flight I want to give informations. For that, I need to display a small picture which half transparent. I want this picture to be in a given in the window.
How do I do that ?
I tried with
'dlg = canvas.Window.new([wx,wy]);'
but the window is always positioned at (0,0) (top left). How do I move it ? Is there any dlg.move() function?

Thanks
alexcherpi
 
Posts: 6
Joined: Wed Feb 04, 2015 1:53 pm

Re: Show information on the Simulator Main View

Postby Necolatis » Fri Mar 13, 2015 1:40 pm

I think you can do:

dlg.setPosition
"Airplane travel is nature's way of making you look like your passport photo."
— Al Gore
User avatar
Necolatis
 
Posts: 2118
Joined: Mon Oct 29, 2012 12:40 am
Location: EKOD
Callsign: Leto
IRC name: Neco
Version: 2019.1.2
OS: Windows 10

Re: Show information on the Simulator Main View

Postby Hooray » Fri Mar 13, 2015 8:09 pm

maybe I am missing something, but isn't the tooltip code already doing exactly what you need ?? Why don't you simply look at the code in question and use that ?
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: 11968
Joined: Tue Mar 25, 2008 8:40 am


Return to Canvas

Who is online

Users browsing this forum: No registered users and 2 guests