diagram_core/src/pointglue.rs#
Source: lib/diagram_core/src/pointglue.rs
pointglue -- (JD21) glue beyond the ends of 1-D shapes: control points that glue (SP-04,
SS-30), glue to vertices, handles, control points and guides (CN-02), the connection point
tool (CN-01, RS-17)
glue_control(tx, eng, shape, row, at, to) a control point dragged to `at` and glued to a
connection point (Target::Point) or let go
(Target::None)
glued_controls(doc, shape) -> [(row, Target)] what its control points are glued to
followers(doc, owner, &moved) shapes whose control points are glued to these
shapes: they changed with them (their own glued
connectors follow in the app)
Anchor / anchor_point(tx, eng, target, anchor) the connection point at a vertex, a handle
or a control point of `target` (made when it
has none there yet) -> its IX; glue::glue or
glue_control glue to it
anchor_at(doc, target, anchor) where that place is on the page
glue_guide(tx, eng, shape, end, at, guide) an end of a 1-D shape on a guide
is_glue_guide(doc, g) / guide_of(doc, shape) a guide ends glue to; the guides its ends are on
add_point / move_point / delete_point / set_point_kind / point_kind / point_at the
connection point tool: a Connection row added,
moved, taken out, its Type (0 inward, 1
outward, 2 both)
The file's record, as Visio writes it (the local files: Ethernet taps glued to computers;
learn.microsoft.com VisFromParts, VisToParts, Cell.GlueTo; Visio 2002 Developer Reference
"Creating a Connected Drawing from a Program"):
* a control point (Controls row k, 0-based position in its section) glued to connection point
n of shape N: X and Y = LOC(PNT(Sheet.N!Connections.Xn,Sheet.N!Connections.Yn)) (LOC: a
control point's X and Y are local), Connect FromCell=Controls.<row name> FromPart=100+k
ToCell=Connections.Xn ToPart=100+n-1. No trigger cell: the formula follows the target.
Control points glue statically only (Visio: "control-handle connectors ... can only glue to
a specific point"), to inward points and points of both kinds (Type 0 and 2), not to
outward ones.
* Glue to a vertex, a selection handle or (assumed: Visio's GlueTo lists them for neither
ends nor control points) a control point of another shape: Visio adds a connection point
there and glues to it ("A connection point is created that is glued to ... new formulas in
both the X and Y cells of the connection row"). The row's X and Y here: Geometry<s>.X<r> and
.Y<r> of the vertex (relative rows: times Width and Height), Width*fx and Height*fy of the
handle, Controls.<row> and Controls.<row>.Y of the control point (assumed); DirX, DirY 0,
Type 0. A row with these formulas that is there already is used again.
* An end on a guide (JD21, as Visio 16 writes it; Visio check visio-run2 [glue]): both
coordinates of the end INTERSECTX/INTERSECTY(Sheet.G!PinX, Sheet.G!PinY, Sheet.G!Angle, the
end's point, Sheet.G!Angle+90 deg) -- the foot of the point on the guide's line, so the end
follows the guide and keeps its place along it; two Connect entries, FromCell BeginX and
BeginY (EndX, EndY), FromPart 7 and 8 (10 and 11), ToSheet=G, ToCell=Angle, ToPart=4
(glue::glue replaces both like any). An older form Visio still reads: the coordinate the
guide fixes = Sheet.G!PinY (PinX), one entry ToPart 2 (1). Only top-level 1-D shapes and
guides that run across or up the page.
The connection point tool (Visio's: Ctrl+click on a selected shape adds a point, a drag moves
it, Del takes it out; the point's menu sets its kind): a new row's X and Y are Width*k and
Height*k (proportional, as Visio writes them), DirX and DirY 0, Type 0; a moved point keeps
the form of its formulas (ops: proportional stays proportional). Taking a point out lets go
of what is glued to it (its cells keep their values) and renumbers the rows after it; what is
glued to them is glued again to the same point under its new number.
Which kinds glue (Visio's Type cell: 0 inward, 1 outward, 2 inward & outward): ends and
control points glue to points of kind 0 and 2; a 2-D shape's points of kind 1 and 2 dock on
points of kind 0 and 2 of another shape (dock.rs). The edit layer leaves kind 1 out as a
target (SPF_OUTWARD).
enum Anchora place on a shape that gets a connection point when something glues there (CN-02)Vertex { section: u32, row: u32 }-- a vertex: the Geometry section's index (Geometry1 is 0) and the row's IXHandle { fx: f64, fy: f64 }-- a selection handle: fractions of Width and Height (0, 0.5, 1)Control(RowKey)-- a control point (its row of the Controls section)
fn glue_control(tx: &mut Transaction, eng: &mut Engine, shape: ShapeRef, row: RowKey, at: [f64; 2], to: Target) -> Result<(), EditError>drag a control point (its row) to the page pointatand glue it toto: a connection point of kind 0 or 2 of another shape on the same page (static glue, LOC(PNT(..)) formulas and a Connect entry), or nothing (the point placed as ops::set_control places it). Invalid: a whole shape, a shape inside this one or around it, an outward point; NoRow: no such connection point. A point that was glued is let go first. A GUARD on X or Y keeps the point where it is ungluedfn glued_controls(doc: &Document, shape: ShapeRef) -> Vec<(RowKey, Target)>the control points of a shape that are glued, with their targets (Connect entries from Controls.<row> to a connection point)fn followers(doc: &Document, owner: Owner, moved: &[ShapeRef]) -> Vec<ShapeRef>the shapes (not amongmovednor inside them) whose control points are glued to these shapes or to shapes inside them, and those glued to those in turn: their control points moved with the targets (the formulas did it), so their own connectors have to followfn anchor_at(doc: &Document, target: ShapeRef, anchor: Anchor) -> Option<[f64; 2]>where an anchor of a shape is on the page (None: no such vertex or control point)fn anchor_point(tx: &mut Transaction, eng: &mut Engine, target: ShapeRef, anchor: Anchor) -> Result<u32, EditError>the connection point oftargetat an anchor: an indexed Connection row whose X and Y have the anchor's formulas, else a new one (DirX, DirY, Type 0) -> its IX. Invalid: a section of named rows, a row without a point (Ellipse, InfiniteLine)fn is_glue_guide(doc: &Document, g: ShapeRef) -> boolwhethergis a guide an end can glue to (top-level, across or up the page)fn glue_guide(tx: &mut Transaction, eng: &mut Engine, shape: ShapeRef, end: End, at: [f64; 2], guide: ShapeRef) -> Result<(), EditError>put an end of a 1-D shape on a guide:atgoes onto the guide's line, the coordinate the guide fixes gets its formula (see the file header), a Connect entry records it; a dynamic connector routes again. Invalid: not a top-level 1-D shape, not such a guide, another pagefn guide_of(doc: &Document, shape: ShapeRef) -> [Option<ShapeRef>; 2]the guides the begin and the end of a 1-D shape are glued to (Connect entries from BeginX or EndX to a guide)fn point_kind(doc: &Document, shape: ShapeRef, row: u32) -> Option<u8>the kind (Type) of connection pointrowof a shape: 0 inward, 1 outward, 2 bothfn point_at(doc: &Document, shape: ShapeRef, row: u32) -> Option<[f64; 2]>the page point of connection pointrow(None: no such row)fn add_point(tx: &mut Transaction, eng: &mut Engine, shape: ShapeRef, at: [f64; 2]) -> Result<u32, EditError>add a connection point at the page pointat(the connection point tool's Ctrl+click): X = Width*k, Y = Height*k (a value where the side is 0), DirX, DirY, Type 0 -> its IX. Invalid: a section of named rows, a shape that cannot be turned back (no local point)fn move_point(tx: &mut Transaction, eng: &mut Engine, shape: ShapeRef, row: u32, at: [f64; 2]) -> Result<(), EditError>move connection pointrowto the page pointat: X and Y keep the form of their formulas (Width*k stays proportional, a value stays a value); what is glued to it follows with the recalculation (ends through glue::update in the app)fn set_point_kind(tx: &mut Transaction, eng: &mut Engine, shape: ShapeRef, row: u32, kind: u8) -> Result<(), EditError>give connection pointrowthe kindkind(Type: 0 inward, 1 outward, 2 both)fn delete_point(tx: &mut Transaction, eng: &mut Engine, shape: ShapeRef, row: u32) -> Result<(), EditError>take connection pointrowout: what is glued to it is let go where it is, the rows after it move one up (Transaction::remove_row) and what is glued to them is glued again under the new number