AlgebraicJulia / Catlab.jl

A framework for applied category theory in the Julia language
https://www.algebraicjulia.org
MIT License
619 stars 58 forks source link

Wire labels for Compose.jl wiring diagrams #71

Open epatters opened 4 years ago

epatters commented 4 years ago

The new wiring diagrams in Compose.jl and in TikZ do not yet support labels on the wires. This feature is crucial but hard to get right, and never worked well in the old TikZ wiring diagrams (see #16). I haven't yet decided how I want to approach this.

epatters commented 4 years ago

For now, I am going to delegate the placement of wire labels entirely to the backend, since the backend-agnostic layout provides only limited information about the routing of the wires, making label placement difficult at this stage.

epatters commented 4 years ago

Wires labels are implemented for TikZ diagrams.

In Compose.jl, wire labels will be more tedious to implement since all the positions have to be calculated manually. AFAIK, Compose does not provide functions to calculate relative positions along cubic Bezier curves. This requires computing the arc length of Bezier curves, which rarely has a closed form. A few helper functions can be found in Luxor.jl.

jpfairbanks commented 4 years ago

How do you enable labels on Tikz diagrams? to_tikz(d, labels=true) throws a keyword unsupported error for me.

epatters commented 4 years ago

The keyword argument labels=true works in the vignette so I think it should generally work. Can you provide a stack trace?

Note that there are two valid ways to call to_tikz: with a morphism expression (to_tikz(f)) or with a syntax module plus a wiring diagram (to_tikz(FreeCartesianCategory, d)). The latter case is a shorthand of the composite of to_hom_expr with to_tikz.