~ubuntu-branches/ubuntu/vivid/grass/vivid-proposed

« back to all changes in this revision

Viewing changes to scripts/d.slide.show/d.slide.show

  • Committer: Package Import Robot
  • Author(s): Bas Couwenberg
  • Date: 2015-02-20 23:12:08 UTC
  • mfrom: (8.2.6 experimental)
  • Revision ID: package-import@ubuntu.com-20150220231208-1u6qvqm84v430b10
Tags: 7.0.0-1~exp1
* New upstream release.
* Update python-ctypes-ternary.patch to use if/else instead of and/or.
* Drop check4dev patch, rely on upstream check.
* Add build dependency on libpq-dev to grass-dev for libpq-fe.h.
* Drop patches applied upstream, refresh remaining patches.
* Update symlinks for images switched from jpg to png.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/bin/sh
2
 
 
3
 
############################################################################
4
 
#
5
 
# MODULE:       d.slide.show 
6
 
# AUTHOR(S):    CERL, updated by Michael Barton
7
 
# PURPOSE:      Slide show of GRASS raster/vector maps
8
 
# COPYRIGHT:    (C) 2004 by the GRASS Development Team
9
 
#
10
 
#               This program is free software under the GNU General Public
11
 
#               License (>=v2). Read the file COPYING that comes with GRASS
12
 
#               for details.
13
 
#
14
 
#############################################################################
15
 
 
16
 
#%Module
17
 
#%  description: Slide show of GRASS raster/vector maps.
18
 
#%  keywords: display, slideshow
19
 
#%End
20
 
#%flag
21
 
#%  key: v
22
 
#%  description: Show vector maps rather than raster maps
23
 
#%END
24
 
#%option
25
 
#% key: prefix
26
 
#% type: string
27
 
#% description: Map prefix. Specify character(s) to view selected maps only
28
 
#% required : no
29
 
#%end
30
 
#%option
31
 
#% key: across
32
 
#% type: integer
33
 
#% description: Map number show across the monitor
34
 
#% gisprompt: 4
35
 
#% required : no
36
 
#%end
37
 
#%option
38
 
#% key: down
39
 
#% type: integer
40
 
#% description: Map number show down the monitor
41
 
#% gisprompt: 3
42
 
#% required : no
43
 
#%end
44
 
#%option
45
 
#% key: mapsets
46
 
#% type: string
47
 
#% description: Mapsets to use. Specify multiple mapsets comma separated
48
 
#% multiple : yes
49
 
#% required : no
50
 
#%end
51
 
#%option
52
 
#% key: delay
53
 
#% type: integer
54
 
#% description: Number of seconds to pause between slides
55
 
#% options: 0-60
56
 
#% answer: 0
57
 
#% required: no
58
 
#%end
59
 
 
60
 
if test "$GISBASE" = ""; then
61
 
 echo "You must be in GRASS GIS to run this program." >&2
62
 
 exit 1
63
 
fi   
64
 
 
65
 
if [ "$1" != "@ARGS_PARSED@" ] ; then
66
 
  exec g.parser "$0" "$@"
67
 
fi
68
 
     
69
 
# set defaults
70
 
DOWN=3
71
 
ACROSS=4
72
 
CWD=`pwd`
73
 
 
74
 
# in case of problems or user break:
75
 
trap 'cd $CWD ; d.frame -s full_screen ; exit 1' 2 3 15
76
 
 
77
 
GISDBASE=`g.gisenv GISDBASE`
78
 
LOCATION_NAME=`g.gisenv LOCATION_NAME`
79
 
MAPSET=`g.gisenv MAPSET`
80
 
LOCATION="$GISDBASE/$LOCATION_NAME/$MAPSET"
81
 
 
82
 
# Get list of current mapsets
83
 
if [ -r $LOCATION/SEARCH_PATH ]
84
 
then
85
 
        MAPSETS=`cat $LOCATION/SEARCH_PATH | tr -s '\012' ' '`
86
 
else
87
 
        if [ "$MAPSET" = "PERMANENT" ]
88
 
        then
89
 
                MAPSETS="$MAPSET"
90
 
        else
91
 
                MAPSETS="$MAPSET PERMANENT"
92
 
        fi
93
 
fi
94
 
 
95
 
if [ -n "$GIS_OPT_PREFIX" ] ; then
96
 
   PREFIX=$GIS_OPT_PREFIX
97
 
fi
98
 
if [ -n "$GIS_OPT_DOWN" ] ; then
99
 
   DOWN=$GIS_OPT_DOWN
100
 
fi
101
 
if [ -n "$GIS_OPT_ACROSS" ] ; then
102
 
   ACROSS=$GIS_OPT_ACROSS
103
 
fi
104
 
if [ -n "$GIS_OPT_MAPSETS" ] ; then
105
 
   MAPSETS=`echo $GIS_OPT_MAPSETS | sed 's/,/ /g'`
106
 
fi
107
 
 
108
 
if [ $GIS_FLAG_V -eq 1 ] ; then
109
 
   SHOW_VECT=1
110
 
else
111
 
   SHOW_VECT=0
112
 
fi
113
 
 
114
 
# Check if mapset exists
115
 
mapsets=""
116
 
for mapset in $MAPSETS
117
 
do
118
 
        if [ -d $LOCATION/../$mapset ]
