Selection of objects from the global dictionary.
This is a support module for other pyFormex plugins.
A selection of objects from the globals().
The class provides facilities to filter the global objects by their type and select one or more objects by their name(s). The values of these objects can be changed and the changes can be undone.
Create a new selection of objects.
If a dict is given, objects will be selected from this dict, else from the global pyFormex dict GD.PF. If a filter is given, only objects passing it will be accepted. The filter will be applied dynamically on the dict.
If a list of names is given, the current selection will be set to those names (provided they are in the dictionary).
Objects objects have the following methods:
Set the selection to a list of names.
namelist can be a single object name or a list of names. This will also store the current values of the variables.
Add a name,value to a selection.
If no value is given, its current value is used. If a value is given, it is exported.
Remember the current values of the variables in selection.
If copy==True, the values are copied, so that the variables’ current values can be changed inplace without affecting the remembered values.
Replace the current values of selection by new ones.
The old values are stored locally, to enable undo operations.
This is only needed to change the values of objects that can not be changed inplace!
Check that we have a current selection.
Returns the list of Objects corresponding to the current selection. If single==True, the selection should hold exactly one Object name and a single Object instance is returned. If there is no selection, or more than one in case of single==True, an error message is displayed and None is returned
Show the names of known objects and let the user select one or more.
mode can be set to’single’ to select a single item. This sets the current selection to the selected names. Return a list with the selected names or None.
Select a single object from the list.
Returns the object, not its name!
A selection of drawable objects from the globals().
annotations, if set, is a list of (func,active) tuples, where
The default is to draw object name and element numbers.
DrawableObjects objects have the following methods:
Draws old and new version of a Formex with different colors.
old and new can be a either Formex instances or names or lists thereof. old are drawn in yellow, new in the current color.
Toggle the display of number On or Off.
If given, onoff is True or False. If no onoff is given, this works as a toggle.
Set the property of the current selection.
prop should be a single integer value or None. If None is given, a value will be asked from the user. If a negative value is given, the property is removed. If a selected object does not have a setProp method, it is ignored.
Functions defined in the module objects
- objects.draw_object_name(n)¶
- Draw the name of an object at its center.
- objects.draw_elem_numbers(n)¶
- Draw the numbers of an object’s elements.
- objects.draw_bbox(n)¶
- Draw the bbox of an object.