-
Notifications
You must be signed in to change notification settings - Fork 6
/
label.tcl
52 lines (40 loc) · 1.3 KB
/
label.tcl
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
# Label atoms with specified atomselect quantity
## Colorid: 8=white 16=black
# labelatoms "all" {name type}
proc labelatoms {{sel ""} {label name} {color 8}\
{size 1.0} {off {0.5 0.5 0.0}}} {
set flag 0
if {$sel == ""} {
set sel [atomselect top "all"]
set flag 1
} elseif {![string match "atomselect*" $sel]} {
if {[catch {atomselect top $sel} sel]} {return}
set flag 1
} else {}
set molid [$sel molid]
foreach x $label {
if {[lsearch -ascii [atomselect keywords] $x] == -1} {
set msg [vmdcon -err "Unknown atomselect keyword: $x"]
return -code error $msg
}
}
## Get the viewpoint for the mol we're labeling
save_viewpoint 99999 $molid
## Make a new mol
set newmol [mol new]
## Set the label color to white
graphics $newmol color $color
foreach x [$sel get x]\
y [$sel get y]\
z [$sel get z]\
w [$sel get $label] {
graphics $newmol text [vecadd [list $x $y $z] $off] [join $w " "] size $size
}
## Make sure the old mol is top
molinfo $molid set top 1
## Apply the viewpoint to the new mol
cpy_viewpoint 99999 $molid $newmol
if {[string match "atomselect*" $sel] && $flag} {
$sel delete
}
}