Shape
action · beginline · color · color_all · color_list · erase · erase_all · exec_menu · flush · label · len_scale · line · mark · menu_action · menu_tool · nearest · observe · point_mark · point_mark_remove · printfile · push_selected · rotate · save_name · select · show · size · unmap · view · view_count

# Shape¶↑

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.

Warning

The form of the constructor that takes a SectionList does not currently work in Python.

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.

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 Graph.size() for other, more rarely use argument sequences.

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.

Shape.flush()
Syntax:
.flush()
Description:
Redraws all views into this scene.

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 (launch via neurondemo --python) 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.

from neuron import h
sl = h.SectionList()
sl.append(h.soma)
sl.append(h.dendrite_1[8])
h.Shape[0].observe(sl)


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.)

Shape.select()
Syntax:
.select(sec=section)
Description:
Colors red the specified section.

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_ac_ contains the arc position 0 - 1 of the nearest node.

Shape.color()
Syntax:
shape.color(i, sec=section)
Description:
colors the specified section according to color index (index same as specified in Graph class). If there are several sections to color it is more efficient to make a SectionList and use .color_list

Shape.color_all()
Syntax:
.color_all(i)
Description:
colors all the sections

Shape.color_list()
Syntax:
.color_list(SectionList, i)
Description:
colors the sections in the list

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 Graph.mark() method of Graph. This extension was contributed by Yichun Wei yichunwe@usc.edu.

Shape.point_mark_remove()
Syntax:
.point_mark_remove([objvar])
Description:
With no arg, removes all the point process marks.

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.

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.

Shape.printfile()
Syntax:
.printfile("filename")
Description:
prints the first view of the graph as an encapsulated post script file

Shape.menu_action()

Shape.exec_menu()

Shape.erase()

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

Shape.beginline()

Shape.line()

Shape.mark()

Shape.label()

Shape.menu_tool()
Syntax:
s.menu_tool("label", "procname")
Description:
Same as Graph.menu_tool() for the 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.
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.

from neuron import h

ss = h.Shape[0]
def p(type, x, y, keystate):
if type == 2:
ss.color_all(1)
d = ss.nearest(x, y)
arc = ss.push_selected()
if arc >= 0:
ss.select()
print('%g from %s(%g)' % (d, h.secname(), a))
h.pop_section()



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 push_section().

Shape.push_selected()

Syntax:

arc = shape.push_selected()
if arc >= 0:
# do something, then end with:
h.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

The pushed section can be read via h.cas().

Note

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 Shape.nearest(). Note, e.g., that Shape.select() does not set the arc position.

Shape.len_scale()
Syntax:
shape.len_scale(scl, sec=section)
Description:
The drawing of the section length (for the specified 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.

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)