discontinuedPackage jet_cad_floor_plan has been discontinued and replaced by jet_cad_2d_plan.

selfSnap method

  1. @override
Vector2? selfSnap(
  1. Vector2 raw,
  2. double apertureWorld
)

Spec 08 D15's edge snap, as 05 D4's self-snap: it wins outright over the chain. With object snap on and a host under raw, the raw point is projected onto the host's centreline and edgeSnap is applied there; on a hit, the snapped centre's world point on the centreline.

Implementation

@override
Vector2? selfSnap(Vector2 raw, double apertureWorld) {
  _edgeSnapped = false;
  final ctx = _context;
  if (ctx == null || !(ctx.snap?.objectSnap ?? true)) return null;
  final doc = ctx.document;
  final host = _hostAt(doc, raw);
  if (host == null || !_ready(doc, host)) return null;
  final layout = _layout!;
  final toWorld = _toWorld!;
  final f = layout.frame;
  final v = edgeSnap(
      layout.stretches,
      _otherCuts,
      f.uOf(_toLocal!.transformPoint(raw)),
      settings.value.width,
      // The aperture in the host's local units along its centreline: one
      // local unit along `d` is `|toWorld ยท d|` in world, exactly, even
      // for a non-uniformly scaled group.
      apertureWorld / toWorld.transformDirection(f.d).length);
  if (v == null) return null;
  _edgeSnapped = true;
  _edgeHost = host;
  _edgeU = v;
  return toWorld.transformPoint(f.at(v, 0));
}