I'd like to 'parent' Locators to one another, ideally organized in any arbitrary tree.
The simplest case: If I have two Locators, A and B, then moving A will move both together, but moving B will only move that one.
Any simple suggestions?
Not as fancy as belisarius' solution, but here's my approach. To store the tree, I'm using nested lists, so for example
would define a tree with root
To construct a list of edges from the tree you can do something like
Finally, we construct a list of
Consider an arbitrary tree
Then you could do something like
With an arbitrary locator dependency tree
Updated Now the sub-blocks move as one piece (per @RM request).
Lets first generate a dependency tree and calculate a few values for future use:
Now the main dynamic code:
Chinese instruction manual:
I would do it by introducing as a third variable the displacement between A and B, and then using
Here is a rather short example of a potential way of getting this functionality. Initially we need to decide on a structure for the tree. I'm going with simply a list of lists type tree, where the first element of each list is assumed to be it's head. Except at the very first level, where each node is considered a child.
Having this structure we can apply a function to each leaf by calling;
Then I define a new dynamic wrapper that will insert this updating function for any element having indexes ending in 1.
Then it's just a matter of mapping this wrapper over the tree and putting it into locators, note that I pass the index through an anonymous function in order for the pattern to match even though