EditScence.ts 46 KB

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