123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311 |
- import Text from "../Geometry/Text.js";
- import { dataService } from "./DataService.js";
- import { mathUtil } from "../Util/MathUtil.js";
- import Settings from "../Settings";
- import { coordinate } from "../Coordinate.js";
- import UIEvents from "../enum/UIEvents.js";
- import VectorCategory from "../enum/VectorCategory.js";
- import Constant from "../Constant.js";
- import VectorStyle from "../enum/VectorStyle.js";
- import VectorWeight from "../enum/VectorWeight.js";
- import RoadTemplate from "../enum/RoadTemplate.js";
- import RoadStructure from "../enum/RoadStructure.js";
- import Message from "@/components/base/components/message/message.vue";
- export default class UIService {
- constructor() {}
- isBelongRoad(ui) {
- if (ui == UIEvents.OneEdgeOneLanRoad) {
- this.setWayType(Constant.oneWay);
- this.setSingleRoadDrivewayCount(1);
- this.setSingleRoadWidth(Settings.singleLaneWidth);
- return true;
- } else if (ui == UIEvents.OneEdgeTwoLanRoad) {
- this.setWayType(Constant.oneWay);
- this.setSingleRoadDrivewayCount(2);
- this.setSingleRoadWidth(Settings.singleLaneWidth * 2);
- return true;
- } else if (ui == UIEvents.OneEdgeThreeLanRoad) {
- this.setWayType(Constant.oneWay);
- this.setSingleRoadDrivewayCount(3);
- this.setSingleRoadWidth(Settings.singleLaneWidth * 3);
- return true;
- } else if (ui == UIEvents.TwoEdgeOneLanRoad) {
- this.setWayType(Constant.twoWay);
- this.setRoadLeftDrivewayCount(1);
- this.setRoadRightDrivewayCount(1);
- this.setLeftRoadWidth(Settings.singleLaneWidth);
- this.setRightRoadWidth(Settings.singleLaneWidth);
- return true;
- } else if (ui == UIEvents.TwoEdgeTwoLanRoad) {
- this.setWayType(Constant.twoWay);
- this.setRoadLeftDrivewayCount(2);
- this.setRoadRightDrivewayCount(2);
- this.setLeftRoadWidth(Settings.singleLaneWidth * 2);
- this.setRightRoadWidth(Settings.singleLaneWidth * 2);
- return true;
- } else if (ui == UIEvents.TwoEdgeThreeLanRoad) {
- this.setWayType(Constant.twoWay);
- this.setRoadLeftDrivewayCount(3);
- this.setRoadRightDrivewayCount(3);
- this.setLeftRoadWidth(Settings.singleLaneWidth * 3);
- this.setRightRoadWidth(Settings.singleLaneWidth * 3);
- return true;
- }
- return false;
- }
- isBelongCurveRoad(ui) {
- if (ui == "SBend") {
- this.setRoadLeftDrivewayCount(0);
- this.setRoadRightDrivewayCount(0);
- return true;
- } else if (ui == UIEvents.OneEdgeOneLanRoad) {
- this.setRoadLeftDrivewayCount(0);
- this.setRoadRightDrivewayCount(0);
- return true;
- }
- }
- isBelongLine(ui) {
- if (ui == UIEvents.SingleArrow) {
- this.setSelectLineCategory(VectorCategory.Line.SingleArrowLine);
- return true;
- } else if (ui == UIEvents.DoubleArrow) {
- this.setSelectLineCategory(VectorCategory.Line.DoubleArrowLine);
- return true;
- } else if (ui == UIEvents.MeasureLine) {
- this.setSelectLineCategory(VectorCategory.Line.MeasureLine);
- return true;
- } else if (ui == UIEvents.Line) {
- this.setSelectLineCategory(VectorCategory.Line.NormalLine);
- return true;
- } else if (ui == UIEvents.FreeMeasureLine) {
- this.setSelectLineCategory(VectorCategory.Line.FreeMeasureLine);
- return true;
- } else if (ui == UIEvents.BaseLine) {
- this.setSelectLineCategory(VectorCategory.Line.BaseLine);
- return true;
- }
- return false;
- }
- isBelongPoint(ui) {
- if (ui == UIEvents.BasePoint) {
- this.setSelectPointCategory(VectorCategory.Point.BasePoint);
- return true;
- } else if (ui == UIEvents.FixPoint) {
- this.setSelectPointCategory(VectorCategory.Point.FixPoint);
- return true;
- }
- return false;
- }
- isBelongRoadEdgeStyle(ui) {
- if (ui == VectorStyle.SingleSolidLine) {
- return true;
- } else if (ui == VectorStyle.SingleDashedLine) {
- return true;
- } else if (ui == VectorStyle.DoubleSolidLine) {
- return true;
- } else if (ui == VectorStyle.DoubleDashedLine) {
- return true;
- } else if (ui == VectorStyle.BrokenLine) {
- return true;
- } else if (ui == VectorStyle.PointDrawLine) {
- return true;
- } else if (ui == VectorStyle.Greenbelt) {
- return true;
- } else if (ui == VectorWeight.Bold) {
- return true;
- } else if (ui == VectorWeight.Thinning) {
- return true;
- } else {
- return false;
- }
- }
- isBelongRoadTemplate(ui) {
- if (RoadTemplate[ui]) {
- this.setSelectRoadTemplate(ui);
- return true;
- } else {
- return false;
- }
- }
- isBelongRoadStructure(ui) {
- if (RoadStructure[ui]) {
- this.setSelectRoadStructure(ui);
- return true;
- } else {
- return false;
- }
- }
- setWayType(value) {
- Settings.wayType = value;
- }
- setSelectBasePointId(value) {
- Settings.selectBasePointId = value;
- }
- setSingleRoadDrivewayCount(value) {
- Settings.singleRoadDrivewayCount = value;
- }
- setRoadLeftDrivewayCount(value) {
- Settings.roadLeftDrivewayCount = value;
- }
- setRoadRightDrivewayCount(value) {
- Settings.roadRightDrivewayCount = value;
- }
- setCurveRoadLeftDrivewayCount(value) {
- Settings.curveRoadLeftDrivewayCount = value;
- }
- setCurveRoadRightDrivewayCount(value) {
- Settings.curveRoadRightDrivewayCount = value;
- }
- setSingleRoadWidth(value) {
- Settings.singleRoadWidth = value;
- }
- setLeftRoadWidth(value) {
- Settings.leftRoadWidth = value;
- }
- setRightRoadWidth(value) {
- Settings.rightRoadWidth = value;
- }
- setCurveRoadLeftDrivewayCount(value) {
- Settings.curveRoadLeftDrivewayCount = value;
- }
- setCurveRoadRightDrivewayCount(value) {
- Settings.curveRoadRightDrivewayCount = value;
- }
- setLeftCurveRoadWidth(value) {
- Settings.leftCurveRoadWidth = value;
- }
- setRightCurveRoadWidth(value) {
- Settings.rightCurveRoadWidth = value;
- }
- setSelectLineCategory(value) {
- Settings.selectLineCategory = value;
- }
- setSelectPointCategory(value) {
- Settings.selectPointCategory = value;
- }
- //设置定位法
- setSelectLocationMode(value) {
- Settings.selectLocationMode = value;
- }
- getSelectLocationMode() {
- return Settings.selectLocationMode;
- }
- setSelectSVGType(value) {
- Settings.selectSVGType = value;
- }
- getSelectRoadTemplate() {
- return Settings.selectRoadTemplate;
- }
- setSelectRoadTemplate(value) {
- Settings.selectRoadTemplate = value;
- }
- setSelectRoadStructure(value) {
- Settings.selectRoadStructure = value;
- }
- getSelectRoadStructure() {
- return Settings.selectRoadStructure;
- }
- //Constant.defaultMidDivideWidth是真实宽度,现在赋值的时候要转换成像素
- setRoadMidDivideWidth(value) {
- Settings.roadMidDivideWidth = value;
- }
- //Constant.defaultMidDivideWidth是真实宽度,现在赋值的时候要转换成像素
- setCurveRoadMidDivideWidth(value) {
- Settings.curveRoadMidDivideWidth = value;
- }
- //Constant.defaultSingleLaneWidth是真实宽度,现在赋值的时候要转换成像素
- setSingleLaneWidth(value) {
- Settings.singleLaneWidth = value;
- }
- getSingleLaneWidth() {
- return Settings.singleLaneWidth;
- }
- getRoadMidDivideWidth() {
- return Settings.roadMidDivideWidth;
- }
- getLineWidth() {
- return Settings.lineWidth;
- }
- setLineWidth(value) {
- Settings.lineWidth = value;
- }
- //如果position在屏幕左上角,返回的就朝向右下角,如果是右下角,则返回的是左上角。其他情况以此类推
- getNewPositionForPop(position) {
- const offset = 50;
- const center = coordinate.getXYFromScreen({
- x: coordinate.width / 2,
- y: coordinate.height / 2,
- });
- let newPosition = {};
- mathUtil.clonePoint(newPosition, position);
- if (position.x > center.x) {
- newPosition.x -= offset;
- } else if (position.x < center.x) {
- newPosition.x += offset;
- }
- if (position.y > center.y) {
- newPosition.y -= offset;
- } else if (position.y < center.y) {
- newPosition.y += offset;
- }
- return newPosition;
- }
- currentShowMsgs = [];
- prompt(msg) {
- const config = typeof msg === "string" ? { msg, time: 1000 } : msg;
- if (this.currentShowMsgs.includes(config.msg)) {
- return;
- }
- this.currentShowMsgs.push(config.msg);
- setTimeout(() => {
- this.currentShowMsgs = this.currentShowMsgs.filter(
- (msg) => msg !== config.msg
- );
- }, config.time);
- Message.success(config);
- }
- }
- const uiService = new UIService();
- export { uiService };
|