[GRASS-dev] Re: windows binaries

Glynn Clements glynn at gclements.plus.com
Thu Nov 9 17:19:32 EST 2006


Michael Barton wrote:

> >>> Disclaimer: I only see a fragment of the entire post, and might
> >>> misunderstand.
> >>> 
> >>> D.vect.thematic does not require any particular driver. It uses d.vect
> >>> (iterated over different theme values) to render the final map.
> >>> 
> >>> This is why it can work with either an xmonitor or a TclTk canvas (the
> >>> latter via the PNG driver and immediate rendering mode.)
> >> 
> >> It won't work in immediate rendering mode since, as you say, it calls
> >> d.vect several times and in immediate rendering mode each call creates a
> >> new map from scratch, thus losing the overlaying of the different
> >> classes.
> > 
> > Could it easily be modified to work with direct rendering? I.e. make
> > multiple calls to d.vect, each generating a separate PPM/PGM pair,
> > then using g.composite to generate the final result?
> 
> I don't know. The problem is that this is being done in a BASH script,
> outside the environment set up to handle such compositing in TclTk. I'll see
> if it's doable without an enormous rewrite.

AFAICT, the necessary changes would be:

1. At the start of the script:

if [ $GRASS_RENDER_IMMEDIATE = TRUE ] ; then
  imgbase=${GRASS_PNGFILE%.ppm}
fi

2. After each d.* command:

if [ $GRASS_RENDER_IMMEDIATE = TRUE ] ; then
  mv $imgbase.ppm $imgbase.$num.ppm	# each image needs a different number
  if [ $GRASS_TRANSPARENT = TRUE ] ; then
    mv $imgbase.pgm $imgbase.$num.pgm
  fi
fi

3. At the end of the script:

if [ $GRASS_RENDER_IMMEDIATE = TRUE ] ; then
  if [ $GRASS_TRANSPARENT = TRUE ] ; then
    g.pnmcomp \
	output=$imgbase.ppm \
	width=$GRASS_WIDTH \
	height=$GRASS_HEIGHT \
	input=$imgbase.1.ppm,$imgbase.2.ppm \
	mask=$imgbase.1.pgm,$imgbase.2.pgm
  else
    g.pnmcomp \
	output=$imgbase.ppm \
	width=$GRASS_WIDTH \
	height=$GRASS_HEIGHT \
	input=$imgbase.1.ppm,$imgbase.2.ppm
  fi
fi

However:

1. I need to extend g.pnmcomp to allow it to output an alpha (mask)
channel.

2. It will fail if $GRASS_PNGFILE ends in .png rather than .ppm. There
isn't a compositing utility for PNG files.

Here's an idea: if direct rendering had an option to initialise the
framebuffer from an image file (or PPM/PGM pair), building up an image
by having multiple d.* commands render on top of each other would
work, in the same way that it does with persistent drivers.

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




More information about the grass-dev mailing list