diagram_core/src/jumps.rs#
Source: lib/diagram_core/src/jumps.rs
jumps -- (JD21, CN-06) line jumps: where two dynamic connectors of a page cross, one of them
hops over the other (an arc, a gap, a square, a bump of 2 to 7 sides). As in Visio they are
rows of the connector's Geometry, written when connectors are laid (routed): the connector laid
and every connector it crosses or crossed get their jumps anew. Nothing is worked out while
drawing and nothing when a file opens -- a file shows what its Geometry holds.
Laid / laid.note(doc, c) the connectors a gesture lays, in the order it lays them
lay(tx, eng, &laid) (glue::run, route_edit::set_way) after they are laid: their
jumps and those of every connector they cross, and of those
whose jumps the crossings no longer explain (a connector they
jumped over went away)
lay_again(tx, eng, &conns) these connectors laid again where they are (the app routes
them instead, as Visio does when their own cells change)
lay_page(tx, eng, page) every connector of the page laid again, in z-order (the page's
line jump cells changed: Seite einrichten, Linienübergänge
anzeigen)
forget(tx, eng, &deleted) (glue::detach) before shapes are deleted: the jumps over their
connectors go
way(doc, c) -> Option<points> a connector's way on the page without its jumps (None: it has
none): glue::path and route_edit read ways through it, so a
file with jumps gives the same handles, ways and routes
read(doc, c) -> Vec<Jump> the jumps a connector's Geometry holds (tests, diagramiotest)
Jump, JumpStyle
Visio's rows (Visio 16 checked, JD21v: visio-run2 [jumps], visio-run3 [jumps2], visio-run4
[jumprows], visio-jumps-1): a connector that jumps has, on the straight piece crossed, a LineTo
to the jump's start and one row to its end -- ArcTo with the bow (A) half the jump's width
(style 0 and 1), MoveTo (2, the gap) or PolylineTo with A = POLYLINE(0, 0, x / Width, y /
Height, ...) through the bump's corners (3 square, 4 .. 9 two to seven sides); the jumps of a
piece in the order the piece runs. The corners in units of half the width, along the piece from the jump's start
and across it, are Visio's own (not exactly on a half circle): square (0, 1) (2, 1); 2 sides
(1, 1); 3 (0.5, 0.86) (1.5, 0.86); 4 (0.3, 0.7) (1, 1) (1.7, 0.7); 5 (0.2, 0.58) (0.7, 0.96)
(1.3, 0.96) (1.8, 0.58); 6 (0.14, 0.5) (0.5, 0.86) (1, 1) (1.5, 0.86) (1.86, 0.5); 7 (0.1,
0.44) (0.38, 0.78) (0.78, 0.98) (1.22, 0.98) (1.62, 0.78) (1.9, 0.44). Visio writes the rows'
numbers as constants in the drawing's unit; here they are constants in inches.
Visio's rules -- belegt by the check:
* When a connector is laid (new, moved, an end changed), Visio works out the jumps of it and
of every connector it crosses: partners gain or lose their jumps over it (all of a
partner's jumps by the rule, not only the one over it). A connector deleted or moved away
takes the jumps over it along. A page's line jump cell changed: every connector of the page
gets its jumps anew where it is (no routing); a connector's ConLineJumpCode changed: Visio
routes it again. A file opened shows its rows (Visio draws the jumps of a file of ours as
they are, and lays them anew to the same rows, 126 of 135 connectors; the others below).
* LineJumpCode (the page): 0 none; 1 at a crossing the more horizontal piece jumps (the
smaller |dy / dx|; equal slopes, as two 45 degree lines: neither); 2 the more vertical one;
3 the one laid last (it jumps over its partners, they lose their jumps over it); 4 the upper
one in the z-order; 5 the lower one. Missing: 1. (Codes 4 and 5 in a file Visio has just
opened: no connector jumps over another until a shape is brought to the front -- Visio's
display order of the shapes read is not known before; here the z-order counts from the
start.)
* LineJumpStyle 0 and 1 arc, 2 gap, 3 square, 4 .. 9 two to seven sides. Missing: 0.
* The width: LineJumpFactorX x LineToLineX on pieces that run more along x (LineJumpFactorY x
LineToLineY on the others), the jump centred on the crossing, as high as half its width.
Missing: the factors 2/3, LineToLineX / Y 2.5 mm (a page without the cells: 0.0656 in).
* Jumps closer than their width merge into one from the first one's start to the last one's
end, as high as half of that (the arc a half circle again).
* PageLineJumpDirX: pieces that run along x jump 0 / 1 up, 2 down; PageLineJumpDirY: the
others 0 / 1 left, 2 right.
* ConLineJumpCode (the connector): 0 the page's, 1 never, 2 always, 3 the other connector
jumps, 4 neither; ConLineJumpStyle 0 the page's, else as LineJumpStyle; ConLineJumpDirX / Y
0 the page's, else as the page's cells. "Always" works on a page with LineJumpCode 0.
Angenommen (no source; earlier assumptions kept):
* "Last laid" for connectors not laid now keeps what their rows show; a whole page laid
anew (lay_page) is laid in z-order.
* The conflicts of the connector codes: "neither" on either side: no jump; "always" on a side,
or "other" on the other side, makes that side jump; asked on both sides, the page's rule
decides (on a tie the upper one); "never" never jumps.
* Only straight pieces of connectors with MoveTo and LineTo rows (and jump rows) take part
(curved connectors neither jump nor are jumped over); a jump that would reach over the end of
its piece (a bend, the end) is left out; a connector's end on another line (a T) is no
crossing, nor are lines along each other; no connector jumps over itself. Rounding does
not move the jumps (they lie on the way without it).
* Connectors in groups take part (where they lie on the page); connectors without a line
(LinePattern 0) or on hidden layers only do not.
Lengths: the page's cells are lengths on paper (as LineToNodeX for the router); the ways are
in drawing units on the page, the widths turned into drawing units by the drawing scale.
Large pages: the pieces lie in a uniform grid (at most 64 x 64 cells), a crossing test looks
only at the pieces in the cells of a piece's box; nothing compares all pairs. A connector's
rows are written only when they change. Who crossed a laid connector before is not known
(its cells have moved when it is laid): a jump with no crossing under it, or one wider on one
side of its crossings than on the other (a merged jump that lost one), is laid anew.
enum JumpStylehow a jump looks (LineJumpStyle)Arc-- a half circle (0, 1)Gap-- the line stops and goes on (2)Square-- three sides of a box (3)Sides(u8)-- 2 .. 7 sides (4 .. 9)
impl JumpStyle
fn from_code(v: u32) -> JumpStyleLineJumpStyle / ConLineJumpStyle 1 .. 9 (0 and other values: the arc)fn corners(self) -> &'static [[f64; 2]]the corners of the bump in units of half the jump's width: along the piece from the jump's start, across it (Visio's numbers)struct Jumpa jump in a connector's Geometrystart: [f64; 2]-- where it starts and ends on the connector's way (page coordinates)end: [f64; 2]normal: [f64; 2]-- the side it rises to (a unit vector across the way; a gap: 0, 0) and how high (drawing units; a gap: half its width)height: f64style: JumpStyle
impl Jump
fn width(&self) -> f64its width along the wayfn way(doc: &Document, c: ShapeRef) -> Option<Vec<[f64; 2]>>a connector's way on the page without its line jumps (None: no connector, or no jump rows: read its Geometry as it is)fn read(doc: &Document, c: ShapeRef) -> Vec<Jump>the line jumps a connector's Geometry holds, in the order of its rowsstruct Laidthe connectors a gesture lays, in its order
impl Laid
fn note(&mut self, doc: &Document, c: ShapeRef)a connector laid (other shapes are passed over)fn is_empty(&self) -> boolwhether no connector was notedfn lay(tx: &mut Transaction, eng: &mut Engine, laid: &Laid) -> Result<(), EditError>after the connectors noted are laid: their jumps, those of every connector they cross and of every connector whose jumps the crossings no longer explain, worked out and written (one call per gesture: the order of the list is the order they were laid in)fn lay_again(tx: &mut Transaction, eng: &mut Engine, conns: &[ShapeRef]) -> Result<(), EditError>these connectors laid again where they are (their line jump cells changed), in this orderfn lay_page(tx: &mut Transaction, eng: &mut Engine, page: PageRef) -> Result<(), EditError>every connector of the page laid again, in z-order (the page's line jump cells changed)fn forget(tx: &mut Transaction, eng: &mut Engine, deleted: &[ShapeRef]) -> Result<(), EditError>before shapes are deleted: the connectors that cross their connectors (theirs and those in them) get their jumps anew without them