zoom in/out?

Hi,

we are building an interface (with some menus) so that non-grass-oriented
people can perform certain tasks, like selecting layers of information
to display, panning/zooming, etc.

To zoom, we could just use the d.zoom command, but it only seems to
allow us to "zoom-in-by-center". a more complete zooming function
can be found in v.digit (the Z option). Here, the mouse becomes
the input device, and the user is allowed to zoom in and out by
selecting a new window. Is it possible to just *lift* that
part of the code out of v.digit, or ....

we're open to any suggestions!

thanks in advance,

todd crane

(responses can be sent directly to me at tecrane@geog.buffalo.edu)

I wrote this little shell script last year. I isn't the nicest solution
but could be something to use if you don't intend to start to program.
I also wish that the zooming function from v.digit could be lifted out.

Lars

Lars Schylberg Email: larss@fmi.kth.se
Dept. of Geodesy and Photogrammetry
Royal Institute of Technology (KTH) Tel. +46 8 790 86 33
S-100 44 STOCKHOLM, SWEDEN Fax. +46 8 790 66 10

----------------------------- cut here -----------------------------

#!/bin/sh
#
# d.zoom_out.sh
#
# Author: Lars Schylberg
# email: larss@fmi.kht.se
#
# Date 920703
#
#------------------------------------------------------------------------
# Check if GRASS is running
#
test "$GISRC" || echo "GRASS is not running" || exit 2
#----------------------------------------------------------------------------
#
# Evaluate arguments
#
if [ $# != 2 ]
then
    echo
    echo Usage: `basename $0`
    echo ' map=mapname '
    echo ' visual=yes|no '
    echo
    exit 1
fi
#
# parse input arguments
#
for i do
  case $i in
    map=*)
      MAP=`echo $i | sed s/map=//` ;;
    visual=*)
      VIS=`echo $i | sed s/visual=//` ;;
    *)
      echo ""
      echo "Unrecognized option: $i"
      echo 'Options: map=mapname '
      echo ' visual=yes|no '
                        echo ""
      exit 1
  esac
done
#-------------------------------------------------------------------------
#
TMP=tmp.`basename $0`.$$
#
# Get the categories max and min coordinates
#
g.region -p | sed "s/\..*//" > $TMP
#
N=`grep north $TMP | sed "s/[^0-9]*//"`
S=`grep south $TMP | sed "s/[^0-9]*//"`
E=`grep east $TMP | sed "s/[^0-9]*//"`
W=`grep west $TMP | sed "s/[^0-9]*//"`
#
# Determine current resolution to place a border
# that equals the currently shown display
#
NSRES=`grep nsres $TMP | sed "s/[^0-9]*//"`
EWRES=`grep ewres $TMP | sed "s/[^0-9]*//"`
/bin/rm $TMP
#
NSBORDER=`expr $N - $S`
EWBORDER=`expr $E - $W`
north=`expr $N + $NSBORDER`
south=`expr $S - $NSBORDER`
east=`expr $E + $EWBORDER`
west=`expr $W - $EWBORDER`
#
# Check that the new region not is outside the default region
#
g.region -dp | sed "s/\..*//" > $TMP
DN=`grep north $TMP | sed "s/[^0-9]*//"`
DS=`grep south $TMP | sed "s/[^0-9]*//"`
DE=`grep east $TMP | sed "s/[^0-9]*//"`
DW=`grep west $TMP | sed "s/[^0-9]*//"`
/bin/rm $TMP
#
if [ $north -gt $DN ]; then
north=$DN
fi
if [ $south -lt $DS ]; then
south=$DS
fi
if [ $east -gt $DE ]; then
east=$DE
fi
if [ $west -lt $DW ]; then
west=$DW
fi
#
# Set the new region
#
g.region n=$north s=$south e=$east w=$west nsres=$NSRES ewres=$EWRES
#
if [ $VIS = yes ] ; then
  d.erase
  d.rast $MAP
fi