This file is indexed.

/usr/lib/grass64/etc/gm/barscale.tcl is in grass-gui 6.4.3-3.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
##########################################################################
# barscale.tcl - barscale layer options file for GRASS GIS Manager
# March 2006 Michael Barton, Arizona State University
# COPYRIGHT:	(C) 1999 - 2006 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.
#
##########################################################################

namespace eval GmBarscale {
    variable array opt ;# barscale current options
    variable count 1
    variable array lfile ;# scale
    variable array lfilemask ;# scale
    variable optlist
    variable first
    variable array dup ;# layer
    variable placement ;#LabelEntry widget for scale bar placment coordinates
};


###############################################################################
# create new barscale layer
proc GmBarscale::create { tree parent } {
    variable opt
    variable count
    variable lfile
    variable lfilemask
    variable optlist
    variable first
	variable dup
	variable can
    global mon
    global iconpath

    set node "barscale:$count"

    set frm [ frame .barscaleicon$count]
    set check [checkbutton $frm.check \
                           -variable GmBarscale::opt($count,1,_check) \
                           -height 1 -padx 0 -width 0]

    image create photo scaleico -file "$iconpath/module-d.barscale.gif"
    set ico [label $frm.ico -image scaleico -bd 1 -relief raised]

    bind $ico <ButtonPress-1> "GmTree::selectn $tree $node"

    pack $check $ico -side left
    
	#insert new layer
	if {[$tree selection get] != "" } {
		set sellayer [$tree index [$tree selection get]]
    } else { 
    	set sellayer "end" 
    }

    $tree insert $sellayer $parent $node \
	-text  "scale $count"\
	-window    $frm \
	-drawcross auto  
        
    set opt($count,1,_check) 1 
    set dup($count) 0

	set opt($count,1,opacity) 1.0
    set opt($count,1,tcolor) \#000000 
    set opt($count,1,bcolor) \#FFFFFF 
    set opt($count,1,bcolor_none) 0
    set opt($count,1,font) ""
    set opt($count,1,line) 0 
    set opt($count,1,at) "2,2" 
    set opt($count,1,feet) 0 
    set opt($count,1,top) 0 
    set opt($count,1,arrow) 0 
    set opt($count,1,scale) 0 
    set opt($count,1,mod) 1
    set opt($count,1,mouseset) 0
    set first 1
        
    set optlist { _check opacity bcolor bcolor_none font tcolor at feet line top arrow scale mouseset}
    
    foreach key $optlist {
		set opt($count,0,$key) $opt($count,1,$key)
    } 

	# create files in tmp diretory for layer output
	set mappid [pid]
	if {[catch {set lfile($count) [exec g.tempfile pid=$mappid]} error]} {
		GmLib::errmsg $error [G_msg "Error creating tempfile"]
	}
	set lfilemask($count) $lfile($count)
	append lfile($count) ".ppm"
	append lfilemask($count) ".pgm"
		
    incr count

    return $node
};

###############################################################################
proc GmBarscale::set_option { node key value } {
    variable opt
 
    set id [GmTree::node_id $node]
    set opt($id,1,$key) $value

};


###############################################################################

proc GmBarscale::mouseset { id } {
	# use mouse to set scalebar placement coordinates
	global mon pctentry
	variable placement

	if { $GmBarscale::opt($id,1,mouseset) == 1 } {
		set pctentry $GmBarscale::placement
	} else {
		set pctentry ""
	}

};

##########################################################################
proc GmBarscale::set_font { id } {
	variable opt

	if {$GmBarscale::opt($id,1,font) != "" } {
		set Gm::dfont $GmBarscale::opt($id,1,font)
	}
	Gm::defaultfont dbarscale
	tkwait variable Gm::dfont
	set GmBarscale::opt($id,1,font) $Gm::dfont
	set Gm::dfont ""

};


