Explorar o código

added title and position parameters

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@34160 15284696-431f-4ddb-bdfa-cd5b030d7da7
Markus Neteler %!s(int64=16) %!d(string=hai) anos
pai
achega
f11e94ea0f
Modificáronse 1 ficheiros con 29 adicións e 8 borrados
  1. 29 8
      scripts/d.rast.leg/d.rast.leg

+ 29 - 8
scripts/d.rast.leg/d.rast.leg

@@ -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 @@ if [ $GIS_FLAG_F -eq 1 ] ; then
   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 @@ d.frame -e
 # 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 @@ then
 	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 @@ else
 	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