UIControl.js 22 KB

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