A tool that allows interactive creation and edition of Shapes.

To create shapes, you can either use one of the preset methods (createSegment, createPolygon...), or start creating a free shape with createShape.

This method allows fine control over the constraints to apply to the shape (how many vertices, styling options, what component to display...).

The enterEditMode method allows the user to edit any shape that the mouse interacts with. Depending on the constraints put on the shape during the creation (assuming of course that the shape was created with this tool), some operations might not be permitted.

To exit edition mode, call exitEditMode.

  • If a shape was created with the createSegment method, it is not possible to insert or remove points, because the constraint forces the shape to have exactly 2 points.

  • If a shape was created with the createPolygon method, then any time the user moves the first or last vertex, the other one is automatically moved at the same position, to ensure the shape remains closed.

Hierarchy (view full)

Implements

Constructors

Methods

  • Enter edition mode. In this mode, existing Shapes can be modified (add/remove points, move points).

    Parameters

    • Optionaloptions: {
          onBeforePointMoved?: MouseCallback;
          onBeforePointRemoved?: MouseCallback;
          onPointInserted?: PointInsertedCallback;
          onPointRemoved?: PointRemovedCallback;
          onPointUpdated?: PointUpdatedCallback;
          onSegmentClicked?: MouseCallback;
          pick?: PickCallback<PickResult<unknown>>;
          pickShapes?: PickCallback<ShapePickResult>;
          shapesToEdit?: entities.Shape<EntityUserData>[];
      }

      The options.

      • OptionalonBeforePointMoved?: MouseCallback

        The optional callback called just before a point is clicked, to determine if it can be moved. By default, points are moved with a left click.

      • OptionalonBeforePointRemoved?: MouseCallback

        The optional callback called just before a point is clicked, to determine if it can be deleted. By default, points are removed with a click on the middle mouse button or Alt + Left click.

      • OptionalonPointInserted?: PointInsertedCallback

        An optional callback called when a point has been inserted.

      • OptionalonPointRemoved?: PointRemovedCallback

        An optional callback called when a point has been removed.

      • OptionalonPointUpdated?: PointUpdatedCallback

        An optional callback called when a point has been updated (i.e moved).

      • OptionalonSegmentClicked?: MouseCallback

        The optional callback to test for mouse or key combination when a segment is clicked. By default, points are inserted with a left click.

      • Optionalpick?: PickCallback<PickResult<unknown>>

        The custom picking function. If unspecified, the default one will be used.

      • OptionalpickShapes?: PickCallback<ShapePickResult>

        A picking function to pick shapes only. If unspecified, the default one will be used.

      • OptionalshapesToEdit?: entities.Shape<EntityUserData>[]

        The shapes to edit. If undefined or empty, all shapes become editable.

    Returns void