208 lines
5.6 KiB
TypeScript
208 lines
5.6 KiB
TypeScript
|
import { Container, DisplayObject, Graphics, IDestroyOptions, Point } from 'pixi.js';
|
|||
|
import { AppDragEvent, InteractionPluginBase, KeyListener } from '.';
|
|||
|
import { IGraphicScene } from '../app';
|
|||
|
import { AbsorbablePosition, VectorText } from '../graphic';
|
|||
|
import { DraggablePoint } from '../graphic/DraggablePoint';
|
|||
|
import { DebouncedFunction } from '../utils';
|
|||
|
export declare class ShiftData {
|
|||
|
/**
|
|||
|
* 起始位置
|
|||
|
*/
|
|||
|
startPosition: Point;
|
|||
|
/**
|
|||
|
* 上一次终点位置
|
|||
|
*/
|
|||
|
lastPosition?: Point;
|
|||
|
/**
|
|||
|
* 当前位置
|
|||
|
*/
|
|||
|
currentPosition?: Point;
|
|||
|
constructor(startPosition: Point, currentPosition?: Point, lastPosition?: Point);
|
|||
|
static new(startPosition: Point, currentPosition?: Point, lastPosition?: Point): ShiftData;
|
|||
|
get dx(): number;
|
|||
|
get dy(): number;
|
|||
|
get dsx(): number;
|
|||
|
get dsy(): number;
|
|||
|
}
|
|||
|
export declare class ScaleData {
|
|||
|
start: Point;
|
|||
|
current?: Point;
|
|||
|
last?: Point;
|
|||
|
constructor(start: Point, current?: Point, last?: Point);
|
|||
|
static new(start: Point, current?: Point, last?: Point): ScaleData;
|
|||
|
}
|
|||
|
export type TransformData = ShiftData | null;
|
|||
|
/**
|
|||
|
* 图形平移事件
|
|||
|
*/
|
|||
|
export declare class GraphicTransformEvent {
|
|||
|
/**
|
|||
|
* 图形对象
|
|||
|
*/
|
|||
|
target: DisplayObject;
|
|||
|
type: 'shift' | 'rotate' | 'scale' | 'skew';
|
|||
|
data: TransformData;
|
|||
|
constructor(target: DisplayObject, type: 'shift' | 'rotate' | 'scale' | 'skew', data: TransformData);
|
|||
|
getData<D extends TransformData>(): D;
|
|||
|
static shift(target: DisplayObject, data: ShiftData): GraphicTransformEvent;
|
|||
|
static scale(target: DisplayObject): GraphicTransformEvent;
|
|||
|
static rotate(target: DisplayObject): GraphicTransformEvent;
|
|||
|
static skew(target: DisplayObject): GraphicTransformEvent;
|
|||
|
isShift(): boolean;
|
|||
|
isRotate(): boolean;
|
|||
|
isScale(): boolean;
|
|||
|
isSkew(): boolean;
|
|||
|
}
|
|||
|
export declare class GraphicTransformPlugin extends InteractionPluginBase {
|
|||
|
static Name: string;
|
|||
|
/**
|
|||
|
* 可吸附位置列表
|
|||
|
*/
|
|||
|
absorbablePositions?: AbsorbablePosition[];
|
|||
|
apContainer: Container;
|
|||
|
static AbsorbablePosisiontsName: string;
|
|||
|
constructor(app: IGraphicScene);
|
|||
|
/**
|
|||
|
* 过滤重复的吸附位置
|
|||
|
* @param positions
|
|||
|
* @returns
|
|||
|
*/
|
|||
|
filterAbsorbablePositions(positions: AbsorbablePosition[]): AbsorbablePosition[];
|
|||
|
static new(app: IGraphicScene): GraphicTransformPlugin;
|
|||
|
bind(): void;
|
|||
|
unbind(): void;
|
|||
|
getDraggedTargets(e: AppDragEvent): DisplayObject[];
|
|||
|
onDragStart(e: AppDragEvent): void;
|
|||
|
onDragMove(e: AppDragEvent): void;
|
|||
|
onDragEnd(e: AppDragEvent): void;
|
|||
|
/**
|
|||
|
* 清理缓存
|
|||
|
*/
|
|||
|
clearCache(): void;
|
|||
|
onGraphicSelectedChange(g: DisplayObject, selected: boolean): void;
|
|||
|
}
|
|||
|
/**
|
|||
|
* 缩放、旋转辅助
|
|||
|
*/
|
|||
|
export declare class TransformPoints extends Container {
|
|||
|
static Name: string;
|
|||
|
static MinLength: number;
|
|||
|
static LeftTopName: string;
|
|||
|
static TopName: string;
|
|||
|
static RightTopName: string;
|
|||
|
static RightName: string;
|
|||
|
static RightBottomName: string;
|
|||
|
static BottomName: string;
|
|||
|
static LeftBottomName: string;
|
|||
|
static LeftName: string;
|
|||
|
static RotateName: string;
|
|||
|
obj: DisplayObject;
|
|||
|
ltScalePoint: DraggablePoint;
|
|||
|
ltLocal: Point;
|
|||
|
tScalePoint: DraggablePoint;
|
|||
|
tLocal: Point;
|
|||
|
tCanvas: Point;
|
|||
|
rtScalePoint: DraggablePoint;
|
|||
|
rtLocal: Point;
|
|||
|
rScalePoint: DraggablePoint;
|
|||
|
rLocal: Point;
|
|||
|
rbScalePoint: DraggablePoint;
|
|||
|
rbLocal: Point;
|
|||
|
bScalePoint: DraggablePoint;
|
|||
|
bLocal: Point;
|
|||
|
lbScalePoint: DraggablePoint;
|
|||
|
lbLocal: Point;
|
|||
|
lScalePoint: DraggablePoint;
|
|||
|
lLocal: Point;
|
|||
|
originScale: Point;
|
|||
|
scalePivot: Point;
|
|||
|
/**
|
|||
|
* 旋转拖拽点
|
|||
|
*/
|
|||
|
rotatePoint: DraggablePoint;
|
|||
|
/**
|
|||
|
* 旋转中心坐标
|
|||
|
*/
|
|||
|
rotatePivot: Point;
|
|||
|
/**
|
|||
|
* 起始旋转坐标
|
|||
|
*/
|
|||
|
rotateLastPoint: Point;
|
|||
|
/**
|
|||
|
* 起始图形角度
|
|||
|
*/
|
|||
|
startAngle: number;
|
|||
|
/**
|
|||
|
* 当前角度信息文本辅助
|
|||
|
*/
|
|||
|
angleAssistantText: VectorText;
|
|||
|
/**
|
|||
|
* 旋转角度步长
|
|||
|
*/
|
|||
|
angleStep: number;
|
|||
|
/**
|
|||
|
* 修改旋转步长键盘监听
|
|||
|
*/
|
|||
|
rotateAngleStepKeyListeners: KeyListener[];
|
|||
|
constructor(obj: DisplayObject);
|
|||
|
onObjTransformStart(): void;
|
|||
|
onObjTransformEnd(): void;
|
|||
|
onGraphicRepaint(): void;
|
|||
|
/**
|
|||
|
* 旋转开始
|
|||
|
* @param de
|
|||
|
*/
|
|||
|
onRotateStart(de: GraphicTransformEvent): void;
|
|||
|
updateAngleAssistantText(de: GraphicTransformEvent): void;
|
|||
|
/**
|
|||
|
* 旋转移动
|
|||
|
* @param de
|
|||
|
*/
|
|||
|
onRotateMove(de: GraphicTransformEvent): void;
|
|||
|
/**
|
|||
|
* 旋转结束
|
|||
|
* @param de
|
|||
|
*/
|
|||
|
onRotateEnd(): void;
|
|||
|
/**
|
|||
|
* 缩放开始
|
|||
|
*/
|
|||
|
onScaleDragStart(): void;
|
|||
|
onScaleDragMove(e: GraphicTransformEvent): void;
|
|||
|
onScaleDragEnd(): void;
|
|||
|
hideOthers(dg: DisplayObject): void;
|
|||
|
hideAll(): void;
|
|||
|
showAll(): void;
|
|||
|
getObjBounds(): {
|
|||
|
width: number;
|
|||
|
height: number;
|
|||
|
};
|
|||
|
/**
|
|||
|
* 更新位置和cursor
|
|||
|
* @returns
|
|||
|
*/
|
|||
|
update(): void;
|
|||
|
updateRotatePoint(): void;
|
|||
|
updateScalePoints(): void;
|
|||
|
}
|
|||
|
/**
|
|||
|
* 包围盒矩形图形,现使用外边框转画布多边形实现
|
|||
|
*/
|
|||
|
export declare class BoundsGraphic extends Graphics {
|
|||
|
static Name: string;
|
|||
|
static BoundsLineStyle: {
|
|||
|
width: number;
|
|||
|
color: string;
|
|||
|
alpha: number;
|
|||
|
};
|
|||
|
obj: DisplayObject;
|
|||
|
debouncedRedraw: DebouncedFunction<() => void>;
|
|||
|
constructor(graphic: DisplayObject);
|
|||
|
onObjTransformStart(): void;
|
|||
|
onObjTransformEnd(): void;
|
|||
|
onGraphicRepaint(): void;
|
|||
|
destroy(options?: boolean | IDestroyOptions | undefined): void;
|
|||
|
redraw(): void;
|
|||
|
doRedraw(): void;
|
|||
|
}
|