EditScence.ts 45 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339
  1. import { SMouseEvent, SUndoStack } from "@saga-web/base";
  2. import { SGraphScene, SGraphLayoutType, SAnchorItem } from '@saga-web/graph/lib';
  3. import { SFloorParser, SLineItem, SPolylineItem, SItemStatus, ItemOrder, STooltipItem, ItemColor } from "@saga-web/big";
  4. import { SGraphItem, SLineStyle,SGraphPropertyCommand, SImageItem, STextItem, SGraphPointListInsert, SGraphPointListDelete, SGraphPointListUpdate, SGraphAddCommand } from "@saga-web/graph/lib";
  5. import { SZoneLegendItem } from "@/lib/items/SZoneLegendItem";
  6. import { SSCPZZoneLegendItem } from "@/lib/items/SSCPZZoneLegendItem";
  7. import { SFHFQZoneLegendItem } from "@/lib/items/SFHFQZoneLegendItem";
  8. import { SImageLegendItem } from "@/lib/items/SImageLegendItem";
  9. import { TipelineItem } from "@/lib/items/TipelineItem";
  10. import { SImageMarkerItem } from "@/lib/items/SImageMarkerItem"
  11. import { SPoint, SFont, SColor, SRect } from '@saga-web/draw/lib';
  12. import { Legend } from '@/lib/types/Legend';
  13. import { Relation } from '@/lib/types/Relation';
  14. import { uuid } from "@/components/mapClass/until";
  15. import { STextMarkerItem } from '@/lib/items/STextMarkerItem';
  16. import { SLineMarkerItem } from '@/lib/items/SLineMarkerItem';
  17. import { SSpaceItem } from '@saga-web/big/lib/items/floor/SSpaceItem';
  18. import { SMathUtil } from '@saga-web/big/lib/utils/SMathUtil';
  19. import { MinDis } from '@saga-web/big/lib/types/MinDis';
  20. import { HighlightItem } from '@/lib/items/HighlightItem';
  21. /**
  22. * 在线绘图
  23. *
  24. * @author 韩耀龙
  25. */
  26. export class EditScence extends SGraphScene {
  27. undoStack = new SUndoStack();
  28. /** 命令 1 绘制直线 */
  29. private cmd = 'choice';
  30. /** 获取当前状态 */
  31. get getCmd(): string {
  32. return this.cmd;
  33. }
  34. /** 编辑当前状态 */
  35. set setCmd(cmd: string) {
  36. if (cmd == 'choice') {
  37. this.grabItem = null;
  38. }
  39. this.cmd = cmd;
  40. if (this.focusItem) {
  41. // 取消操作
  42. this.focusItem.cancelOperate();
  43. this.focusItem = null;
  44. // this.selectContainer.clear()
  45. }
  46. if (this.view) {
  47. this.view.update();
  48. }
  49. };
  50. /** 绘制区域时 是否为点选 */
  51. isSelecting: boolean = false;
  52. /** 是否开启吸附 */
  53. isAbsorbing: boolean = false;
  54. /** 吸附展示item */
  55. highLight: HighlightItem | null = null;
  56. /** 当前选中焦点Item */
  57. focusItem: SGraphItem | null = null;
  58. /** 当前选中焦点ItemList */
  59. focusItemList: SGraphItem[] | null = null;
  60. /**图例节点 */
  61. Nodes: any = []; // 图例节点,所有与工程信息化相关的图例(图标类型与区域)
  62. /**图例节点 */ // 与工程信息无关的标识对象(增加文本注释,图上的图片说明)
  63. Markers: any = [];
  64. /** 管线对象 */
  65. Relations: any = [];
  66. _isEditStatus: Boolean = true; // 是否可编辑
  67. set isEditStatus(bol: Boolean): void {
  68. this._isEditStatus = bol;
  69. }
  70. get isEditStatus(): Boolean {
  71. return this._isEditStatus
  72. }
  73. constructor() {
  74. super();
  75. // // 选择绑定选额item事件
  76. this.selectContainer.connect("listChange", this, this.listChange);
  77. ItemColor.spaceColor = new SColor("#A4ABB22B")
  78. ItemColor.wallColor = new SColor("#A7AEB3FF")
  79. ItemColor.columnColor = new SColor("#A7AEB3FF")
  80. ItemColor.virtualWallColor = new SColor("#A7AEB3FF")
  81. ItemColor.selectColor = new SColor("#84A0BB2B")
  82. ItemColor.spaceBorderColor = new SColor("#A7AEB3FF")
  83. }
  84. /** 绘制图例样式 */
  85. _legend: any | null = null;
  86. get getlegend(): any {
  87. return this._legend;
  88. };
  89. set setlegend(obj: any) {
  90. this._legend = obj;
  91. console.log('aaaaaa', obj)
  92. }
  93. /** fid=>item映射,由解析器存入 */
  94. fidToItem = {}
  95. /**
  96. * 监听变化
  97. * @param obj 变化后的对象
  98. */
  99. listChange(obj: any) {
  100. let itemType: string = 'equipment';
  101. this.focusItemList = obj.itemList;
  102. if (obj.itemList[0] instanceof STextMarkerItem) {
  103. itemType = 'baseText'
  104. } else if (obj.itemList[0] instanceof SImageMarkerItem) {
  105. itemType = 'baseImage'
  106. } else if (obj.itemList[0] instanceof SLineMarkerItem) {
  107. itemType = 'baseLine'
  108. } else if (obj.itemList[0] instanceof SZoneLegendItem) {
  109. itemType = 'Zone'
  110. } else if (obj.itemList[0] instanceof SFHFQZoneLegendItem) {
  111. itemType = 'Zone'
  112. } else if (obj.itemList[0] instanceof SSCPZZoneLegendItem) {
  113. itemType = 'Zone'
  114. } else if (obj.itemList[0] instanceof SImageLegendItem) {
  115. itemType = 'Image'
  116. } else if (obj.itemList[0] instanceof TipelineItem) {
  117. itemType = 'Line'
  118. } else if (obj.itemList[0] instanceof SSpaceItem) { // 点选
  119. this.clickToAddArea(obj.itemList[0]);
  120. return
  121. } else {
  122. itemType = ''
  123. };
  124. if (obj.itemList.length == 1) {
  125. // 获取聚焦item
  126. this.focusItem = obj.itemList[0]
  127. } else {
  128. this.focusItem = null
  129. }
  130. let msg = {
  131. itemList: obj.itemList,
  132. itemType,
  133. }
  134. this.emitChange(msg)
  135. }
  136. emitChange(msg: any) {
  137. }
  138. /**
  139. * 增加线段item
  140. */
  141. addLine(event: SMouseEvent): boolean {
  142. const clickItem = this.clickIsItem(event);
  143. if (clickItem) {
  144. let centerPoint = clickItem.boundingRect().center();
  145. const p = clickItem.mapToScene(centerPoint.x, centerPoint.y);
  146. event.x = p.x;
  147. event.y = p.y;
  148. }
  149. const data = {
  150. /** ID */
  151. ID: uuid(),
  152. /** 名称 */
  153. Name: '直线',
  154. /** 图标(Image),线类型(Line) */
  155. Type: "Line",
  156. /** 位置 */
  157. Pos: { X: 0, Y: 0 },
  158. /** 由应用自己定义 */
  159. Properties: {
  160. IconUrl: require("../../assets/images/t-line-hover.png"),
  161. Line: [{ X: event.x, Y: event.y }],
  162. LineWidth: 2
  163. }
  164. }
  165. const item = new SLineMarkerItem(null, data);
  166. item.status = SItemStatus.Create;
  167. item.zOrder = ItemOrder.lineOrder;
  168. item.selectable = true;
  169. this.addItem(item);
  170. this.Markers.push(item);
  171. item.connect("finishCreated", this, this.finishCreated);
  172. this.grabItem = item;
  173. this.focusItem = item;
  174. // 起始item点
  175. item.startItem = clickItem;
  176. if (clickItem) {
  177. clickItem.connect('onMove', item, item.changePos);
  178. }
  179. this.scenceUpdate(this);
  180. // item.connect("onMove", this, this.onItemMove.bind(this));
  181. return true
  182. }
  183. /**
  184. * 增加折线item
  185. */
  186. addPolylineItem(event: SMouseEvent): boolean {
  187. const point = new SPoint(event.x, event.y)
  188. const item = new TipelineItem(null, [point]);
  189. //设置状态
  190. item.selectable = true;
  191. item.status = SItemStatus.Create;
  192. item.zOrder = ItemOrder.polylineOrder
  193. this.addItem(item);
  194. item.connect("finishCreated", this, this.finishCreated);
  195. this.grabItem = item;
  196. this.focusItem = item;
  197. return true
  198. }
  199. /**
  200. * 增加管道 lenged
  201. */
  202. addTipelineItem(event: SMouseEvent): boolean {
  203. const anc = this.clickIsAnchor(event);
  204. if (anc) {
  205. const p = anc.mapToScene(0, 0)
  206. anc.isConnected = true;
  207. event.x = p.x;
  208. event.y = p.y;
  209. }
  210. const LegendData: Relation = {
  211. ID: uuid(),
  212. Name: this._legend.Name,
  213. GraphElementId: this._legend.Id,
  214. PointList: [{ X: event.x, Y: event.y }],
  215. LineType: "Line",
  216. Properties: {
  217. IconUrl: '/serve/topology-wanda/Picture/query/' + this._legend.Url,
  218. LineDash: this._legend.LineDash,
  219. LineWidth: this._legend.LineWidth,
  220. Color: this._legend.Color,
  221. },
  222. }
  223. const item = new TipelineItem(null, LegendData);
  224. //设置状态
  225. item.selectable = true;
  226. item.status = SItemStatus.Create;
  227. item.zOrder = ItemOrder.polylineOrder
  228. this.addItem(item);
  229. this.Relations.push(item);
  230. item.connect("finishCreated", this, this.finishCreated);
  231. this.grabItem = item;
  232. this.focusItem = item;
  233. // 起始锚点
  234. item.startAnchor = anc;
  235. if (anc) {
  236. anc.parent ?.connect('changePos', item, item.changePos)
  237. item.anchor1ID = anc.id;
  238. item.node1Id = anc.parent.id;
  239. }
  240. this.scenceUpdate(this);
  241. return true
  242. }
  243. /**
  244. * 增加多边形item lenged
  245. */
  246. addPolygonItem(event: SMouseEvent): void {
  247. const SubType = this._legend.SubType ? this._legend.SubType : '';
  248. const LegendData: Legend = {
  249. ID: uuid(),
  250. Name: this._legend.Name,
  251. GraphElementType: this._legend.Type,
  252. Num: 1,
  253. GraphElementId: this._legend.Id,
  254. AttachObjectIds: [],
  255. Type: "Zone",
  256. Pos: { X: event.x, Y: event.y },
  257. OutLine: [{ X: event.x, Y: event.y }],
  258. SubType: SubType,
  259. Properties: {
  260. IconUrl: '/serve/topology-wanda/Picture/query/' + this._legend.Url,
  261. StrokeColor: this._legend.Color,
  262. FillColor: this._legend.FillColor,
  263. LineDash: this._legend.LineDash,
  264. LineWidth: this._legend.LineWidth,
  265. font: 0,
  266. color: '',
  267. TextPos: { X: 0, Y: 0 }
  268. },
  269. }
  270. let Polylines = null;
  271. if (SubType == "SCPZ") {
  272. Polylines = new SSCPZZoneLegendItem(null, LegendData);
  273. } else if (SubType == "FHFQ") {
  274. Polylines = new SFHFQZoneLegendItem(null, LegendData);
  275. } else {
  276. Polylines = new SZoneLegendItem(null, LegendData);
  277. }
  278. Polylines.selectable = true;
  279. //设置状态
  280. Polylines.status = SItemStatus.Create;
  281. Polylines.zOrder = ItemOrder.polygonOrder;
  282. // Polylines.moveable = true;
  283. this.addItem(Polylines);
  284. this.Nodes.push(Polylines);
  285. Polylines.connect("finishCreated", this, this.finishCreated);
  286. this.grabItem = Polylines;
  287. this.focusItem = Polylines;
  288. this.scenceUpdate(this);
  289. }
  290. /**
  291. * 点选创建区域
  292. */
  293. clickToAddArea(item: SSpaceItem): void {
  294. if (this.cmd != 'Zone') {
  295. return
  296. }
  297. if (this.isSelecting && this._legend) {
  298. //@ts-ignore
  299. item.isExtracted = true
  300. const SubType = this._legend.SubType ? this._legend.SubType : '';
  301. const LegendData: Legend = {
  302. ID: uuid(),
  303. Name: this._legend.Name,
  304. GraphElementType: this._legend.Type,
  305. Num: 1,
  306. GraphElementId: this._legend.Id,
  307. AttachObjectIds: [],
  308. Type: "Zone",
  309. Pos: { X: item.x, Y: item.y },
  310. OutLine: item.pointArr[0],
  311. SubType: SubType,
  312. Properties: {
  313. IconUrl: '/serve/topology-wanda/Picture/query/' + this._legend.Url,
  314. StrokeColor: this._legend.Color,
  315. FillColor: this._legend.FillColor,
  316. LineDash: this._legend.LineDash,
  317. LineWidth: this._legend.LineWidth,
  318. font: 12,
  319. color: '',
  320. FID: item.data.SourceId,
  321. TextPos: { X: item.data.Location.Points[0].X, Y: -item.data.Location.Points[0].Y }
  322. },
  323. }
  324. let Polylines = null;
  325. if (SubType == "SCPZ") {
  326. Polylines = new SSCPZZoneLegendItem(null, LegendData);
  327. } else if (SubType == "FHFQ") {
  328. Polylines = new SFHFQZoneLegendItem(null, LegendData);
  329. } else {
  330. Polylines = new SZoneLegendItem(null, LegendData);
  331. }
  332. Polylines.selectable = true;
  333. //设置状态
  334. Polylines.status = SItemStatus.Normal;
  335. this.addItem(Polylines);
  336. this.Nodes.push(Polylines);
  337. Polylines.connect("finishCreated", this, this.finishCreated);
  338. this.focusItem = Polylines;
  339. this.scenceUpdate(this);
  340. }
  341. }
  342. /**
  343. * 增加图片Item mark
  344. */
  345. addImgItem(event: SMouseEvent) {
  346. const data = {
  347. /** ID */
  348. ID: uuid(),
  349. /** 名称 */
  350. Name: '图片',
  351. Num: 1,
  352. /** 图标(Image),线类型(Line) */
  353. Type: "Image",
  354. /** 位置 */
  355. Pos: { X: event.x, Y: event.y },
  356. /** 由应用自己定义 */
  357. Properties: {
  358. IconUrl: require(`../../assets/images/t-img-hover.png`),
  359. Url: '',
  360. }
  361. }
  362. const item = new SImageMarkerItem(null, data);
  363. item.zOrder = ItemOrder.imageOrder;
  364. item.selectable = true;
  365. item.moveable = true;
  366. this.addItem(item);
  367. this.Markers.push(item);
  368. this.grabItem == null;
  369. this.focusItem = item;
  370. this.finishCreated(item);
  371. this.scenceUpdate(this);
  372. }
  373. /**
  374. * 增加文字item
  375. */
  376. addTextItem(event: SMouseEvent): void {
  377. const data = {
  378. /** ID */
  379. ID: uuid(),
  380. /** 名称 */
  381. Name: '文本',
  382. /** 图标 */
  383. Type: "Text",
  384. /** 位置 */
  385. Pos: { X: event.x, Y: event.y },
  386. /** 由应用自己定义 */
  387. Properties: {
  388. IconUrl: require(`../../assets/images/t-text-hover.png`),
  389. Text: '请在右侧属性栏输入文字!',
  390. Color: '',
  391. Font: 12,
  392. BackgroundColor: '#f7f9fa'
  393. }
  394. }
  395. const item = new STextMarkerItem(null, data);
  396. item.moveTo(event.x, event.y);
  397. item.selectable = true;
  398. item.moveable = true;
  399. item.zOrder = ItemOrder.textOrder;
  400. this.addItem(item);
  401. this.Markers.push(item);
  402. this.grabItem = item;
  403. this.focusItem = item;
  404. this.cmd = 'choice';
  405. this.finishCreated(item);
  406. this.scenceUpdate(this);
  407. }
  408. /**
  409. * 增加图标lenged图标
  410. */
  411. addIconItem(event: SMouseEvent): void {
  412. //获取信息工程化相关参数
  413. const LegendData: Legend = {
  414. ID: uuid(),
  415. Name: this._legend.Name,
  416. GraphElementType: this._legend.Type,
  417. Num: 1,
  418. GraphElementId: this._legend.Id,
  419. AttachObjectIds: [],
  420. Pos: { X: event.x, Y: event.y },
  421. Scale: { X: 1, Y: 1, Z: 1 }, // 缩放
  422. Rolate: { X: 0, Y: 0, Z: 0 },
  423. Size: { Width: 0, Height: 0 }, // 大小
  424. Type: this._legend.Type,
  425. Properties: {
  426. IconUrl: '/serve/topology-wanda/Picture/query/' + this._legend.Url,
  427. Url: '/serve/topology-wanda/Picture/query/' + this._legend.Url,
  428. Num: 1, // 此num与信息工程化得num无关
  429. sWidth: 24, //icon 的宽
  430. sHeight: 24, //icon 的高
  431. font: 12, //font
  432. color: '', //字体颜色
  433. GraphCategoryId: this._legend.GraphCategoryId
  434. },
  435. }
  436. const item = new SImageLegendItem(null, LegendData);
  437. this.cmd = 'choice';
  438. item.selectable = true;
  439. item.moveable = true;
  440. item.zOrder = ItemOrder.markOrder;
  441. this.addItem(item);
  442. this.Nodes.push(item);
  443. this.grabItem = item;
  444. this.focusItem = item;
  445. this.finishCreated(item);
  446. this.scenceUpdate(this);
  447. }
  448. /**
  449. * 更改item对应属性
  450. */
  451. editItemStatus(): void {
  452. }
  453. /**
  454. * 更改文本对应属性
  455. * @param str string 文字内容
  456. */
  457. updatedText(str: string): void {
  458. if (this.focusItem) {
  459. const oldMsg = this.focusItem.text;
  460. const newMsg = str;
  461. this.focusItem.text = str;
  462. this.undoStack.push(new SGraphPropertyCommand(this, this.focusItem, "text", oldMsg, newMsg));
  463. this.scenceUpdate(this);
  464. }
  465. }
  466. /**
  467. * 更改文本fontSize属性
  468. * @param size number 文字大小
  469. */
  470. updatedFontSize(size: number): void {
  471. if (this.focusItem) {
  472. let old = new SFont(this.focusItem.font);
  473. let font = new SFont(this.focusItem.font);
  474. font.size = size;
  475. this.focusItem.font = font;
  476. this.undoStack.push(new SGraphPropertyCommand(this, this.focusItem, "font", old, font));
  477. }
  478. }
  479. /**
  480. * 更改线宽属性
  481. * @param lineWidth number 线宽大小
  482. */
  483. updatedLineWidth(lineWidth: number): void {
  484. if (this.focusItem) {
  485. const oldMsg = this.focusItem.lineWidth;
  486. const newMsg = lineWidth;
  487. this.focusItem.lineWidth = lineWidth;
  488. this.undoStack.push(new SGraphPropertyCommand(this, this.focusItem, "lineWidth", oldMsg, newMsg));
  489. }
  490. }
  491. /**
  492. * 更改文本颜色属性
  493. * @param str string 颜色
  494. */
  495. updatedFontColor(color: string): void {
  496. if (this.focusItem) {
  497. const oldMsg = this.focusItem.color;
  498. const newMsg = new SColor(color);
  499. this.focusItem.color = newMsg;
  500. this.undoStack.push(new SGraphPropertyCommand(this, this.focusItem, "color", oldMsg, newMsg));
  501. }
  502. }
  503. /**
  504. * 更改border颜色
  505. * @param color string 颜色
  506. */
  507. updatedBorderColor(color: string): void {
  508. if (this.focusItem) {
  509. const oldMsg = this.focusItem.strokeColor;
  510. const newMsg = new SColor(color);
  511. this.focusItem.strokeColor = newMsg;
  512. this.undoStack.push(new SGraphPropertyCommand(this, this.focusItem, "strokeColor", oldMsg, newMsg));
  513. }
  514. }
  515. /**
  516. * 更改item宽
  517. * @param width number 颜色
  518. */
  519. updatedWidth(width: number): void {
  520. if (this.focusItem) {
  521. let oldMsg = null;
  522. const newMsg = width;
  523. if (this.focusItem.data && this.focusItem.data.GraphElementType && this.focusItem.data.GraphElementType == "Image") {
  524. oldMsg = this.focusItem.sWidth
  525. this.focusItem.sWidth = width;
  526. this.undoStack.push(new SGraphPropertyCommand(this, this.focusItem, "sWidth", oldMsg, newMsg));
  527. } else {
  528. oldMsg = this.focusItem.width
  529. this.focusItem.width = width;
  530. this.undoStack.push(new SGraphPropertyCommand(this, this.focusItem, "width", oldMsg, newMsg));
  531. }
  532. }
  533. }
  534. /**
  535. * 更改item高
  536. * @param height number 颜色
  537. */
  538. updatedHeight(height: number): void {
  539. if (this.focusItem) {
  540. let oldMsg = null;
  541. const newMsg = height;
  542. if (this.focusItem.data && this.focusItem.data.GraphElementType && this.focusItem.data.GraphElementType == "Image") {
  543. oldMsg = this.focusItem.sHeight;
  544. this.focusItem.sHeight = height;
  545. this.undoStack.push(new SGraphPropertyCommand(this, this.focusItem, "sHeight", oldMsg, newMsg));
  546. } else {
  547. oldMsg = this.focusItem.height;
  548. this.focusItem.height = height;
  549. this.undoStack.push(new SGraphPropertyCommand(this, this.focusItem, "height", oldMsg, newMsg));
  550. }
  551. }
  552. }
  553. /**
  554. * 更改item坐标
  555. * @param x number x x坐标
  556. * @param y number y y坐标
  557. */
  558. updatedPosition(x: number, y: number): void {
  559. if (this.focusItem) {
  560. let p = this.focusItem.mapFromScene(x, y)
  561. // newx - oldx = newleft - oldleft
  562. // 要求的值(新的x坐标) - 旧的x坐标 = 新的左边界(用户输入的值) - 旧的左边界
  563. this.focusItem.x = p.x - this.focusItem.boundingRect().left + this.focusItem.x;
  564. this.focusItem.y = p.y - this.focusItem.boundingRect().top + this.focusItem.y;
  565. }
  566. }
  567. /**
  568. * 更改item 背景色坐标
  569. * @param color string 颜色color
  570. */
  571. updatedbackColor(color: string): void {
  572. if (this.focusItem) {
  573. const newMsg = new SColor(color);
  574. const oldMsg = this.focusItem.backgroundColor;
  575. this.focusItem.backgroundColor = new SColor(color);
  576. this.undoStack.push(new SGraphPropertyCommand(this, this.focusItem, "backgroundColor", oldMsg, newMsg));
  577. }
  578. }
  579. /**
  580. * 更改item Url
  581. * @param url string 图片key
  582. */
  583. upadataImageUrl(url: string): void {
  584. if (this.focusItem) {
  585. const newMsg = '/serve/topology-wanda/Picture/query/' + url;
  586. const oldMsg = this.focusItem.url;
  587. this.focusItem.url = newMsg;
  588. this.undoStack.push(new SGraphPropertyCommand(this, this.focusItem, "url", oldMsg, newMsg));
  589. }
  590. }
  591. /**
  592. * 更改item border
  593. * @param val string border类型
  594. */
  595. upadataBorder(val: string): void {
  596. if (this.focusItem) {
  597. let borderStyle = null;
  598. if (val == 'dashed') {
  599. borderStyle = SLineStyle.Dashed;
  600. } else if (val == 'dotted') {
  601. borderStyle = SLineStyle.Dotted;
  602. } else if (val == 'solid') {
  603. borderStyle = SLineStyle.Soild;
  604. }
  605. const newMsg = borderStyle;
  606. const oldMsg = this.focusItem.lineStyle;
  607. this.focusItem.lineStyle = borderStyle;
  608. this.undoStack.push(new SGraphPropertyCommand(this, this.focusItem, "lineStyle", oldMsg, newMsg));
  609. }
  610. }
  611. /**
  612. * 更改item 名称
  613. * @param val string border类型
  614. */
  615. upadataLengedName(val: string): void {
  616. if (this.focusItem && this.focusItem.data) {
  617. const newMsg = val;
  618. const oldMsg = this.focusItem.text;
  619. this.focusItem.text = val;
  620. this.undoStack.push(new SGraphPropertyCommand(this, this.focusItem, "text", oldMsg, newMsg));
  621. this.scenceUpdate(this);
  622. }
  623. }
  624. /**
  625. * 更改item Num数量
  626. * @param num number item数量 (只对icon设备类)
  627. */
  628. upadatImageNum(num: number): void {
  629. if (this.focusItem && this.focusItem.num) {
  630. const newMsg = num;
  631. const oldMsg = this.focusItem.num;
  632. this.focusItem.num = num;
  633. this.undoStack.push(new SGraphPropertyCommand(this, this.focusItem, "num", oldMsg, newMsg));
  634. }
  635. }
  636. /**
  637. * 更改item Num数量
  638. * @param num number item数量 (只对icon设备类)
  639. */
  640. upadatfillColor(fillColor: string): void {
  641. if (this.focusItem && this.focusItem.fillColor) {
  642. const newMsg = new SColor(fillColor);
  643. const oldMsg = this.focusItem.fillColor;
  644. this.focusItem.fillColor = new SColor(fillColor);
  645. this.undoStack.push(new SGraphPropertyCommand(this, this.focusItem, "num", oldMsg, newMsg));
  646. }
  647. }
  648. /**
  649. * 更改图例说
  650. * @param num number
  651. */
  652. upadatitemExplain(ItemExplain: string): void {
  653. if (this.focusItem) {
  654. this.focusItem.data.Properties.ItemExplain = ItemExplain;
  655. }
  656. }
  657. /**
  658. * 更新工程信息化的相关数据
  659. * @param AttachObjectIds Array
  660. */
  661. upadatAttachObjectIds(AttachObjectIds: []): void {
  662. if (this.focusItem) {
  663. this.focusItem.data.AttachObjectIds = AttachObjectIds;
  664. // 重新选中focusitem
  665. const item = this.focusItem;
  666. this.selectContainer.clear();
  667. this.selectContainer.toggleItem(item)
  668. }
  669. }
  670. /**
  671. * 删除指定item
  672. */
  673. deleiteItem(): void {
  674. if (this.focusItem) {
  675. if ((this.focusItem instanceof SZoneLegendItem ||
  676. this.focusItem instanceof SSCPZZoneLegendItem ||
  677. this.focusItem instanceof SFHFQZoneLegendItem ||
  678. this.focusItem instanceof TipelineItem) &&
  679. this.focusItem.curIndex != -1
  680. ) {
  681. this.focusItem.deletePoint(this.focusItem.curIndex);
  682. } else {
  683. this.removeItem(this.focusItem);
  684. let a = -1
  685. this.Nodes.forEach((item: any, index: number) => {
  686. if (item.id == this.focusItem.id) {
  687. a = index
  688. }
  689. });
  690. if (a > -1) {
  691. this.Nodes.splice(a, 1);
  692. }
  693. let b = -1;
  694. this.Markers.forEach((item: any, index: number) => {
  695. if (item.id == this.focusItem.id) {
  696. b = index
  697. }
  698. });
  699. if (b > -1) {
  700. this.Markers.splice(b, 1);
  701. }
  702. let c = -1;
  703. this.Relations.forEach((item: any, index: number) => {
  704. if (item.id == this.focusItem.id) {
  705. c = index
  706. }
  707. });
  708. if (c > -1) {
  709. this.Relations.splice(c, 1);
  710. }
  711. this.focusItem = null;
  712. if (this.view) {
  713. this.view.update();
  714. }
  715. this.scenceUpdate(this);
  716. }
  717. } else {
  718. //批量删除
  719. if (!this.focusItemList) {
  720. return
  721. }
  722. this.focusItemList.forEach((focusItem) => {
  723. this.removeItem(focusItem);
  724. let a = -1
  725. this.Nodes.forEach((item: any, index: number) => {
  726. if (item.id == focusItem.id) {
  727. a = index
  728. }
  729. });
  730. if (a > -1) {
  731. this.Nodes.splice(a, 1);
  732. }
  733. let b = -1;
  734. this.Markers.forEach((item: any, index: number) => {
  735. if (item.id == focusItem.id) {
  736. b = index
  737. }
  738. });
  739. if (b > -1) {
  740. this.Markers.splice(b, 1);
  741. }
  742. let c = -1;
  743. this.Relations.forEach((item: any, index: number) => {
  744. if (item.id == focusItem.id) {
  745. c = index
  746. }
  747. });
  748. if (c > -1) {
  749. this.Relations.splice(c, 1);
  750. }
  751. });
  752. this.focusItemList = [];
  753. if (this.view) {
  754. this.view.update();
  755. }
  756. this.scenceUpdate(this);
  757. }
  758. }
  759. scenceUpdate(scence: any) {
  760. }
  761. /**
  762. * 对齐指定item
  763. * @param v
  764. */
  765. changeAlignItem(v: any): void {
  766. this.selectContainer.layout(v);
  767. }
  768. /**
  769. * 提取item
  770. */
  771. extractItem(): void {
  772. console.log(this)
  773. }
  774. /**
  775. * 保存数据
  776. */
  777. saveMsgItem(): any {
  778. const Nodes: any = [];
  779. const Markers: any = [];
  780. const Relations: any = [];
  781. this.Nodes.forEach(e => {
  782. Nodes.push(e.toData())
  783. });
  784. this.Markers.forEach(e => {
  785. Markers.push(e.toData())
  786. });
  787. this.Relations.forEach(e => {
  788. Relations.push(e.toData())
  789. });
  790. let element = {
  791. Nodes, Markers, Relations
  792. }
  793. return element
  794. }
  795. /**
  796. * 执行取消操作
  797. */
  798. redo(): void {
  799. this.undoStack.undo();
  800. }
  801. /**
  802. * 执行重做操作执行
  803. */
  804. undo(): void {
  805. this.undoStack.redo();
  806. }
  807. /**
  808. * 完成事件创建的回调函数
  809. */
  810. finishCreated(item: any) {
  811. this.cmd = 'choice';
  812. this.selectContainer.clear()
  813. this.selectContainer.toggleItem(item)
  814. setTimeout(()=>{
  815. this.focusItem = item;
  816. })
  817. // 做相应得redo/undo处理
  818. this.undoStack.push(new SGraphAddCommand(this, item));
  819. }
  820. ////////////////////////
  821. // 以下为鼠标键盘操作事件
  822. onMouseDown(event: SMouseEvent): any {
  823. if (!this.isEditStatus) {
  824. return super.onMouseDown(event);
  825. }
  826. // 判断是否开启吸附,并且有吸附的点
  827. if (
  828. this.isAbsorbing &&
  829. this.highLight &&
  830. this.highLight.visible
  831. ) {
  832. event.x = this.highLight.point.x;
  833. event.y = this.highLight.point.y;
  834. }
  835. if (this.grabItem) {
  836. if (this.grabItem instanceof TipelineItem) {
  837. this.setTipeEndanchor(event)
  838. return true;
  839. } else if (this.grabItem instanceof SLineMarkerItem && this.grabItem.status == SItemStatus.Create) {
  840. this.setLineItem(event)
  841. return true;
  842. }
  843. return this.grabItem.onMouseDown(event);
  844. }
  845. switch (this.cmd) {
  846. case 'baseLine':
  847. this.addLine(event);
  848. break;
  849. case 'baseText':
  850. this.addTextItem(event);
  851. break;
  852. case 'baseImage':
  853. this.addImgItem(event)
  854. break;
  855. case 'Zone':
  856. if (!this.isSelecting) {
  857. this.addPolygonItem(event);
  858. } else {
  859. // 点选创建区域
  860. return super.onMouseDown(event)
  861. }
  862. break;
  863. case 'Image':
  864. this.addIconItem(event);
  865. break;
  866. case 'Line':
  867. this.addTipelineItem(event);
  868. break;
  869. default:
  870. return super.onMouseDown(event);
  871. }
  872. }
  873. onMouseMove(event: SMouseEvent): boolean {
  874. if (!this.isEditStatus) {
  875. return super.onMouseMove(event);
  876. }
  877. if (this.isAbsorbing) {
  878. if (!this.highLight) {
  879. this.highLight = new HighlightItem(null);
  880. this.addItem(this.highLight);
  881. }
  882. this.highLight.visible = false;
  883. this.absorbSpace(event);
  884. }
  885. return super.onMouseMove(event)
  886. }
  887. onMouseUp(event: SMouseEvent): boolean {
  888. if (this.grabItem) {
  889. if (this.grabItem instanceof SLineMarkerItem && this.grabItem.status == SItemStatus.Edit) {
  890. this.setLineItem(event)
  891. return true;
  892. }
  893. return this.grabItem.onMouseUp(event);
  894. }
  895. return super.onMouseUp(event)
  896. }
  897. /**
  898. * 键盘事件
  899. *
  900. * @param event 事件参数
  901. * @return boolean
  902. */
  903. onKeyDown(event: KeyboardEvent): any {
  904. if (!this.isEditStatus) {
  905. return super.onKeyDown(event);
  906. }
  907. if (this.grabItem) {
  908. this.grabItem.onKeyDown(event);
  909. if (event.code == "Escape") {
  910. const item = this.grabItem;
  911. this.grabItem = null
  912. this.removeItem(item);
  913. if (this.view) {
  914. this.view.update()
  915. }
  916. this.setCmd = 'choice'
  917. }
  918. }
  919. // if (event.key == "Enter") {
  920. // this.cmd = 0
  921. // }
  922. return false
  923. }
  924. /**
  925. * 鼠标双击事件
  926. *
  927. * @param event 事件参数
  928. * @return boolean
  929. */
  930. onDoubleClick(event: SMouseEvent): boolean {
  931. if (!this.isEditStatus) {
  932. return true
  933. } else {
  934. return super.onDoubleClick(event);
  935. }
  936. } // Function onDoubleClick()
  937. /**
  938. * 设置管线结束锚点
  939. *
  940. */
  941. setTipeEndanchor(event: SMouseEvent): void {
  942. if (this.grabItem instanceof TipelineItem) {
  943. if (this.grabItem.status == SItemStatus.Create) {
  944. const anc = this.clickIsAnchor(event);
  945. if (anc) {
  946. const p = anc.mapToScene(0, 0)
  947. anc.isConnected = true;
  948. event.x = p.x;
  949. event.y = p.y;
  950. if (this.grabItem.pointList.length) {
  951. this.grabItem.endAnchor = anc;
  952. anc.parent ?.connect('changePos', this.grabItem, this.grabItem.changePos)
  953. }
  954. this.grabItem.anchor2ID = anc.id
  955. this.grabItem.node2Id = anc.parent.id
  956. this.grabItem.onMouseDown(event)
  957. this.grabItem.status = SItemStatus.Normal;
  958. this.finishCreated(this.grabItem)
  959. return
  960. }
  961. }
  962. this.grabItem.onMouseDown(event)
  963. }
  964. }
  965. /**
  966. * 设置直线结束Item
  967. *
  968. */
  969. setLineItem(event: SMouseEvent): void {
  970. if (this.grabItem instanceof SLineMarkerItem) {
  971. const item = this.clickIsItem(event);
  972. // 鼠标点是否在某个item内
  973. if (item) {
  974. let scenePoint = item.boundingRect().center();
  975. const p = item.mapToScene(scenePoint.x, scenePoint.y);
  976. event.x = p.x;
  977. event.y = p.y;
  978. if (this.grabItem.status == SItemStatus.Create) {
  979. // 点击在item内、创建状态且端点列表不为空时将直线结束端点和item绑定
  980. if (this.grabItem.line.length) {
  981. if (this.grabItem.startItem ?.id == item.id) {
  982. this.grabItem.endItem = null;
  983. } else {
  984. this.grabItem.endItem = item;
  985. this.grabItem.line[1] = new SPoint(event.x, event.y);
  986. item.connect('onMove', this.grabItem, this.grabItem.changePos);
  987. }
  988. }
  989. this.grabItem.onMouseDown(event);
  990. return
  991. } else if (this.grabItem.status == SItemStatus.Edit) {
  992. // 点击在item内、编辑状态且点击的为结束端点时
  993. if (this.grabItem.curIndex == 1) {
  994. // 直线关联的起始item是直线结束端点所在的item时,不吸附在点击item中心并将直线关联的结束item置为null
  995. if (this.grabItem.startItem ?.id == item.id) {
  996. this.grabItem.endItem = null;
  997. } else {// 反正吸附,关联
  998. this.grabItem.endItem = item;
  999. this.grabItem.line[1] = new SPoint(event.x, event.y);
  1000. item.connect('onMove', this.grabItem, this.grabItem.changePos);
  1001. }
  1002. } else if (this.grabItem.curIndex == 0) {
  1003. if (this.grabItem.endItem ?.id == item.id) {
  1004. this.grabItem.startItem = null;
  1005. } else {
  1006. this.grabItem.startItem = item;
  1007. this.grabItem.line[0] = new SPoint(event.x, event.y);
  1008. item.connect('onMove', this.grabItem, this.grabItem.changePos);
  1009. }
  1010. }
  1011. }
  1012. } else {
  1013. // 如果不在item内且点击的是直线的某个端点,将端点的关联item置为null
  1014. if (this.grabItem.line.length && this.grabItem.curIndex != -1) {
  1015. if (this.grabItem.curIndex == 1) {
  1016. this.grabItem.endItem = null;
  1017. } else if (this.grabItem.curIndex == 0) {
  1018. this.grabItem.startItem = null;
  1019. }
  1020. } else {
  1021. this.grabItem.onMouseDown(event);
  1022. return
  1023. }
  1024. }
  1025. // if (this.grabItem.status == SItemStatus.Create) {
  1026. // // 鼠标点是否在某个item内
  1027. // if (item) {
  1028. // let scenePoint = item.boundingRect().center();
  1029. // const p = item.mapToScene(scenePoint.x, scenePoint.y);
  1030. // event.x = p.x;
  1031. // event.y = p.y;
  1032. // if (this.grabItem.line.length && this.grabItem.curIndex == -1) {
  1033. // this.grabItem.endItem = item;
  1034. // this.grabItem.line[1] = new SPoint(event.x, event.y);
  1035. // item.connect('onMove', this.grabItem, this.grabItem.changePos);
  1036. // }
  1037. // this.grabItem.onMouseDown(event);
  1038. // return
  1039. // } else {
  1040. // if (this.grabItem.line.length && this.grabItem.curIndex != -1) {
  1041. // if (this.grabItem.curIndex == 1) {
  1042. // this.grabItem.endItem = null;
  1043. // } else if (this.grabItem.curIndex == 0) {
  1044. // this.grabItem.startItem = null;
  1045. // }
  1046. // }
  1047. // }
  1048. // } else if (this.grabItem.status == SItemStatus.Edit) {
  1049. // if (this.grabItem.curIndex == 1) {
  1050. // this.grabItem.endItem = item;
  1051. // this.grabItem.line[1] = new SPoint(event.x, event.y);
  1052. // item.connect('onMove', this.grabItem, this.grabItem.changePos);
  1053. // } else if (this.grabItem.curIndex == 0) {
  1054. // this.grabItem.startItem = item;
  1055. // this.grabItem.line[0] = new SPoint(event.x, event.y);
  1056. // item.connect('onMove', this.grabItem, this.grabItem.changePos);
  1057. // }
  1058. // }
  1059. this.grabItem.onMouseUp(event);
  1060. }
  1061. }
  1062. /**
  1063. * 划线时点击位置是否是锚点
  1064. *
  1065. * @param event 事件
  1066. * @param len 限制距离
  1067. * @return 点击的锚点
  1068. * */
  1069. clickIsAnchor(event: SMouseEvent): SAnchorItem | null {
  1070. let minAnchor = null;
  1071. let len: number = -1;
  1072. this.Nodes.forEach(image => {
  1073. if (image.anchorList && image.anchorList.length) {
  1074. image.anchorList.forEach(anchor => {
  1075. let anchorPoint = anchor.mapToScene(0, 0);
  1076. let dis = SMathUtil.pointDistance(
  1077. event.x,
  1078. event.y,
  1079. anchorPoint.x,
  1080. anchorPoint.y
  1081. );
  1082. if (len < 0) {
  1083. len = anchor.sceneDis;
  1084. }
  1085. if (dis < len) {
  1086. minAnchor = anchor;
  1087. len = dis;
  1088. }
  1089. })
  1090. }
  1091. })
  1092. console.log('-----------------------')
  1093. console.log(minAnchor)
  1094. console.log('-----------------------')
  1095. return minAnchor;
  1096. }
  1097. /**
  1098. * 划线时点击位置是在文本,图片,,区域内
  1099. *
  1100. * @param event 事件
  1101. * @return 点击的item
  1102. * */
  1103. clickIsItem(event: SMouseEvent): SGraphItem | null {
  1104. let minIten = null;
  1105. let len: number = -1;
  1106. let itemList = this.Nodes.concat(this.Markers);
  1107. itemList.forEach(item => {
  1108. if (
  1109. item instanceof STextMarkerItem ||
  1110. item instanceof SImageMarkerItem ||
  1111. item instanceof SZoneLegendItem ||
  1112. item instanceof SFHFQZoneLegendItem ||
  1113. item instanceof SSCPZZoneLegendItem
  1114. ) {
  1115. let scenePoint = item.mapFromScene(event.x, event.y);
  1116. if (item.contains(scenePoint.x, scenePoint.y)) {
  1117. let dis = SMathUtil.pointDistance(
  1118. scenePoint.x,
  1119. scenePoint.y,
  1120. item.boundingRect().center().x,
  1121. item.boundingRect().center().y
  1122. );
  1123. if (len < 0) {
  1124. minIten = item;
  1125. len = dis;
  1126. }
  1127. if (dis < len) {
  1128. minIten = item;
  1129. len = dis;
  1130. }
  1131. }
  1132. }
  1133. })
  1134. console.log('-----------------------')
  1135. console.log(minIten)
  1136. console.log('-----------------------')
  1137. return minIten;
  1138. }
  1139. /**
  1140. * 点是否在吸附区域内
  1141. *
  1142. * @param p 要判断的点
  1143. * @param minX 空间区域
  1144. * @param minY 空间区域
  1145. * @param maxX 空间区域
  1146. * @param maxY 空间区域
  1147. */
  1148. static isPointInAbsorbArea(
  1149. p: SPoint,
  1150. minX: number,
  1151. maxX: number,
  1152. minY: number,
  1153. maxY: number
  1154. ): boolean {
  1155. let rect = new SRect(
  1156. minX - 1000,
  1157. minY - 1000,
  1158. maxX - minX + 2000,
  1159. maxY - minY + 2000
  1160. );
  1161. return rect.contains(p.x, p.y);
  1162. } // Function isPointInAbsorbArea()
  1163. /**
  1164. * 吸附空间
  1165. *
  1166. * @param event 鼠标事件对象
  1167. * @return boolean 是否找到吸附的对象
  1168. */
  1169. absorbSpace(event: SMouseEvent): boolean {
  1170. if (!this.highLight) {
  1171. return false;
  1172. }
  1173. let absorbLen = 1000;
  1174. if (this.view) {
  1175. absorbLen = 10 / this.view.scale;
  1176. }
  1177. let P = this.absorbSpacePoint(event, absorbLen);
  1178. if (P.Point) {
  1179. this.highLight.distance = P.MinDis;
  1180. this.highLight.point = new SPoint(P.Point.X, -P.Point.Y);
  1181. this.highLight.visible = true;
  1182. return true;
  1183. } else {
  1184. let L = this.absorbSpaceLine(event, absorbLen);
  1185. if (L.Line && L.Point) {
  1186. this.highLight.distance = L.MinDis;
  1187. this.highLight.point = L.Point;
  1188. this.highLight.line = L.Line;
  1189. this.highLight.visible = true;
  1190. return true;
  1191. }
  1192. return false;
  1193. }
  1194. } // Function absorbSpace()
  1195. /**
  1196. * 吸附空间点
  1197. *
  1198. * @param event 鼠标事件对象
  1199. * @param absorbLen 吸附距离
  1200. * @return MinDis 吸附的点
  1201. */
  1202. absorbSpacePoint(event: SMouseEvent, absorbLen: number): MinDis {
  1203. let minPointDis = Number.MAX_SAFE_INTEGER;
  1204. let Point;
  1205. this.spaceList.map((space): void => {
  1206. if (
  1207. EditScence.isPointInAbsorbArea(
  1208. new SPoint(event.x, event.y),
  1209. space.minX,
  1210. space.maxX,
  1211. space.minY,
  1212. space.maxY
  1213. )
  1214. ) {
  1215. space.data.OutLine.forEach((item): void => {
  1216. let minDis = SMathUtil.getMinDisPoint(
  1217. new SPoint(event.x, event.y),
  1218. item
  1219. );
  1220. if (
  1221. minDis &&
  1222. minDis.MinDis < absorbLen &&
  1223. minDis.MinDis < minPointDis
  1224. ) {
  1225. minPointDis = minDis.MinDis;
  1226. Point = minDis.Point;
  1227. }
  1228. });
  1229. }
  1230. });
  1231. return {
  1232. MinDis: minPointDis,
  1233. Point: Point
  1234. };
  1235. } // Function absorbSpacePoint()
  1236. /**
  1237. * 吸附空间线
  1238. *
  1239. * @param event 鼠标事件对象
  1240. * @param absorbLen 吸附距离
  1241. * @return PointToLine 吸附的线
  1242. */
  1243. absorbSpaceLine(event: SMouseEvent, absorbLen: number): PointToLine {
  1244. let minPointDis = Number.MAX_SAFE_INTEGER;
  1245. let Point, Line;
  1246. this.spaceList.forEach((space): void => {
  1247. if (
  1248. EditScence.isPointInAbsorbArea(
  1249. new SPoint(event.x, event.y),
  1250. space.minX,
  1251. space.maxX,
  1252. space.minY,
  1253. space.maxY
  1254. )
  1255. ) {
  1256. space.data.OutLine.forEach((item): void => {
  1257. let minDisLine = SMathUtil.getMinDisLine(
  1258. new SPoint(event.x, event.y),
  1259. item
  1260. );
  1261. if (
  1262. minDisLine &&
  1263. minDisLine.MinDis < absorbLen &&
  1264. minDisLine.MinDis < minPointDis
  1265. ) {
  1266. minPointDis = minDisLine.MinDis;
  1267. Point = minDisLine.Point;
  1268. Line = minDisLine.Line;
  1269. }
  1270. });
  1271. }
  1272. });
  1273. return {
  1274. MinDis: minPointDis,
  1275. Point: Point,
  1276. Line: Line
  1277. };
  1278. } // Function absorbSpaceLine()
  1279. }