#!/bin/sh
############################################################################
#
# MODULE:	d.redraw
# AUTHOR(S):	Huidae Cho - grass4u@gmail.com
# PURPOSE:	To redraw current displayed maps without saving d.save info
#		before d.erase.
# COPYRIGHT:	(C) 2000 by the GRASS Development Team
#
#		This program is free software under the GNU General Public
#		License (>=v2). Read the file COPYING that comes with GRASS
#		for details.
#
#############################################################################

#%Module
#% description: Redraws the current display frame in the GRASS monitor
#% keywords: display
#%End
#%flag
#% key: a
#% description: Redraw all frames
#%end
#%flag
#% key: r
#% description: Do not preserve individual regions when redrawing all frames
#%end



if [ -z "$GISBASE" ] ; then
    echo "You must be in GRASS GIS to run this program." 1>&2
    exit 1
fi

# GUI is not very useful here, skip it if no args are given
if [ "$#" -gt 0 ] ; then
  if [ "$1" != "@ARGS_PARSED@" ] ; then
    exec g.parser "$0" "$@"
  fi
else
  # no args given
  GIS_FLAG_A=0
  GIS_FLAG_R=0
fi


if [ "$GIS_FLAG_A" -eq 0 ] ; then
   dsave=`d.save -o`
else
   if [ "$GIS_FLAG_R" -eq 0 ] ; then
      dsave=`d.save -a`
   else
      dsave=`d.save -a | grep -v '^g.region'`
   fi
fi

# With -x flag, d.redraw behaves as if it actually stops and restarts monitor,
# which is good for PNG non-white transparency and d.mvmon.
d.erase -x
eval "$dsave"

exit
