File: shape.rst

package info (click to toggle)
neuron 8.2.6-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 34,760 kB
  • sloc: cpp: 149,571; python: 58,465; ansic: 50,329; sh: 3,510; xml: 213; pascal: 51; makefile: 35; sed: 5
file content (574 lines) | stat: -rw-r--r-- 10,663 bytes parent folder | download | duplicates (3)
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
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574

.. _hoc_shape:

Shape
-----



.. hoc:class:: Shape

        Class for making a Shape window for executing a user defined action 
        when a section is clicked on. (When the section mode is selected 
        from the mouse menu.) An argument of 0 will prevent default mapping 
        of the	window. 
        If the first arg is a SectionList (then a second arg of 0 will 
        prevent default mapping) then only the sections in the list are 
        drawn. Shape is redrawn automatically whenever length or diameter 
        of a section changes. 

----



.. hoc:method:: Shape.view


    Syntax:
        ``.view(mleft, mbottom, mwidth, mheight, sleft, stop, swidth, sheight)``


    Description:
        maps a view of the Shape scene. m stands for model coordinates, 
        s stands for screen pixel coordinates where 0,0 is the top left 
        corner of the screen. 

         

----



.. hoc:method:: Shape.size


    Syntax:
        ``.size(mleft, mright, mbottom, mtop)``

        ``...``


    Description:
        Model coordinates for the scene. 
        This is the "whole scene" size. 
        Since, the aspect ratio for shape views is unity, the bounding box expressed 
        by the arguments may not fit exactly on the screen window. The scale factor 
        is decreased so that the first view window displays the entire bounding box 
        with the center of the bounding box in the center of the view. 
         
        See :hoc:meth:`Graph.size` for other, more rarely use argument sequences.

         

----



.. hoc:method:: Shape.show


    Syntax:
        ``shape.show(mode)``


    Description:


        mode = 0 
            displays diameters 

        mode = 1 
            displays centroid. ie line through all the 3d points. 

        mode = 2 
            displays schematic. ie line through 1st and last 2d points of each 
            section. 



----



.. hoc:method:: Shape.flush


    Syntax:
        ``.flush()``


    Description:
        Redraws all views into this scene. 

         

----



.. hoc:method:: Shape.observe


    Syntax:
        ``shape.observe()``

        ``shape.observe(sectionlist)``


    Description:
        Replace the list of observed sections in the Shape with the specified 
        list. With no arguments, all sections are observed. 

    Example:
        In the context of the pyramidal cell demo of neurondemo the following 
        will change the Shape shown in the point process manager 
        to show only the soma and the main part of the primary dendrite. 

        .. code-block::
            none

            objref sl 
            sl = new SectionList() 
            soma sl.append() 
            dendrite_1[8] sl.append() 
            Shape[0].observe(sl) 


         

----



.. hoc:method:: Shape.view_count


    Syntax:
        ``.view_count()``


    Description:
        Returns number of views into this scene. (stdrun.hoc removes 
        scenes from the \ ``flush_list`` and \ ``graphList[]`` when this goes to 
        0. If no other \ ``objectvar`` points to the scene, it will be 
        freed.) 

         

----



.. hoc:method:: Shape.select


    Syntax:
        ``.select()``


    Description:
        Colors red the currently accessed section. 

         

----



.. hoc:method:: Shape.action


    Syntax:
        ``.action("command")``


    Description:
        command is executed whenever the user clicks on a section. 
        The clicked section is pushed before execution and popped after. 
        \ :hoc:data:`hoc_ac_` contains the arc position 0 - 1 of the nearest node.

         

----



.. hoc:method:: Shape.color


    Syntax:
        ``section  shape.color(i)``


    Description:
        colors the currently accessed section according to color index 
        (index same as specified in :hoc:class:`Graph` class). If there are several
        sections to color it is more efficient to make a SectionList and 
        use \ ``.color_list`` 

         

----



.. hoc:method:: Shape.color_all


    Syntax:
        ``.color_all(i)``


    Description:
        colors all the sections 

         

----



.. hoc:method:: Shape.color_list


    Syntax:
        ``.color_list(SectionList, i)``


    Description:
        colors the sections in the list 

         

----



.. hoc:method:: Shape.point_mark


    Syntax:
        ``.point_mark(objvar, colorindex)``

        ``.point_mark(objvar, colorindex, style)``

        ``.point_mark(objvar, colorindex, style, size)``



    Description:
        draw a little filled circle with indicated color where the point process 
        referenced by \ ``objvar`` is located. Note, if you subsequently relocate 
        the point process or destroy it the proper thing will happen to the 
        mark. (at least after a flush) 
         
        The optional arguments specify the style and size as in the 
        :hoc:meth:`Graph.mark` method of :hoc:class:`Graph`. This extension was contributed
        by Yichun Wei ``yichunwe@usc.edu``.

         

----



.. hoc:method:: Shape.point_mark_remove


    Syntax:
        ``.point_mark_remove([objvar])``


    Description:
        With no arg, removes all the point process marks. 

         