###############################################################################
# barscale options
proc GmBarscale::options { id frm } {
    variable opt    
    variable placement
    global bgcolor
    global iconpath
    global mon

    # Panel heading
    set row [ frame $frm.heading1 ]
    Label $row.a -text [G_msg "Display scale and north arrow"] \
    	-fg MediumBlue    
    pack $row.a -side left
    pack $row -side top -fill both -expand yes

	#opacity
	set row [ frame $frm.opc]
	Label $row.a -text [G_msg "Opaque "]
	scale $row.b -from 1.0 -to 0.0 -showvalue 1  \
		-orient horizontal -length 300 -resolution 0.01 -fg "#656565"\
		-variable GmBarscale::opt($id,1,opacity) 
	Label $row.c -text [G_msg " Transparent"]
    pack $row.a $row.b $row.c -side left
    pack $row -side top -fill both -expand yes	
	
    # at1
    set row [ frame $frm.at1 ]
    Label $row.a -text [G_msg "Scale placement: 0-100% from top left of display"]
    pack $row.a -side left
    pack $row -side top -fill both -expand yes
        
    # at2
    set row [ frame $frm.at2 ]
    Label $row.a -text [G_msg "\t enter x,y of scale/arrow upper left corner"]
    set placement [LabelEntry $row.b -width 8 \
    	-textvariable GmBarscale::opt($id,1,at)]
    Label $row.c -text [G_msg "    "]
    Button $row.d -text [G_msg "Help"] \
            -image [image create photo -file "$iconpath/gui-help.gif"] \
            -command "spawn g.manual --q d.barscale" \
            -background $bgcolor \
            -helptext [G_msg "Help"]
    pack $row.a $row.b $row.c $row.d -side left
    pack $row -side top -fill both -expand yes

    # at3
    set row [ frame $frm.at3 ]
    Label $row.a -text [G_msg "\t "]
    checkbutton $row.b -text [G_msg "place with mouse"] \
    	-variable GmBarscale::opt($id,1,mouseset) \
    	-command "GmBarscale::mouseset $id"
    pack $row.a $row.b -side left
    pack $row -side top -fill both -expand yes

    # color
    set row [ frame $frm.color ]
    Label $row.a -text [G_msg "Scale appearance:  text color"] 
    SelectColor $row.b -type menubutton -variable GmBarscale::opt($id,1,tcolor)
    Label $row.c -text [G_msg "  font "]
    Button $row.d -image [image create photo -file "$iconpath/gui-font.gif"] \
        -highlightthickness 0 -takefocus 0 -relief raised -borderwidth 1  \
        -helptext [G_msg "select font for text"] \
	    -command "GmBarscale::set_font $id"
    pack $row.a $row.b $row.c $row.d -side left
    pack $row -side top -fill both -expand yes
    
    # background
    set row [ frame $frm.background ]
    Label $row.a -text [G_msg "\tbackground color "] 
    SelectColor $row.b -type menubutton -variable GmBarscale::opt($id,1,bcolor)
    Label $row.c -text "   " 
    checkbutton $row.d -text [G_msg "transparent background"] \
    	-variable GmBarscale::opt($id,1,bcolor_none) 
    pack $row.a $row.b $row.c $row.d -side left
    pack $row -side top -fill both -expand yes

    # arrow or scale only
    set row [ frame $frm.arrow ]
    Label $row.a -text "\t "
    checkbutton $row.b -text [G_msg "display N. arrow only"] \
    	-variable GmBarscale::opt($id,1,arrow) 
    checkbutton $row.c -text [G_msg "display scale only"] \
    	-variable GmBarscale::opt($id,1,scale) 
    pack $row.a $row.b $row.c -side left
    pack $row -side top -fill both -expand yes

    # text on top
    set row [ frame $frm.textontop ]
    Label $row.a -text "\t " 
    checkbutton $row.b -text [G_msg "text on top of scale, instead of to right"] \
    	-variable GmBarscale::opt($id,1,top) 
    pack $row.a $row.b -side left
    pack $row -side top -fill both -expand yes

    # scale options
    set row [ frame $frm.opts ]
    Label $row.a -text "\t " 
    checkbutton $row.b -text [G_msg "line scale instead of bar"] \
    	-variable GmBarscale::opt($id,1,line) 
    checkbutton $row.c -text [G_msg "use feet/miles instead of meters"] \
    	-variable GmBarscale::opt($id,1,feet) 
    pack $row.a $row.b $row.c -side left
    pack $row -side top -fill both -expand yes

};

