JFLib

diagram_core#

the diagram model: ShapeSheet cells, formulas, geometry, routing and layout -- crate root lib/diagram_core/src/lib.rs

diagram_core -- the diagram model: ShapeSheet cells, formulas, geometry, routing and layout

The model behind JFDiagrammer (apps/JFDiagrammer, plan in its PLAN.md), usable by any app that
draws or reads diagrams of the Visio kind.  It holds no file format (that is diagram_io) and no
widget (the canvas is ui::diagram); it is plain data and the rules that compute it.

The ShapeSheet is the model (decision V1): every cell is kept as the file has it -- formula,
cached value, unit and where it comes from (local, inherited from the master or from a style,
deleted) -- and documents, pages and shapes are views on these cells.  So a round trip through
a file loses nothing, and the behaviour Visio files carry works without translation.

  Document            pages (foreground, background), masters, styles, the document sheet,
                      themes and parts kept as bytes; a stencil is a document without pages
  Page, Master, Style  their attributes, sheets, shape trees and Connect entries
  ShapeTree, ShapeData, Shape   shapes, groups, foreign objects, guides and their subshapes
  Sheet, Section, Row, Cell     the ShapeSheet store; Value, Formula, Unit, Origin
  doc.resolve(sheet, addr)      a cell with inheritance: shape -> master shape -> styles
  doc.rows / shape_data / user_cells / hyperlinks / layers   rows as they really are
  doc.transaction(label)        edits with undo and redo (Change; ui::history wraps it)
  Unit, convert, Implicit       unit codes and conversion to the internal units (inches,
                                radians, days)
  Strings, Sym                  the document's string table (compact cells)
  Extras                        what the file had and the model does not know (DF-03)
  formula::Engine               the formula engine: parse, evaluate, recalculate (JD6)

  instance::*                   (JD9) masters from stencils into documents and onto pages:
                                import_master, place, the texts in five languages
  geometry::*                   (JD4) Geometry rows as paths of lines and cubic curves,
                                transforms (pin, local pin, angle, flips, groups)
  render::build(..) -> Drawing  (JD4) a page as a display list: fills, lines, line ends,
                                texts laid out, pictures, in painter's order with a grid;
                                render::rebuild (JD7) builds some top-level shapes again
  ops::*                        (JD7) gestures as cell writes: move, resize, rotate, flip,
                                pin, control points, vertices, groups, z-order, new shapes,
                                text, the clipboard inside an app
  glue::* / route::*            (JD7) connection points, static and dynamic glue (Connect
                                entries), the dynamic connector, right-angle routing around
                                obstacles
  hit::*                        (JD7) the shape under a point of a display list, shapes in a
                                rectangle

  structure::*                  (JD10) containers, lists, callouts: membership in the
                                Relationships cell, automatic size, list order and layout
  dock::*                       (JD13) 2-D shapes that snap with an outward connection point
                                onto an inward one (equipment into racks)
  pagesetup::*                  (JD8) a page's size against its drawing and its paper:
                                orientation, sizes, fit to the drawing, automatic size in
                                tiles of the printed sheet; Transaction::add_page_like and
                                duplicate_page insert pages with settings or content
  data::*                       (JD18) external data: connections, recordsets with their
                                cached rows, rows bound to shapes (Prop rows, DataLinked),
                                refresh with conflicts, automatic linking (DA-04, DA-05)
  shapeops::*                   (JD21) shape operations: Vereinigen, Kombinieren,
                                Fragmentieren, Schneiden, Subtrahieren (SP-08) on geom's plane
                                Booleans, arcs rebuilt as arcs; fit_frame (the box follows the
                                geometry after vertex edits, SP-05), update_alignment_box (SP-16)
  groups::*                     (JD21) group behaviour: SelectMode and the other Group
                                Properties, Zu Gruppe hinzufügen / Aus Gruppe entfernen,
                                dropping into a group, the ungroup warning (SS-17, SP-06, RS-27)
  replace::*                    (JD21) Shape ändern: shapes replaced by a master's instance,
                                text, data, format, glue kept (SP-11, Change Shape Behavior)
  field::*                      (JD8) text fields: a Field row's value in its format picture,
                                new fields, the text with its fields, the document's
                                properties (Document::fields: the app's locale and clock)
  layout::*                     (JD21) the page laid out anew in Visio's styles (flowchart,
                                hierarchy, compact tree, radial, circular; CN-13), connected
                                shapes aligned and spaced (CN-14), shapes off the page
                                breaks (PR-03), the diagram turned or flipped (RS-25)
  autoconn::*                   (JD21) a shape dropped on a connector splits it and the shapes
                                after it make room (CN-08), a deleted shape's connectors go
                                and the flow through it heals (CN-09), drops push shapes
                                away (PlowCode)
  tools::*                      (JD21) Visio's add-ons as tools (AS-11, RA-09): numbering
                                shapes, arrays of copies, dimension lines glued or tied to
                                the shapes they measure
  route_styles::*               (JD21) the routing styles of page and connector with their
                                directions (flowchart, tree, organization chart, simple ...;
                                CN-05, SS-40), the ways they lay as Visio 16 does (JD21v),
                                shapes connectors may cross (SS-19)
  route_edit::*                 (JD21) a connector's way by hand: midpoints and vertices
                                moved, added, removed, the way kept when its shapes move (CN-04)
  jumps::*                      (JD21) line jumps where connectors cross, written into the
                                connectors' Geometry when they are laid, as Visio does (CN-06)
  pointglue::*                  (JD21) control points that glue to connection points and
                                follow them (SP-04), glue to vertices, handles, control points
                                and guides (CN-02), the connection point tool (CN-01)
  datagraphic::*                (JD19) data graphics: callouts, data bars, icon sets and
                                colour by value from a shape's data as Visio keeps them (a
                                hidden master per graphic, callout instances as subshapes),
                                the legend of lists and containers (DA-07, DA-08, ST-08)
  report::*                     (JD19) shape reports: Visio's report definitions as a model
                                (their XML and the document sheet's visPropRptN rows are
                                diagram_io::report), run into a table with groups and
                                summaries, the table shape on the page and its refresh
                                (DA-09, DA-13, EX-12)

Rules that hold from the start: no std (only alloc), no unsafe code, nothing recalculated on
opening a file (connectors, layout and containers move only when something moves), and a
formula with an unknown function keeps its cached value instead of failing.

Sections

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