File: xselect.g

package info (click to toggle)
genesis 2.1-1.1
  • links: PTS
  • area: main
  • in suites: potato
  • size: 14,288 kB
  • ctags: 10,667
  • sloc: ansic: 111,959; makefile: 2,240; yacc: 1,797; lex: 976; csh: 54; sh: 13
file content (455 lines) | stat: -rw-r--r-- 12,177 bytes parent folder | download | duplicates (5)
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
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
//genesis

function do_xselect_funcs
	int channo

	create x1form /compt_display [480,50,520,370]
	// disable /compt_display
	//DHB create xdraw /compt_display/draw [0,2,100%,335] -transform z2d  \
	    //DHB -wx 18 -wy 18 -cx 9 -cy 9 -refresh_flag FALSE
	create x1draw /compt_display/draw [0,2,100%,335] -transform z2d  \
	    -xmin 0 -xmax 18 -ymin 0 -ymax 18
	ce ^
	copy /xproto/draw/hhna.icon hh.icon
		setfield hh.icon pixcolor Orange linewidth 2
	copy /xproto/draw/excsyn.icon syn.icon
		setfield syn.icon pixcolor Green linewidth 2
	copy /xproto/draw/soma.icon rec.icon
	copy /xproto/draw/fillbox.icon vdep.icon
	copy /xproto/draw/hilight hilight

	setfield # tx -1000 ty -1000   // move proto pixes out of view

	copy /xproto/draw/comptshape compt
	setfield compt pixflags clickable_not
	create x1shape dummy.icon
	create x1shape comptpath -tx 10 -ty 10
	setfield comptpath pixflags clickable_not
	/* This is a brutish hack. We need to handle all this much better  */
	for (channo = 0; channo < 20; channo = channo + 1)
		create x1shape chan{channo} -tx {6 + 2.2*(channo%5)} -ty  \
		    {3.5 + 0.82*channo}
	end

	// turn off automatic select highlighting
	setfield chan# hldispmode invert hlhistmode lastone
        setfield #[ISA=xshape] pixflags hlt1 pixflags ~hlt2

	create x1toggle /compt_display/mouse_mode -script  \
	    "set_compt_disp_mode "<widget>
		setfield /compt_display/mouse_mode label0 "Select"  \
		    label1 "Cut-n-Paste"
	setup_mouse /compt_display/draw 0 0 paste do_chanpaste cut  \
	    do_chancut copy do_chancopy
	setup_mouse /compt_display/draw 0 0 select  \
	    "do_channelselect /compt_display/draw" dummy do_dummy dummy  \
	    do_dummy


	create x1form /compt_select [0,440,480,450]
	// disable /compt_select
	create x1draw /compt_select/draw [0,2,100%,400] -transform  \
	    ortho3d -wx 0.0015 -wy 0.0015 -cz 0.2e-3 -vx 10 -vy -15 -vz  \
	    7
	//DHB setfield ^ wx {user_wx} wy {user_wy} cx {user_cx} cy {user_cy}  \
	    //DHB cz {user_cz}
	setfield ^ xmin {user_cx - user_wx/2} xmax {user_cx + user_wx/2} \
		   ymin {user_cy - user_wy/2} ymax {user_cy + user_wy/2}
	create x1toggle /compt_select/scope [0,5:draw.bottom,49%,25]
		setfield /compt_select/scope  \
		    label0 "Select One Compartment"  \
		    label1 "Select Sub Tree"
	create x1toggle /compt_select/mouse_mode  \
	    [51%,5:draw.bottom,49%,25] -script  \
	    "set_compt_sel_mode "<widget>
		setfield /compt_select/mouse_mode label0 "Edit"  \
		    label1 "Cut-n-Paste"
	setup_mouse /compt_select/draw 0 0 paste do_comptpaste cut  \
	    do_comptcut copy do_comptcopy
	setup_mouse /compt_select/draw 0 0 select do_comptselect stretch \
	     do_stretch rotate do_rotate
