/usr/share/nrn/lib/hoc/vplay.hoc is in neuron 7.5-1.
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 | begintemplate VectorPlay
public b, g, vx, vy, sname, set_vec, oldval, con1, contin, scale
objref b, g, this, vx, vy, sc
strdef sname, tstr
i=0
oldval=0
proc init() {
have_name = 0
is_con = 0
state = 0
contin = 0
sc = new SymChooser("Variable Name to Play into")
build()
if (numarg() == 0) {
sprint(tstr, "%s", this)
b.map(tstr)
}
}
proc build() {
sname = "Choose Variable Name in Graph menu"
b = new VBox()
b.ref(this)
b.save("save()")
b.intercept(1)
xpanel("", 1)
xmenu("Specify")
xbutton("Variable Name", "varname()")
xbutton("Vector from Clipboard", "clipboard()")
xcheckbox("Piecewise continuous", &contin, "con()")
xbutton("*10", "scale(10)")
xbutton("/10", "scale(.1)")
xbutton("*2", "scale(2)")
xbutton("/2", "scale(.5)")
xmenu()
xstatebutton("Connected", &state, "con()")
xvarlabel(sname)
xpanel()
g = new Graph()
b.intercept(0)
}
proc varname() {
if (sc.run()) {
have_name = 1
sc.text(sname)
}
con1(is_con)
}
proc clipboard() {
sprint(tstr, "%s.set_vec(hoc_obj_[1], hoc_obj_[0])", this)
if(execute1(tstr) == 0) {
continue_dialog("No data in the Vector clipboard.")
}else{
con1(is_con)
}
}
proc set_vec() {
vx = $o1.c
vy = $o2.c
vy.plot(g, vx)
}
proc scale() {
if (object_id(vy)) {
vy.mul($1)
g.erase
vy.plot(g, vx)
}
}
proc con() {
if (!have_name) {
continue_dialog("Choose Variable name (see Graph Menu)")
state = 0
}else if (!object_id(vy)) {
continue_dialog("Choose Vector from Clipboard (see Graph Menu)")
state = 0
}else{
con1(state)
}
}
proc con1() {
if (object_id(vy)) {
if (is_con) {
vy.play_remove()
sprint(tstr, "%s = %g", sname, oldval)
execute(tstr)
is_con = 0
state = 0
}
if ($1) {
if (contin) {
sprint(tstr, "{%s.vy.play(&%s, %s.vx, 1)}", this, sname, this)
}else{
sprint(tstr, "{%s.vy.play(&%s, %s.vx)}", this, sname, this)
}
if (execute1(tstr)) {
sprint(tstr, "%s.oldval = %s", this, sname)
execute(tstr)
is_con = 1
state = 1
}else{
continue_dialog("Invalid Variable name")
}
}
}
}
proc save() {local i
b.save("load_file(\"vplay.hoc\")\n}\n{")
b.save("ocbox_=new VectorPlay(1)")
b.save("}\n{object_push(ocbox_)}")
if (object_id(vy)) {
sprint(tstr, "vy = new Vector(%d)", vy.size)
b.save(tstr)
sprint(tstr, "vx = new Vector(%d)", vx.size)
b.save(tstr)
sprint(tstr, "for i=0,%d { vx.x[i]=fscan() vy.x[i]=fscan()}",\
vx.size-1)
b.save(tstr)
for i=0, vx.size-1 {
sprint(tstr, "%g %g", vx.x[i], vy.x[i])
b.save(tstr)
}
b.save("{vy.plot(g, vx)}")
}
sprint(tstr, "{sname = \"%s\" have_name = %d contin = %d con1(%d)}",\
sname, have_name, contin, is_con)
b.save(tstr)
b.save("{object_pop()}\n{")
g.save_name("ocbox_.g", 1)
b.save("ocbox_ = ocbox_.b")
}
endtemplate VectorPlay
objref tobj
proc makeVectorPlay() {
tobj = new VectorPlay()
objref tobj
}
|