Differences between revisions 1 and 2
Revision 1 as of 2011-09-14 17:44:12
Size: 2544
Editor: JohnFlanagan
Comment:
Revision 2 as of 2011-09-14 17:52:58
Size: 3106
Editor: JohnFlanagan
Comment:
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
'''EMAN2 3D Widget for Python applications:'''
= EMAN2 3D Widget for Python applications: =
Line 13: Line 12:
'''Useful EMScene3D functions:'''
=== Useful EMScene3D functions: ===
Line 21: Line 19:
'''updateSG():''' Updates the 3D widget, used when you have finished building the 3D widget

'''copyNodes(nodes):''' Makes a copy of the supplied nodes. Does not work for data nodes and their children

'''groupNodes(nodes):''' Groups the nodes by placing them in their own subnode. Useful if you want to control a group of node together.

'''unGroupNodes(nodes):''' Does the opposite of the above.

=== Useful EMDataItem3D functions: ===
'''setData(data):''' sets the data that the EMDataItem3D owns, useful if you process the EMData and want to redisplay

EMAN2 3D Widget for Python applications:

The 3D widget is a python class allowing display of 3D items in EMAN2. These include isosurafces, volume slices, volumes, in additon to text and shapes for annotation. The 3D object is arranged in a tree datastructure for easy data grouping and control. The scene itself can be save for later analysis and snapshots can be taken for publication.

Importing the widget and assoicated classes:

To use the EMAN2 3D widget you need to add the line: from emscene3d import EMScene3D to your python programs. This will allow creation of the 3D Widget. If you want to add enable to additon of EMData objects to the 3D widget for display of isosurfaces, slices, and volumes, then the lines: from emdataitem3d import EMDataItem3D, EMIsosurface, EMSliceItem3D, EMVolumeItem3D need to added to your python programs.

Creating the 3D widget and adding EMData items for rendering:

To create the 3D widget simply instatiate it by: widget = EMScene3D(). To add a EMData item, you need to first instatiate a data widget by: dataitem = EMDataItem3D("mydatafile.hdf", transform=Transform()) OR by: EMDataItem3D(myemdataobject, transform=Transform()) if you want to use a emdata object rather than a file as the EMData source. After instantiation, you need to add the EMDataItem3D as a child of the 3D widget by: widget.insertNewNode('My Data', dataitem, parentnode=widget). This does not add isosurfaces and the like to the 3D widget, so you need to add these as children of the EMDataItem3D widget. For example, first create an isosurface by: isosurfacewidget = EMisosurface(dataitem, transform=Transform()) and then add it as a child of dataitem by: widget.insertNewNode('My Iso', isosurfacewidget, parentnode=dataitem). Similar logic applies to the slice and volume objects.

Useful EMScene3D functions:

InsertNewNode(name, node, parentnode=None, parentidx=None): Inserts a node into the 3D widget. If the inspector is open the node is inserted below which ever item is currently selected. name is the name of the node, node is the node to be inserted, parentnode sets the parent of node, and parentidx determines where the insertion takes place.

loadSession(filename): Loads a session from file. The file, filename, must be a python pickle, which was previously saved.

saveSession(filename): Saves a session to a file named, filename. The file is saved as a python pickle.

updateSG(): Updates the 3D widget, used when you have finished building the 3D widget

copyNodes(nodes): Makes a copy of the supplied nodes. Does not work for data nodes and their children

groupNodes(nodes): Groups the nodes by placing them in their own subnode. Useful if you want to control a group of node together.

unGroupNodes(nodes): Does the opposite of the above.

Useful EMDataItem3D functions:

setData(data): sets the data that the EMDataItem3D owns, useful if you process the EMData and want to redisplay

Eman2Using3DWidget (last edited 2012-05-02 22:15:22 by JohnFlanagan)