JFLib

diagram_core/src/ops/arcs.rs#

Source: lib/diagram_core/src/ops/arcs.rs

ops::arcs -- (JD21, SP-05) the handles of arcs in vertex editing: an arc's control point and
the eccentricity handles of an elliptical arc

  arc_handles(doc, shape) -> Vec<ArcHandle>    per ArcTo, EllipticalArcTo and
                                               RelEllipticalArcTo row of the shown sections:
                                               the control point on the page and (absolute
                                               EllipticalArcTo) the two eccentricity handles
  set_arc_point(tx, eng, shape, section, row, at)     the control point dragged to `at`
  set_eccentricity(tx, eng, shape, section, row, at)  an eccentricity handle dragged to `at`

Visio's vertex editing (pencil tool) shows a control point in the middle of an arc segment;
dragging it bends the arc.  An ArcTo keeps its bow A (the distance of the arc's middle from
the middle of its chord, positive right of the chord: geometry.rs), the control point is the
arc's middle; an EllipticalArcTo goes through its control point A, B, which is where the
handle shows (relative rows: fractions of Width and Height).  A clicked control point of an
elliptical arc shows two eccentricity handles on a line through it (Visio: "drag the
eccentricity handles to change the angle and the eccentricity"): the line runs along the
major axis (C, its angle) and each handle lies D x L from the control point, L a quarter of the
chord (assumed: Visio's own spacing is not documented).  Dragging one sets C to the
direction and D to the distance over L (D between 0.01 and 100).  The written cells keep the
form of their formulas where they are proportional (ops::keep_form); the box follows the
geometry afterwards (shapeops::fit_frame), as after every vertex edit.
  • struct ArcHandle the handles of one arc row

    • section: u32 -- the Geometry section's index (Geometry1 is 0)
    • row: u32 -- the row's IX
    • at: [f64; 2] -- the control point on the page (an ArcTo: the arc's middle; an EllipticalArcTo: A, B)
    • ecc: Option<[[f64; 2]; 2]> -- the two eccentricity handles on the page (an absolute EllipticalArcTo only)
  • fn arc_handles(doc: &Document, shape: ShapeRef) -> Vec<ArcHandle> the arc handles of a shape, section by section (hidden sections left out)

  • fn set_arc_point(tx: &mut Transaction, eng: &mut Engine, shape: ShapeRef, section: u32, row: u32, at: [f64; 2]) -> Result<(), EditError> drag the control point of arc row row to the page point at: an ArcTo gets the bow that puts its middle at the point's projection onto the chord's normal, an elliptical arc A and B there. NoRow: not an arc row; Invalid: LockVtxEdit

  • fn set_eccentricity(tx: &mut Transaction, eng: &mut Engine, shape: ShapeRef, section: u32, row: u32, at: [f64; 2]) -> Result<(), EditError> drag an eccentricity handle of the elliptical arc row row to the page point at: the major axis (C) turns towards it, the ratio (D) is its distance from the control point over the handles' unit (see the module comment). NoRow: not an absolute EllipticalArcTo

Source: docs/API.md in the JFLib repository.