// hack added to allow stretch and rotate functions to get coords - DEB 8/3/95
	setfield /compt_select/draw script \
          "do_comptselect.d1; do_stretch.d2 <x> <y> <z>; do_rotate.d3 <x> <y> <z>"

	create x1cell /compt_select/draw/cell -colfield activation  \
	    -colmin -1 -colmax 2 -autocol FALSE
	setfield /compt_select/draw/cell fatrange {user_fatrange1}  // DEB 8/2/95

	/* create xcell /compt_select/draw/cell -colfield activation  \
	    -colmin -1 -colmax 2 -fatfield dia -autocol FALSE
	    */
end

function sub_hilight(name)
	str name

	int nmsgs
	int i
	str child

	setfield {name} activation 1

	nmsgs = {getmsg {name} -incoming -count}

	for (i = 0; i < nmsgs; i = i + 1)
		if ( \
		    {strcmp {getmsg {name} -incoming -type {i}} RAXIAL} == 0 \
		    )
			child = {getmsg {name} -incoming -source {i}}
			sub_hilight {child}
		end
	end
end

function hilight_compt(name)
	str name

	int scope = {getfield /compt_select/scope state}

	if ((user_symcomps))
		setfield {cellpath}/##[TYPE=symcompartment] activation 0
	else
		setfield {cellpath}/##[TYPE=compartment] activation 0
	end
	if ((scope) == 0)	// local

		setfield {name} activation 1
	else
		sub_hilight {name}
	end

	call /compt_select/draw/cell PROCESS
end

