Jig for handling zoom-to-box selection interaction.

This jig handles the user interaction for selecting a rectangular area to zoom to. It extends AcEdJig to provide interactive selection capabilities.

The jig allows users to:

  • Select a rectangular area on the drawing
  • Zoom the view to fit the selected area
  • Provide visual feedback during selection
const jig = new AcApZoomToBoxJig(view);
await jig.drag(); // User selects area to zoom to

Hierarchy (View Summary)

Constructors

Accessors

Methods

Constructors

Accessors

Methods

  • Starts the interactive jig operation.

    This method initiates both the jig loop and the sampling process. It returns a promise that resolves when the jig operation completes or rejects if an error occurs.

    Returns Promise<void>

    Promise that resolves when the jig operation completes

    const jig = new MyCustomJig(view);
    try {
    const result = await jig.drag();
    console.log('Jig completed with result:', result);
    } catch (error) {
    console.log('Jig was cancelled or failed:', error);
    }
  • Rejects the jig operation with an error.

    This method should be called when the jig operation fails or is cancelled. It cleans up event listeners and rejects the underlying promise.

    Parameters

    • reason: string

      The reason for the rejection

    Returns void

    // If user cancels or invalid input is detected
    if (userPressedEscape) {
    this.reject('Operation cancelled by user');
    }
  • Resolves the jig operation with the specified result.

    This method should be called when the jig operation completes successfully. It cleans up event listeners and resolves the underlying promise.

    Parameters

    • result: boolean

      The result to return from the jig operation

    Returns void

    // In a line drawing jig, when user completes the line
    if (this.hasValidEndPoint()) {
    const line = new Line(this.startPoint, this.endPoint);
    this.resolve(line);
    }
  • Handles the selection sampling and zooming operation.

    This method gets the user's selection box and applies the zoom operation to fit that area in the view.

    Returns Promise<void>

    Promise that resolves when the zoom operation completes

  • Called during each update cycle to refresh the jig display.

    This method should be overridden by subclasses to implement the visual update logic. It's called automatically by the jig loop whenever the display needs to be refreshed (typically on mouse movement).

    Common update operations include:

    • Redrawing preview geometry
    • Updating dimension displays
    • Refreshing visual feedback elements

    Returns void

    update() {
    if (this.startPoint && this.currentMousePoint) {
    // Clear previous preview
    this.clearPreview();

    // Draw new preview line
    this.drawPreviewLine(this.startPoint, this.currentMousePoint);
    }
    }