Interface ILspSnapper

All Known Implementing Classes:
TLspPointToPointSnapper

public interface ILspSnapper
Interface that defines snapping behavior for an ILspEditor. Snapping is performed by allowing the TLspEditOperations received by the editor to be mutated before the editor processes them. For instance, an ILspSnapper could detect operations that describe an object translation, and modify them to make the translation coincide with a particular snap target (e.g. a vertex of a neighboring polygon).

Edit operations are not modified in place by ILspSnapper. Instead this interface takes one operation as input and can produce any number of new ones as output. This enables complex implementations, such as for instance performing snapping on individual vertices of a polygon while dragging the polygon as a whole (i.e. allowing the snapping to change the shape of the polygon).

Note that the class TLspPointToPointSnapper implements the most common use case for snapping, namely snapping of one point onto another.

Snappers can provide visual feedback about their operation by letting the snap method create "visual components", which are later painted in the view by the controller.

Since:
2012.0
  • Method Details

    • snap

      TLspSnapOperation snap(TLspEditOperation aIncomingOperation, TLspEditContext aContext)
      Performs snapping, if possible, based on the incoming edit operation. Returns a TLspSnapOperation containing a new list of edit operations. The contents of this list may be identical to these of aIncomingOperation.
      Parameters:
      aIncomingOperation - the incoming edit operation to be processed by the snapper
      aContext - provides context information for the edit operation
      Returns:
      a TLspSnapOperation containing a new list of edit operations.
    • canSnap

      boolean canSnap(TLspEditOperation aIncomingOperation, TLspEditContext aContext)
      Returns true if snapping can be performed on the given incoming operation. This method allows the snapper to quickly reject edit operations which it does not understand.
      Parameters:
      aIncomingOperation - the operation that may be processed by the snapper
      aContext - provides context information for the edit operation
      Returns:
      true if the snapper can process the given incoming operation