UIControl.js 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668
  1. import { coordinate } from "../Coordinate.js";
  2. import LayerEvents from "../enum/LayerEvents.js";
  3. import UIEvents from "../enum/UIEvents.js";
  4. import RoadTemplate from "../enum/RoadTemplate.js";
  5. import RoadStructure from "../enum/RoadStructure.js";
  6. import VectorType from "../enum/VectorType.js";
  7. import VectorStyle from "../enum/VectorStyle.js";
  8. import VectorWeight from "../enum/VectorWeight.js";
  9. import GeoActions from "../enum/GeoActions.js";
  10. import VectorEvents from "../enum/VectorEvents.js";
  11. import SVGType from "../enum/SVGType.js";
  12. import { stateService } from "../Service/StateService.js";
  13. import { uiService } from "../Service/UIService.js";
  14. import { dataService } from "../Service/DataService.js";
  15. import { historyService } from "../Service/HistoryService.js";
  16. import { elementService } from "../Service/ElementService";
  17. import { lineService } from "../Service/LineService.js";
  18. import { circleService } from "../Service/CircleService.js";
  19. import { textService } from "../Service/TextService.js";
  20. import { svgService } from "../Service/SVGService.js";
  21. import { magnifierService } from "../Service/MagnifierService.js";
  22. import { mathUtil } from "../Util/MathUtil";
  23. import Constant from "../Constant";
  24. // import { roomsUtil } from "../Room/RoomsUtil.js";
  25. import { addRoad } from "../Controls/AddRoad";
  26. import { addLine } from "./AddLine.js";
  27. import VectorCategory from "../enum/VectorCategory.js";
  28. // import { floorplanData } from "../VectorData.js";
  29. import Message from "@/components/base/components/message/message.vue";
  30. import { pointService } from "../Service/PointService.js";
  31. import Settings from "../Settings.js";
  32. import { addPoint } from "./AddPoint.js";
  33. import { locationModeControl } from "./LocationModeControl.js";
  34. import { curveRoadPointService } from "../Service/CurveRoadPointService.js";
  35. import { roadService } from "../Service/RoadService.js";
  36. import { curveRoadService } from "../Service/CurveRoadService.js";
  37. import Msg from "../enum/Msg.js";
  38. export default class UIControl {
  39. constructor(layer, newsletter, graphicStateUI) {
  40. this._prompts = [];
  41. this.layer = layer;
  42. this.newsletter = newsletter;
  43. this.graphicStateUI = graphicStateUI;
  44. }
  45. get selectUI() {
  46. return this.newsletter.selectUI;
  47. }
  48. set selectUI(selectUI) {
  49. this.updateEventNameForSelectUI(selectUI);
  50. this.newsletter.selectUI = selectUI;
  51. }
  52. get focusVector() {
  53. return this.newsletter.focusVector;
  54. }
  55. set focusVector(focusVector) {
  56. this.newsletter.focusVector = focusVector;
  57. }
  58. /**
  59. * 获取选中要操作的UI
  60. */
  61. get currentUI() {}
  62. /**
  63. * 设置选中要操作的UI
  64. */
  65. set currentUI(value) {
  66. this.selectUI = value;
  67. }
  68. clearUI() {
  69. this.clearCurrentUI();
  70. this.clearSelectUI();
  71. }
  72. clearFocusVector() {
  73. this.focusVector = null;
  74. }
  75. clearSelectUI() {
  76. this.selectUI = null;
  77. }
  78. clearCurrentUI() {
  79. this.currentUI = null;
  80. }
  81. //点击左侧栏后,更新事件
  82. updateEventNameForSelectUI(selectUI) {
  83. console.log(this.selectUI, selectUI);
  84. if (selectUI != null) {
  85. if (this.selectUI == selectUI) {
  86. return;
  87. } else if (this.selectUI != selectUI) {
  88. if (this.selectUI != null) {
  89. //先取消当前事件和进程
  90. this.layer.exit();
  91. }
  92. //执行新的事件
  93. if (uiService.isBelongRoad(selectUI) || selectUI == "road") {
  94. stateService.setEventName(LayerEvents.AddRoad);
  95. } else if (selectUI == UIEvents.CurveRoad) {
  96. stateService.setEventName(LayerEvents.AddCurveRoad);
  97. } else if (uiService.isBelongLine(selectUI)) {
  98. stateService.setEventName(LayerEvents.AddLine);
  99. }
  100. // else if (selectUI == UIEvents.CurveLine) {
  101. // stateService.setEventName(LayerEvents.AddCurveLine);
  102. // }
  103. else if (uiService.isBelongPoint(selectUI)) {
  104. stateService.setEventName(LayerEvents.AddPoint);
  105. } else if (selectUI == UIEvents.Circle) {
  106. stateService.setEventName(LayerEvents.AddCircle);
  107. } else if (selectUI == UIEvents.Text) {
  108. stateService.setEventName(LayerEvents.AddText);
  109. } else if (selectUI == UIEvents.Magnifier) {
  110. stateService.setEventName(LayerEvents.AddMagnifier);
  111. } else if (SVGType[selectUI]) {
  112. uiService.setSelectSVGType(selectUI);
  113. stateService.setEventName(LayerEvents.AddSVG);
  114. } else if (selectUI == UIEvents.Img) {
  115. stateService.setEventName(LayerEvents.Img);
  116. } else if (uiService.isBelongRoadTemplate(selectUI)) {
  117. stateService.setEventName(LayerEvents.AddRoadTemplate);
  118. } else if (uiService.isBelongRoadStructure(selectUI)) {
  119. stateService.setEventName(LayerEvents.AddRoadStructure);
  120. } else if (selectUI == Constant.angleLocationMode) {
  121. uiService.setSelectLocationMode(Constant.angleLocationMode);
  122. let msg = locationModeControl.setAngle();
  123. if (msg != Msg.OK) {
  124. this.prompt({ msg: msg, time: 1000 });
  125. } else {
  126. this.layer.history.save();
  127. this.layer.renderer.autoRedraw();
  128. }
  129. }
  130. }
  131. }
  132. }
  133. updateVectorForSelectUI(selectUI) {
  134. console.log("selectUI", selectUI);
  135. const focusItem = stateService.getFocusItem();
  136. // if (selectUI == VectorStyle.Bold || selectUI == VectorStyle.Thinning) {
  137. // if (focusItem.type == VectorType.Line) {
  138. // let Line = dataService.getLine(focusItem.vectorId);
  139. // Line.setStyle(selectUI);
  140. // } else if (focusItem.type == VectorType.RoadEdge) {
  141. // let roadEdge = dataService.getRoadEdge(focusItem.vectorId);
  142. // if (roadEdge) {
  143. // roadEdge.setStyle(selectUI);
  144. // } else {
  145. // roadEdge = dataService.getCurveRoadEdge(focusItem.vectorId);
  146. // roadEdge.setStyle(selectUI);
  147. // }
  148. // }
  149. // this.layer.history.save();
  150. // this.layer.renderer.autoRedraw();
  151. // }
  152. // else
  153. if (uiService.isBelongRoadEdgeStyle(selectUI)) {
  154. let key = null;
  155. if (VectorStyle[selectUI]) {
  156. key = "setStyle";
  157. } else if (VectorWeight[selectUI]) {
  158. key = "setWeight";
  159. }
  160. if (focusItem.type == VectorType.Line) {
  161. let Line = dataService.getLine(focusItem.vectorId);
  162. // Line.setStyle(selectUI);
  163. Line[key](selectUI);
  164. } else if (focusItem.type == VectorType.CurveLine) {
  165. let Line = dataService.getCurveLine(focusItem.vectorId);
  166. // Line.setStyle(selectUI);
  167. Line[key](selectUI);
  168. } else {
  169. let roadEdge = dataService.getRoadEdge(focusItem.vectorId);
  170. if (roadEdge) {
  171. // roadEdge.setStyle(selectUI);
  172. roadEdge[key](selectUI);
  173. let crossPoint = dataService.getCrossPoint4(focusItem.vectorId);
  174. if (crossPoint) {
  175. crossPoint[key](selectUI);
  176. }
  177. } else {
  178. roadEdge = dataService.getCurveRoadEdge(focusItem.vectorId);
  179. // roadEdge.setStyle(selectUI);
  180. roadEdge[key](selectUI);
  181. }
  182. }
  183. this.layer.history.save();
  184. this.layer.renderer.autoRedraw();
  185. } else if (selectUI == VectorEvents.AddLane) {
  186. if (focusItem && focusItem.vectorId) {
  187. stateService.setEventName(VectorEvents.AddLane);
  188. }
  189. // if (focusItem && focusItem.dir && focusItem.vectorId) {
  190. // let road = dataService.getRoad(focusItem.vectorId);
  191. // if (road) {
  192. // if (focusItem.dir == "left") {
  193. // roadService.updateForAddSubtractLanesCount(
  194. // road.vectorId,
  195. // road.leftDrivewayCount + 1,
  196. // focusItem.dir
  197. // );
  198. // } else {
  199. // roadService.updateForAddSubtractLanesCount(
  200. // road.vectorId,
  201. // road.rightDrivewayCount + 1,
  202. // focusItem.dir
  203. // );
  204. // }
  205. // } else {
  206. // road = dataService.getCurveRoad(focusItem.vectorId);
  207. // if (focusItem.dir == "left") {
  208. // curveRoadService.updateForAddSubtractLanesCount(
  209. // road.vectorId,
  210. // road.leftDrivewayCount + 1,
  211. // focusItem.dir
  212. // );
  213. // } else {
  214. // curveRoadService.updateForAddSubtractLanesCount(
  215. // road.vectorId,
  216. // road.rightDrivewayCount + 1,
  217. // focusItem.dir
  218. // );
  219. // }
  220. // }
  221. // }
  222. } else if (selectUI == VectorEvents.DelLane) {
  223. if (focusItem && focusItem.vectorId) {
  224. stateService.setEventName(VectorEvents.DelLane);
  225. }
  226. // if (focusItem && focusItem.dir && focusItem.vectorId) {
  227. // let road = dataService.getRoad(focusItem.vectorId);
  228. // if (road) {
  229. // if (focusItem.dir == "left") {
  230. // roadService.updateForAddSubtractLanesCount(
  231. // road.vectorId,
  232. // road.leftDrivewayCount - 1,
  233. // focusItem.dir
  234. // );
  235. // } else {
  236. // roadService.updateForAddSubtractLanesCount(
  237. // road.vectorId,
  238. // road.rightDrivewayCount - 1,
  239. // focusItem.dir
  240. // );
  241. // }
  242. // } else {
  243. // road = dataService.getCurveRoad(focusItem.vectorId);
  244. // if (focusItem.dir == "left") {
  245. // curveRoadService.updateForAddSubtractLanesCount(
  246. // road.vectorId,
  247. // road.leftDrivewayCount - 1,
  248. // focusItem.dir
  249. // );
  250. // } else {
  251. // curveRoadService.updateForAddSubtractLanesCount(
  252. // road.vectorId,
  253. // road.rightDrivewayCount - 1,
  254. // focusItem.dir
  255. // );
  256. // }
  257. // }
  258. // }
  259. } else if (selectUI == VectorEvents.AddCrossPoint) {
  260. if (focusItem && focusItem.vectorId) {
  261. stateService.setEventName(VectorEvents.AddCrossPoint);
  262. }
  263. // if (focusItem && focusItem.dir && focusItem.vectorId) {
  264. // const curveRoad = dataService.getCurveRoad(focusItem.vectorId);
  265. // let index = mathUtil.getIndexForCurvesPoints(
  266. // this.mousePosition,
  267. // curveRoad.points
  268. // );
  269. // if (index != -1) {
  270. // curveRoadService.addCPoint(curveRoad, this.mousePosition, index);
  271. // } else {
  272. // const dis1 = mathUtil.getDistance(
  273. // curveRoad.points[0],
  274. // this.mousePosition
  275. // );
  276. // const dis2 = mathUtil.getDistance(
  277. // curveRoad.points[curveRoad.points.length - 1],
  278. // this.mousePosition
  279. // );
  280. // if (dis1 > dis2) {
  281. // curveRoadService.addCPoint(
  282. // curveRoad,
  283. // this.mousePosition,
  284. // curveRoad.points.length - 2
  285. // );
  286. // } else {
  287. // curveRoadService.addCPoint(curveRoad, this.mousePosition, 1);
  288. // }
  289. // }
  290. // }
  291. } else if (selectUI == VectorEvents.MinusCrossPoint) {
  292. if (focusItem && focusItem.vectorId) {
  293. stateService.setEventName(VectorEvents.MinusCrossPoint);
  294. }
  295. // if (focusItem && focusItem.dir && focusItem.vectorId) {
  296. // const curvePoint = dataService.getCurveRoadPoint(focusItem.vectorId);
  297. // const curveRoad = dataService.getCurveRoad(curvePoint.parent);
  298. // curveRoadService.subCPoint(curveRoad, curvePoint.getIndex());
  299. // }
  300. } else if (selectUI == VectorEvents.AddBranchRoad) {
  301. } else if (selectUI == VectorEvents.AddNarrowRoad) {
  302. } else if (selectUI == VectorEvents.UnLock) {
  303. let road = dataService.getRoad(focusItem.vectorId);
  304. if (road) {
  305. roadService.convertToLines(focusItem.vectorId);
  306. } else {
  307. road = dataService.getCurveRoad(focusItem.vectorId);
  308. if (road) {
  309. curveRoadService.convertToCurveLines(focusItem.vectorId);
  310. }
  311. }
  312. if (road) {
  313. this.deleteVector(focusItem.vectorId, focusItem.type);
  314. this.layer.history.save();
  315. this.layer.renderer.autoRedraw();
  316. }
  317. }
  318. }
  319. async handleGeo(action) {
  320. let needAutoRedraw = false;
  321. const item = stateService.getFocusItem();
  322. if (item && item.vectorId) {
  323. switch (action) {
  324. case GeoActions.CopyAction:
  325. await this.copyVector(item.vectorId, item.type);
  326. needAutoRedraw = true;
  327. break;
  328. case GeoActions.DeleteAction:
  329. this.deleteVector(item.vectorId, item.type);
  330. needAutoRedraw = true;
  331. break;
  332. }
  333. }
  334. if (needAutoRedraw) {
  335. this.layer.history.save();
  336. this.layer.renderer.autoRedraw();
  337. }
  338. }
  339. //删除按钮
  340. deleteVector(vectorId, geoType) {
  341. switch (geoType) {
  342. case VectorType.Point:
  343. pointService.deletePoint(vectorId);
  344. break;
  345. case VectorType.Line:
  346. let line = dataService.getLine(vectorId);
  347. dataService.deleteLine(vectorId);
  348. if (vectorId == Settings.baseLineId) {
  349. this.layer.initLocation();
  350. } else if (
  351. line.getCategory() == VectorCategory.Line.ExtendedPositionLine ||
  352. line.getCategory() == VectorCategory.Line.PositionLine ||
  353. line.getCategory() == VectorCategory.Line.GuidePositionLine
  354. ) {
  355. let startPoint = dataService.getPoint(line.startId);
  356. let endPoint = dataService.getPoint(line.endId);
  357. if (startPoint.getCategory() != VectorCategory.Point.BasePoint) {
  358. pointService.deletePoint(line.startId);
  359. }
  360. if (endPoint.getCategory() != VectorCategory.Point.BasePoint) {
  361. pointService.deletePoint(line.endId);
  362. }
  363. }
  364. break;
  365. case VectorType.CurveLine:
  366. lineService.deleteCurveLine(vectorId);
  367. break;
  368. case VectorType.CurvePoint:
  369. const curvePoint = dataService.getCurvePoint(vectorId);
  370. lineService.deleteCrossPointForCurveLine(
  371. vectorId,
  372. curvePoint.getParent()
  373. );
  374. break;
  375. case VectorType.Circle:
  376. dataService.deleteCircle(vectorId);
  377. break;
  378. case VectorType.Text:
  379. dataService.deleteText(vectorId);
  380. break;
  381. case VectorType.Magnifier:
  382. dataService.deleteMagnifier(vectorId);
  383. break;
  384. case VectorType.Road:
  385. roadService.deleteRoadForLinked(vectorId);
  386. break;
  387. case VectorType.RoadPoint:
  388. const roadPoint = dataService.getRoadPoint(vectorId);
  389. const roadPointParent = roadPoint.getParent();
  390. for (let key in roadPointParent) {
  391. roadService.deleteRoadForLinked(key);
  392. }
  393. break;
  394. case VectorType.CurveRoadPoint:
  395. curveRoadPointService.deleteCurveRoadPoint(vectorId);
  396. break;
  397. case VectorType.CurveRoad:
  398. dataService.deleteCurveRoad(vectorId);
  399. break;
  400. case VectorType.SVG:
  401. dataService.deleteSVG(vectorId);
  402. break;
  403. }
  404. this.layer.exit();
  405. uiService.setSelectLineCategory(VectorCategory.Line.NormalLine);
  406. uiService.setSelectPointCategory(VectorCategory.Point.NormalPoint);
  407. this.clearFocusVector();
  408. }
  409. //复制按钮
  410. async copyVector(vectorId, geoType) {
  411. let item;
  412. switch (geoType) {
  413. case VectorType.Line:
  414. lineService.copy(vectorId);
  415. break;
  416. case VectorType.CurveLine:
  417. lineService.copyCurveLine(vectorId);
  418. break;
  419. case VectorType.Circle:
  420. circleService.copy(vectorId);
  421. break;
  422. case VectorType.Text:
  423. textService.copy(vectorId);
  424. break;
  425. case VectorType.Road:
  426. const roadId = roadService.copyRoad(vectorId);
  427. item = stateService.getFocusItem();
  428. item.vectorId = roadId;
  429. break;
  430. case VectorType.CurveRoad:
  431. const curveRoadId = curveRoadService.copyCurveRoad(vectorId);
  432. item = stateService.getFocusItem();
  433. item.vectorId = curveRoadId;
  434. break;
  435. case VectorType.Magnifier:
  436. await magnifierService.copy(vectorId);
  437. break;
  438. case VectorType.SVG:
  439. svgService.copy(vectorId);
  440. break;
  441. }
  442. }
  443. //截图
  444. async screenShot() {
  445. let canvas = this.layer.canvas;
  446. this.menu_view_reset();
  447. //隐藏grid
  448. Settings.screenMode = true;
  449. dataService.setGridDisplay(false);
  450. this.layer.renderer.autoRedraw();
  451. // this.downloadCadImg(canvas, "test.jpg");
  452. const blob = await this.getCadBlob(canvas);
  453. //显示grid
  454. dataService.setGridDisplay(true);
  455. Settings.screenMode = false;
  456. this.layer.renderer.autoRedraw();
  457. return blob;
  458. }
  459. getCadBlob(canvas) {
  460. var type = "jpg";
  461. return new Promise((resolve) => canvas.toBlob(resolve, `${type}/image`));
  462. }
  463. // downloadCadImg(canvas, filename) {
  464. // // 图片导出为 jpg 格式
  465. // var type = "jpg";
  466. // var imgData = canvas.toDataURL(type, 3);
  467. // canvas.toBlob(`${type}/image`);
  468. // // 加工image data,替换mime type
  469. // imgData = imgData.replace(this._fixType(type), "image/octet-stream");
  470. // // 下载后的图片名
  471. // //var filename = 'cad_' + new Date().getTime() + '.' + type
  472. // // download
  473. // this.saveFile(imgData, filename);
  474. // }
  475. saveFile(data, filename) {
  476. var save_link = document.createElementNS(
  477. "http://www.w3.org/1999/xhtml",
  478. "a"
  479. );
  480. save_link.href = data;
  481. save_link.download = filename;
  482. var event = document.createEvent("MouseEvents");
  483. event.initMouseEvent(
  484. "click",
  485. true,
  486. false,
  487. window,
  488. 0,
  489. 0,
  490. 0,
  491. 0,
  492. 0,
  493. false,
  494. false,
  495. false,
  496. false,
  497. 0,
  498. null
  499. );
  500. save_link.dispatchEvent(event);
  501. }
  502. _fixType(type) {
  503. type = type.toLowerCase().replace(/jpg/i, "jpeg");
  504. var r = type.match(/png|jpeg|bmp|gif/)[0];
  505. return "image/" + r;
  506. }
  507. /****************************************************************************针对菜单*******************************************************************************/
  508. //撤销
  509. menu_revoke() {
  510. this.layer.history.goPreState();
  511. const historyState = historyService.getHistoryState();
  512. this.graphicStateUI.canRevoke = historyState.pre;
  513. this.graphicStateUI.canRecovery = true;
  514. this.layer.stopAddVector();
  515. this.layer.renderer.autoRedraw();
  516. }
  517. //恢复
  518. menu_recovery() {
  519. this.layer.history.goNextState();
  520. const historyState = historyService.getHistoryState();
  521. this.graphicStateUI.canRecovery = historyState.next;
  522. this.graphicStateUI.canRevoke = true;
  523. this.layer.stopAddVector();
  524. this.layer.renderer.autoRedraw();
  525. }
  526. menu_view_reset() {
  527. coordinate.reSet(this.layer.canvas);
  528. this.layer.renderer.autoRedraw();
  529. }
  530. // value 为true则开 false则关
  531. menu_backgroundImg(value) {
  532. console.log(value);
  533. //
  534. const backgroundImg = dataService.getBackgroundImg();
  535. backgroundImg.setDisplay(value);
  536. this.graphicStateUI.showBackImage = value;
  537. this.layer.renderer.autoRedraw();
  538. }
  539. menu_clear(isBack) {
  540. dataService.clear();
  541. Settings.selectLocationMode = null;
  542. Settings.baseLineId = null;
  543. uiService.setSelectBasePointId(null);
  544. elementService.hideAll();
  545. this.layer.exit();
  546. this.layer.initLocation();
  547. if (!isBack) {
  548. this.layer.history.save();
  549. } else {
  550. historyService.clearHistoryRecord();
  551. this.layer.uiControl.graphicStateUI.canRevoke = false;
  552. this.layer.uiControl.graphicStateUI.canRecovery = false;
  553. }
  554. this.layer.renderer.autoRedraw();
  555. }
  556. /******************************************************************************************************************************************************************/
  557. prompt(msg) {
  558. this._prompts.push(
  559. Message.success(typeof msg === "string" ? { msg } : msg)
  560. );
  561. }
  562. // 进入持续添加出确认与取消框
  563. showConfirm() {
  564. this.graphicStateUI.continuedMode = true;
  565. }
  566. confirmEntry() {
  567. console.log("确认");
  568. this.graphicStateUI.continuedMode = false;
  569. this.layer.exit();
  570. this.layer.history.save();
  571. this.layer.renderer.autoRedraw();
  572. uiService.setSelectPointCategory(VectorCategory.Point.NormalPoint);
  573. uiService.setSelectLineCategory(VectorCategory.Line.NormalLine);
  574. }
  575. confirmCancel() {
  576. console.log("取消");
  577. this.graphicStateUI.continuedMode = false;
  578. this.layer.exit();
  579. this.layer.history.save();
  580. this.layer.history.handleUndo();
  581. this.layer.renderer.autoRedraw();
  582. uiService.setSelectPointCategory(VectorCategory.Point.NormalPoint);
  583. uiService.setSelectLineCategory(VectorCategory.Line.NormalLine);
  584. }
  585. // 设置默认设置
  586. setDefaultSetting(setting) {
  587. console.log("获得设置", setting);
  588. uiService.setRoadMidDivideWidth(
  589. // (setting.roadQuarantineWidth / coordinate.res) * coordinate.ratio
  590. setting.roadQuarantineWidth / coordinate.res
  591. );
  592. uiService.setCurveRoadMidDivideWidth(
  593. // (setting.roadQuarantineWidth / coordinate.res) * coordinate.ratio
  594. setting.roadQuarantineWidth / coordinate.res
  595. );
  596. uiService.setSingleLaneWidth(
  597. // (setting.singleRoadWidth / coordinate.res) * coordinate.ratio
  598. setting.singleRoadWidth / coordinate.res
  599. );
  600. // uiService.setLineWidth(setting.lineWidth / 1000 / coordinate.res);
  601. uiService.setLineWidth(setting.lineWidth);
  602. this.layer.renderer.autoRedraw();
  603. }
  604. // 获取默认设置
  605. getDefaultSetting() {
  606. const singleLaneWidth = uiService.getSingleLaneWidth();
  607. const roadMidDivideWidth = uiService.getRoadMidDivideWidth();
  608. const lineWidth = uiService.getLineWidth();
  609. return {
  610. singleRoadWidth: singleLaneWidth * coordinate.res,
  611. roadQuarantineWidth: roadMidDivideWidth * coordinate.res,
  612. // lineWidth: lineWidth * coordinate.res * 1000,
  613. lineWidth: lineWidth,
  614. };
  615. }
  616. hidePrompt() {
  617. for (let prompt of this._prompts) {
  618. prompt();
  619. }
  620. }
  621. }