1
##########################################################################
5
# Primary tcltk script for GIS Manager: GUI for GRASS 6
6
# Author: Michael Barton (Arizona State University)
7
# Based on Display Manager for GRASS 5.7 by Radim Blazek (ITC-IRST)
8
# and tcltkgrass for GRASS 5.7 by Michael Barton (Arizona State University)--
9
# with contributions by Glynn Clements, Markus Neteler, Lorenzo Moretti,
10
# Florian Goessmann, and others
14
# COPYRIGHT: (C) 1999 - 2005 by the GRASS Development Team
16
# This program is free software under the GNU General Public
17
# License (>=v2). Read the file COPYING that comes with GRASS
20
##########################################################################
22
lappend auto_path $env(GISBASE)/bwidget
23
package require -exact BWidget 1.2.1
25
set env(GISDBASE) [exec g.gisenv get=GISDBASE]
26
set env(LOCATION_NAME) [exec g.gisenv get=LOCATION_NAME]
27
set env(MAPSET) [exec g.gisenv get=MAPSET]
29
set gisdbase [exec g.gisenv get=GISDBASE]
30
set location_name [exec g.gisenv get=LOCATION_NAME]
31
set mapset [exec g.gisenv get=MAPSET]
34
set dmpath $env(GISBASE)/etc/dm/
36
set keycontrol "Control"
42
if {[info exists env(HOSTTYPE)]} {
43
set HOSTTYPE $env(HOSTTYPE)
51
if {[info exists env(osxaqua)]} {
52
set osxaqua $env(osxaqua)
57
if { $osxaqua == "1"} {
58
set keycontrol "Command"
64
#fetch GRASS Version number:
65
set fp [open $env(GISBASE)/etc/VERSIONNUMBER r]
66
set GRASSVERSION [read -nonewline $fp]
69
source $env(GISBASE)/etc/gui.tcl
70
# gui.tcl also sources these:
71
# $env(GISBASE)/etc/gtcltk/gmsg.tcl
72
# $env(GISBASE)/etc/gtcltk/options.tcl
73
# $env(GISBASE)/etc/gtcltk/select.tcl
74
# $env(GISBASE)/etc/gtcltk/gronsole.tc
76
source $dmpath/cmd.tcl
77
source $dmpath/tree.tcl
78
source $dmpath/tool1.tcl
79
source $dmpath/tool2.tcl
80
source $dmpath/group.tcl
81
source $dmpath/vector.tcl
82
source $dmpath/raster.tcl
83
source $dmpath/labels.tcl
84
source $dmpath/gridline.tcl
85
source $dmpath/rgbhis.tcl
86
source $dmpath/legend.tcl
87
source $dmpath/frames.tcl
88
source $dmpath/barscale.tcl
89
source $dmpath/chart.tcl
90
source $dmpath/thematic.tcl
91
source $dmpath/fttext.tcl
92
source $dmpath/dtext.tcl
93
source $dmpath/print.tcl
101
variable max_prgindic 20
109
################################################################################
114
set code [exec -- $cmd --tcltk]
121
###############################################################################
123
append regexp .* $env(GISBASE) {[^:]*}
124
regsub -- $regexp $env(PATH) "&:$env(GISBASE)/etc/dm/script" env(PATH)
127
###############################################################################
128
proc spawn {cmd args} {
129
eval exec -- $cmd $args &
132
###############################################################################
133
proc cmd_output {fh} {
137
if {[regexp -- {^GRASS_INFO_PERCENT: (.+)$} $str match val rest]} {
141
if { [fblocked $fh] } { set str [read $fh] }
142
while {[set idx [string first "\b" $str]] != -1} {
143
set last [expr $idx - 1]
144
set str1 [string range $str 1 $last]
145
set first [expr $idx + 1]
146
set str [string range $str $first end]
147
set pos [$outtext index "end - 1 chars"]
149
$outtext insert end $str1
152
$outtext insert end $str
161
###############################################################################
163
proc run_panel {cmd} {
166
set message_env [exec g.gisenv get=GRASS_MESSAGE_FORMAT]
167
set env(GRASS_MESSAGE_FORMAT) gui
169
set cmd [concat | $cmd 2>/dev/null ]
170
if { [catch {open $cmd r } fh] } {
173
$outtext insert end "$cmd_name\n"
175
catch {cmd_output $fh}
176
set env(GRASS_MESSAGE_FORMAT) $message_env
180
###############################################################################
186
eval exec -- $cmd >@ stdout 2>@ stderr
187
$outtext insert end "$cmd_name\n"
191
###############################################################################
192
proc term_panel {cmd} {
195
eval exec -- $env(GISBASE)/etc/grass-xterm-wrapper -name xterm-grass -e $env(GISBASE)/etc/grass-run.sh $cmd &
197
$outtext insert end "$cmd\n"
203
###############################################################################
204
proc run {cmd args} {
205
eval exec -- $cmd $args >@ stdout 2>@ stderr
211
###############################################################################
212
proc term {cmd args} {
214
eval exec -- $env(GISBASE)/etc/grass-xterm-wrapper -name xterm-grass -e $env(GISBASE)/etc/grass-run.sh $cmd $args &
217
###############################################################################
218
# Make sure there's an xmon before running some commands.
219
# Used in menus. Dummy for now.
220
proc guarantee_xmon {} {
224
###############################################################################
226
proc read_moncap {} {
229
set file [open [file join $env(GISBASE) etc monitorcap] r]
230
set data [read $file]
233
set data [subst -nocommands -novariables $data]
235
foreach line [split $data \n] {
236
if {[string match {\#*} $line]} continue
237
if {![string match {*:*:*:*:*:*} $line]} continue
239
foreach field [split $line :] {
240
lappend fields [string trim $field]
242
lappend moncap $fields
246
###############################################################################
248
proc monitor_menu {op} {
253
foreach mon $moncap {
254
set name [lindex $mon 0]
255
set driver [lindex $mon 1]
256
if {$last_driver != "" && $last_driver != $driver} {
257
lappend submenu {separator}
259
set last_driver $driver
260
lappend submenu [list command $name {} "" {} -command "run d.mon $op=$name"] }
262
return [list $submenu]
265
###############################################################################
269
proc Dm::color { color } {
271
regexp -- {#(..)(..)(..)} $color x r g b
280
###############################################################################
282
proc Dm::displmon { mon } {
283
global dmpath outtext
284
if ![catch {open "|d.mon -L" r} input] {
285
while {[gets $input line] >= 0} {
286
if {[regexp -nocase "$mon.*not running" $line]} {
287
run "d.mon start=$mon"
288
} elseif {[regexp -nocase "$mon.* running" $line]} {
289
run "d.mon select=$mon"
298
###############################################################################
301
proc Dm::create { } {
314
set prgtext [G_msg "Loading GIS Manager"]
320
# eval "exec sleep 20"
323
source $dmpath/menu.tcl
325
set prgtext "Creating MainFrame..."
326
set mainframe [MainFrame .mainframe \
327
-menu $descmenu -background $bgcolor \
328
-textvariable Dm::status \
329
-progressvar Dm::prgindic ]
331
set mainwindow [$mainframe getframe]
333
# check for currently active monitor
334
if ![catch {open "|d.mon -L" r} input] {
335
while {[gets $input line] >= 0} {
336
if {[regexp -nocase {.*(selected).*} $line]} {
337
regexp -nocase {..} $line mon
343
# toolbar 1 & 2 creation
344
set tb1 [$mainframe addtoolbar]
345
DmToolBar1::create $tb1
346
set tb2 [$mainframe addtoolbar]
347
DmToolBar2::create $tb2
348
set pw2 [PanedWindow $mainwindow.pw2 -side left -pad 0 -width 10 -background $bgcolor ]
349
pack $pw2 -side left -expand yes -fill both -anchor n
350
set firstpane [$pw2 add -minsize 50 -weight 1]
351
set pw1 [PanedWindow $firstpane.pw1 -side top -pad 0 -width 6 -background $bgcolor]
352
pack $pw1 -side top -expand yes -fill both -anchor n
354
# MANAGE DISPLAY MONITORS
355
set monitor_pane [$pw1 add -minsize 1 -weight 0 ]
357
label $monitor_pane.lbl1 -bg $bgcolor -fg darkgreen -text "Display"
358
radiobutton $monitor_pane.rb0 -text "x0" -variable mon -value "x0" \
359
-bg $bgcolor -command "Dm::displmon x0"
360
radiobutton $monitor_pane.rb1 -text "x1" -variable mon -value "x1" \
361
-bg $bgcolor -command "Dm::displmon x1"
362
radiobutton $monitor_pane.rb2 -text "x2" -variable mon -value "x2" \
363
-bg $bgcolor -command "Dm::displmon x2"
364
radiobutton $monitor_pane.rb3 -text "x3" -variable mon -value "x3" \
365
-bg $bgcolor -command "Dm::displmon x3"
366
radiobutton $monitor_pane.rb4 -text "x4" -variable mon -value "x4" \
367
-bg $bgcolor -command "Dm::displmon x4"
368
radiobutton $monitor_pane.rb5 -text "x5" -variable mon -value "x5" \
369
-bg $bgcolor -command "Dm::displmon x5"
370
radiobutton $monitor_pane.rb6 -text "x6" -variable mon -value "x6" \
371
-bg $bgcolor -command "Dm::displmon x6"
373
pack $monitor_pane.lbl1 $monitor_pane.rb0 $monitor_pane.rb1 $monitor_pane.rb2 \
374
$monitor_pane.rb3 $monitor_pane.rb4 $monitor_pane.rb5 \
375
$monitor_pane.rb6 -side top -expand yes -anchor nw -fill both
376
pack $monitor_pane -side left -expand no -fill both
380
set tree_pane [$pw1 add -minsize 50 -weight 1]
381
set tree [ DmTree::create $tree_pane ]
385
set options_pane [$pw2 add -minsize 50 -weight 1]
386
set options_sw [ScrolledWindow $options_pane.sw -relief raised -borderwidth 1]
387
set options_sf [ScrollableFrame $options_sw.sf]
388
$options_sf configure -height 145 -width 500
389
$options_sw setwidget $options_sf
390
set options [$options_sf getframe]
391
pack $options_sw -fill both -expand yes
392
bind_scroll $options_sf
395
set output_pane [$pw2 add -minsize 50 -weight 1 ]
396
pack $pw2 -fill both -expand yes
398
set output_sw [ScrolledWindow $output_pane.win -relief sunken -borderwidth 1]
399
set outtext [text $output_sw.text -height 5 -width 30]
400
$output_sw setwidget $outtext
401
pack $output_sw -fill both -expand yes
404
set prgtext [G_msg "Done"]
406
set Dm::status [G_msg "Welcome to the GRASS GIS manager"]
407
$mainframe showstatusbar status
409
pack $mainframe -fill both -expand yes
411
set fon [font create -family Verdana -size 12 ]
412
DynamicHelp::configure -font $fon -background yellow
418
###############################################################################
420
proc Dm::_create_intro { } {
424
variable max_prgindic
426
set top [toplevel .intro -relief raised -borderwidth 2]
429
wm overrideredirect $top 1
431
set ximg [label $top.x -image [image create photo -file "$dmpath/intro.gif"] ]
433
set frame [frame $ximg.f -background white]
434
set lab1 [label $frame.lab1 -text "GRASS $GRASSVERSION GIS Manager - $location_name" \
435
-background white -foreground black -font {times 16}]
436
set lab2 [label $frame.lab2 -textvariable Dm::prgtext -background white -font {times 12} -width 35]
437
set prg [ProgressBar $frame.prg -width 50 -height 15 -background white \
438
-variable Dm::prgindic -maximum $max_prgindic]
439
pack $lab1 $prg $lab2 -side left
440
place $frame -x 0 -y 0 -anchor nw
442
BWidget::place $top 0 0 center
446
###############################################################################
454
$tree delete [$tree nodes root]
457
catch {unset ::Dm::filename}
459
set new_root_node [DmGroup::create $tree "root"]
460
$tree itemconfigure $new_root_node -text "UNTITLED"
462
set ::Dm::filename Untitled.dmrc
465
###############################################################################
467
#Ctrl-W to close file
468
proc Dm::FileClose { stay_alive} {
472
$tree delete [$tree nodes root]
475
if { $stay_alive == ""} {
476
catch {unset ::Dm::filename}
480
###############################################################################
482
# add new group/layer to tree
483
proc Dm::add { type } {
487
if { [catch {match string {} $new_root_node}] } {
488
set new_root_node root
491
set parent_node [ lindex [$tree selection get] 0 ]
492
if { $parent_node == "" } {
493
set parent_node $new_root_node
496
set parent_type [Dm::node_type $parent_node]
497
if { $parent_type != "group" } {
498
set parent_node [$tree parent $parent_node]
503
DmGroup::create $tree $parent_node
506
DmRaster::create $tree $parent_node
509
DmVector::create $tree $parent_node
512
DmLabels::create $tree $parent_node
515
DmCmd::create $tree $parent_node
518
DmGridline::create $tree $parent_node
521
DmRgbhis::create $tree $parent_node
524
DmLegend::create $tree $parent_node
527
DmDframe::create $tree $parent_node
530
DmBarscale::create $tree $parent_node
533
DmChart::create $tree $parent_node
536
DmThematic::create $tree $parent_node
539
DmFTtext::create $tree $parent_node
542
DmDtext::create $tree $parent_node
547
###############################################################################
549
# autoname layer when a map is selected
550
proc Dm::autoname { name } {
553
set node [ lindex [$tree selection get] 0 ]
554
DmTree::autoname $tree $node $name
557
###############################################################################
558
# selected node ( show options )
559
proc Dm::select { node } {
563
set type [Dm::node_type $node]
564
set id [Dm::node_id $node]
566
# destroy old panel with options
569
set opt [frame $options.fr ]
570
pack $opt -fill both -expand yes
574
DmRaster::options $id $opt
577
DmVector::options $id $opt
580
DmLabels::options $id $opt
583
DmCmd::options $id $opt
586
DmGridline::options $id $opt
589
DmRgbhis::options $id $opt
592
DmLegend::options $id $opt
595
DmDframe::options $id $opt
598
DmBarscale::options $id $opt
601
DmChart::options $id $opt
604
DmThematic::options $id $opt
607
DmFTtext::options $id $opt
610
DmDtext::options $id $opt
615
###############################################################################
617
# deselect ( hide options )
618
proc Dm::deselect { node } {
625
###############################################################################
627
# delete selected node
628
proc Dm::delete { } {
632
set sel [ lindex [$tree selection get] 0 ]
633
if { $sel == "" } { return }
639
###############################################################################
641
# open monitor if no one is runnning
642
proc Dm::monitor { } {
643
if ![catch {open "|d.mon -L" r} input] {
644
while {[gets $input line] >= 0} {
645
if {[regexp -nocase {(x.).*display *running} $line buffer monitor]} {
655
###############################################################################
662
set sel [ lindex [$tree selection get] 0 ]
664
set message "No map selected"
665
tk_messageBox -type ok -icon warning -message $message
669
set type [Dm::node_type $sel]
680
DmVector::WorkOnVector $sel
716
###############################################################################
717
proc message_dialog { msgtxt } {
718
set msg [MessageDlg .msgdlg \
719
-title "The Message Dialog" \
722
if { $msg == 1 } {puts "no way" }
723
if { $msg == 0 } {puts "way to go"}
728
###############################################################################
731
proc Dm::display { } {
734
$outtext delete 1.0 end
738
DmGroup::display "root"
742
###############################################################################
745
proc Dm::displayall { } {
747
set cmd "g.region -d"
753
###############################################################################
756
proc Dm::display_region { } {
758
set reg [GSelect windows]
760
set cmd "g.region region=$reg"
767
###############################################################################
777
###############################################################################
780
proc Dm::zoom_back { } {
787
###############################################################################
798
###############################################################################
801
proc Dm::measure { } {
808
###############################################################################
811
proc Dm::position { } {
818
###############################################################################
826
if { $HOSTTYPE == "macintosh" || $HOSTTYPE == "powermac" || $HOSTTYPE == "powerpc" || $HOSTTYPE == "intel-pc"} {
827
if { $osxaqua == "1"} {
838
###############################################################################
843
set cmd "d.nviz -i --ui"
848
###############################################################################
851
proc Dm::xganim { } {
858
###############################################################################
863
# set cmd "d.erase white"
869
###############################################################################
879
###############################################################################
882
proc Dm::display_node { node } {
885
set type [Dm::node_type $node]
889
DmGroup::display $node
892
DmRaster::display $node
895
DmLabels::display $node
898
DmVector::display $node
904
DmGridline::display $node
907
DmRgbhis::display $node
910
DmLegend::display $node
913
DmDframe::display $node
916
DmBarscale::display $node
919
DmChart::display $node
922
DmThematic::display $node
925
DmFTtext::display $node
928
DmDtext::display $node
933
###############################################################################
936
proc Dm::print_node { file node } {
938
global raster_printed
940
set type [Dm::node_type $node]
944
DmGroup::print $file $node
947
if { ! $raster_printed } {
948
DmRaster::print $file $node
953
DmLabels::print $file $node
956
DmVector::print $file $node
959
puts "Command may not be printed to postscript file"
962
puts "not be printed to postscript file"
965
puts "not be printed to postscript file"
968
puts "not be printed to postscript file"
971
puts "not be printed to postscript file"
974
puts "not be printed to postscript file"
977
puts "not be printed to postscript file"
980
puts "not be printed to postscript file"
983
puts "not be printed to postscript file"
986
puts "not be printed to postscript file"
991
###############################################################################
998
set sel [ lindex [$tree selection get] 0 ]
999
if { $sel == "" } { return }
1001
set type [Dm::node_type $sel]
1005
DmRaster::query $sel
1008
DmLabels::query $sel
1011
DmVector::query $sel
1020
DmRgbhis::query $sel
1047
###############################################################################
1049
# duplicate selected layer
1050
proc Dm::duplicate { } {
1054
global new_root_node
1056
if { [catch {match string {} $new_root_node}] } {
1057
set new_root_node root
1060
set parent_node [ lindex [$tree selection get] 0 ]
1061
if { $parent_node == "" } {
1062
set parent_node $new_root_node
1065
set parent_type [Dm::node_type $parent_node]
1066
if { $parent_type != "group" } {
1067
set parent_node [$tree parent $parent_node]
1070
set sel [ lindex [$tree selection get] 0 ]
1071
if { $sel == "" } { return }
1073
set type [Dm::node_type $sel]
1074
set id [Dm::node_id $sel]
1078
DmRaster::duplicate $tree $parent_node $sel $id
1081
DmLabels::duplicate $tree $parent_node $sel $id
1084
DmVector::duplicate $tree $parent_node $sel $id
1087
DmCmd::duplicate $tree $parent_node $sel $id
1090
DmGridline::duplicate $tree $parent_node $sel $id
1093
DmRgbhis::duplicate $tree $parent_node $sel $id
1096
DmLegend::duplicate $tree $parent_node $sel $id
1099
DmDframe::duplicate $tree $parent_node $sel $id
1102
DmBarscale::duplicate $tree $parent_node $sel $id
1105
DmChart::duplicate $tree $parent_node $sel $id
1108
DmThematic::duplicate $tree $parent_node $sel $id
1111
DmFTtext::duplicate $tree $parent_node $sel $id
1114
DmDtext::duplicate $tree $parent_node $sel $id
1117
DmGroup::duplicate $tree $parent_node $sel $id
1123
###############################################################################
1125
# save tree/options to file
1126
proc Dm::save { spth } {
1127
global gisdbase location_name mapset
1133
set rcfile [open $fpath w]
1136
DmGroup::save $tree 0 "root"
1141
###############################################################################
1144
proc Dm::save_node { depth node } {
1148
set type [Dm::node_type $node]
1149
set name [$tree itemcget $node -text]
1151
if { $type == "group" && $name == "UNTITLED" } {
1152
set name "File $::Dm::filename"
1157
Dm::rc_write $depth Group $name
1159
DmGroup::save $tree $depth $node
1162
Dm::rc_write $depth Raster $name
1164
DmRaster::save $tree $depth $node
1167
Dm::rc_write $depth Labels $name
1169
DmLabels::save $tree $depth $node
1172
Dm::rc_write $depth Vector $name
1174
DmVector::save $tree $depth $node
1177
Dm::rc_write $depth Cmd $name
1179
DmCmd::save $tree $depth $node
1182
Dm::rc_write $depth gridline $name
1184
DmGridline::save $tree $depth $node
1187
Dm::rc_write $depth rgbhis $name
1189
DmRgbhis::save $tree $depth $node
1192
Dm::rc_write $depth legend $name
1194
DmLegend::save $tree $depth $node
1197
Dm::rc_write $depth dframe $name
1199
DmDframe::save $tree $depth $node
1202
Dm::rc_write $depth barscale $name
1204
DmBarscale::save $tree $depth $node
1207
Dm::rc_write $depth chart $name
1209
DmChart::save $tree $depth $node
1212
Dm::rc_write $depth thematic $name
1214
DmThematic::save $tree $depth $node
1217
Dm::rc_write $depth fttext $name
1219
DmFTtext::save $tree $depth $node
1222
Dm::rc_write $depth dtext $name
1224
DmDtext::save $tree $depth $node
1227
set depth [expr $depth - 1]
1228
Dm::rc_write $depth End
1232
###############################################################################
1234
# load tree/options from file
1235
proc Dm::load { lpth } {
1236
global gisdbase location_name mapset
1240
variable max_prgindic
1243
set prgtext "Loading layers..."
1247
if { ![file exist $fpath] || ![file readable $fpath] } {
1251
set rcfile [open $fpath r]
1252
set file_size [file size $fpath]
1253
set nrows [expr $file_size / 15]
1258
while { [gets $rcfile in] > -1 } {
1261
set in [string trim $in " "]
1262
if { $in == "" } { continue }
1264
if { ![regexp -- {([^ ]+) (.+)$} $in r key val] } {
1269
if { $print_section } {
1270
if { $key == "End" } {
1273
DmPrint::set_option $key $val
1276
if { $key == "Print" } {
1283
if { [regexp -- {^File (.+)} $val r leftover] && ($leftover !=
1285
set val "<-- $leftover"
1288
set current_node [DmGroup::create $tree $parent]
1289
$tree itemconfigure $current_node -text $val
1290
set parent $current_node
1293
set current_node [DmRaster::create $tree $parent]
1294
$tree itemconfigure $current_node -text $val
1297
set current_node [DmLabels::create $tree $parent]
1298
$tree itemconfigure $current_node -text $val
1301
set current_node [DmVector::create $tree $parent]
1302
$tree itemconfigure $current_node -text $val
1305
set current_node [DmCmd::create $tree $parent]
1306
$tree itemconfigure $current_node -text $val
1309
set current_node [DmGridline::create $tree $parent]
1310
$tree itemconfigure $current_node -text $val
1313
set current_node [DmRgbhis::create $tree $parent]
1314
$tree itemconfigure $current_node -text $val
1317
set current_node [DmLegend::create $tree $parent]
1318
$tree itemconfigure $current_node -text $val
1321
set current_node [DmDframe::create $tree $parent]
1322
$tree itemconfigure $current_node -text $val
1325
set current_node [DmBarscale::create $tree $parent]
1326
$tree itemconfigure $current_node -text $val
1329
set current_node [DmChart::create $tree $parent]
1330
$tree itemconfigure $current_node -text $val
1333
set current_node [DmThematic::create $tree $parent]
1334
$tree itemconfigure $current_node -text $val
1337
set current_node [DmFTtext::create $tree $parent]
1338
$tree itemconfigure $current_node -text $val
1341
set current_node [DmDtext::create $tree $parent]
1342
$tree itemconfigure $current_node -text $val
1345
set type [Dm::node_type $current_node]
1346
if { $type == "group" } {
1347
set parent [$tree parent $parent]
1349
set current_node [$tree parent $current_node]
1352
if {[catch {Dm::node_type $current_node}] } {
1353
tk_messageBox -type ok -message "Can't open $fpath - bad file format"
1357
set type [Dm::node_type $current_node]
1360
DmGroup::set_option $current_node $key $val
1363
DmRaster::set_option $current_node $key $val
1366
DmLabels::set_option $current_node $key $val
1369
DmVector::set_option $current_node $key $val
1372
DmCmd::set_option $current_node $key $val
1375
DmGridline::set_option $current_node $key $val
1378
DmRgbhis::set_option $current_node $key $val
1381
DmLegend::set_option $current_node $key $val
1384
DmDframe::set_option $current_node $key $val
1387
DmBarscale::set_option $current_node $key $val
1390
DmChart::set_option $current_node $key $val
1393
DmThematic::set_option $current_node $key $val
1396
DmFTtext::set_option $current_node $key $val
1399
DmDtext::set_option $current_node $key $val
1407
set prg [expr $max_prgindic * $row / $nrows]
1408
if { $prg > $max_prgindic } { set prg $max_prgindic }
1409
set Dm::prgindic $prg
1413
set Dm::prgindic $max_prgindic
1414
set prgtext "Layers loaded"
1417
###############################################################################
1420
proc Dm::rc_write { depth args } {
1423
set offset [string repeat " " $depth]
1425
set key [lindex $args 0]
1426
if { [llength $args] > 1 } {
1427
set value [lindex $args 1]
1428
set row "$offset$key $value"
1430
set row "$offset$key"
1435
###############################################################################
1438
proc Dm::node_type { node } {
1441
if { [string compare $node "root"] == 0 } {
1444
if { [string match group* $node] } {
1447
if { [string match raster* $node] } {
1450
if { [string match labels* $node] } {
1453
if { [string match vector* $node] } {
1456
if { [string match cmd* $node] } {
1459
if { [string match gridline* $node] } {
1462
if { [string match rgbhis* $node] } {
1465
if { [string match legend* $node] } {
1468
if { [string match dframe* $node] } {
1471
if { [string match barscale* $node] } {
1474
if { [string match chart* $node] } {
1477
if { [string match thematic* $node] } {
1480
if { [string match fttext* $node] } {
1483
if { [string match dtext* $node] } {
1490
###############################################################################
1493
proc Dm::node_id { node } {
1496
if { ![regexp {[^:]+:(.+)$} $node x id] } {
1503
###############################################################################
1506
proc Dm::execute { cmd } {
1509
# warning: DBMI - be careful and test 'd.vect where=' after changes
1512
## This was old version - does not work, because $shell have not LD_LIBRARY_PATH to GRASS libs ?
1513
#set shell $env(SHELL)
1514
#set cmd [ string map { \" \\\" \$ \\\$ } $cmd ]
1515
#eval "exec echo \"$cmd\" | $shell >@stdout 2>@stdout"
1517
eval "exec $cmd >@stdout 2>@stdout"
1520
###############################################################################
1523
proc Dm::print { } {
1527
###############################################################################
1530
proc Dm::OpenFileBox {w} {
1536
if { $win == ""} {set win $mainwindow}
1539
{{Adm Resource Files} {{.dm} {.dmrc}}}
1543
if {[catch {tk_getOpenFile \
1546
-title {Load File}} \
1547
::Dm::filename_new] || \
1548
[string match {} $::Dm::filename_new]} return
1550
if {[catch {if { [ regexp -- {^Untitled.dmrc$} $::Dm::filename r]} {}}] } {
1551
set ::Dm::filename $::Dm::filename_new
1554
Dm::load $::Dm::filename_new
1558
###############################################################################
1561
proc Dm::SaveFileBox {w} {
1566
if { $win == ""} {set win $mainwindow}
1567
catch {if { [ regexp -- {^Untitled.dmrc$} $::Dm::filename r]} {unset ::Dm::filename}}
1568
if {[catch {Dm::save $::Dm::filename}]} {
1570
{{Adm Resource Files} {{.dm} {.dmrc}}}
1573
if {[catch {tk_getSaveFile \
1576
-title {Save File}} \
1577
::Dm::filename] || \
1578
[string match {} $::Dm::filename]} return
1580
Dm::save $::Dm::filename
1581
Dm::FileClose stay_alive
1582
Dm::load $::Dm::filename
1586
###############################################################################
1588
proc main {argc argv} {
1591
global location_name
1595
wm title . [G_msg "GRASS $GRASSVERSION GIS Manager - $location_name"]
1597
bind . <$keycontrol-Key-o> {
1600
bind . <$keycontrol-Key-n> {
1603
bind . <$keycontrol-Key-s> {
1606
bind . <$keycontrol-Key-q> {
1607
DmPrint::clean; exit
1609
bind . <$keycontrol-Key-x> {
1612
bind . <$keycontrol-Key-w> {
1615
bind . <$keycontrol-Key-p> {
1622
DmPrint::init_tmpfiles
1623
BWidget::place . 0 0 center
1629
if { $argc == "1"} {
1630
set ::Dm::filename $argv
1631
Dm::load $::Dm::filename
1636
bind . <Destroy> { if { "%W" == "."} { DmPrint::clean } }
1638
wm geom . [wm geom .]