###############################################################################
# save barscale layer node to grc file
proc GmBarscale::save { tree depth node } {
    variable opt
    variable optlist
    global mon
    
    set id [GmTree::node_id $node]

    foreach key $optlist {
        GmTree::rc_write $depth "$key $opt($id,1,$key)"
    } 
};


###############################################################################
# render and composite barscale layer

proc GmBarscale::display { node mod } {
    global mon
    global env
    variable optlist
    variable lfile 
    variable lfilemask
    variable opt
    variable tree
    variable dup
    variable count
    variable first

 	set line ""
    set input ""
    set cmd ""

    set tree($mon) $GmTree::tree($mon)
    set id [GmTree::node_id $node]

    # If we are told dirty (for zoom) force dirty
    # Don't remove a dirty from a previous unrendered zoom
    if {$mod} {set opt($id,1,mod) 1}

    # set hex colors to rgb         
    set tcolor [GmLib::color $opt($id,1,tcolor)]
    set bcolor [GmLib::color $opt($id,1,bcolor)]

    # no background color
    if { $opt($id,1,bcolor_none) == 1 } { 
        set bcolor "none"
    }
    
    set cmd "d.barscale tcolor=$tcolor bcolor=$bcolor at=$opt($id,1,at)"

    # line scale
    if { $opt($id,1,line) != 0 } { 
        append cmd " -l"
    }

    # text on top
    if { $opt($id,1,top) != 0 } { 
        append cmd " -t"
    }

    # english units
    if { $opt($id,1,feet) != 0} { 
        append cmd " -f"
    }

	# arrow only
	if { $opt($id,1,arrow) != 0 } {
		append cmd " -n"
	}
	
	# scale only
	if { $opt($id,1,scale) != 0 } {
		append cmd " -s"
	}

    # check value of GRASS_FONT variable prior to display
	if {![catch {set env(GRASS_FONT)}]} {
		set currfont $env(GRASS_FONT)
	} else {
		set currfont "romans"
	}
	
    # set grass font environmental variable to user selection"
	if { $GmBarscale::opt($id,1,font) != ""} { 
		set env(GRASS_FONT) $GmBarscale::opt($id,1,font) 
	}

	# Decide whether to run, run command, and copy files to temp
	GmCommonLayer::display_command [namespace current] $id $cmd
	
	# set grass font environmental variable to whatever it was when we started
	# this lets different text layers have different fonts
	
	set env(GRASS_FONT) $currfont
	
};

###############################################################################
#duplicate barscale layer

proc GmBarscale::duplicate { tree parent node id } {
    variable optlist
    variable lfile
    variable lfilemask
    variable opt
    variable count
	variable dup
	variable first
	global iconpath

    set node "barscale:$count"
	set dup($count) 1

    set frm [ frame .barscaleicon$count]
    set check [checkbutton $frm.check \
		-variable GmBarscale::opt($count,1,_check) \
		-height 1 -padx 0 -width 0]

    image create photo scaleico -file "$iconpath/module-d.barscale.gif"
    set ico [label $frm.ico -image scaleico -bd 1 -relief raised]
    
    bind $ico <ButtonPress-1> "GmTree::selectn $tree $node"

    pack $check $ico -side left

	#insert new layer
	if {[$tree selection get] != "" } {
		set sellayer [$tree index [$tree selection get]]
    } else { 
    	set sellayer "end" 
    }

    $tree insert $sellayer $parent $node \
		-text      "scale $count" \
		-window    $frm \
		-drawcross auto
		
	set opt($count,1,opacity) $opt($id,1,opacity)
    set first 1
    
    foreach key $optlist {
    	set opt($count,1,$key) $opt($id,1,$key)
		set opt($count,0,$key) $opt($count,1,$key)
    } 
	
	set id $count
	
	# create files in tmp directory for layer output
	set mappid [pid]
	if {[catch {set lfile($count) [exec g.tempfile pid=$mappid]} error]} {
		GmLib::errmsg $error [G_msg "Error creating tempfile"]
	}
	set lfilemask($count) $lfile($count)
	append lfile($count) ".ppm"
	append lfilemask($count) ".pgm"

    incr count
    return $node
}