diff --git a/graphic-pixi b/graphic-pixi index df9615f..c66f841 160000 --- a/graphic-pixi +++ b/graphic-pixi @@ -1 +1 @@ -Subproject commit df9615fe48fb15a572746e51462e5508db7d4c07 +Subproject commit c66f841526d22af7dcb8ce768ad96488f13468c3 diff --git a/src/jl-graphic/app/index.ts b/src/jl-graphic/app/index.ts index abd1d21..b9f5fa2 100644 --- a/src/jl-graphic/app/index.ts +++ b/src/jl-graphic/app/index.ts @@ -15,6 +15,7 @@ import { IGraphicStorage, IJlCanvas, } from './JlGraphicApp'; +import { GraphicDataUpdateOperation } from './BasicOperation'; /** * 实例化图形app @@ -34,7 +35,7 @@ export function newDrawApp(options: DrawAppOptions): IDrawApp { return new JlDrawApp(options); } -export { AppConsts, GraphicDrawAssistant }; +export { AppConsts, GraphicDrawAssistant, GraphicDataUpdateOperation }; export type { DrawAssistant, ICanvasProperties, diff --git a/src/jl-graphic/plugins/CommonMousePlugin.ts b/src/jl-graphic/plugins/CommonMousePlugin.ts index bab7249..20eec59 100644 --- a/src/jl-graphic/plugins/CommonMousePlugin.ts +++ b/src/jl-graphic/plugins/CommonMousePlugin.ts @@ -1,5 +1,11 @@ -import { DisplayObject, FederatedMouseEvent, Graphics, Point } from 'pixi.js'; -import { IGraphicScene } from '../app'; +import { + Color, + DisplayObject, + FederatedMouseEvent, + Graphics, + Point, +} from 'pixi.js'; +import { ICanvasProperties, IGraphicScene } from '../app'; import { JlGraphic } from '../core'; import { AppDragEvent, @@ -14,10 +20,6 @@ export interface IMouseToolOptions { * 是否启用框选,默认启用 */ boxSelect?: boolean; - /** - * 框选框的颜色--默认黑色 - */ - boxSelectColor?: string; /** * 是否启用视口拖拽(默认右键),默认启用 */ @@ -36,7 +38,6 @@ class CompleteMouseToolOptions implements IMouseToolOptions { boxSelect: boolean; viewportDrag: boolean; wheelZoom: boolean; - boxSelectColor?: string; selectFilter?: GraphicSelectFilter | undefined; constructor() { this.boxSelect = true; @@ -53,7 +54,6 @@ class CompleteMouseToolOptions implements IMouseToolOptions { if (options.wheelZoom != undefined) { this.wheelZoom = options.wheelZoom; } - this.boxSelectColor = options.boxSelectColor; this.selectFilter = options.selectFilter; } } @@ -66,6 +66,7 @@ export class CommonMouseTool extends AppInteractionPlugin { static SelectBox = '__select_box'; options: CompleteMouseToolOptions; box: Graphics; + _boxLineColor: Color; leftDownTarget: DisplayObject | null = null; drag = false; @@ -73,16 +74,19 @@ export class CommonMouseTool extends AppInteractionPlugin { rightTarget: DisplayObject | null = null; - constructor(graphicApp: IGraphicScene) { - super(CommonMouseTool.Name, graphicApp); + constructor(scene: IGraphicScene) { + super(CommonMouseTool.Name, scene); this.options = new CompleteMouseToolOptions(); this.box = new Graphics(); + this._boxLineColor = new Color(); + + scene.canvas.on('dataupdate', this.updateBoxLineColor, this); this.box.name = CommonMouseTool.SelectBox; this.box.visible = false; this.app.canvas.addAssistantAppends(this.box); - graphicApp.on('options-update', (options) => { + scene.on('options-update', (options) => { if (options.mouseToolOptions) { this.options.update(options.mouseToolOptions); if (this.isActive()) { @@ -97,6 +101,13 @@ export class CommonMouseTool extends AppInteractionPlugin { return new CommonMouseTool(app); } + private updateBoxLineColor(cp: ICanvasProperties) { + // 根据画布背景调整线色 + const color = new Color(cp.backgroundColor); + const cn = color.toNumber() ^ 0xffffff; + this._boxLineColor.setValue(cn); + } + bind(): void { const canvas = this.app.canvas; canvas.on('mousedown', this.onMouseDown, this); @@ -294,7 +305,7 @@ export class CommonMouseTool extends AppInteractionPlugin { if (!this.drag) return; // 绘制框选矩形框 this.box.clear(); - this.box.lineStyle({ width: 1, color: this.options.boxSelectColor }); + this.box.lineStyle({ width: 1, color: this._boxLineColor }); const dsx = end.x - start.x; const dsy = end.y - start.y; let { x, y } = start; diff --git a/xian-ncc-da-message b/xian-ncc-da-message index a65253b..7aebba1 160000 --- a/xian-ncc-da-message +++ b/xian-ncc-da-message @@ -1 +1 @@ -Subproject commit a65253b7a3685dabe0376caa36bda8b47d675ff7 +Subproject commit 7aebba13bf04bf2c59df3595c5650a96e616bef4