~ubuntu-branches/ubuntu/wily/grass/wily

« back to all changes in this revision

Viewing changes to gui/tcltk/d.m/vector.tcl

Tags: 7.0.0~rc1+ds1-1~exp1
* New upstream release candidate.
* Repack upstream tarball, remove precompiled Python objects.
* Add upstream metadata.
* Update gbp.conf and Vcs-Git URL to use the experimental branch.
* Update watch file for GRASS 7.0.
* Drop build dependencies for Tcl/Tk, add build dependencies:
  python-numpy, libnetcdf-dev, netcdf-bin, libblas-dev, liblapack-dev
* Update Vcs-Browser URL to use cgit instead of gitweb.
* Update paths to use grass70.
* Add configure options: --with-netcdf, --with-blas, --with-lapack,
  remove --with-tcltk-includes.
* Update patches for GRASS 7.
* Update copyright file, changes:
  - Update copyright years
  - Group files by license
  - Remove unused license sections
* Add patches for various typos.
* Fix desktop file with patch instead of d/rules.
* Use minimal dh rules.
* Bump Standards-Version to 3.9.6, no changes.
* Use dpkg-maintscript-helper to replace directories with symlinks.
  (closes: #776349)
* Update my email to use @debian.org address.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# 18 March 2005
2
 
 
3
 
namespace eval DmVector {
4
 
    variable array opt # vector options
5
 
    variable count 1
6
 
}
7
 
 
8
 
 
9
 
proc DmVector::legend { id } {
10
 
    variable opt
11
 
   
12
 
    set lh $DmTree::legend_height
13
 
    set lw $DmTree::legend_width
14
 
    set mar 2
15
 
    set leg $opt($id,_legend)
16
 
 
17
 
    $leg delete all
18
 
 
19
 
    # point 
20
 
    set xc [expr $lw / 6 + 1 ]
21
 
    set yc [expr $lh / 2 ]
22
 
    set size $opt($id,size)
23
 
   
24
 
    set maxpsize  [expr $lw / 3 - 2 ]
25
 
    if { $size > $maxpsize } { set size $maxpsize }
26
 
    set x1 [expr $xc - $size / 2 ]
27
 
    set x2 [expr $xc + $size / 2 + 1 ]
28
 
    set y1  [expr $yc - $size / 2 ]
29
 
    set y2  [expr $yc + $size / 2 + 1 ]
30
 
 
31
 
    if { $opt($id,type_point) || $opt($id,type_centroid) } {
32
 
        $leg create line $x1 $yc $x2 $yc -fill $opt($id,color)
33
 
        $leg create line $xc $y1 $xc $y2 -fill $opt($id,color)
34
 
    }
35
 
    # line    
36
 
    if { $opt($id,type_line) || $opt($id,type_boundary) || $opt($id,type_face) } {
37
 
        set x1 [expr $lw / 3 + $mar ]
38
 
        set x2 [expr 2 * $lw / 3 - $mar ]
39
 
        set y1 [expr $lh - $mar ]
40
 
        set y2 [expr $mar ]
41
 
        $leg create line $x1 $y1 $x2 $y2 -fill $opt($id,color)
42
 
    }
43
 
    # area    
44
 
    if { $opt($id,type_area) } {
45
 
        set x1 [expr 2 * $lw / 3 + $mar ]
46
 
        set x2 [expr $lw - $mar ]
47
 
        set y1 [expr $mar ]
48
 
        set y2 [expr $lh - $mar ]
49
 
        $leg create rectangle $x1 $y1 $x2 $y2 -outline $opt($id,color) \
50
 
                              -fill $opt($id,fcolor)
51
 
    }
52
 
}
53
 
 
54
 
proc DmVector::create { tree parent } {
55
 
    global form_mode
56
 
    variable opt
57
 
    variable count
58
 
 
59
 
    set node "vector:$count"
60
 
 
61
 
    set frm [ frame .vectoricon$count]
62
 
    set fon [font create -size 10] 
63
 
    set check [checkbutton $frm.check -font $fon \
64
 
                           -variable DmVector::opt($count,_check) \
65
 
                           -height 1 -padx 0 -width 0]
66
 
    set can [ canvas $frm.c -width $DmTree::legend_width \
67
 
                     -height $DmTree::legend_height ]
68
 
    set opt($count,_legend) $can
69
 
    pack $check $can -side left
70
 
 
71
 
    $tree insert end $parent $node \
72
 
        -text      "vector $count" \
73
 
        -window    $frm \
74
 
        -drawcross auto 
75
 
 
76
 
    set opt($count,_check) 1 
77
 
 
78
 
    set opt($count,map) "" 
79
 
    set opt($count,display_shape) 1 
80
 
    set opt($count,display_cat) 0
81
 
    set opt($count,display_topo) 0 
82
 
    set opt($count,display_dir) 0 
83
 
    set opt($count,display_attr) 0
84
 
    set opt($count,type_point) 1 
85
 
    set opt($count,type_line) 1
86
 
    set opt($count,type_boundary) 1
87
 
    set opt($count,type_centroid) 1
88
 
    set opt($count,type_area) 1
89
 
    set opt($count,type_face) 0 
90
 
 
91
 
    set opt($count,color) \#000000
92
 
    set opt($count,sqlcolor) 0
93
 
    set opt($count,rdmcolor) 0
94
 
    set opt($count,fcolor) \#AAAAAA 
95
 
    set opt($count,lcolor) \#000000
96
 
    set opt($count,_use_color) 1
97
 
    set opt($count,_use_fcolor) 1
98
 
    set opt($count,lwidth) 1 
99
 
 
100
 
    set opt($count,symdir) "basic"
101
 
    set opt($count,icon) "basic/x"
102
 
    set opt($count,size) 5 
103
 
 
104
 
    set opt($count,field) 1 
105
 
    set opt($count,lfield) 1 
106
 
    set opt($count,cat) "" 
107
 
    set opt($count,where) "" 
108
 
    set opt($count,_use_where) 1
109
 
 
110
 
    set opt($count,attribute) "" 
111
 
    set opt($count,xref) "left"
112
 
    set opt($count,yref) "center"
113
 
    set opt($count,lsize) 8
114
 
 
115
 
    set opt($count,minreg) "" 
116
 
    set opt($count,maxreg) "" 
117
 
 
118
 
    # Default form mode used for vectors, it can be 'gui' (default) or 'txt'
119
 
    set form_mode [exec g.gisenv get=DM_FORM_MODE]
120
 
    if { $form_mode == "txt" } {
121
 
        set opt($count,_query_text) 1 
122
 
    } else {
123
 
        set opt($count,_query_text) 0
124
 
    }
125
 
    set opt($count,_query_edit) 0 
126
 
 
127
 
    set opt($count,_width) 1
128
 
 
129
 
    DmVector::legend $count
130
 
 
131
 
    incr count
132
 
    return $node
133
 
}
134
 
 
135
 
proc DmVector::set_option { node key value } {
136
 
    variable opt
137
 
 
138
 
    set id [Dm::node_id $node]
139
 
    set opt($id,$key) $value
140
 
 
141
 
    DmVector::legend $id
142
 
}
143
 
 
144
 
proc DmVector::select_map { id } {
145
 
    set m [GSelect vector]
146
 
    if { $m != "" } { 
147
 
        set DmVector::opt($id,map) $m
148
 
        Dm::autoname $m
149
 
    }
150
 
}
151
 
 
152
 
proc DmVector::show_columns { id } {
153
 
        variable opt
154
 
        global bgcolor
155
 
        set mapname $opt($id,map)
156
 
        set layernum $opt($id,field)
157
 
        set cmd "v.info -c map=$mapname layer=$layernum"
158
 
        run_panel $cmd
159
 
}
160
 
 
161
 
proc DmVector::show_data { id } {
162
 
        variable opt
163
 
        global bgcolor
164
 
        set mapname $opt($id,map)
165
 
        set layernum $opt($id,field)
166
 
        if {![catch {open "|v.db.connect map=$mapname layer=$layernum -g" r} vdb]} {
167
 
                set vectdb [read $vdb]
168
 
                catch {close $vdb}
169
 
                set vdblist [split $vectdb " "]
170
 
                set tbl [lindex $vdblist 1]
171
 
                set db [lindex $vdblist 3]
172
 
                set drv [lindex $vdblist 4]
173
 
                set cmd "db.select table=$tbl database=$db driver=$drv"
174
 
                run_panel $cmd
175
 
        }
176
 
}
177
 
 
178
 
# select symbols from directories
179
 
proc DmVector::select_symbol { id } {
180
 
    variable opt
181
 
    set i [GSelect symbol]
182
 
    if { $i != "" } {
183
 
        set DmVector::opt($id,icon) $i
184
 
    }
185
 
}
186
 
 
187
 
# display vector options
188
 
proc DmVector::options { id frm } {
189
 
    variable opt
190
 
    global dmpath
191
 
    global bgcolor
192
 
    global mapname
193
 
    set mapname ""
194
 
 
195
 
    # vector name
196
 
    set row [ frame $frm.name ]
197
 
    Button $row.a -text [G_msg "Vector name:"] \
198
 
           -command "DmVector::select_map $id"
199
 
    Entry $row.b -width 40 -text "$opt($id,map)" \
200
 
          -textvariable DmVector::opt($id,map) \
201
 
          -background white
202
 
    Button $row.c -text [G_msg "Help"] \
203
 
            -image [image create photo -file "$dmpath/grass.gif"] \
204
 
            -command "run g.manual d.vect" \
205
 
            -background $bgcolor \
206
 
            -helptext [G_msg "Help"]
207
 
    pack $row.a $row.b $row.c -side left
208
 
    pack $row -side top -fill both -expand yes
209
 
 
210
 
    # display
211
 
    set row [ frame $frm.disp ]
212
 
    Label $row.a -text [G_msg "Display:"]
213
 
    checkbutton $row.b -text [G_msg "shapes"] -variable DmVector::opt($id,display_shape) \
214
 
                -command "DmVector::legend $id"
215
 
    checkbutton $row.c -text [G_msg "categories"] -variable DmVector::opt($id,display_cat) \
216
 
                -command "DmVector::legend $id"
217
 
    checkbutton $row.d -text [G_msg "topology"] -variable DmVector::opt($id,display_topo) \
218
 
                -command "DmVector::legend $id"
219
 
    checkbutton $row.e -text [G_msg "line directions"] -variable DmVector::opt($id,display_dir) \
220
 
                -command "DmVector::legend $id"
221
 
    pack $row.a $row.b $row.c $row.d $row.e -side left
222
 
    pack $row -side top -fill both -expand yes
223
 
 
224
 
    # type
225
 
    set row [ frame $frm.type ]
226
 
    Label $row.a -text [G_msg "            "]
227
 
    checkbutton $row.b -text [G_msg "points"] -variable DmVector::opt($id,type_point) \
228
 
                -command "DmVector::legend $id"
229
 
    checkbutton $row.c -text [G_msg "lines"] -variable DmVector::opt($id,type_line) \
230
 
                -command "DmVector::legend $id"
231
 
    checkbutton $row.d -text [G_msg "boundaries"] -variable DmVector::opt($id,type_boundary) \
232
 
                -command "DmVector::legend $id"
233
 
    checkbutton $row.e -text [G_msg "centroids"] -variable DmVector::opt($id,type_centroid)\
234
 
                -command "DmVector::legend $id"
235
 
    checkbutton $row.f -text [G_msg "areas"] -variable DmVector::opt($id,type_area) \
236
 
                -command "DmVector::legend $id"
237
 
    checkbutton $row.g -text [G_msg "faces"] -variable DmVector::opt($id,type_face) \
238
 
                -command "DmVector::legend $id"
239
 
    pack $row.a $row.b $row.c $row.d $row.e $row.f $row.g -side left
240
 
    pack $row -side top -fill both -expand yes
241
 
 
242
 
    # points
243
 
    set row [ frame $frm.icon ]  
244
 
    Label $row.a -text "Point symbols:" 
245
 
    Button $row.b -text [G_msg "icon"] \
246
 
            -command "DmVector::select_symbol $id"
247
 
    Entry $row.c -width 15 -text "$opt($id,icon)" \
248
 
                -textvariable DmVector::opt($id,icon) \
249
 
                -background white 
250
 
    Label $row.d -text "  size" 
251
 
    SpinBox $row.e -range {1 50 1} -textvariable DmVector::opt($id,size) \
252
 
                   -width 2 -helptext "Icon size" -modifycmd "DmVector::legend $id" \
253
 
                   -entrybg white 
254
 
    pack $row.a $row.b $row.c $row.d $row.e -side left
255
 
    pack $row -side top -fill both -expand yes
256
 
 
257
 
    # lines
258
 
    set row [ frame $frm.color ]
259
 
    Label $row.a -text [G_msg "Draw lines:"] 
260
 
    checkbutton $row.b -variable DmVector::opt($id,_use_color) \
261
 
                -command "DmVector::legend $id"
262
 
    Label $row.c -text [G_msg "color"] 
263
 
    SelectColor $row.d  -type menubutton -variable DmVector::opt($id,color) \
264
 
               -command "DmVector::legend $id"
265
 
    Label $row.e -text " width" 
266
 
    SpinBox $row.f -range {1 50 1} -textvariable DmVector::opt($id,lwidth) \
267
 
                   -entrybg white -width 2 -helptext "Line width" \
268
 
                   -modifycmd "DmVector::legend $id"
269
 
    Label $row.g -text "(pixels) " 
270
 
    pack $row.a $row.b $row.c $row.d $row.e $row.f $row.g -side left
271
 
    pack $row -side top -fill both -expand yes
272
 
 
273
 
    # fills
274
 
    set row [ frame $frm.multicolor ]
275
 
    Label $row.a -text [G_msg "Fill areas:"] 
276
 
    checkbutton $row.b -variable DmVector::opt($id,_use_fcolor) \
277
 
                -command "DmVector::legend $id"
278
 
    Label $row.c -text [G_msg "color"] 
279
 
    SelectColor $row.d -type menubutton -variable DmVector::opt($id,fcolor) \
280
 
                -command "DmVector::legend $id"
281
 
    Label $row.e -text [G_msg "  "] 
282
 
    checkbutton $row.f -text [G_msg "random colors"] -variable DmVector::opt($id,rdmcolor) \
283
 
                -command "DmVector::legend $id"
284
 
    checkbutton $row.g -text [G_msg "GRASSRGB column colors"] -variable DmVector::opt($id,sqlcolor) \
285
 
                -command "DmVector::legend $id"
286
 
    pack $row.a $row.b $row.c $row.d $row.e $row.f $row.g -side left
287
 
    pack $row -side top -fill both -expand yes
288
 
 
289
 
    # labels
290
 
    set row [ frame $frm.label ]
291
 
    Label $row.a -text [G_msg "Label vectors:"] 
292
 
    checkbutton $row.b -text [G_msg "label"] -variable DmVector::opt($id,display_attr) \
293
 
                -command "DmVector::legend $id"
294
 
    Label $row.c -text [G_msg "color"] 
295
 
    SelectColor $row.d -type menubutton -variable DmVector::opt($id,lcolor) \
296
 
                -command "DmVector::legend $id"
297
 
    Label $row.e -text [G_msg " size"] 
298
 
    SpinBox $row.f -range {1 50 1} -textvariable DmVector::opt($id,lsize) \
299
 
                   -width 2 -helptext [G_msg "text size"] \
300
 
                   -modifycmd "DmVector::legend $id" -entrybg white 
301
 
    ComboBox $row.g -label [G_msg " align with pt"] \
302
 
                    -width 6  -textvariable DmVector::opt($id,xref) \
303
 
                    -entrybg white \
304
 
                    -values {"left" "center" "right"} \
305
 
                    -modifycmd "DmVector::legend $id"
306
 
    ComboBox $row.h -width 6  -textvariable DmVector::opt($id,yref) \
307
 
                    -entrybg white \
308
 
                    -values {"top" "center" "bottom"} \
309
 
                    -modifycmd "DmVector::legend $id"
310
 
    pack $row.a $row.b $row.c $row.d $row.e $row.f $row.g $row.h -side left
311
 
    pack $row -side top -fill both -expand yes
312
 
 
313
 
    # labels layer and attribute column
314
 
    set row [ frame $frm.attribute ]
315
 
    LabelEntry $row.a -label [G_msg "     layer for labels"] \
316
 
                -textvariable DmVector::opt($id,lfield) -width 3 \
317
 
                -entrybg white
318
 
    LabelEntry $row.b -label [G_msg " attribute col for labels"] \
319
 
                -textvariable DmVector::opt($id,attribute) -width 26 \
320
 
                -entrybg white
321
 
    pack $row.a $row.b -side left
322
 
    pack $row -side top -fill both -expand yes
323
 
 
324
 
    # category
325
 
    set row [ frame $frm.cat ]
326
 
    Label $row.a -text [G_msg "Query vectors: "] 
327
 
    LabelEntry $row.b -label [G_msg "layer for query"] \
328
 
                -textvariable DmVector::opt($id,field) -width 3 \
329
 
                -entrybg white
330
 
    LabelEntry $row.c -label [G_msg " query cat values"] \
331
 
                -textvariable DmVector::opt($id,cat) \
332
 
               -width 5 -entrybg white
333
 
    checkbutton $row.d -text [G_msg "SQL query"] -variable DmVector::opt($id,_use_where) \
334
 
                -command "DmVector::legend $id"
335
 
    pack $row.a $row.b $row.c $row.d -side left
336
 
    pack $row -side top -fill both -expand yes
337
 
 
338
 
    # sql where
339
 
    set row [ frame $frm.where ]
340
 
    LabelEntry $row.a -label [G_msg "     SQL where statement"] \
341
 
                -textvariable DmVector::opt($id,where) \
342
 
               -width 44 -entrybg white
343
 
    pack $row.a -side left
344
 
    pack $row -side top -fill both -expand yes
345
 
    
346
 
        #show columns and data
347
 
        set row [ frame $frm.columns ]
348
 
    Label $row.a -text [G_msg "    show attribute columns"] 
349
 
    Button $row.b -text [G_msg "columns"] \
350
 
            -image [image create photo -file "$dmpath/columns.gif"] \
351
 
            -command "DmVector::show_columns $id" \
352
 
            -background $bgcolor \
353
 
            -helptext [G_msg "Show columns"]
354
 
    Label $row.c -text [G_msg "     show data"] 
355
 
    Button $row.d -text [G_msg "data"] \
356
 
            -image [image create photo -file "$dmpath/columns.gif"] \
357
 
            -command "DmVector::show_data $id" \
358
 
            -background $bgcolor \
359
 
            -helptext [G_msg "Show data"]
360
 
    pack $row.a $row.b $row.c $row.d -side left
361
 
    pack $row -side top -fill both -expand yes
362
 
 
363
 
 
364
 
    # mouse query setup
365
 
    set row [ frame $frm.query ]
366
 
    Label $row.a -text [G_msg "Mouse query setup:"]
367
 
    checkbutton $row.b -text [G_msg "edit attributes (form mode)"] \
368
 
                -variable DmVector::opt($id,_query_edit) 
369
 
    checkbutton $row.c -text [G_msg "results as text in terminal"] \
370
 
                -variable DmVector::opt($id,_query_text) 
371
 
    pack $row.a $row.b $row.c -side left
372
 
    pack $row -side top -fill both -expand yes
373
 
 
374
 
    # display only in limited region size range
375
 
    set row [ frame $frm.region ]
376
 
    Label $row.a -text [G_msg "Display when avg. region dimension is"]
377
 
    LabelEntry $row.b -label ">" -textvariable DmVector::opt($id,minreg) \
378
 
                -width 8 -entrybg white
379
 
    LabelEntry $row.c -label " or <" -textvariable DmVector::opt($id,maxreg) \
380
 
                -width 8 -entrybg white
381
 
    pack $row.a $row.b $row.c -side left
382
 
    pack $row -side top -fill both -expand yes
383
 
 
384
 
    # Width
385
 
    set row [ frame $frm.print ]
386
 
    Label $row.a -text [G_msg "Line width for ps.map print output:"] 
387
 
    SpinBox $row.b -range {1 100 1} -textvariable DmVector::opt($id,_width) \
388
 
                   -width 2 -helptext [G_msg "Line width used for printing"] \
389
 
                   -entrybg white 
390
 
    pack $row.a $row.b -side left
391
 
    pack $row -side top -fill both -expand yes
392
 
}
393
 
 
394
 
proc DmVector::save { tree depth node } {
395
 
    variable opt
396
 
    
397
 
    set id [Dm::node_id $node]
398
 
 
399
 
 
400
 
    foreach key { _check map display_shape display_cat display_topo display_dir display_attr
401
 
                  type_point type_line type_boundary type_centroid type_area type_face
402
 
                  color _use_color fcolor _use_fcolor lcolor rdmcolor sqlcolor icon size lwidth field lfield attribute
403
 
                  xref yref lsize cat where _query_text _query_edit _use_where minreg maxreg _width } {
404
 
        Dm::rc_write $depth "$key $opt($id,$key)"
405
 
    } 
406
 
}
407
 
 
408
 
 
409
 
proc DmVector::display { node } {
410
 
    variable opt
411
 
    
412
 
    set tree $Dm::tree
413
 
    set id [Dm::node_id $node]
414
 
 
415
 
    if { ! ( $opt($id,_check) ) } { return } 
416
 
 
417
 
    if { $opt($id,map) == "" } { return } 
418
 
 
419
 
    if { !$opt($id,display_shape) && !$opt($id,display_cat) &&
420
 
         !$opt($id,display_topo)  && !$opt($id,display_dir) &&
421
 
         !$opt($id,display_attr) } { return } 
422
 
 
423
 
    if { !$opt($id,type_point) && !$opt($id,type_line) &&
424
 
         !$opt($id,type_boundary)  && !$opt($id,type_centroid) && 
425
 
         !$opt($id,type_area) && !$opt($id,type_face) } { return } 
426
 
 
427
 
    set cmd "d.vect map=$opt($id,map)"
428
 
 
429
 
    # color
430
 
    if { $opt($id,rdmcolor) } { append cmd " -c" }
431
 
    if { $opt($id,sqlcolor) } { append cmd " -a" }
432
 
    set color [Dm::color $opt($id,color)]
433
 
    set fcolor [Dm::color $opt($id,fcolor)]
434
 
    set lcolor [Dm::color $opt($id,lcolor)]
435
 
 
436
 
    if { $opt($id,_use_color) } { append cmd " color=$color" } { append cmd " color=none" }
437
 
    append cmd " lcolor=$lcolor" 
438
 
 
439
 
    if { $opt($id,_use_fcolor) } { append cmd " fcolor=$fcolor" } { append cmd " fcolor=none" }
440
 
 
441
 
    # display
442
 
    set dlist [list]
443
 
    foreach d { shape cat topo dir } {
444
 
       if { $opt($id,display_$d) } { lappend dlist $d }
445
 
    }
446
 
    if { $opt($id,display_attr) && $opt($id,attribute) != "" } { lappend dlist attr }
447
 
    
448
 
    set display [join $dlist , ]
449
 
    append cmd " display=$display"
450
 
 
451
 
    # type
452
 
    set tlist [list]
453
 
    foreach t { point line boundary centroid area face } {
454
 
       if { $opt($id,type_$t) } { lappend tlist $t }
455
 
    }
456
 
    set type [join $tlist , ]
457
 
    append cmd " type=$type"
458
 
 
459
 
    append cmd " icon=$opt($id,icon) size=$opt($id,size)" 
460
 
 
461
 
    if { $opt($id,lwidth) != 1 } { 
462
 
        append cmd " width=$opt($id,lwidth)" 
463
 
    } 
464
 
 
465
 
 
466
 
    if { $opt($id,field) != "" } { 
467
 
        append cmd " layer=$opt($id,field)" 
468
 
    } 
469
 
    if { $opt($id,attribute) != "" && $opt($id,display_attr) } { 
470
 
        append cmd " {att=$opt($id,attribute)}" 
471
 
    } 
472
 
    append cmd " lsize=$opt($id,lsize)" 
473
 
    
474
 
    append cmd " xref=$opt($id,xref) yref=$opt($id,yref)"
475
 
 
476
 
    if { $opt($id,lfield) != "" } { 
477
 
        append cmd " llayer=$opt($id,lfield)" 
478
 
    } 
479
 
    if { $opt($id,cat) != "" } { 
480
 
        append cmd " cat=$opt($id,cat)" 
481
 
    } 
482
 
    if { $opt($id,where) != "" && $opt($id,_use_where) } { 
483
 
        append cmd " {where=$opt($id,where)}" 
484
 
    } 
485
 
    if { $opt($id,minreg) != "" } { 
486
 
        append cmd " minreg=$opt($id,minreg)" 
487
 
    } 
488
 
    if { $opt($id,maxreg) != "" } { 
489
 
        append cmd " maxreg=$opt($id,maxreg)" 
490
 
    } 
491
 
 
492
 
    run_panel $cmd
493
 
}
494
 
 
495
 
proc DmVector::print { file node } {
496
 
    variable opt
497
 
 
498
 
    set tree $Dm::tree
499
 
    set id [Dm::node_id $node]
500
 
 
501
 
    if { ! $opt($id,_check) } { return } 
502
 
    if { $opt($id,map) == "" } { return } 
503
 
 
504
 
    if { $opt($id,display_cat) || $opt($id,display_topo) || 
505
 
         $opt($id,display_dir) || $opt($id,display_attr) 
506
 
    } { puts "At least one of selected display options for vector is not supported for PS"  }
507
 
 
508
 
    if { ! $opt($id,display_shape) } { return } 
509
 
 
510
 
    set color [Dm::color $opt($id,color)]
511
 
    set fcolor [Dm::color $opt($id,fcolor)]
512
 
 
513
 
    # Points
514
 
    if { $opt($id,type_point) || $opt($id,type_centroid) } {
515
 
        puts $file "vpoints $opt($id,map)"
516
 
 
517
 
        set str "  type"
518
 
        if { $opt($id,type_point) } { append str " point" }
519
 
        if { $opt($id,type_centroid) } { append str " centroid" }
520
 
        puts $file $str
521
 
 
522
 
        if { $opt($id,field) != "" } { puts $file "  layer $opt($id,field)" }
523
 
        if { $opt($id,cat) != "" }   { puts $file "  cats $opt($id,cat)" }
524
 
        if { $opt($id,where) != "" } { puts $file "  where $opt($id,where)" } 
525
 
 
526
 
            if { $opt($id,_use_color) } { 
527
 
            puts $file "  color $color"
528
 
        } else { 
529
 
            puts $file "  color none"
530
 
        }
531
 
 
532
 
        #puts $file "width $opt($id,ps_width)"
533
 
 
534
 
        if { $opt($id,_use_fcolor) } { 
535
 
            puts $file "  fcolor $fcolor"
536
 
        } else { 
537
 
            puts $file "  fcolor none"
538
 
        }
539
 
 
540
 
        puts $file "  symbol $opt($id,icon)"
541
 
        puts $file "  size $opt($id,size)"
542
 
 
543
 
       # confuses ps.map:
544
 
       # puts $file "  xref $opt($id,xref)"
545
 
       # puts $file "  yref $opt($id,yref)"
546
 
 
547
 
        puts $file "end"
548
 
    } 
549
 
 
550
 
    # Lines
551
 
    if { $opt($id,type_line) || $opt($id,type_boundary) } {
552
 
        puts $file "vlines $opt($id,map)"
553
 
 
554
 
        set str "  type"
555
 
        if { $opt($id,type_line) } { append str " line" }
556
 
        if { $opt($id,type_boundary) } { append str " boundary" }
557
 
        puts $file $str
558
 
 
559
 
        if { $opt($id,field) != "" } { puts $file "  layer $opt($id,field)" }
560
 
        if { $opt($id,cat) != "" }   { puts $file "  cats $opt($id,cat)" }
561
 
        if { $opt($id,where) != "" } { puts $file "  where $opt($id,where)" } 
562
 
 
563
 
        if { $opt($id,_use_color) } { 
564
 
            puts $file "  color $color"
565
 
        } else { 
566
 
            puts $file "  color none"
567
 
        }
568
 
 
569
 
        puts $file "width $opt($id,_width)"
570
 
 
571
 
        puts $file "  hcolor NONE"
572
 
 
573
 
        puts $file "end"
574
 
    } 
575
 
 
576
 
    # Areas
577
 
    if { $opt($id,type_area) } {
578
 
        puts $file "vareas $opt($id,map)"
579
 
 
580
 
        if { $opt($id,field) != "" } { puts $file "  layer $opt($id,field)" }
581
 
        if { $opt($id,cat) != "" }   { puts $file "  cats $opt($id,cat)" }
582
 
        if { $opt($id,where) != "" } { puts $file "  where $opt($id,where)" } 
583
 
 
584
 
        if { $opt($id,_use_color) } { 
585
 
            puts $file "  color $color"
586
 
        } else { 
587
 
            puts $file "  color none"
588
 
        }
589
 
 
590
 
        puts $file "width $opt($id,_width)"
591
 
 
592
 
        if { $opt($id,_use_fcolor) } { 
593
 
            puts $file "  fcolor $fcolor"
594
 
        } else { 
595
 
            puts $file "  fcolor none"
596
 
        }
597
 
 
598
 
        puts $file "end"
599
 
    } 
600
 
}
601
 
 
602
 
proc DmVector::query { node } {
603
 
    variable opt
604
 
    
605
 
    set tree $Dm::tree
606
 
    set id [Dm::node_id $node]
607
 
 
608
 
    if { ! ( $opt($id,_check) ) } { return } 
609
 
 
610
 
    if { $opt($id,map) == "" } { return } 
611
 
 
612
 
    if { !$opt($id,display_shape) && !$opt($id,display_cat) &&
613
 
         !$opt($id,display_topo)  && !$opt($id,display_dir) &&
614
 
         !$opt($id,display_attr) } { return } 
615
 
 
616
 
    if { !$opt($id,type_point) && !$opt($id,type_line) &&
617
 
         !$opt($id,type_boundary)  && !$opt($id,type_centroid) && 
618
 
         !$opt($id,type_area) && !$opt($id,type_face) } { return } 
619
 
 
620
 
    set cmd "d.what.vect -f map=$opt($id,map)"
621
 
    if { $opt($id,_query_text) && !$opt($id,_query_edit) } { 
622
 
        append cmd " -x" 
623
 
    } 
624
 
    if { $opt($id,_query_edit) } { 
625
 
        append cmd " -e" 
626
 
    } 
627
 
 
628
 
    if { $opt($id,_query_text) && !$opt($id,_query_edit) } {
629
 
        term $cmd
630
 
    } else {
631
 
        spawn $cmd
632
 
    }
633
 
}
634
 
 
635
 
proc DmVector::WorkOnVector { node } {
636
 
    variable opt
637
 
    variable bg
638
 
    
639
 
    set tree $Dm::tree
640
 
    set id [Dm::node_id $node]
641
 
 
642
 
    if { ! ( $opt($id,_check) ) } { return } 
643
 
 
644
 
    if { $opt($id,map) == "" } { return } 
645
 
 
646
 
    if { !$opt($id,display_shape) && !$opt($id,display_cat) &&
647
 
         !$opt($id,display_topo)  && !$opt($id,display_dir) &&
648
 
         !$opt($id,display_attr) } { return } 
649
 
 
650
 
    if { !$opt($id,type_point) && !$opt($id,type_line) &&
651
 
         !$opt($id,type_boundary)  && !$opt($id,type_centroid) && 
652
 
         !$opt($id,type_area) && !$opt($id,type_face) } { return } 
653
 
    
654
 
    set bg [exec d.save -o | cut -f1 -d# | tr {\n} {;}]
655
 
    set bg "$bg"
656
 
    Dm::monitor
657
 
    spawn v.digit -n map=$opt($id,map) bgcmd=$bg
658
 
#    spawn $cmd
659
 
}
660
 
 
661
 
proc DmVector::duplicate { tree parent node id } {
662
 
    global form_mode
663
 
    variable opt
664
 
    variable count
665
 
 
666
 
    set node "vector:$count"
667
 
 
668
 
    set frm [ frame .vectoricon$count]
669
 
    set fon [font create -size 10] 
670
 
    set check [checkbutton $frm.check -font $fon \
671
 
                           -variable DmVector::opt($count,_check) \
672
 
                           -height 1 -padx 0 -width 0]
673
 
    set can [ canvas $frm.c -width $DmTree::legend_width \
674
 
                     -height $DmTree::legend_height -borderwidth 0 ]
675
 
    set opt($count,_legend) $can
676
 
    pack $check $can -side left
677
 
 
678
 
        if { $opt($id,map) == ""} {
679
 
        $tree insert end $parent $node \
680
 
                -text      "vector $count" \
681
 
                -window    $frm \
682
 
                -drawcross auto
683
 
        } else {
684
 
            $tree insert end $parent $node \
685
 
                -text      "$opt($id,map)" \
686
 
                -window    $frm \
687
 
                -drawcross auto
688
 
        } 
689
 
 
690
 
    set opt($count,_check) $opt($id,_check)
691
 
 
692
 
    set opt($count,map) "$opt($id,map)" 
693
 
    set opt($count,display_shape) $opt($id,display_shape)
694
 
    set opt($count,display_cat) $opt($id,display_cat)
695
 
    set opt($count,display_topo) $opt($id,display_topo)
696
 
    set opt($count,display_dir) $opt($id,display_dir)
697
 
    set opt($count,display_attr) $opt($id,display_attr)
698
 
    set opt($count,type_point) $opt($id,type_point)
699
 
    set opt($count,type_line) $opt($id,type_line)
700
 
    set opt($count,type_boundary) $opt($id,type_boundary)
701
 
    set opt($count,type_centroid) $opt($id,type_centroid)
702
 
    set opt($count,type_area) $opt($id,type_area)
703
 
    set opt($count,type_face)  $opt($id,type_face)
704
 
 
705
 
    set opt($count,color) $opt($id,color)
706
 
    set opt($count,sqlcolor) $opt($id,sqlcolor)
707
 
    set opt($count,rdmcolor) $opt($id,rdmcolor)
708
 
    set opt($count,fcolor) $opt($id,fcolor)
709
 
    set opt($count,lcolor) $opt($id,lcolor)
710
 
    set opt($count,_use_color) $opt($id,_use_color)
711
 
    set opt($count,_use_fcolor) $opt($id,_use_fcolor)
712
 
 
713
 
    set opt($count,symdir) "$opt($id,symdir)"
714
 
    set opt($count,icon) "$opt($id,icon)"
715
 
    set opt($count,size)  $opt($id,size)
716
 
    set opt($count,lwidth)  $opt($id,lwidth)
717
 
 
718
 
    set opt($count,field) $opt($id,field)
719
 
    set opt($count,lfield) $opt($id,lfield)
720
 
    set opt($count,cat) "$opt($id,cat)"
721
 
    set opt($count,where)  "$opt($id,where)"
722
 
    set opt($count,_use_where) $opt($id,_use_where)
723
 
 
724
 
    set opt($count,attribute) "$opt($id,attribute)"
725
 
    set opt($count,xref) "$opt($id,xref)"
726
 
    set opt($count,yref) "$opt($id,yref)"
727
 
    set opt($count,lsize) $opt($id,lsize)
728
 
 
729
 
    set opt($count,minreg) "$opt($id,minreg)" 
730
 
    set opt($count,maxreg)  "$opt($id,maxreg)"
731
 
 
732
 
    # Default form mode used for vectors, it can be 'gui' (default) or 'txt'
733
 
    set form_mode [exec g.gisenv get=DM_FORM_MODE]
734
 
    if { $form_mode == "txt" } {
735
 
        set opt($count,_query_text) $opt($id,_query_text)
736
 
    } else {
737
 
        set opt($count,_query_text) $opt($id,_query_text)
738
 
    }
739
 
    set opt($count,_query_edit) $opt($id,_query_edit)
740
 
 
741
 
    set opt($count,_width) $opt($id,_width)
742
 
 
743
 
    DmVector::legend $count
744
 
 
745
 
    incr count
746
 
    return $node
747
 
}