Hierarchies
Packing or grouping things together in one place is something we do quite naturally – we use paper folders, boxes, cases, binders, and the like.
Dizmo allows the user to have similar hierarchies. Every object (dizmo) may be the carrier of other objects that should be put into one (geometrically identifiable) place. If the user zooms out, the items will automatically lose their detail at a certain zoom level and then disappear completely when zooming further out.
Arranging dizmos spatially
That being said the aforementioned carrier (which is the Pad dizmo) will most likely still be visible. This creates a hierarchy that remains geometrically stable and therefore comprehensible for the user. The user might remember that they have put something ‘in the upper left-hand corner Pad’ and they can zoom to that spot instantly by just double clicking on the Pad and retrieve the items.
Besides organizing objects in hierarchies, having objects carry other objects allows users to drag a group of items to a different spot in dizmoViewer without losing their relative spatial order. This is particularly important if the spatial arrangement has a meaning to the user such as a floor plan in which control and visualization elements have been arranged to reflect their real-world position or impact.
Arranging dizmos on a Pad
As dizmos can be arranged in a hierarchical order, the dizmo object can have a parent or spawn a child. The parent and child dizmo objects themselves are instances of the dizmojs.Dizmo
class. If a dizmo is a child of another dizmo, coordinates and angles are relative to the parent dizmo.
Please refer to Dizmo coordinate system.
Since the dizmos can be arranged hierarchically in dizmoViewer, there are operations to get the parent or the children of the dizmo object.
Get the parent object of your own dizmo:
var parent = dizmo.getParentDizmo();
Get an array containing all the children objects of your dizmo:
var children = dizmo.getChildDizmos();
You can then for example loop through the array and modify the attributes of those child dizmos or access their public data:
for (var i = children.length - 1; i >= 0; i--) {
children[i].setAttribute("geometry/angle", 0);
var data=children[i].publicStorage.getProperty("stdout");
}
The subtree /dizmos/[dizmoID]/publicStorage
of these child dizmos can be read and written to. Please refer to chapter Communication between dizmos.
Setting a new parent
You can also set a dizmo to have a new parent, use the following function and pass a dizmo instance:
var parentChanged = dizmo.setParentDizmo(myNewDizmo);
parentChanged
will be true
if changing the parent worked, otherwise it will return false
.
If you want to get the current Parent of a dizmo, use the getParentDizmo
function:
var currentParent = dizmo.getParentDizmo();
This call will return a dizmo instance of the current parent or in the case of dizmoViewer, undefined
.
For example, if you want to have no parent set on your dizmo, use
Limitations
Any of the following conditions will prevent a change of parent.
- One of the dizmos is the «About» or the «Creator» dizmo
- The new parent is currently a child of the caller dizmo (recursive)
- The new parent or the child is not visible
- The new parent or the child is in sticky mode
- The area of overlap between the new parent and the child is less than 10% of the area of the child.