display in grass7 [was: Re: [GRASS-dev] r.watershed]

Glynn Clements glynn at gclements.plus.com
Wed Jan 21 17:51:19 EST 2009


Markus Neteler wrote:

> >> P.S. I often do grass stuff from home over the net. For grass7 display
> >> through gui, even clicking off or changing
> >> the names of layers is rather time consuming compared to d.rast with x0 (I
> >> have cable).
> >> Any hints, tricks on how to display maps fast when testing would be
> >> appreciated.
> >
> > You could try ximgview. See [1] for Glynn's explanations of how it works.
> >
> > I have also successfully used gqview as my viewer (just point it to map.png
> > and it gets updated automatically).
> 
> Could you wrap this up into some d.mon command? Would be cool
> unless there is a wx based monitor system.

The main problem with trying to emulate d.mon is that the libraries
use environment variables for most of their configuration parameters,
and one process (e.g. d.mon) can't change the environment of another
process (in this case, the shell).

It has occurred to me that it might be better to use GRASS variables
instead, but that would require changing the GUI to match.

The biggest problem with monitoring the image files generated by the
display drivers is the need to handle the case where the program tries
to read the file while it's being modified.

This isn't an issue for ximgview, as it intentionally only works with
mmap()d 32-bit BMP files. The PNG and cairo drivers can modify these
files in-place, so the file is never in an invalid state.

The polling behaviour of ximgview probably isn't ideal for a remote
connection, as it will continually redraw the display. However, I've
fixed it so that you can specify percent=0, which will prevent the
redrawing.

You can force a redraw by sending SIGUSR1 to the ximgview process, and
you can make this happen whenever a display command completes with
e.g.:

	export GRASS_NOTIFY='kill -USR1 `pidof ximgview`'

A brief guide to using mmap()d BMP files and ximgview (works with both
the PNG and cairo drivers):

	export GRASS_PNGFILE=map.bmp
	export GRASS_PNG_MAPPED=TRUE
	d.erase # create the file
	export GRASS_PNG_READ=TRUE
	ximgview map.bmp percent=0 &
	export GRASS_NOTIFY='kill -USR1 `pidof ximgview`'
	# d.* commands follow

-- 
Glynn Clements <glynn at gclements.plus.com>


More information about the grass-dev mailing list