2023-05-11 18:20:22 +08:00
|
|
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
2023-05-06 16:28:04 +08:00
|
|
|
declare namespace GlobalMixins {
|
2023-12-13 16:01:53 +08:00
|
|
|
type JlCanvasType = import('./src/app').IJlCanvas;
|
|
|
|
type CanvasProperties = import('./src/app').ICanvasProperties;
|
|
|
|
type GraphicApp = import('./src/app').IGraphicApp;
|
|
|
|
type JlGraphicType = import('./src/core').JlGraphic;
|
|
|
|
type GraphicData = import('./src/core').GraphicData;
|
|
|
|
type GraphicState = import('./src/core').GraphicState;
|
|
|
|
type GraphicTransform = import('./src/core').GraphicTransform;
|
|
|
|
type GraphicTransformEvent = import('./src/plugins').GraphicTransformEvent;
|
|
|
|
type BoundsGraphic = import('./src/plugins').BoundsGraphic;
|
2023-05-06 16:28:04 +08:00
|
|
|
type IPointDataType = import('pixi.js').IPointData;
|
|
|
|
type PointType = import('pixi.js').Point;
|
2023-05-12 18:17:13 +08:00
|
|
|
type FederatedMouseEvent = import('pixi.js').FederatedMouseEvent;
|
2023-05-06 16:28:04 +08:00
|
|
|
type DisplayObjectType = import('pixi.js').DisplayObject;
|
|
|
|
type ContainerType = import('pixi.js').Container;
|
|
|
|
interface DisplayObjectEvents {
|
|
|
|
'enter-absorbable-area': [number | undefined, number | undefined];
|
|
|
|
'out-absorbable-area': [number | undefined, number | undefined];
|
2023-05-11 18:20:22 +08:00
|
|
|
dataupdate: [newVal: any, oldVal: any];
|
|
|
|
stateupdate: [newVal: any, oldVal: any];
|
2023-05-06 16:28:04 +08:00
|
|
|
repaint: [DisplayObjectType];
|
2023-05-11 18:20:22 +08:00
|
|
|
transformstart: [e: GraphicTransformEvent];
|
|
|
|
transforming: [e: GraphicTransformEvent];
|
|
|
|
transformend: [e: GraphicTransformEvent];
|
2023-05-12 18:17:13 +08:00
|
|
|
_rightclick: [e: FederatedMouseEvent];
|
|
|
|
_leftclick: [e: FederatedMouseEvent];
|
2023-05-06 16:28:04 +08:00
|
|
|
selected: [DisplayObjectType];
|
|
|
|
unselected: [DisplayObjectType];
|
|
|
|
childselected: [DisplayObjectType];
|
|
|
|
childunselected: [DisplayObjectType];
|
|
|
|
}
|
|
|
|
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
|
|
|
interface GraphicAppEvents {
|
2023-05-21 18:04:39 +08:00
|
|
|
// propertiesupdate: [selectedData: GraphicData | CanvasProperties | null];
|
2023-05-06 16:28:04 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
interface DisplayObject {
|
|
|
|
_selectable: boolean;
|
|
|
|
_selected: boolean;
|
|
|
|
selectable: boolean; //是否可选中
|
|
|
|
selected: boolean; // 是否选中
|
|
|
|
_childEdit: boolean; // 子元素编辑模式
|
|
|
|
childEdit: boolean;
|
|
|
|
_transformSave: boolean; // 变换是否保存
|
|
|
|
transformSave: boolean; //
|
|
|
|
_assistantAppendMap: Map<string, DisplayObjectType> | null; // 辅助附加图形map
|
|
|
|
assistantAppendMap: Map<string, DisplayObjectType>;
|
|
|
|
_draggable: boolean; // 是否可拖拽
|
|
|
|
draggable: boolean;
|
2023-05-11 18:20:22 +08:00
|
|
|
_shiftStartPoint: PointType | null; // 位移起始坐标
|
|
|
|
shiftStartPoint: PointType | null;
|
|
|
|
_shiftLastPoint: PointType | null; // 位移上一个事件时坐标
|
|
|
|
shiftLastPoint: PointType | null;
|
2023-05-06 16:28:04 +08:00
|
|
|
_scalable: boolean; // 是否可缩放
|
|
|
|
scalable: boolean;
|
|
|
|
_keepAspectRatio: boolean; // 缩放是否保持纵横比,默认保持
|
|
|
|
keepAspectRatio: boolean;
|
|
|
|
_rotatable: boolean; // 是否可旋转
|
|
|
|
rotatable: boolean;
|
|
|
|
worldAngle: number; // 世界角度,(-180, 180]
|
2023-06-25 15:04:28 +08:00
|
|
|
/**
|
|
|
|
* 获取所有父级元素叠加缩放
|
|
|
|
*/
|
2023-05-06 16:28:04 +08:00
|
|
|
getAllParentScaled(): PointType;
|
2023-06-25 15:04:28 +08:00
|
|
|
/**
|
|
|
|
* 获取位置在画布的坐标
|
|
|
|
*/
|
|
|
|
getPositionOnCanvas(): PointType;
|
|
|
|
/**
|
|
|
|
* 通过画布坐标更新位置
|
|
|
|
* @param p 画布坐标
|
|
|
|
*/
|
|
|
|
updatePositionByCanvasPosition(p: IPointData): void;
|
|
|
|
/**
|
|
|
|
* 保存变换数据
|
|
|
|
*/
|
|
|
|
saveTransform(): GraphicTransform;
|
|
|
|
/**
|
|
|
|
* 加载变换
|
|
|
|
* @param transform 变换数据
|
|
|
|
*/
|
|
|
|
loadTransform(transform: GraphicTransform): void;
|
2023-05-06 16:28:04 +08:00
|
|
|
isChild(obj: DisplayObject): boolean; // 是否子元素
|
|
|
|
isParent(obj: DisplayObject): boolean; // 是否父元素
|
|
|
|
isAssistantAppend(): boolean; // 是否辅助附加图形
|
|
|
|
addAssistantAppend<D extends DisplayObjectType>(...appends: D[]): void;
|
|
|
|
removeAssistantAppend(...appends: DisplayObjectType[]): void;
|
|
|
|
removeAssistantAppendByName(...names: string[]): void;
|
|
|
|
removeAllAssistantAppend(): void;
|
|
|
|
getAssistantAppend<D extends DisplayObjectType>(
|
|
|
|
name: string
|
|
|
|
): D | undefined; // 获取辅助附加图形对象
|
|
|
|
isGraphic(): boolean; // 是否业务图形对象
|
|
|
|
getGraphic<G extends JlGraphicType>(): G | null; // 获取所属的图形对象
|
|
|
|
isGraphicChild(): boolean; // 是否图形子元素
|
2023-12-01 15:43:07 +08:00
|
|
|
onAddToCanvas(canvas: JlCanvasType): void; // 添加到画布处理
|
|
|
|
onRemoveFromCanvas(canvas: JlCanvasType): void; //从画布移除处理
|
2023-05-06 16:28:04 +08:00
|
|
|
isInCanvas(): boolean; // 是否添加到画布中
|
|
|
|
getCanvas(): JlCanvasType; // 获取所在画布
|
2023-05-11 18:20:22 +08:00
|
|
|
isCanvas(): boolean; // 是否画布对象
|
2023-05-06 16:28:04 +08:00
|
|
|
getViewport(): Viewport; // 获取视口
|
|
|
|
getGraphicApp(): GraphicApp; // 获取图形app
|
2023-06-25 15:04:28 +08:00
|
|
|
/**
|
|
|
|
* 图形本地坐标转为画布坐标
|
|
|
|
* @param p 图形本地坐标
|
|
|
|
*/
|
|
|
|
localToCanvasPoint(p: IPointData): PointType;
|
|
|
|
/**
|
|
|
|
* 批量转换图形本地坐标为画布坐标
|
|
|
|
* @param points 图形本地坐标
|
|
|
|
*/
|
|
|
|
localToCanvasPoints(...points: IPointData[]): PointType[];
|
|
|
|
/**
|
|
|
|
* 画布坐标转为图形本地坐标
|
|
|
|
* @param p 画布坐标
|
|
|
|
*/
|
|
|
|
canvasToLocalPoint(p: IPointData): PointType;
|
|
|
|
/**
|
|
|
|
* 批量转换画布坐标为图形本地坐标
|
|
|
|
* @param points 画布坐标
|
|
|
|
*/
|
|
|
|
canvasToLocalPoints(...points: IPointData[]): PointType[];
|
|
|
|
/**
|
|
|
|
* 本地坐标转为屏幕坐标
|
|
|
|
* @param p 本地坐标
|
|
|
|
*/
|
|
|
|
localToScreenPoint(p: IPointData): PointType;
|
|
|
|
/**
|
|
|
|
* 批量转换本地坐标为屏幕坐标
|
|
|
|
* @param points 本地坐标
|
|
|
|
*/
|
|
|
|
localToScreenPoints(...points: IPointData[]): PointType[];
|
|
|
|
/**
|
|
|
|
* 屏幕坐标转为本地坐标
|
|
|
|
* @param p 屏幕坐标
|
|
|
|
*/
|
|
|
|
screenToLocalPoint(p: IPointData): PointType;
|
|
|
|
/**
|
|
|
|
* 批量转换屏幕坐标为本地坐标
|
|
|
|
* @param points 屏幕坐标
|
|
|
|
*/
|
2023-05-06 16:28:04 +08:00
|
|
|
screenToLocalPoints(...points: IPointData[]): PointType[]; // 批量
|
|
|
|
|
|
|
|
localBoundsToCanvasPoints(): PointType[]; // 本地包围框转为多边形点坐标
|
|
|
|
}
|
|
|
|
|
|
|
|
interface Graphics {
|
|
|
|
drawBezierCurve(
|
|
|
|
p1: IPointData,
|
|
|
|
p2: IPointData,
|
|
|
|
cp1: IPointData,
|
|
|
|
cp2: IPointData,
|
|
|
|
segmentsCount: number
|
|
|
|
): Graphics;
|
|
|
|
}
|
|
|
|
}
|