----



.. hoc:method:: Shape.save_name


    Syntax:
        ``.save_name("name")``


    Description:
        The \ ``objectvar`` used to save the scene when the print window 
        manager is used to save a session. 

         

----



.. hoc:method:: Shape.unmap


    Syntax:
        ``.unmap()``


    Description:
        dismisses all windows that are a direct view into this scene. 
        (does not unmap boxes containing scenes.) \ ``unmap`` is called 
        automatically when no hoc object variable references the Shape. 

         

----



.. hoc:method:: Shape.printfile


    Syntax:
        ``.printfile("filename")``


    Description:
        prints the first view of the graph as an encapsulated post script 
        file 


----



.. hoc:method:: Shape.menu_action


    .. seealso::
        :hoc:meth:`Graph.menu_action`

         

----



.. hoc:method:: Shape.exec_menu


    .. seealso::
        :hoc:meth:`Graph.exec_menu`


----



.. hoc:method:: Shape.erase


    .. seealso::
        :hoc:meth:`Graph.erase`


----



.. hoc:method:: Shape.erase_all


    Description:
        Erases everything in the Shape, including all PointMarks and Sections. 

    .. seealso::
        :hoc:meth:`Graph.erase_all`, :hoc:meth:`Shape.observe`, :hoc:meth:`Shape.point_mark`


----



.. hoc:method:: Shape.beginline


    .. seealso::
        :hoc:meth:`Graph.beginline`


----



.. hoc:method:: Shape.line


    .. seealso::
        :hoc:meth:`Graph.line`


----



.. hoc:method:: Shape.mark


    .. seealso::
        :hoc:meth:`Graph.mark`


----



.. hoc:method:: Shape.label


    .. seealso::
        :hoc:meth:`Graph.label`


----



.. hoc:method:: Shape.menu_tool


    Syntax:
        ``s.menu_tool("label", "procname")``


    Description:
        Same as :hoc:meth:`Graph.menu_tool` for the :hoc:func:`Graph` class. When procname is
        called it is given four arguments: type, x, y, keystate. Type = 1,2,3 means 
        move, press, release respectively and x and are in model coordinates. 
        Keystate reflects the 
        state of control (bit 1), shift (bit 2), and meta (bit 3) keys, ie 
        control and shift down has a value of 3. 
         

    .. seealso::
        :hoc:meth:`Graph.menu_tool`, :hoc:meth:`Shape.nearest`, :hoc:meth:`Shape.push_selected`

    Example:
        The following example will work if executed in the context of the 
        pyramidal cell demo of the neurondemo. It colors red the section 
        you click nearest and prints the name and position of the selected section 
        as well as the mouse distance the selection. 

        .. code-block::
            none

            objref ss 
            ss = Shape[0] 
            proc p() {local d, a 
                    if ($1 == 2) { 
                            ss.color_all(1) 
                            d = ss.nearest($2,$3)  
                            a = ss.push_selected() 
                            if (a >= 0) { 
                                    ss.select() 
                                    printf("%g from %s(%g)\n", d, secname(), a) 
                                    pop_section() 
                            } 
                    } 
            } 
            ss.menu_tool("test", "p") 
            ss.exec_menu("test") 



----



.. hoc:method:: Shape.nearest


    Syntax:
        ``d = shape.nearest(x, y)``


    Description:
        returns the distance (in model coordinates) to the nearest section. 
        The section becomes the selected section of the Shape. It is NOT 
        pushed onto the section stack and it is NOT colored. The nearest 
        arc position of the selected section as well 
        as the section is available from :hoc:func:`push_section`.

         

----



.. hoc:method:: Shape.push_selected


    Syntax:
        ``arc = shape.push_selected()``

        ``if (arc >= 0) {``

        ``pop_section()``

        ``}``


    Description:
        If there is a selection for the Shape class, then it is pushed onto 
        the section stack (becomes the currently accessed section) and the 
        arc position (0 to 1) returned. If no section is selected the function 
        returns -1 and no section is pushed. 
         
        Note that it is important that a pop_section be executed if a section 
        is pushed onto the stack. 

    .. warning::
        The arc position is relevant only if the section was selected using 
        :hoc:meth:`Shape.nearest`. Note, e.g., that :hoc:meth:`Shape.select` does not
        set the arc position. 

         

----



.. hoc:method:: Shape.len_scale


    Syntax:
        ``section shape.len_scale(scl)``


    Description:
        The drawing of the section length (currently accessed section) in the Shape 
        scene is scaled by the factor. Diameter is drawn normally. 
        Note that this does not change the physical length of the section but 
        only its appearance in this Shape instance. 

         

----



.. hoc:method:: Shape.rotate


    Syntax:
        ``shape.rotate()``

        ``shape.rotate(xorg, yorg, zorg, xrad, yrad, zrad)``


    Description:
        With no args the view is in the xy plane. 
        With args, incrementally rotate about the indicated origin by the 
        amount given in radians around the current view coordinates (order is 
        sequentially about x,y,z axes)