119
 
        then
120
 
                mapsets="$mapsets $mapset"
121
 
        fi
122
 
done
123
 
if [ "$mapsets" = "" ]
124
 
then
125
 
        g.message -e "$MAPSETS: No such mapset(s) found"
126
 
        exit 1
127
 
fi
128
 
MAPSETS=$mapsets
129
 
 
130
 
drawframes()
131
 
{
132
 
 d.frame -e
133
 
 if [ $? -ne 0 ] ; then
134
 
   g.message -e "An error occured while running 'd.frame -e'"
135
 
   exit 1
136
 
 fi
137
 
 
138
 
 # figure height and widths of the windows
139
 
 avail_width=`expr 99 - $ACROSS`
140
 
 avail_height=`expr 99 - $DOWN`
141
 
 map_width=`expr $avail_width / $ACROSS`
142
 
 wind_height=`expr $avail_height / $DOWN`
143
 
 label_height=`expr $wind_height / 10`
144
 
 map_height=`expr $wind_height - $label_height`
145
 
 
146
 
 # generate the needed windows
147
 
 at_horiz=0
148
 
 left=1
149
 
 while [ $at_horiz -lt $ACROSS ]
150
 
 do
151
 
        at_vert=0
152
 
        top=99
153
 
        right=`expr $left + $map_width`
154
 
        while [ $at_vert -lt $DOWN ]
155
 
        do
156
 
                bottom=`expr $top - $map_height`
157
 
                d.frame -c map.$at_horiz.$at_vert at=$bottom,$top,$left,$right
158
 
                top=$bottom
159
 
                bottom=`expr $top - $label_height`
160
 
                d.frame -c lab.$at_horiz.$at_vert at=$bottom,$top,$left,$right
161
 
                at_vert=`expr $at_vert + 1`
162
 
                top=`expr $bottom - 1`
163
 
        done
164
 
        at_horiz=`expr $at_horiz + 1`
165
 
        left=`expr $right + 1`
166
 
 done
167
 
}
168
 
 
169
 
drawraster()
170
 
{
171
 
 for mapset in $MAPSETS
172
 
 do
173
 
        cd $LOCATION/../$mapset
174
 
        if [ ! -d cell ]
175
 
        then
176
 
                continue
177
 
        fi
178
 
        for i in MASK `ls cell/$PREFIX* 2> /dev/null`
179
 
        do
180
 
                i=`echo $i | sed 's/cell\///'`
181
 
                if [ ! $i = "MASK" ]
182
 
                then
183
 
                        atnum=`expr $atnum % $totmaps`
184
 
                        at_vert=`expr $atnum % $DOWN`
185
 
                        at_hori=`expr $atnum / $DOWN`
186
 
 
187
 
                        d.frame -s lab.$at_hori.$at_vert
188
 
                        d.erase
189
 
                        echo $i in $mapset | d.text size=80
190
 
 
191
 
                        d.frame -s map.$at_hori.$at_vert
192
 
                        d.erase
193
 
                        g.message -v message="[$i]"
194
 
                        d.rast $i --quiet
195
 
 
196
 
                        if [ "$GIS_OPT_DELAY" -gt 0 ] ; then
197
 
                            sleep "$GIS_OPT_DELAY"
198
 
                        fi
199
 
 
200
 
                        atnum=`expr $atnum + 1`
201
 
                fi
202
 
        done
203
 
 done
204
 
}
205
 
 
206
 
 
207
 
drawvector()
208
 
{
209
 
 for mapset in $MAPSETS
210
 
 do
211
 
        cd $LOCATION/../$mapset
212
 
        if [ ! -d vector ]
213
 
        then
214
 
                continue
215
 
        fi
216
 
        for i in `ls -d vector/$PREFIX* 2> /dev/null`
217
 
        do
218
 
                i=`echo $i | sed 's/^vector\///'`
219
 
                atnum=`expr $atnum % $totmaps`
220
 
                at_vert=`expr $atnum % $DOWN`
221
 
                at_hori=`expr $atnum / $DOWN`
222
 
 
223
 
                d.frame -s lab.$at_hori.$at_vert
224
 
                d.erase
225
 
                echo $i in $mapset | d.text size=80
226
 
 
227
 
                d.frame -s map.$at_hori.$at_vert
228
 
                d.erase
229
 
                g.message -v message="[$i]"
230
 
                d.vect -c $i --quiet
231
 
 
232
 
                if [ "$GIS_OPT_DELAY" -gt 0 ] ; then
233
 
                    sleep "$GIS_OPT_DELAY"
234
 
                fi
235
 
 
236
 
                atnum=`expr $atnum + 1`
237
 
        done
238
 
 done
239
 
}
240
 
 
241
 
 
242
 
####################################
243
 
# main code
244
 
 
245
 
drawframes
246
 
 
247
 
# Draw the maps
248
 
 
249
 
atnum=0
250
 
totmaps=`expr $ACROSS \* $DOWN`
251
 
 
252
 
if [ $SHOW_VECT -eq 0 ] ; then
253
 
   g.message "Displaying raster maps..." 
254
 
   drawraster
255
 
else
256
 
   g.message "Displaying vector maps..."
257
 
   drawvector
258
 
fi
259
 
 
260
 
cd $CWD
261
 
d.frame -s full_screen
262
 
 
263
 
exit 0