diagram_core/src/route_styles.rs#
Source: lib/diagram_core/src/route_styles.rs
route_styles -- (JD21, CN-05, SS-40, SS-19) the routing styles of a page and of a connector with
their directions, the ways they lay, and the shapes connectors may cross
Kind, RouteStyle { kind, dir } a style and its direction (organization chart, flowchart,
tree and simple have one; the others None)
RouteStyle::from_code(c) / code() Visio's RouteStyle / ShapeRouteStyle codes 0 .. 22
RouteStyle::new(kind, dir) (a direction where the style has none is dropped, one
where it needs one defaults to top to bottom)
of(doc, connector) -> RouteStyle its ShapeRouteStyle, else its page's RouteStyle (0 and
unknown codes: right angle)
pass(doc, shape) -> u8 route::PASS_X | PASS_Y from ShapePermeableX / Y
permeable_place(doc, shape) ShapePermeablePlace: a layout may place shapes on it
(layout::diagram leaves it out of the obstacles)
dynamics_off(doc, owner) -> bool the page's DynamicsOff
(crate) shape(doc, target) -> Option<Shape> a dynamic end's shape: box, middle, outline
(crate) route(style, [shapes], &a_ports, &b_ports, ..) -> Routed the way of a connector in its
style and whether Visio's right-angle router lays it
(crate) mark(tx, connector, router) ConFixedCode afterwards as Visio writes it (6 / 0)
Visio's rules -- belegt (Microsoft Learn: the cells RouteStyle, ShapeRouteStyle, ConFixedCode,
ShapePermeableX/Y/Place, DynamicsOff, CtrlAsInput, LineAdjustFrom/To, LineRouteExt; the archived
Visio 2002 developer pages "Creating Routable and Other 1-D Connectors" and "Designing Shapes for
Automatic Layout"; the Visio 2000 user's guide, chapter 6):
* RouteStyle / ShapeRouteStyle: 0 default (right angle), 1 right angle, 2 straight,
3/4/10/11 organization chart top to bottom / left to right / bottom to top / right to left,
5/6/12/13 flowchart, 7/8/14/15 tree (the same four directions), 9 network, 16 centre to
centre, 17/18/19/20 simple (top to bottom, left to right, bottom to top, right to left),
21 simple horizontal-vertical, 22 simple vertical-horizontal. ShapeRouteStyle 0 takes the
page's.
* ShapePermeableX / Y: TRUE lets connectors route horizontally / vertically through the
(placeable) shape. ShapePermeablePlace: shapes may be placed on top of it by a layout
(layout.rs). ObjType 4: routing behaves as if the shape did not exist (glue.rs).
* DynamicsOff: TRUE turns off "placeable shapes move and connectors reroute around other shapes
and connectors". CtrlAsInput: which shape is the parent of a control handle's glue -- not
routing, kept for Visio. LineAdjustFrom / LineAdjustTo: which connectors routed on top of each
other are spaced apart / lined up -- kept for Visio and shown in Seite einrichten (JD21v: Visio
16 spread connectors at one shape apart whatever the two cells said, 0 .. 2; see below).
LineRouteExt / ConLineRouteExt: 0 default, 1 straight, 2 curved (the appearance, glue.rs).
* ConFixedCode: 0 reroute freely, 1 reroute as needed (manual reroute), 2 never reroute,
3 reroute on crossover, 4 .. 6 internal (route_edit.rs keeps a way by hand).
(JD21v) The ways as a real Visio 16 lays them -- belegt by the counter-check of 2026-11-27
(Documents\JFLib-jd21-visio-check: visio-run3 grid.txt, every style against a child in ten places
around its parent, the tests in route_styles_visio_tests.rs; visio-route-1 / -2, Visio's own
drawings with obstacles, permeable shapes, WalkPreference, ConFixedCode; visio-run2 [route] and
visio-route-3, our drawing after a move: 63 of 100 ways the same; visio-obst-1 / -2, what Visio
routes around and how it spreads connectors, then 76 of 100, the rest below under "Not here").
A is the connector's begin shape, B its end shape (both glued dynamically); "the stub" is half
the page's AvenueSize (route clearance, glue::opts_for: 3.75 mm by default;
AvenueSize 0.5 in gave 0.25 in, LineToNode 0.4 in nothing); "overlap" means the two boxes share
a stretch along an axis:
* The direction of a style decides nothing but its axis: bottom to top lays the same ways as top
to bottom, right to left as left to right (the sides come from where B lies).
* Right angle (0, 1) and network (9; not straight): B beside A (overlap across the axis): one
straight line in the middle of the overlap. Else an L that leaves A vertically (top or bottom,
at its middle) and comes into B's side from the side (at its middle) -- for squares, tall and
wide shapes, far and near, whatever WalkPreference says (it has no effect on these ways), and
the other way round when the connector runs from the lower shape (the begin leaves
vertically). Obstacles (placeable shapes): each leg of the straight line or the L runs in the
middle of the part of its band (the stretch of the shape's side it may leave from) that no
obstacle between the shapes covers -- the nearest such part, then the one towards the other
shape, then the higher one; no part free: the L leaving A sideways (horizontal, then vertical);
neither: a detour around the obstacles at the stub's distance (route.rs; Visio's detours were
matched in form, not always in the side they pass). Visio writes ConFixedCode 6. (visio-obst-1
[sprd]) The straight pieces of the other connectors glued to A or B that run along a leg split
its band as well (no clearance to them): a second connector leaving A's bottom runs in the
middle of the part the first leaves free (A 3.2 .. 4.8 wide, the first at 4.0: 4.4 towards C,
3.6 towards B), each connector routed again keeps out of the others' way; connectors between
other shapes do not count. Placeable is ObjType with bit 1 (not 4): glue.rs.
* Straight (2): B beside A: the right-angle's straight line (ConFixedCode 6); else a line from
A's corner nearest to B to B's corner nearest to A (0). Obstacles do not matter.
* Centre to centre (16): the line between the middles, from outline to outline (6).
* Organization chart (3/4/10/11) and flowchart (5/6/12/13): B beyond A along the axis: out of A's
side facing B at its middle, into B's side facing A at its middle; one straight line when the
middles line up, else a Z whose middle piece runs one stub before B (organization chart) or one
stub after A (flowchart); where an obstacle lies on that piece, at the other of the two places
(Visio did so), where both are blocked or the straight line is, around the obstacles keeping to
the two sides. B beside A (overlap along the axis): the right-angle router (ConFixedCode 6),
else 0.
* Tree (7/8/14/15): one straight line from the middle of A's side facing B to the middle of B's
side facing A, along the axis -- across it when B lies beside A; obstacles do not matter (0).
* Simple (17 .. 20): like the tree's sides, one line when the middles line up, else a Z bending
halfway between the two sides; obstacles do not matter (0).
* Simple horizontal-vertical (21) / vertical-horizontal (22): an L out of A's side (21) or its top
or bottom (22), into B's top or bottom (21) or its side (22), through the middles; B beside A
(no L): one line when the middles line up, else a Z -- above or below A bending one stub before
B, to its left or right one stub after A (both styles alike); obstacles do not matter (0).
* After routing Visio writes ConFixedCode 6 where its right-angle router laid the way and 0 where
a style laid its own (also over 4, 5, 6 and 0 set before); 1, 2 and 3 stay (mark).
Angenommen: ends glued to connection points or free keep the rules from before (the sides of
the direction, the right-angle search); a stub longer than the gap gives the middle; Visio's only
data had the parent at the begin (organization chart before B, flowchart after A are taken as
before the end and after the begin). Not here: in our own drawings Visio laid the stubs of
organization chart and flowchart larger (0.264 in for our connectors, 0.189 in for its own
there; 0.148 in in its drawings, half the AvenueSize): Visio reads our page's AvenueSize as
7.5 mm, and 0.264 stayed with AvenueSize 0.375 in, LineToNode 0.4 in and without arrows
(visio-obst-2 [stub]) -- unexplained, the drawing's theme is left; the counter-check of our
drawing after the moves: 76 of 100 ways the same, the other 24 these stubs. Two connectors
between the same two shapes: when one end moves Visio left the first where it was (the second
avoided it), here both are routed again.
enum Kinda routing style without its directionRightAngle-- right angles around obstacles (also the page default)Straight-- one straight line, corner to corner (beside each other: across in the middle)OrgChart-- right angles, the bend one stub before the end's shapeFlowchart-- right angles, the bend one stub after the begin's shapeTree-- one straight line between the middles of the facing sidesNetwork-- right angles, as RightAngle (Visio lays the same ways)Simple-- right angles bending halfway, around nothingSimpleHV-- leave horizontally, arrive vertically, around nothingSimpleVH-- leave vertically, arrive horizontally, around nothingCentreToCentre-- one straight line between the middles
impl Kind
fn directed(self) -> boolwhether the style has a directionfn straight(self) -> boolwhether the style draws one straight line (straight, centre to centre)struct RouteStylea routing style and its direction (Visio's RouteStyle / ShapeRouteStyle)kind: Kind-- the styledir: Option<Dir>-- the flow (directed kinds only; the ways use only its axis)
impl RouteStyle
const RIGHT_ANGLE: RouteStyle = RouteStyle { kind: Kind::RightAngle, dir: None }right angles (RouteStyle 1)fn new(kind: Kind, dir: Option<Dir>) -> RouteStylea style in a direction (dropped where the style has none; top to bottom where it needs one)fn from_code(code: i64) -> Option<RouteStyle>a RouteStyle / ShapeRouteStyle code (None: 0, the default, and unknown codes)fn code(self) -> i64its RouteStyle / ShapeRouteStyle codefn of(doc: &Document, connector: ShapeRef) -> RouteStylethe style a connector routes in: its own ShapeRouteStyle, else its page's RouteStylefn pass(doc: &Document, shape: ShapeRef) -> u8how connectors may cross a shape: PASS_X (ShapePermeableX), PASS_Y (ShapePermeableY)fn permeable_place(doc: &Document, shape: ShapeRef) -> boolwhether a layout may place shapes on top of the shape (ShapePermeablePlace)fn dynamics_off(doc: &Document, owner: Owner) -> boolwhether the page turns dynamics off (DynamicsOff): connectors do not reroute around shapes moved onto them