/// import { DisplayObject, FederatedMouseEvent, FederatedPointerEvent, Point } from 'pixi.js'; import { IGraphicScene } from '../app/JlGraphicApp'; import { JlGraphic } from '../core/JlGraphic'; export declare enum InteractionPluginType { App = "app", Graphic = "graphic", Other = "other" } /** * 交互插件 */ export interface InteractionPlugin { readonly _type: string; name: string; app: IGraphicScene; /** * 恢复 */ resume(): void; /** * 停止 */ pause(): void; /** * 是否生效 */ isActive(): boolean; isAppPlugin(): boolean; isOtherPlugin(): boolean; isGraphicPlugin(): boolean; } export declare abstract class InteractionPluginBase implements InteractionPlugin { readonly _type: string; name: string; app: IGraphicScene; _pause: boolean; constructor(app: IGraphicScene, name: string, type: string); /** * 恢复 */ resume(): void; /** * 停止 */ pause(): void; abstract bind(): void; abstract unbind(): void; /** * 是否生效 */ isActive(): boolean; isGraphicPlugin(): boolean; isAppPlugin(): boolean; isOtherPlugin(): boolean; } export declare abstract class OtherInteractionPlugin extends InteractionPluginBase { constructor(app: IGraphicScene, name: string); } export declare class AppDragEvent { app: IGraphicScene; type: 'start' | 'move' | 'end'; target: DisplayObject; original: FederatedPointerEvent; start: Point; constructor(app: IGraphicScene, type: 'start' | 'move' | 'end', target: DisplayObject, original: FederatedPointerEvent, start: Point); get isMouse(): boolean; get isLeftButton(): boolean; get isRightButton(): boolean; get isMiddleButton(): boolean; get isTouch(): boolean; /** * 终点坐标(画布坐标) */ get end(): Point; get dx(): number; get dy(): number; get dsx(): number; get dsy(): number; /** * 转换为目标对象的位移距离 */ toTargetShiftLen(target: DisplayObject): { dx: number; dy: number; }; } /** * 拖拽操作插件 */ export declare class DragPlugin extends OtherInteractionPlugin { static Name: string; private threshold; target: DisplayObject | null; start: Point | null; startClientPoint: Point | null; drag: boolean; constructor(app: IGraphicScene); static new(app: IGraphicScene): DragPlugin; bind(): void; unbind(): void; onPointerDown(e: FederatedPointerEvent): void; onPointerMove(e: FederatedPointerEvent): void; onPointerUp(e: FederatedPointerEvent): void; /** * 清理缓存 */ clearCache(): void; } /** * 视口移动插件 */ export declare class ViewportMovePlugin extends OtherInteractionPlugin { static Name: string; static MoveInterval: number; static TriggerRange: number; static DefaultMoveSpeed: number; moveHandler: NodeJS.Timeout | null; moveSpeedx: number; moveSpeedy: number; constructor(app: IGraphicScene); static new(app: IGraphicScene): ViewportMovePlugin; pause(): void; bind(): void; unbind(): void; startMove(moveSpeedx: number, moveSpeedy: number): void; stopMove(): void; private calculateBoundaryMoveSpeed; calculateMoveSpeed(dd: number): number; viewportMove(e: FederatedMouseEvent): void; } /** * 应用交互插件,同时只能生效一个 */ export declare abstract class AppInteractionPlugin extends InteractionPluginBase { constructor(name: string, app: IGraphicScene); /** * 恢复,app交互插件同时只能生效一个 */ resume(): void; } /** * 图形交互插件,可同时生效 */ export declare abstract class GraphicInteractionPlugin implements InteractionPlugin { readonly _type = InteractionPluginType.Graphic; app: IGraphicScene; name: string; _pause: boolean; constructor(name: string, app: IGraphicScene); isActive(): boolean; isAppPlugin(): boolean; isOtherPlugin(): boolean; isGraphicPlugin(): boolean; resume(): void; pause(): void; /** * 过滤需要的图形对象 */ abstract filter(...grahpics: JlGraphic[]): G[] | undefined; binds(list?: G[]): void; unbinds(list?: G[]): void; /** * 绑定图形对象的交互处理 * @param g 图形对象 */ abstract bind(g: G): void; /** * 取消图形对象的交互处理 * @param g 图形对象 */ abstract unbind(g: G): void; }