import type { ModelIndexImpl } from "sprotty"; import { SCanvasElement } from "../../model/canvas/sCanvasElement.js"; import { SCanvasPoint } from "../../model/canvas/sCanvasPoint.js"; import { SMarker } from "../../model/canvas/sMarker.js"; /** * Helper to select the points and elements which have to be modified during a move edit. * Automatically detects which points are implicitly moved by other points. * If a relative point is not editable, it tries to move the target instead. * After initialization the result can be found in the following fields: * - movedElements: Elements which are moved. * - hasConflict: True if there is any conflict that prevents the move. */ export declare class MovedElementsSelector { readonly selected: (SCanvasElement | SCanvasPoint | SMarker)[]; private readonly index; /** * The actually selected elements after processing markers and filtering to canvas content. */ private readonly actualSelected; /** * Elements (canvas elements and points) which are moved in the X direction. */ movedElementsX: Set; /** * Elements (canvas elements and points) which are moved in the Y direction. */ movedElementsY: Set; /** * Elements which are implicitly moved in the X direction. */ private readonly implicitlyMovedElementsX; /** * Elements which are implicitly moved in the Y direction. */ private readonly implicitlyMovedElementsY; /** * True if there is any conflict that prevents the move */ hasConflict: boolean; /** * Lookup cache for X-axis movement status to avoid recomputation. */ private readonly isMovedXLookup; /** * Lookup cache for Y-axis movement status to avoid recomputation. */ private readonly isMovedYLookup; /** * Map of elements to their dependencies in the X direction (elements that depend on this element). */ private readonly dependedOnX; /** * Map of elements to their dependencies in the Y direction (elements that depend on this element). */ private readonly dependedOnY; /** * Map of elements to what they depend on in the X direction. */ private readonly dependsOnX; /** * Map of elements to what they depend on in the Y direction. */ private readonly dependsOnY; /** * Returns the (implicitely) moved element ids */ get affectedElementIds(): Set; /** * Creates a new moved elements selector. * The results are available immediately after creation. * * @param selected the selected elements * @param index index for element lookup */ constructor(selected: (SCanvasElement | SCanvasPoint | SMarker)[], index: ModelIndexImpl); /** * Initializes the selector for a specific move operation. * Clears previous state and registers elements that need to be moved. * * @param moveX whether to move elements in the X direction * @param moveY whether to move elements in the Y direction */ initialize(moveX: boolean, moveY: boolean): void; /** * Validates the consistency of the selected elements based on their global rotations. * If there are inconsistencies, sets hasConflict to true. * Conflicts can only occur if not both moveX and moveY are enabled. * * @param moveX whether to move elements in the X direction * @param moveY whether to move elements in the Y direction */ private validateConsistency; /** * Registers the points and elements which are required to move so that elements are moved as a whole. * Does not perform pruning of implicitly moved elements * * @param elements the elements to move * @param moveX whether to move elements in the X direction * @param moveY whether to move elements in the Y direction */ private registerElements; /** * Calculates the rotation difference between two canvas elements. * * @param canvas1 the first canvas element * @param canvas2 the second canvas element * @returns the rotation delta in degrees (0-359) */ private getRotationDelta; /** * Registers all dependency relationships between canvas elements. * This includes position dependencies, line provider dependencies, etc. */ private registerDependencies; /** * Adds a dependency relationship between two canvas elements. * * @param source the element that depends on another element * @param dependency the element that the source depends on * @param isXSource whether the source dependency is in the X direction * @param isXTarget whether the target dependency is in the X direction */ private addDependency; /** * Gets the canvas dependencies for a given canvas element. * Returns elements that this canvas depends on for positioning. * * @param canvas the canvas to get dependencies for * @returns array of canvas content elements that this canvas depends on */ private getCanvasDependencies; /** * Gets the dependencies for a specific segment of a canvas connection. * Returns all points that affect the position of the specified segment. * * @param connection the canvas connection * @param segmentIndex the index of the segment to get dependencies for * @returns array of canvas content elements that this segment depends on */ private getCanvasConnectionSegmentDependencies; /** * Fixes elements that are partially moved by ensuring they are moved in both directions * when their dependencies require it. Continues until no more changes are needed. */ private fixPartiallyMovedElements; /** * Checks if an element is inconsistently moved (has dependencies that conflict). * An element is inconsistently moved if some of its dependencies are moved while others are not. * * @param element the element to check for inconsistent movement * @returns true if the element is inconsistently moved, false otherwise */ private isInconsitentlyMoved; /** * Prunes the moved elements and points to remove implicitly moved elements. */ private pruneMovedElements; /** * Checks if an element is moved in the X direction. * Uses caching to avoid recomputation. * * @param element the element to check * @returns true if the element is moved in the X direction, otherwise false */ private isMovedX; /** * Checks if an element is moved in the Y direction. * Uses caching to avoid recomputation. * * @param element the element to check * @returns true if the element is moved in the Y direction, otherwise false */ private isMovedY; /** * Checks if an element is implicitly moved. * - A canvas element is moved if its position is moved, if it is moved explicitly, or if the parent canvas is moved. * - A relative point is moved if the target is moved. * - A line point is moved if the (relevant segment of the) line provider is moved. * - An absolute point is moved if the parent canvas is moved. * * @param dependencies the dependency entry containing the elements this element depends on * @returns true if the element is implicitly moved, otherwise false */ private isElementImplicitlyMoved; } //# sourceMappingURL=movedElementsSelector.d.ts.map