Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delayed subtrees #47

Merged
merged 5 commits into from
Nov 14, 2013
Merged

Delayed subtrees #47

merged 5 commits into from
Nov 14, 2013

Conversation

byorgey
Copy link
Member

@byorgey byorgey commented Nov 13, 2013

This pull request contains some extra machinery, the original motivation for which was to fix diagrams/diagrams-lib#112, but which I hope may turn out to be more generally useful.

The basic idea is that in addition to having Prims at the leaves of a QDiagram, we can now also have a function of type DownAnnots v -> QDiagram b v m. That is, a leaf which expands to a QDiagram once it knows the final context (including transformations and style) in which it is to be rendered. The prototypical example is an arrow with scale-invariant head and tail, which needs to know the final transformation applied to it before it can figure out exactly how to draw the shaft. (Other possibilities for the future include things like diagrams which do not scale linearly, e.g. they scale only up to a certain maximum size and then stop getting bigger.)

The tradeoff is that, as with scale-invariant wrappers, we must come up with an envelope and trace up front---there is no way to delay their generation too (short of a more general solution for constraint solving), since we need them to construct the rest of the QDiagram.

There is a bit of trickiness with making sure transformations do not get applied twice. When compiling a QDiagram to a raw DTree (which now includes expansion of delayed leaves), we mark any expansion points with a special node. Later, when crunching the DTree down to an RTree, we drop any accumulated transformations upon encountering one of those special nodes. The idea is that the tree underneath that special node, being the expansion of a delayed leaf, must have already taken those transformations into account, so we do not want to apply them again.

Brent Yorgey added 5 commits November 10, 2013 13:45
Delayed subtrees consist of a continuation which generate a QDiagram
when given the accumulated d-annotation at that point in the tree.
Useful for things which need to know the final transformation applied
to them before deciding what diagram to generate.  The prototypical
use case is arrows: see
diagrams/diagrams-lib#112 .  However, I hope
this may be useful for other things as well: for example, diagrams
which scale normally until hitting some maximum or minimum size, at
which point they refuse to scale any further (or more generally
diagrams which scale as some non-linear function of the transformation
applied to them).

The only downside is that the u-annotation must be fixed ahead of
time---doing otherwise requires a more general solution for constraint
solving.
The idea is that the function in a DelayedLeaf should produce a
diagram which already takes the non-frozen transformation into
account, so we must drop them when we reach a DDelay node (otherwise
we end up applying them twice).
@byorgey
Copy link
Member Author

byorgey commented Nov 13, 2013

I have a bit more work to do on the corresponding diagrams-lib branch; feel free to hold off on merging this until then.

@byorgey
Copy link
Member Author

byorgey commented Nov 13, 2013

Still building diagrams-doc to do final validation. Will report on the outcome here.

@bergey
Copy link
Member

bergey commented Nov 14, 2013

Looks good to me.

@jeffreyrosenbluth
Copy link
Member

Looks good to me as well

bergey added a commit that referenced this pull request Nov 14, 2013
@bergey bergey merged commit f3551f7 into master Nov 14, 2013
@byorgey byorgey deleted the delayed-subtrees branch November 14, 2013 03:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Arrows do not behave correctly under scaling
3 participants