[GRASS5] Embedding GRASS display in my application

Glynn Clements glynn.clements at virgin.net
Sat Apr 24 14:41:01 EDT 2004


Sajith VK wrote:

> > > Currenlty I use PNG driver, create an Image and load that
> > > image into my application, but it is not a good way.
> > 
> > Why not?
> 
> 	I guess it is less efficient. It need some hardisk access
> etc, which can be avoided if we can directly render it. Creating
> and loading a new PNG image for each operation (say paning, or
> displaying a new layer etc) will impact perfomance.. Correct
> me if I am wrong

For most operations, the overhead of writing, reading and rendering
the rasterised image is negligible compared to the effort involved in
actually generating it. Most of the effort tends to be involved in
getting the data from GRASS to the driver.

> > Under X, you can set the environment variable XDRIVER_WINDOW to the
> > XID of an existing X window, and XDRIVER will use that window instead
> > of creating its own. That won't work on Windows, though.
> 
> Thanks! it is enough, I dont plan to use my application is windows. 
> But will it render on my canvas, or in the entire window?
> The driver knows only XID of my window, how can it render
> on my canvas, which is one amoung several widgets in my window?
> My window has menus, toobar etc and a canvas widget on which
> I want to render the GRASS display...

In which case, you need to pass the XID of the canvas widget's window,
not the top-level window.

X "windows" aren't limited to top-level windows (the ones with a title
bar etc); each widget normally has its own window. Most toolkits have
some exceptions, e.g. menu items are often "gadgets", which are just
rectangular regions of the parent window, but "canvas" widgets (e.g. 
GtkDrawingArea, XmDrawingArea) usually have their own window.

Incidentally, XDRIVER doesn't draw directly onto the window. Instead,
it creates a background pixmap for the window, and draws on that. That
eliminates the need to redraw the window in response to Expose events.

-- 
Glynn Clements <glynn.clements at virgin.net>




More information about the grass-dev mailing list