function display_compt(name)
	str name
	str chan
	int channo = 0

	foreach chan ({el /compt_display/draw/chan#})
		//DHB
		setfield {chan} text "" iconname dummy.icon
		/*
		setfield {chan} text "" &&xpts &/compt_display/draw/dummy.icon/xpts \
				        &&ypts &/compt_display/draw/dummy.icon/ypts \
				        &&zpts &/compt_display/draw/dummy.icon/zpts \
					npts 0
	*/
	end

	pushe /compt_display/draw

	foreach chan ({el {name}/#[TYPE=tabchannel]})
		//DHB
		setfield chan{channo} text {getfield {chan} name}  \
		    iconname hh.icon
		/*
		setfield chan{channo} text {getfield {chan} name}  \
		    &&xpts &hh.icon/xpts \
		    &&ypts &hh.icon/ypts \
		    &&zpts &hh.icon/zpts \
		    npts {getfield hh.icon npts}
		*/
		channo = channo + 1
	end
	foreach chan ({el {name}/#[TYPE=tab2Dchannel]})
		setfield chan{channo} text {getfield {chan} name}  \
		    iconname hh.icon
		channo = channo + 1
	end
	foreach chan ({el {name}/#[TYPE=hh_channel]})
		//DHB
		setfield chan{channo} text {getfield {chan} name}  \
		    iconname hh.icon
		/*
		setfield chan{channo} text {getfield {chan} name}  \
		    &&xpts &hh.icon/xpts \
		    &&ypts &hh.icon/ypts \
		    &&zpts &hh.icon/zpts \
		    npts {getfield hh.icon npts}
		*/
		channo = channo + 1
	end
	foreach chan ({el {name}/#[TYPE=channelC2]})
		//DHB 
		setfield chan{channo} text {getfield {chan} name}  \
		    iconname syn.icon
		/*
		setfield chan{channo} text {getfield {chan} name}  \
		    &&xpts &syn.icon/xpts \
		    &&ypts &syn.icon/ypts \
		    &&zpts &syn.icon/zpts \
		    npts {getfield syn.icon npts}
		*/
		channo = channo + 1
	end
	foreach chan ({el {name}/#[TYPE=synchan]})  // DEB 8/3/95
		setfield chan{channo} text {getfield {chan} name}  \
		    iconname syn.icon
		channo = channo + 1
	end
	foreach chan ({el {name}/#[TYPE=vdep_channel]})
		//DHB 
		setfield chan{channo} text {getfield {chan} name}  \
		    iconname vdep.icon
		/*
		setfield chan{channo} text {getfield {chan} name}  \
		    &&xpts &vdep.icon/xpts \
		    &&ypts &vdep.icon/ypts \
		    &&zpts &vdep.icon/zpts \
		    npts {getfield vdep.icon npts}
		*/
		channo = channo + 1
	end
	foreach chan ({el {name}/#[TYPE=receptor2]})
		//DHBi
		setfield chan{channo} text {getfield {chan} name}  \
		    iconname rec.icon
		/*
		setfield chan{channo} text {getfield {chan} name}  \
		    &&xpts &rec.icon/xpts \
		    &&ypts &rec.icon/ypts \
		    &&zpts &rec.icon/zpts \
		    npts {getfield rec.icon npts}
		*/
		channo = channo + 1
	end

	setfield comptpath text {name}

	foreach chan ({el /compt_display/draw/chan#})
		if ({strcmp {getfield {chan} text} {channelname}} == 0)
			setfield hilight tx {getfield {chan} tx}  \
			    ty {getfield {chan} ty}
			xupdate /compt_display/draw
			pope
			return
		end
	end
	setfield hilight tx -1000 ty -1000

	xupdate .
	pope
end


function do_comptcut
	str src = {getfield /compt_select/draw value}

	hilight_compt {src}
	cut_to_lib compt_lib {src} {getfield /compt_select/scope state}
	if ((user_symcomps))
		setfield /compt_select/draw/cell  \
		    path {cellpath}/##[TYPE=symcompartment]
	else
		setfield /compt_select/draw/cell  \
		    path {cellpath}/##[TYPE=compartment]
	end
end


function do_comptcopy
	str src = {getfield /compt_select/draw value}

	hilight_compt {src}
	copy_to_lib compt_lib {src} {getfield /compt_select/scope state}
end

function do_comptpaste
	str dst = {getfield /compt_select/draw value}
	str elm = {getfield /compt_lib_form/sel value}
	str  \
	    elmname = {getfield {elm} name} @ "[" @ {getfield {elm} index} @ "]"
	str src = (cellpath) @ "/" @ (elmname)
	float x, y, z
	int rename_flag = {getfield /compt_lib_form/auto_rename state}
	str newname

	if ( \
	    {strcmp {getfield {elm}/{elmname} object->name} "compartment"} != 0 \
	    )
		echo Only compartments may be pasted onto the cell.
		return
	end

	hilight_compt {dst}

	if ((!rename_flag) && ({exists {cellpath}/{elmname}}))
		echo Element {elmname} already exists. Paste not done.
		return
	end
	if ({exists /buffer/temp2})
		delete /buffer/temp2
	end
	copy {elm} /buffer/temp2
	if (rename_flag)
		newname = {do_child_rename /buffer/temp2/{elmname} {dst}}
		src = (cellpath) @ "/" @ (newname)
		subtree_move /buffer/temp2/{newname} {cellpath}
	else
		subtree_move /buffer/temp2/{elmname} {cellpath}; 
	end

	addmsg {dst} {src} AXIAL Vm
	addmsg {src} {dst} RAXIAL Ra Vm
	x = {getfield {dst} x}
	y = {getfield {dst} y}
	z = {getfield {dst} z}
	position {src} R{x} R{y} R{z}
	// refresh the cell display

	if ((user_symcomps))
		setfield /compt_select/draw/cell  \
		    path {cellpath}/##[TYPE=symcompartment]
		setfield {cellpath}xout1/draw/cell  \
		    path {cellpath}/##[TYPE=symcompartment]
		setfield {cellpath}xout2/draw/cell  \
		    path {cellpath}/##[TYPE=symcompartment]
	else
		setfield /compt_select/draw/cell  \
		    path {cellpath}/##[TYPE=compartment]
		setfield {cellpath}xout1/draw/cell  \
		    path {cellpath}/##[TYPE=compartment]
		setfield {cellpath}xout2/draw/cell  \
		    path {cellpath}/##[TYPE=compartment]
	end
end


function do_channelselect(widget)
	str widget

	str icon = {getfield {widget} pixchoose}

	channelname = ({getfield {widget}/{icon} text})
	channelpath = (comptpath) @ "/" @ (channelname)
	hilight_channel
	if (({exists {channelpath}}))
		if (({strcmp {analysis_level} neuron}) == 0)
			update_neuron_params
		end
		/*
		if ({strcmp({analysis_level},compt)} == 0)
			update_compt_params
		end
		*/
		if (({strcmp {analysis_level} channel}) == 0)
			update_channel_params
		end
	end
end


function do_chancut
	do_channelselect /compt_display/draw

	hilight_channel
	cut_to_lib compt_lib {channelpath}  \
	    {getfield /compt_select/scope state}
	display_compt {comptpath}
end


function do_chancopy
	do_channelselect /compt_display/draw

	hilight_channel
	copy_to_lib compt_lib {channelpath}  \
	    {getfield /compt_select/scope state}
end

function do_chanpaste
	str elm = {getfield /compt_lib_form/sel value}
	str  \
	    elmname = {getfield {elm} name} @ "[" @ {getfield {elm} index} @ "]"
	str src = "/compt_lib/" @ (elmname) @ "/" @ (elmname)
	str chtype = {getfield {src} object->name}
	str name

	if ({strcmp {chtype} "compartment"} == 0)
		echo element {elmname} is not a channel
		return
	end

	if (({getfield /compt_select/scope state}) == 1)	// global

		foreach name ({el {cellpath}/#[][activation>0.99]})
			if ({exists {name}/{elmname}})
				echo Element {elmname} already exists.  \
				    Paste not done.
			else
				pastechannel {src} {name}
			end
		end
	else	// local

		if ({exists {comptpath}/{elmname}})
			echo Element {elmname} already exists. Paste not \
			     done.
			return
		end
		pastechannel {src} {comptpath}
	end

	hilight_compt {comptpath}

	display_compt {comptpath}
end


function do_comptselect
	str name

	name = {getfield /compt_select/draw value}
	if (({exists {name}}))
		comptpath = name
		comptname = {getfield {name} name}
		channelpath = (comptpath) @ "/" @ (channelname)
		hilight_compt {comptpath}
		// hilight_compt({comptpath},{get(/compt_select/scope,state)})
		if (({strcmp {analysis_level} neuron}) == 0)
			update_neuron_params
		end
		if (({strcmp {analysis_level} compt}) == 0)
			update_compt_params
		end
		if (({strcmp {analysis_level} channel}) == 0)
			update_channel_params
		end
		display_compt {comptpath}
	end
end

function set_compt_sel_mode(widget)
    str widget

    int state = {getfield {widget} state}

    if (state == 1)
        select_mouse /compt_select/draw paste do_comptpaste cut  \
            do_comptcut copy do_comptcopy
    else
        select_mouse /compt_select/draw select do_comptselect stretch  \
            do_stretch rotate do_rotate
// hack added to allow stretch and rotate functions to get coords - DEB 8/3/95
	setfield /compt_select/draw script \
	"do_comptselect.d1; do_stretch.d2 <x> <y> <z>; do_rotate.d3 <x> <y> <z>"

    end
end

function set_compt_disp_mode(widget)
    str widget

    int state = {getfield {widget} state}

    if (state == 1)
        select_mouse /compt_display/draw paste do_chanpaste cut  \
            do_chancut copy do_chancopy
    else
        select_mouse /compt_display/draw select  \
            "do_channelselect /compt_display/draw" dummy do_dummy dummy  \
            do_dummy
    end
end