import { SUndoStack } from "@saga-web/base"; import { SGraphScene } from '@saga-web/graph/lib'; import { SItemStatus, ItemOrder } from "@saga-web/big"; import { SLineStyle } from "@saga-web/graph/lib"; import { SZoneLegendItem } from "@/lib/items/SZoneLegendItem"; import { SImageLegendItem } from "@/lib/items/SImageLegendItem"; import { TipelineItem } from "@/lib/items/TipelineItem"; import { SImageMarkerItem } from "@/lib/items/SImageMarkerItem"; import { SPoint, SFont } from '@saga-web/draw/lib'; import { uuid } from "@/components/mapClass/until"; import { STextMarkerItem } from '@/lib/items/STextMarkerItem'; import { SLineMarkerItem } from '@/lib/items/SLineMarkerItem'; /** * 在线绘图 * * @author 韩耀龙 */ export class EditScence extends SGraphScene { constructor() { super(); this.undoStack = new SUndoStack(); /** 命令 1 绘制直线 */ this.cmd = 'choice'; /** 绘制区域时 是否为点选 */ this.isSelecting = false; /** 是否开启吸附 */ this.isAbsorbing = false; /** 吸附展示item */ this.highLight = null; /** 当前选中焦点Item */ this.focusItem = null; /**图例节点 */ this.Nodes = []; // 图例节点,所有与工程信息化相关的图例(图标类型与区域) /**图例节点 */ // 与工程信息无关的标识对象(增加文本注释,图上的图片说明) this.Markers = []; /** 管线对象 */ this.Relations = []; this._isEditStatus = true; // 是否可编辑 /** 绘制图例样式 */ this._legend = null; /** fid=>item映射,由解析器存入 */ this.fidToItem = {}; // // 选择绑定选额item事件 this.selectContainer.connect("listChange", this, this.listChange); ItemColor.spaceColor = new SColor("#A4ABB22B"); ItemColor.wallColor = new SColor("#A7AEB3FF"); ItemColor.columnColor = new SColor("#A7AEB3FF"); ItemColor.virtualWallColor = new SColor("#A7AEB3FF"); ItemColor.selectColor = new SColor("#84A0BB2B"); ItemColor.spaceBorderColor = new SColor("#A7AEB3FF"); } /** 获取当前状态 */ get getCmd() { return this.cmd; } /** 编辑当前状态 */ set setCmd(cmd) { if (cmd == 'choice') { this.grabItem = null; } this.cmd = cmd; if (this.focusItem) { // 取消操作 this.focusItem.cancelOperate(); this.focusItem = null; // this.selectContainer. } if (this.view) { this.view.update(); } } ; set isEditStatus(bol) { this._isEditStatus = bol; } get isEditStatus() { return this._isEditStatus; } get getlegend() { return this._legend; } ; set setlegend(obj) { this._legend = obj; console.log('aaaaaa', obj); } /** * 监听变化 * @param obj 变化后的对象 */ listChange(obj) { let itemType = 'equipment'; if (obj.itemList[0] instanceof STextMarkerItem) { itemType = 'baseText'; } else if (obj.itemList[0] instanceof SImageMarkerItem) { itemType = 'baseImage'; } else if (obj.itemList[0] instanceof SLineMarkerItem) { itemType = 'baseLine'; } else if (obj.itemList[0] instanceof SZoneLegendItem) { itemType = 'Zone'; } else if (obj.itemList[0] instanceof SFHFQZoneLegendItem) { itemType = 'Zone'; } else if (obj.itemList[0] instanceof SSCPZZoneLegendItem) { itemType = 'Zone'; } else if (obj.itemList[0] instanceof SImageLegendItem) { itemType = 'Image'; } else if (obj.itemList[0] instanceof TipelineItem) { itemType = 'Line'; } else if (obj.itemList[0] instanceof SSpaceItem) { // 点选 this.clickToAddArea(obj.itemList[0]); return; } else { itemType = ''; } ; if (obj.itemList.length == 1) { // 获取聚焦item this.focusItem = obj.itemList[0]; } let msg = { itemList: obj.itemList, itemType, }; this.emitChange(msg); } emitChange(msg) { } /** * 增加线段item */ addLine(event) { const clickItem = this.clickIsItem(event); if (clickItem) { let centerPoint = clickItem.boundingRect().center(); const p = clickItem.mapToScene(centerPoint.x, centerPoint.y); event.x = p.x; event.y = p.y; } const data = { /** ID */ ID: uuid(), /** 名称 */ Name: '直线', /** 图标(Image),线类型(Line) */ Type: "Line", /** 位置 */ Pos: { X: 0, Y: 0 }, /** 由应用自己定义 */ Properties: { IconUrl: require("../../assets/images/t-line-hover.png"), Line: [{ X: event.x, Y: event.y }], LineWidth: 2 } }; const item = new SLineMarkerItem(null, data); item.status = SItemStatus.Create; item.zOrder = ItemOrder.lineOrder; item.selectable = true; this.addItem(item); this.Markers.push(item); item.connect("finishCreated", this, this.finishCreated); this.grabItem = item; this.focusItem = item; this.scenceUpdate(this); // this.undoStack.push(new SGraphAddCommand(this, item)); // item.connect("onMove", this, this.onItemMove.bind(this)); return true; } /** * 增加折线item */ addPolylineItem(event) { const point = new SPoint(event.x, event.y); const item = new TipelineItem(null, [point]); //设置状态 item.selectable = true; item.status = SItemStatus.Create; item.zOrder = ItemOrder.polylineOrder; this.addItem(item); item.connect("finishCreated", this, this.finishCreated); // this.undoStack.push(new SGraphAddCommand(this, item)); this.grabItem = item; this.focusItem = item; return true; } /** * 增加管道 lenged */ addTipelineItem(event) { var _a; const anc = this.clickIsAnchor(event); if (anc) { const p = anc.mapToScene(0, 0); anc.isConnected = true; event.x = p.x; event.y = p.y; } const LegendData = { ID: uuid(), Name: this._legend.Name, GraphElementId: this._legend.Id, PointList: [{ X: event.x, Y: event.y }], LineType: "Line", Properties: { IconUrl: '/serve/topology-wanda/Picture/query/' + this._legend.Url, LineDash: this._legend.LineDash, LineWidth: this._legend.LineWidth, Color: this._legend.Color, }, }; const item = new TipelineItem(null, LegendData); //设置状态 item.selectable = true; item.status = SItemStatus.Create; item.zOrder = ItemOrder.polylineOrder; this.addItem(item); this.Relations.push(item); item.connect("finishCreated", this, this.finishCreated); // this.undoStack.push(new SGraphAddCommand(this, item)); this.grabItem = item; this.focusItem = item; // 起始锚点 item.startAnchor = anc; if (anc) { (_a = anc.parent) === null || _a === void 0 ? void 0 : _a.connect('changePos', item, item.changePos); item.anchor1ID = anc.id; item.node1Id = anc.parent.id; } this.scenceUpdate(this); return true; } /** * 增加多边形item lenged */ addPolygonItem(event) { const SubType = this._legend.SubType ? this._legend.SubType : ''; const LegendData = { ID: uuid(), Name: this._legend.Name, GraphElementType: this._legend.Type, Num: 1, GraphElementId: this._legend.Id, AttachObjectIds: [], Type: "Zone", Pos: { X: event.x, Y: event.y }, OutLine: [{ X: event.x, Y: event.y }], SubType: SubType, Properties: { IconUrl: '/serve/topology-wanda/Picture/query/' + this._legend.Url, StrokeColor: this._legend.Color, FillColor: this._legend.FillColor, LineDash: this._legend.LineDash, LineWidth: this._legend.LineWidth, font: 0, color: '', TextPos: { X: 0, Y: 0 } }, }; let Polylines = null; if (SubType == "SCPZ") { Polylines = new SSCPZZoneLegendItem(null, LegendData); } else if (SubType == "FHFQ") { Polylines = new SFHFQZoneLegendItem(null, LegendData); } else { Polylines = new SZoneLegendItem(null, LegendData); } Polylines.selectable = true; //设置状态 Polylines.status = SItemStatus.Create; Polylines.zOrder = ItemOrder.polygonOrder; // Polylines.moveable = true; this.addItem(Polylines); this.Nodes.push(Polylines); Polylines.connect("finishCreated", this, this.finishCreated); this.grabItem = Polylines; this.focusItem = Polylines; this.scenceUpdate(this); } /** * 点选创建区域 */ clickToAddArea(item) { if (this.cmd != 'Zone') { return; } if (this.isSelecting && this._legend) { //@ts-ignore item.isExtracted = true; const SubType = this._legend.SubType ? this._legend.SubType : ''; const LegendData = { ID: uuid(), Name: this._legend.Name, GraphElementType: this._legend.Type, Num: 1, GraphElementId: this._legend.Id, AttachObjectIds: [], Type: "Zone", Pos: { X: item.x, Y: item.y }, OutLine: item.pointArr[0], SubType: SubType, Properties: { IconUrl: '/serve/topology-wanda/Picture/query/' + this._legend.Url, StrokeColor: this._legend.Color, FillColor: this._legend.FillColor, LineDash: this._legend.LineDash, LineWidth: this._legend.LineWidth, font: 12, color: '', FID: item.data.SourceId, TextPos: { X: item.data.Location.Points[0].X, Y: -item.data.Location.Points[0].Y } }, }; let Polylines = null; if (SubType == "SCPZ") { Polylines = new SSCPZZoneLegendItem(null, LegendData); } else if (SubType == "FHFQ") { Polylines = new SFHFQZoneLegendItem(null, LegendData); } else { Polylines = new SZoneLegendItem(null, LegendData); } Polylines.selectable = true; //设置状态 Polylines.status = SItemStatus.Normal; this.addItem(Polylines); this.Nodes.push(Polylines); Polylines.connect("finishCreated", this, this.finishCreated); this.finishCreated(Polylines); this.focusItem = Polylines; this.scenceUpdate(this); } } /** * 增加图片Item mark */ addImgItem(event) { const data = { /** ID */ ID: uuid(), /** 名称 */ Name: '图片', Num: 1, /** 图标(Image),线类型(Line) */ Type: "Image", /** 位置 */ Pos: { X: event.x, Y: event.y }, /** 由应用自己定义 */ Properties: { IconUrl: require(`../../assets/images/t-img-hover.png`), Url: '', } }; const item = new SImageMarkerItem(null, data); item.zOrder = ItemOrder.imageOrder; item.selectable = true; item.moveable = true; this.addItem(item); this.Markers.push(item); this.grabItem == null; this.focusItem = item; this.cmd = 'choice'; this.scenceUpdate(this); } /** * 增加文字item */ addTextItem(event) { const data = { /** ID */ ID: uuid(), /** 名称 */ Name: '文本', /** 图标 */ Type: "Text", /** 位置 */ Pos: { X: event.x, Y: event.y }, /** 由应用自己定义 */ Properties: { IconUrl: require(`../../assets/images/t-text-hover.png`), Text: '请在右侧属性栏输入文字!', Color: '', Font: 12, BackgroundColor: '' } }; const item = new STextMarkerItem(null, data); item.moveTo(event.x, event.y); item.selectable = true; item.moveable = true; item.zOrder = ItemOrder.textOrder; this.addItem(item); this.Markers.push(item); this.grabItem = item; this.focusItem = item; this.cmd = 'choice'; this.scenceUpdate(this); } /** * 增加图标lenged图标 */ addIconItem(event) { //获取信息工程化相关参数 const LegendData = { ID: uuid(), Name: this._legend.Name, GraphElementType: this._legend.Type, Num: 1, GraphElementId: this._legend.Id, AttachObjectIds: [], Pos: { X: event.x, Y: event.y }, Scale: { X: 1, Y: 1, Z: 1 }, Rolate: { X: 0, Y: 0, Z: 0 }, Size: { Width: 0, Height: 0 }, Properties: { IconUrl: '/serve/topology-wanda/Picture/query/' + this._legend.Url, Url: '/serve/topology-wanda/Picture/query/' + this._legend.Url, Num: 1, sWidth: 24, sHeight: 24, font: 12, color: '', GraphCategoryId: this._legend.GraphCategoryId }, }; const item = new SImageLegendItem(null, LegendData); this.cmd = 'choice'; item.selectable = true; item.moveable = true; item.zOrder = ItemOrder.markOrder; this.addItem(item); this.Nodes.push(item); this.grabItem = item; this.focusItem = item; this.scenceUpdate(this); } /** * 更改item对应属性 */ editItemStatus() { } /** * 更改文本对应属性 * @param str string 文字内容 */ updatedText(str) { if (this.focusItem) { const old = this.focusItem.text; this.focusItem.text = str; this.scenceUpdate(this); // this.undoStack.push(new SGraphPropertyCommand(this, this.focusItem, "text", old, str)); } } /** * 更改文本fontSize属性 * @param size number 文字大小 */ updatedFontSize(size) { if (this.focusItem) { let old = new SFont(this.focusItem.font); let font = new SFont(this.focusItem.font); font.size = size; this.focusItem.font = font; // this.undoStack.push(new SGraphPropertyCommand(this, this.focusItem, "font", old, font)); } } /** * 更改线宽属性 * @param lineWidth number 线宽大小 */ updatedLineWidth(lineWidth) { if (this.focusItem) { // let old = new SFont(this.focusItem.font); // let font = new SFont(this.focusItem.font); // font.size = size; this.focusItem.lineWidth = lineWidth; // this.undoStack.push(new SGraphPropertyCommand(this, this.focusItem, "font", old, font)); } } /** * 更改文本颜色属性 * @param str string 颜色 */ updatedFontColor(color) { if (this.focusItem) { let old = this.focusItem.color; this.focusItem.color = new SColor(color); // this.undoStack.push(new SGraphPropertyCommand(this, this.focusItem, "color", old, color)); } } /** * 更改border颜色 * @param color string 颜色 */ updatedBorderColor(color) { if (this.focusItem) { if (this.focusItem instanceof SZoneLegendItem || this.focusItem instanceof SSCPZZoneLegendItem || this.focusItem instanceof SFHFQZoneLegendItem) { this.focusItem.strokeColor = new SColor(color); } else { // let old = this.focusItem.strokeColor; this.focusItem.strokeColor = new SColor(color); } // this.undoStack.push(new SGraphPropertyCommand(this, this.focusItem, "color", old, color)); } } /** * 更改item宽 * @param width number 颜色 */ updatedWidth(width) { if (this.focusItem) { // let old = this.focusItem.width; if (this.focusItem.data && this.focusItem.data.GraphElementType && this.focusItem.data.GraphElementType == "Image") { this.focusItem.sWidth = width; } else { this.focusItem.width = width; } // this.undoStack.push(new SGraphPropertyCommand(this, this.focusItem, "color", old, color)); } } /** * 更改item高 * @param height number 颜色 */ updatedHeight(height) { if (this.focusItem) { // let old = this.focusItem.width; if (this.focusItem.data && this.focusItem.data.GraphElementType && this.focusItem.data.GraphElementType == "Image") { this.focusItem.sHeight = height; } else { this.focusItem.height = height; } // this.undoStack.push(new SGraphPropertyCommand(this, this.focusItem, "color", old, color)); } } /** * 更改item坐标 * @param x number x x坐标 * @param y number y y坐标 */ updatedPosition(x, y) { if (this.focusItem) { let p = this.focusItem.mapFromScene(x, y); // newx - oldx = newleft - oldleft // 要求的值(新的x坐标) - 旧的x坐标 = 新的左边界(用户输入的值) - 旧的左边界 this.focusItem.x = p.x - this.focusItem.boundingRect().left + this.focusItem.x; this.focusItem.y = p.y - this.focusItem.boundingRect().top + this.focusItem.y; } } /** * 更改item 背景色坐标 * @param color string 颜色color */ updatedbackColor(color) { if (this.focusItem) { this.focusItem.backgroundColor = new SColor(color); } } /** * 更改item Url * @param url string 图片key */ upadataImageUrl(url) { if (this.focusItem) { this.focusItem.url = '/serve/topology-wanda/Picture/query/' + url; } } /** * 更改item border * @param val string border类型 */ upadataBorder(val) { if (this.focusItem) { let borderStyle = null; if (val == 'dashed') { borderStyle = SLineStyle.Dashed; } else if (val == 'dotted') { borderStyle = SLineStyle.Dotted; } else if (val == 'solid') { borderStyle = SLineStyle.Soild; } this.focusItem.lineStyle = borderStyle; } } /** * 更改item 名称 * @param val string border类型 */ upadataLengedName(val) { if (this.focusItem && this.focusItem.data) { this.focusItem.text = val; this.scenceUpdate(this); } } /** * 更改item Num数量 * @param num number item数量 (只对icon设备类) */ upadatImageNum(num) { if (this.focusItem && this.focusItem.num) { this.focusItem.num = num; } } /** * 更改item Num数量 * @param num number item数量 (只对icon设备类) */ upadatfillColor(fillColor) { if (this.focusItem && this.focusItem.fillColor) { this.focusItem.fillColor = new SColor(fillColor); } } /** * 更改图例说 * @param num number */ upadatitemExplain(ItemExplain) { if (this.focusItem) { this.focusItem.data.Properties.ItemExplain = ItemExplain; } } /** * 更新工程信息化的相关数据 * @param AttachObjectIds Array */ upadatAttachObjectIds(AttachObjectIds) { if (this.focusItem) { this.focusItem.data.AttachObjectIds = AttachObjectIds; } } /** * 删除指定item */ deleiteItem() { if (this.focusItem) { if ((this.focusItem instanceof SZoneLegendItem || this.focusItem instanceof SSCPZZoneLegendItem || this.focusItem instanceof SFHFQZoneLegendItem || this.focusItem instanceof TipelineItem) && this.focusItem.curIndex != -1) { this.focusItem.deletePoint(this.focusItem.curIndex); } else { this.removeItem(this.focusItem); let a = -1; this.Nodes.forEach((item, index) => { if (item.id == this.focusItem.id) { a = index; } }); if (a > -1) { this.Nodes.splice(a, 1); } let b = -1; this.Markers.forEach((item, index) => { if (item.id == this.focusItem.id) { b = index; } }); if (b > -1) { this.Markers.splice(b, 1); } let c = -1; this.Relations.forEach((item, index) => { if (item.id == this.focusItem.id) { c = index; } }); if (c > -1) { this.Relations.splice(c, 1); } this.focusItem = null; if (this.view) { this.view.update(); } this.scenceUpdate(this); } } } scenceUpdate(scence) { } /** * 对齐指定item * @param v */ changeAlignItem(v) { this.selectContainer.layout(v); } /** * 提取item */ extractItem() { console.log(this); } /** * 保存数据 */ saveMsgItem() { const Nodes = []; const Markers = []; const Relations = []; this.Nodes.forEach(e => { Nodes.push(e.toData()); }); this.Markers.forEach(e => { Markers.push(e.toData()); }); this.Relations.forEach(e => { Relations.push(e.toData()); }); let element = { Nodes, Markers, Relations }; return element; } /** * 锁住item */ lockItem() { } /** * 执行取消操作 */ redo() { this.undoStack.undo(); } /** * 执行重做操作执行 */ undo() { this.undoStack.redo(); } /** * 完成事件创建的回调函数 */ finishCreated(item) { this.setCmd = 'choice'; this.focusItem = item; this.selectContainer.toggleItem(item); } //////////////////////// // 以下为鼠标键盘操作事件 onMouseDown(event) { if (!this.isEditStatus) { return super.onMouseDown(event); } // 判断是否开启吸附,并且有吸附的点 if (this.isAbsorbing && this.highLight && this.highLight.visible) { event.x = this.highLight.point.x; event.y = this.highLight.point.y; } if (this.grabItem) { if (this.grabItem instanceof TipelineItem) { this.setTipeEndanchor(event); return true; } return this.grabItem.onMouseDown(event); } switch (this.cmd) { case 'baseLine': this.addLine(event); break; case 'baseText': this.addTextItem(event); break; case 'baseImage': this.addImgItem(event); break; case 'Zone': if (!this.isSelecting) { this.addPolygonItem(event); } else { // 点选创建区域 return super.onMouseDown(event); } break; case 'Image': this.addIconItem(event); break; case 'Line': this.addTipelineItem(event); break; default: return super.onMouseDown(event); } } onMouseMove(event) { if (!this.isEditStatus) { return super.onMouseMove(event); } if (this.isAbsorbing) { if (!this.highLight) { this.highLight = new HighlightItem(null); this.addItem(this.highLight); } this.highLight.visible = false; this.absorbSpace(event); } return super.onMouseMove(event); } /** * 键盘事件 * * @param event 事件参数 * @return boolean */ onKeyDown(event) { if (!this.isEditStatus) { return super.onKeyDown(event); } if (this.grabItem) { this.grabItem.onKeyDown(event); if (event.code == "Escape") { const item = this.grabItem; this.grabItem = null; this.removeItem(item); if (this.view) { this.view.update(); } this.setCmd = 'choice'; } } // if (event.key == "Enter") { // this.cmd = 0 // } return false; } /** * 鼠标双击事件 * * @param event 事件参数 * @return boolean */ onDoubleClick(event) { if (!this.isEditStatus) { return true; } else { return super.onDoubleClick(event); } } // Function onDoubleClick() /** * 设置结束锚点 * */ setTipeEndanchor(event) { var _a; if (this.grabItem instanceof TipelineItem) { if (this.grabItem.status == SItemStatus.Create) { const anc = this.clickIsAnchor(event); if (anc) { const p = anc.mapToScene(0, 0); anc.isConnected = true; event.x = p.x; event.y = p.y; if (this.grabItem.pointList.length) { this.grabItem.endAnchor = anc; (_a = anc.parent) === null || _a === void 0 ? void 0 : _a.connect('changePos', this.grabItem, this.grabItem.changePos); } this.grabItem.anchor2ID = anc.id; this.grabItem.node2Id = anc.parent.id; this.grabItem.onMouseDown(event); this.grabItem.status = SItemStatus.Normal; this.finishCreated(this.grabItem); return; } } this.grabItem.onMouseDown(event); } } /** * 划线时点击位置是否是锚点 * * @param event 事件 * @param len 限制距离 * @return 点击的锚点 * */ clickIsAnchor(event) { let minAnchor = null; let len = -1; this.Nodes.forEach(image => { if (image.anchorList && image.anchorList.length) { image.anchorList.forEach(anchor => { let anchorPoint = anchor.mapToScene(0, 0); let dis = SMathUtil.pointDistance(event.x, event.y, anchorPoint.x, anchorPoint.y); if (len < 0) { len = anchor.sceneDis; } if (dis < len) { minAnchor = anchor; len = dis; } }); } }); console.log('-----------------------'); console.log(minAnchor); console.log('-----------------------'); return minAnchor; } /** * 划线时点击位置是在文本,图片,,区域内 * * @param event 事件 * @return 点击的item * */ clickIsItem(event) { let minIten = null; let len = -1; let itemList = this.Nodes.concat(this.Markers); itemList.forEach(item => { if (item instanceof STextMarkerItem || item instanceof SImageMarkerItem || item instanceof SZoneLegendItem || item instanceof SFHFQZoneLegendItem || item instanceof SSCPZZoneLegendItem) { let scenePoint = item.mapFromScene(event.x, event.y); if (item.contains(scenePoint.x, scenePoint.y)) { let dis = SMathUtil.pointDistance(scenePoint.x, scenePoint.y, item.boundingRect().center().x, item.boundingRect().center().y); if (len < 0) { minIten = item; len = dis; } if (dis < len) { minIten = item; len = dis; } } } }); console.log('-----------------------'); console.log(minIten); console.log('-----------------------'); return minIten; } /** * 点是否在吸附区域内 * * @param p 要判断的点 * @param minX 空间区域 * @param minY 空间区域 * @param maxX 空间区域 * @param maxY 空间区域 */ static isPointInAbsorbArea(p, minX, maxX, minY, maxY) { let rect = new SRect(minX - 1000, minY - 1000, maxX - minX + 2000, maxY - minY + 2000); return rect.contains(p.x, p.y); } // Function isPointInAbsorbArea() /** * 吸附空间 * * @param event 鼠标事件对象 * @return boolean 是否找到吸附的对象 */ absorbSpace(event) { if (!this.highLight) { return false; } let absorbLen = 1000; if (this.view) { absorbLen = 10 / this.view.scale; } let P = this.absorbSpacePoint(event, absorbLen); if (P.Point) { this.highLight.distance = P.MinDis; this.highLight.point = new SPoint(P.Point.X, -P.Point.Y); this.highLight.visible = true; return true; } else { let L = this.absorbSpaceLine(event, absorbLen); if (L.Line && L.Point) { this.highLight.distance = L.MinDis; this.highLight.point = L.Point; this.highLight.line = L.Line; this.highLight.visible = true; return true; } return false; } } // Function absorbSpace() /** * 吸附空间点 * * @param event 鼠标事件对象 * @param absorbLen 吸附距离 * @return MinDis 吸附的点 */ absorbSpacePoint(event, absorbLen) { let minPointDis = Number.MAX_SAFE_INTEGER; let Point; this.spaceList.map((space) => { if (EditScence.isPointInAbsorbArea(new SPoint(event.x, event.y), space.minX, space.maxX, space.minY, space.maxY)) { space.data.OutLine.forEach((item) => { let minDis = SMathUtil.getMinDisPoint(new SPoint(event.x, event.y), item); if (minDis && minDis.MinDis < absorbLen && minDis.MinDis < minPointDis) { minPointDis = minDis.MinDis; Point = minDis.Point; } }); } }); return { MinDis: minPointDis, Point: Point }; } // Function absorbSpacePoint() /** * 吸附空间线 * * @param event 鼠标事件对象 * @param absorbLen 吸附距离 * @return PointToLine 吸附的线 */ absorbSpaceLine(event, absorbLen) { let minPointDis = Number.MAX_SAFE_INTEGER; let Point, Line; this.spaceList.forEach((space) => { if (EditScence.isPointInAbsorbArea(new SPoint(event.x, event.y), space.minX, space.maxX, space.minY, space.maxY)) { space.data.OutLine.forEach((item) => { let minDisLine = SMathUtil.getMinDisLine(new SPoint(event.x, event.y), item); if (minDisLine && minDisLine.MinDis < absorbLen && minDisLine.MinDis < minPointDis) { minPointDis = minDisLine.MinDis; Point = minDisLine.Point; Line = minDisLine.Line; } }); } }); return { MinDis: minPointDis, Point: Point, Line: Line }; } // Function absorbSpaceLine() }