SheetSnap.fs

Snap Data Definitions

  1. snapIndicatorLine: Defines the style for a visual indicator line when snapping occurs.
  2. snapLineHorizontal and snapLineVertical: Helper functions to create horizontal and vertical snap indicator lines based on a given position (y or x).
  3. snapIndicatorLineX and snapIndicatorLineY: Functions that create the horizontal and vertical snap indicator lines for a given model and canvas.
  4. emptySnap: Represents an initial state of snap data, which means no snapping is occurring.
  5. symbolMatch: Maps different component types to values that partition them into sets of components that should be treated as the same type during snap operations.

Main Snap Data Definitions

  1. getNewSymbolSnapInfo: Extracts static snap data used to control symbol snapping during a move operation. It considers other symbols and ports for potential snapping points.
  2. getNewSegmentSnapInfo: Extracts static snap data used to control segment snapping during a drag operation. It considers other segments for potential snapping points.

Snap Functions

  1. snap1D: Main snap function for one-dimensional snapping. It determines if a position should snap to a snap point and calculates the offset.
  2. snap2DSymbol: Determines how a dragged symbol snaps in both X and Y dimensions. It uses snap1D for both X and Y dimensions.
  3. snap2DSegment: Determines how a dragged segment snaps in both X and Y dimensions. It uses snap1D based on the orientation of the segment.

Explanation

Overall, this system ensures that symbols and segments align with specific points on the canvas during user interactions, making it easier to create well-organized schematics.