[GRASS-SVN] r34160 - grass/trunk/scripts/d.rast.leg

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Nov 5 05:33:28 EST 2008


Author: neteler
Date: 2008-11-05 05:33:28 -0500 (Wed, 05 Nov 2008)
New Revision: 34160

Modified:
   grass/trunk/scripts/d.rast.leg/d.rast.leg
Log:
added title and position parameters

Modified: grass/trunk/scripts/d.rast.leg/d.rast.leg
===================================================================
--- grass/trunk/scripts/d.rast.leg/d.rast.leg	2008-11-05 06:47:18 UTC (rev 34159)
+++ grass/trunk/scripts/d.rast.leg/d.rast.leg	2008-11-05 10:33:28 UTC (rev 34160)
@@ -67,6 +67,19 @@
 #% description: Name of raster map to generate legend from
 #% required : no
 #%end
+#%option
+#% key: title
+#% type: string
+#% description: Name of raster map to print in legend
+#% required : no
+#%end
+#%option
+#% key: position
+#% type: double
+#% description: Position of vertical map-legend separator (in percent)
+#% answer: 65
+#% required : no
+#%end
 
 if test "$GISBASE" = ""; then
  echo "You must be in GRASS GIS to run this program." >&2
@@ -85,6 +98,12 @@
   FLIP="-f"
 fi
 
+if [ ! -z $GIS_OPT_TITLE ] ; then
+   MAPNAME="$GIS_OPT_TITLE"
+else
+   MAPNAME="$GIS_OPT_MAP"
+fi
+
 #for -n flag of d.legend
 eval `g.findfile el=cell file=$GIS_OPT_MAP`
 if [ ! "$file" ] ; then
@@ -110,22 +129,24 @@
 # restore font setting
 $FONTCMD
 
+XPOS=$GIS_OPT_POSITION
+
 #at=bottom,top,left,right
 
 if [ -z "$GIS_OPT_NUM_OF_LINES" ]
 then
 
        #draw title
-        d.frame -s at=90,100,65,100  frame=title
+        d.frame -s at=90,100,$XPOS,100  frame=title
 #	if test -f $GISBASE/bin/d.text.freetype ; then
 #          d.text.freetype -sp text=$GIS_OPT_MAP col=black size=18 \
 #	         east_north=20,20 path=/usr/X11R6/lib/X11/fonts/TTF/luximb.ttf
 #	else
-          echo "$GIS_OPT_MAP" | d.text col=black size=30
+          echo "$MAPNAME" | d.text col=black size=30
 #	fi
 
        #draw legend
-    	d.frame -s at=0,90,65,100 frame=right
+    	d.frame -s at=0,90,$XPOS,100 frame=right
 	if [ -z $GIS_OPT_RAST ] ; then
 		if test -f $HISTFILEDIR/$GIS_OPT_MAP/histogram ; then
 	  	     d.legend $FLIP -n map=$GIS_OPT_MAP
@@ -141,22 +162,22 @@
 	fi
 
        #draw map
-	d.frame -s at=0,100,0,65 frame=left
+	d.frame -s at=0,100,0,$XPOS frame=left
     	d.rast map=$GIS_OPT_MAP
 
 else
 
        #draw title
-        d.frame -s at=90,100,65,100 frame=title
+        d.frame -s at=90,100,$XPOS,100 frame=title
 #	if test -f $GISBASE/bin/d.text.freetype ; then
 #          d.text.freetype -sp text=$GIS_OPT_MAP col=black size=18 \
 #	         east_north=20,20 path=/usr/X11R6/lib/X11/fonts/TTF/luximb.ttf
 #	else
-          echo "$GIS_OPT_MAP" | d.text col=black size=30
+          echo "$MAPNAME" | d.text col=black size=30
 #	fi
 
        #draw legend
-    	d.frame -s at=0,90,65,100 frame=right
+    	d.frame -s at=0,90,$XPOS,100 frame=right
 	if [ -z $GIS_OPT_RAST ] ; then
 		if test -f $HISTFILEDIR/$GIS_OPT_MAP/histogram ; then
 	             d.legend $FLIP -n map=$GIS_OPT_MAP lines=$GIS_OPT_NUM_OF_LINES
@@ -172,7 +193,7 @@
 	fi
 
        #draw map
-	d.frame -s at=0,100,0,65 frame=left
+	d.frame -s at=0,100,0,$XPOS frame=left
     	d.rast map=$GIS_OPT_MAP
 fi
 



More information about the grass-commit mailing list