Module fig :: Class Container

Class Container




Container for fig objects, derived from the standard python list. This is the common superclass of File (for the whole document), Compound, and ObjectProxy (for search results, see findObjects() or layer()).

Instance Methods
 
allObjects(container, includeCompounds= False)
Returns an iterator iterating over all objects in this container, recursively entering compound objects.
 
findObjects(self, **kwargs)
Return a list of objects which have attribute/value pairs matching the given keyword parameters.
 
layer(container, layer)
Returns an ObjectProxy for all objects within this container that have the given depth; convenience shortcut for findObjects(depth = layer).
 
layers(container)
Returns the list of all integer depths that are assigned to at least one object within this container.
 
__deepcopy__(self, memo)
 
remove(container, obj)
Removes the given object from this Container.
 
bounds(self)
Return the union of all bounding boxes of the contained objects.

Inherited from list: __add__, __contains__, __delitem__, __delslice__, __eq__, __ge__, __getattribute__, __getitem__, __getslice__, __gt__, __hash__, __iadd__, __imul__, __init__, __iter__, __le__, __len__, __lt__, __mul__, __ne__, __new__, __repr__, __reversed__, __rmul__, __setitem__, __setslice__, append, count, extend, index, insert, pop, reverse, sort

Inherited from object: __delattr__, __reduce__, __reduce_ex__, __setattr__, __str__

Properties

Inherited from object: __class__

Method Details

allObjects(container, includeCompounds= False)

 
Returns an iterator iterating over all objects in this container, recursively entering compound objects. You can use the optional parameter includeCompounds (default: False) to get the compound objects themselves returned, too.
Returns:
iterator

findObjects(self, **kwargs)

 

Return a list of objects which have attribute/value pairs matching the given keyword parameters. The key "type" is treated special, see these useful examples:

figFile.findObjects(depth = 40)
figFile.findObjects(type = fig.Polygon)
# all conditions must be fulfilled:
figFile.findObjects(lineWidth = 10, depth = 100)
# for disjunctive conditions, use list concatenation:
figFile.findObjects(depth = 10) + figFile.findObjects(depth = 20)

The returned object is actually an ObjectProxy, which is a special Container (which is a special python list) and allows to quickly change properties on all contained objects. See the Container and ObjectProxy classes.

layer(container, layer)

 
Returns an ObjectProxy for all objects within this container that have the given depth; convenience shortcut for findObjects(depth = layer).
Returns:
`ObjectProxy`

layers(container)

 
Returns the list of all integer depths that are assigned to at least one object within this container.
Returns:
list

remove(container, obj)

 
Removes the given object from this Container. Also works recursively for objects within Compound objects within this Container. Raises a ValueError if obj is not contained.
Overrides: list.remove

bounds(self)

 
Return the union of all bounding boxes of the contained objects. This value is not cached (because it cannot be reliably updated if childrens change) but will be determined on each call.