| | |
| | | Result |
| | | } from "ant-design-vue"; |
| | | |
| | | import { |
| | | session, |
| | | } from "../../../comm/utils.js" |
| | | |
| | | // import okIcon from '../../../static/images/confirm.svg'; |
| | | // import cancelIcon from '../../../static/images/remove.svg'; |
| | | |
| | |
| | | img_x: 1, |
| | | img_y: 1 |
| | | }, |
| | | pressObjTimer: 0 |
| | | |
| | | pressObjTimer: 0, |
| | | } |
| | | }, |
| | | mounted() { |
| | |
| | | mainObj: obj |
| | | }); |
| | | this.canvas.add(objGroup) |
| | | |
| | | this.$ownerInstance.callMethod('receiveRenderData', { |
| | | method: "cancel_positioning_agv", |
| | | }); |
| | | }, |
| | | |
| | | canvasEventListener() { |
| | |
| | | _this.canvas.requestRenderAll(); |
| | | |
| | | _this.onSelectionChanage() |
| | | //_this.selectionChangeCanvas(); |
| | | |
| | | }); |
| | | _this.canvas.on("selection:updated", function(e) { |
| | | console.log("selection:updated", e); |
| | |
| | | |
| | | _this.canvas.on("object:modified", function(e) { |
| | | // console.log("object:modified", e.target); |
| | | |
| | | |
| | | // _this.resizetCanvas(); |
| | | }); |
| | | _this.canvas.on("object:moving", function(e) { |
| | | console.log("object:moving", e.target); |
| | |
| | | const data = activeObj.mainObj?.data |
| | | |
| | | data.path.push({ |
| | | x: _this.getActualXFromImg(activeObj.left), |
| | | y: _this.getActualYFromImg(activeObj.top) |
| | | x: _this.getActualXFromImg(activeObj.left) || 0, |
| | | y: _this.getActualYFromImg(activeObj.top) || 0 |
| | | }) |
| | | _this.updateRegion(activeObj.mainObj, data) |
| | | } else if (activeObj.eleType == "cmd") { |
| | | let data = activeObj.mainObj.data |
| | | if (activeObj.mainObj.eleType == "edit_teaching") { |
| | | const objCmdMain = activeObj.mainObj |
| | | if (objCmdMain.eleType == "edit_teaching") { |
| | | |
| | | let left = _this.getActualXFromImg(activeObj.left) |
| | | let top = _this.getActualYFromImg(activeObj.top) |
| | | let right = _this.getActualXFromImg(activeObj.left + activeObj.width) |
| | | let bottom = _this.getActualYFromImg(activeObj.top + activeObj.height) |
| | | data = [ |
| | | [left, top], |
| | | [left, bottom], |
| | | [right, bottom], |
| | | [right, top] |
| | | ] |
| | | const left = _this.getActualXFromImg(objCmdMain.left) |
| | | const top = _this.getActualYFromImg(objCmdMain.top) |
| | | const right = _this.getActualXFromImg(objCmdMain.left + objCmdMain.width) |
| | | const bottom = _this.getActualYFromImg(objCmdMain.top + objCmdMain.height) |
| | | data = [] |
| | | if (Number.isNaN(left) || Number.isNaN(top) || Number.isNaN(right) || Number |
| | | .isNaN(bottom)) { |
| | | const now = new Date() |
| | | const date = `${now.getHours()}:${now.getMinutes()}:${now.getSeconds()}` |
| | | _this.$ownerInstance.callMethod('receiveRenderData', { |
| | | method: "show_log", |
| | | data: { |
| | | date, |
| | | method: `POST`, |
| | | url: "app/log/edit_teaching", |
| | | param: objCmdMain, |
| | | statusCode: 100, |
| | | data: _this.mapInfo |
| | | }, |
| | | }); |
| | | } |
| | | data.push([left, top]) |
| | | data.push([left, bottom]) |
| | | data.push([right, bottom]) |
| | | data.push([right, top]) |
| | | console.log(data) |
| | | } |
| | | _this.$ownerInstance.callMethod('receiveRenderData', { |
| | | method: "edit_finish", |
| | | cmd: activeObj.id, |
| | | type: activeObj.mainObj.eleType, |
| | | type: objCmdMain.eleType, |
| | | data: data, |
| | | }); |
| | | if (activeObj.id == "ok") { |
| | | if (activeObj.mainObj.eleType == "region") { |
| | | if (objCmdMain.eleType == "region") { |
| | | _this.addRegionFinish(activeObj.mainObj) |
| | | } else if (activeObj.mainObj.eleType == "virtual_wall") { |
| | | _this.addVirtualWallFinish(activeObj.mainObj) |
| | | } |
| | | |
| | | } |
| | | if (activeObj.mainObj.eleType == "edit_teaching") { |
| | | if (objCmdMain.eleType == "edit_teaching") { |
| | | let list = _this.canvas.getObjects() || [] |
| | | for (let i2 in list) { |
| | | const obj = list[i2] |
| | |
| | | opacity: 1 |
| | | }) |
| | | } |
| | | if (activeObj.mainObj?.mainObj) { |
| | | activeObj.mainObj.mainObj.set({ |
| | | if (objCmdMain?.mainObj) { |
| | | objCmdMain.mainObj.set({ |
| | | selectable: true |
| | | }) |
| | | } |
| | | const ptObjs = activeObj.mainObj.ptObjs || [] |
| | | _this.canvas.remove(activeObj.mainObj) |
| | | const ptObjs = objCmdMain.ptObjs || [] |
| | | _this.canvas.remove(objCmdMain) |
| | | for (let i2 in ptObjs) { |
| | | const obj = ptObjs[i2] |
| | | _this.canvas.remove(obj) |
| | | } |
| | | } |
| | | if (activeObj.mainObj.eleType == "station") { |
| | | if (objCmdMain.eleType == "station") { |
| | | |
| | | _this.setAllObjectSelectable(true) |
| | | activeObj.mainObj.tipObj.set({ |
| | | left: activeObj.mainObj.left, |
| | | top: activeObj.mainObj.top - activeObj.mainObj.height / 2 - |
| | | activeObj.mainObj |
| | | .tipObj.height / 2, |
| | | objCmdMain.tipObj.set({ |
| | | left: objCmdMain.left, |
| | | top: objCmdMain.top - objCmdMain.height / 2 - |
| | | objCmdMain.tipObj.height / 2, |
| | | visible: true |
| | | }) |
| | | activeObj.mainObj.tipObj.setCoords() |
| | | objCmdMain.tipObj.setCoords() |
| | | } |
| | | _this.closeOkCancelControl() |
| | | |
| | |
| | | const objects = this.canvas.getObjects(); |
| | | |
| | | objects.splice(0, 1); |
| | | this.canvas.discardActiveObject() |
| | | const objActive = this.canvas.getActiveObject() |
| | | |
| | | let pointerList = [] |
| | | let pointerList2 = [] |
| | |
| | | if (obj.selectable && obj.opacity > 0) { |
| | | if (obj instanceof fabric.Path || obj instanceof fabric.Line) { |
| | | if (this.isPointOnStroke(obj, pointer)) { |
| | | console.log(i, obj.eleType) |
| | | // console.log(i, obj.eleType) |
| | | pointerList.unshift(obj) |
| | | |
| | | } |
| | | } else { |
| | | const isHit = obj.containsPoint(pointer); |
| | | if (isHit) { |
| | | console.log(i, obj.eleType) |
| | | // console.log(i, obj.eleType) |
| | | pointerList.unshift(obj) |
| | | |
| | | } |
| | |
| | | const obj = pointerList[i]; |
| | | if (obj instanceof fabric.Path || obj instanceof fabric.Line) { |
| | | if (this.isPointOnStroke(obj, pointer, 1)) { |
| | | this.canvas.discardActiveObject() |
| | | this.canvas.setActiveObject(obj); |
| | | this.canvas.requestRenderAll(); |
| | | if (objActive != obj) { |
| | | |
| | | this.canvas.discardActiveObject() |
| | | this.canvas.setActiveObject(obj); |
| | | this.canvas.requestRenderAll(); |
| | | } |
| | | return |
| | | } |
| | | pointerList2.unshift(obj) |
| | | } else { |
| | | this.canvas.discardActiveObject() |
| | | this.canvas.setActiveObject(obj); |
| | | this.canvas.requestRenderAll(); |
| | | if (objActive != obj) { |
| | | |
| | | this.canvas.discardActiveObject() |
| | | this.canvas.setActiveObject(obj); |
| | | this.canvas.requestRenderAll(); |
| | | } |
| | | return |
| | | } |
| | | } |
| | | |
| | | if (pointerList2.length > 0) { |
| | | if (pointerList2.length == 1) { |
| | | const obj = pointerList2[i]; |
| | | this.canvas.discardActiveObject() |
| | | this.canvas.setActiveObject(obj); |
| | | this.canvas.requestRenderAll(); |
| | | const obj = pointerList2[0]; |
| | | if (objActive != obj) { |
| | | |
| | | this.canvas.discardActiveObject() |
| | | this.canvas.setActiveObject(obj); |
| | | this.canvas.requestRenderAll(); |
| | | } |
| | | return |
| | | } |
| | | pointerList = pointerList2 |
| | |
| | | for (let i = pointerList.length - 1; i >= 0; i--) { |
| | | const obj = pointerList[i]; |
| | | if (this.isPointOnStroke(obj, pointer, 2)) { |
| | | this.canvas.discardActiveObject() |
| | | this.canvas.setActiveObject(obj); |
| | | this.canvas.requestRenderAll(); |
| | | if (objActive != obj) { |
| | | |
| | | this.canvas.discardActiveObject() |
| | | this.canvas.setActiveObject(obj); |
| | | this.canvas.requestRenderAll(); |
| | | } |
| | | return |
| | | } |
| | | pointerList2.unshift(obj) |
| | |
| | | } |
| | | if (pointerList2.length > 0) { |
| | | if (pointerList2.length == 1) { |
| | | const obj = pointerList2[i]; |
| | | this.canvas.discardActiveObject() |
| | | this.canvas.setActiveObject(obj); |
| | | this.canvas.requestRenderAll(); |
| | | const obj = pointerList2[0]; |
| | | if (objActive != obj) { |
| | | |
| | | this.canvas.discardActiveObject() |
| | | this.canvas.setActiveObject(obj); |
| | | this.canvas.requestRenderAll(); |
| | | } |
| | | return |
| | | } |
| | | pointerList = pointerList2 |
| | |
| | | for (let i = pointerList.length - 1; i >= 0; i--) { |
| | | const obj = pointerList[i]; |
| | | if (this.isPointOnStroke(obj, pointer, 3)) { |
| | | this.canvas.discardActiveObject() |
| | | this.canvas.setActiveObject(obj); |
| | | this.canvas.requestRenderAll(); |
| | | if (objActive != obj) { |
| | | |
| | | this.canvas.discardActiveObject() |
| | | this.canvas.setActiveObject(obj); |
| | | this.canvas.requestRenderAll(); |
| | | } |
| | | return |
| | | } |
| | | pointerList2.unshift(obj) |
| | |
| | | } |
| | | if (pointerList2.length > 0) { |
| | | if (pointerList2.length == 1) { |
| | | const obj = pointerList2[i]; |
| | | this.canvas.discardActiveObject() |
| | | this.canvas.setActiveObject(obj); |
| | | this.canvas.requestRenderAll(); |
| | | const obj = pointerList2[0]; |
| | | if (objActive != obj) { |
| | | |
| | | this.canvas.discardActiveObject() |
| | | this.canvas.setActiveObject(obj); |
| | | this.canvas.requestRenderAll(); |
| | | } |
| | | return |
| | | } |
| | | pointerList = pointerList2 |
| | |
| | | for (let i = pointerList.length - 1; i >= 0; i--) { |
| | | const obj = pointerList[i]; |
| | | if (this.isPointOnStroke(obj, pointer, 4)) { |
| | | this.canvas.discardActiveObject() |
| | | this.canvas.setActiveObject(obj); |
| | | this.canvas.requestRenderAll(); |
| | | if (objActive != obj) { |
| | | |
| | | this.canvas.discardActiveObject() |
| | | this.canvas.setActiveObject(obj); |
| | | this.canvas.requestRenderAll(); |
| | | } |
| | | return |
| | | } |
| | | pointerList2.unshift(obj) |
| | |
| | | if (pointerList2.length > 0) { |
| | | |
| | | const obj = pointerList2[pointerList2.length - 1]; |
| | | this.canvas.discardActiveObject() |
| | | this.canvas.setActiveObject(obj); |
| | | this.canvas.requestRenderAll(); |
| | | if (objActive != obj) { |
| | | |
| | | this.canvas.discardActiveObject() |
| | | this.canvas.setActiveObject(obj); |
| | | this.canvas.requestRenderAll(); |
| | | } |
| | | return |
| | | } |
| | | // objects.forEach(obj => { |
| | |
| | | }, |
| | | |
| | | onSelectionChanage() { |
| | | const _this = this |
| | | // const list = _this.canvas.getActiveObjects() |
| | | // if (list.length === 1) { |
| | | // if (list[0].eleType == "station") { |
| | | // _this.$ownerInstance.callMethod('receiveRenderData', { |
| | | // method: "selected_change", |
| | | // type: list[0].eleType, |
| | | // param: list[0].data |
| | | // }); |
| | | // } else if (list[0].eleType == "agv") { |
| | | // _this.$ownerInstance.callMethod('receiveRenderData', { |
| | | // method: "selected_change", |
| | | // type: list[0].eleType, |
| | | // param: list[0].data |
| | | // }); |
| | | // } else if (list[0].eleType == "agv_line") { |
| | | // _this.$ownerInstance.callMethod('receiveRenderData', { |
| | | // method: "selected_change", |
| | | // type: list[0].eleType, |
| | | // param: list[0].data |
| | | // }); |
| | | // } else { |
| | | // _this.$ownerInstance.callMethod('receiveRenderData', { |
| | | // method: "selected_change", |
| | | // type: "" |
| | | // }); |
| | | // } |
| | | |
| | | // } else { |
| | | // _this.$ownerInstance.callMethod('receiveRenderData', { |
| | | // method: "selected_change", |
| | | // type: "" |
| | | // }); |
| | | // } |
| | | }, |
| | | safeLoadImage(url, maxSize = 2048) { |
| | | console.log(url) |
| | |
| | | resolve(null); |
| | | }; |
| | | img.src = url; |
| | | }); |
| | | }, |
| | | safeLoadImageData(data, maxSize = 2048) { |
| | | //console.log("safeLoadImageData") |
| | | const _this = this |
| | | return new Promise((resolve) => { |
| | | let base64Image = data |
| | | if (base64Image.indexOf("data:image/png;base64,") < 0) { |
| | | base64Image = "data:image/png;base64," + data |
| | | } |
| | | // var img = new fabric.Image(); |
| | | // img.setSrc(base64Image, function() { |
| | | // console.log("img", JSON.stringify(img)) |
| | | // const scale = Math.min( |
| | | // maxSize / Math.max(img.width, img.height), |
| | | // 1 |
| | | // ); |
| | | // img.set({ |
| | | // scaleX: scale, |
| | | // scaleY: scale |
| | | // }) |
| | | // resolve(img) |
| | | // }); |
| | | fabric.Image.fromURL(base64Image, { |
| | | crossOrigin: 'anonymous' // 重要:设置跨域 |
| | | }).then((img) => { |
| | | |
| | | //console.log("img",JSON.stringify(img)) |
| | | const scale = Math.min( |
| | | maxSize / Math.max(img.width, img.height), |
| | | 1 |
| | | ); |
| | | img.set({ |
| | | scaleX: scale, |
| | | scaleY: scale, |
| | | }) |
| | | resolve(img) |
| | | }).catch((err) => { |
| | | console.error("图片加载失败", err) |
| | | _this.showError("图片加载失败") |
| | | resolve(null); |
| | | }) |
| | | |
| | | }); |
| | | }, |
| | | // 将 Base64 转为 Blob,再生成 URL |
| | |
| | | const cantainerEl = document.getElementById("canvasMap") |
| | | this.eleWidth = cantainerEl.clientWidth |
| | | this.eleHeight = cantainerEl.clientHeight |
| | | console.log("client", this.eleWidth, this.eleHeight) |
| | | this.canvas.setWidth(this.eleWidth); |
| | | this.canvas.setHeight(this.eleHeight); |
| | | this.mapInfo = { |
| | | proportion: info.proportion || 1, |
| | | img_proportion: info.img_proportion || 1, |
| | | max_x: info.max_x || 1, |
| | | max_y: info.max_y || 1, |
| | | min_x: info.min_x || 0, |
| | | min_y: info.min_y || 0, |
| | | img_x: info.img_x || 1, |
| | | img_y: info.img_y || 1, |
| | | proportion: parseInt(info.proportion) || 1, |
| | | img_proportion: parseInt(info.img_proportion) || 1, |
| | | max_x: parseInt(info.max_x) || 1, |
| | | max_y: parseInt(info.max_y) || 1, |
| | | min_x: parseInt(info.min_x) || 0, |
| | | min_y: parseInt(info.min_y) || 0, |
| | | img_x: parseInt(info.img_x) || 1, |
| | | img_y: parseInt(info.img_y) || 1, |
| | | } |
| | | |
| | | return new Promise((resolve, reject) => { |
| | | |
| | | if (info.filedata) { |
| | |
| | | const eleWidth = this.eleWidth - 20 |
| | | const eleHeight = this.eleHeight - 200 |
| | | if (!this.workSpace) |
| | | return 1 |
| | | return 0.8 |
| | | const width = this.workSpace.width |
| | | const height = this.workSpace.height |
| | | if (eleWidth / eleHeight < width / height) { |
| | | return eleWidth / width; |
| | | let scale = eleWidth / width; |
| | | return scale - scale / 10 |
| | | } // 按照宽度缩放 |
| | | return eleHeight / height; |
| | | let scale = eleHeight / height; |
| | | return scale - scale / 10 |
| | | }, |
| | | |
| | | auto() { |
| | |
| | | clearTimeout(this.pressObjTimer); |
| | | this.pressObjTimer = null |
| | | } |
| | | this.$ownerInstance.callMethod('receiveRenderData', { |
| | | method: "cancel_positioning_agv", |
| | | }); |
| | | } |
| | | |
| | | // 移动视口 |
| | | // console.log('relativePan', deltaX, deltaY); |
| | | const vpt = this.canvas.viewportTransform; |
| | |
| | | } |
| | | //console.log(scale, scaleAuto) |
| | | this.setZoomAuto(scale, center) |
| | | |
| | | this.$ownerInstance.callMethod('receiveRenderData', { |
| | | method: "cancel_positioning_agv", |
| | | }); |
| | | // console.log('多点移动 - 距离:', distance, '角度:', angle); |
| | | // 多点移动逻辑 |
| | | }, |
| | |
| | | pos_list.push(item) |
| | | } |
| | | }) |
| | | |
| | | console.log(posArr.length, pos_list.length) |
| | | let path2 = "" |
| | | |
| | | const theta = 20; |
| | |
| | | |
| | | |
| | | } |
| | | //console.log(path2) |
| | | |
| | | // console.log("addTeachingPath",path2) |
| | | // path2 += " Z" |
| | | let strokeWidth = 1 |
| | | let stroke = "#95DE64" |
| | |
| | | lockMovementX: true, |
| | | lockMovementY: true, |
| | | selectable: false, |
| | | opacity: 0, |
| | | opacity: 1, |
| | | mainRoad: main_road, |
| | | data: teachingData |
| | | }) |
| | | this.canvas.add(objPath) |
| | | |
| | | // this.canvas.sendObjectToBack(objPath); |
| | | |
| | | // lenTeaching = 0 |
| | | // for (let i = list.length - 1; i >= 0; i--) { |
| | | // const obj = list[i] |
| | | // if (this.compareOverlap(obj, objPath)) { |
| | | // lenTeaching = i + 1 |
| | | // break |
| | | // } |
| | | // } |
| | | this.canvas.sendObjectToBack(objPath); |
| | | this.canvas.moveObjectTo(objPath, lenTeaching + 1); |
| | | |
| | | return objPath |
| | |
| | | |
| | | }, |
| | | showTeachingPath(show) { |
| | | |
| | | if (!show) |
| | | this.canvas.discardActiveObject(); |
| | | let list = this.canvas.getObjects() || [] |
| | | list = list.filter((a) => a.eleType == "station_teaching" || a.eleType == "public_teaching") |
| | | for (let i2 in list) { |
| | |
| | | left = pt.x - width / 2 |
| | | top = pt.y - height / 2 |
| | | } |
| | | console.log(left, |
| | | top, |
| | | width, |
| | | height, scale2) |
| | | const rect = new fabric.Rect({ |
| | | id: `edit_teaching`, |
| | | eleType: "edit_teaching", |
| | |
| | | oldLeft: rect.left, |
| | | oldTop: rect.top, |
| | | }) |
| | | /*const zoom = this.canvas.getZoom(); |
| | | const eleHeight = this.eleHeight - 150 |
| | | const info = { |
| | | x: rect.left + rect.width / 2, |
| | | y: rect.top + rect.height / 2 |
| | | } |
| | | let deltaX = info.x * zoom - this.eleWidth / 2 // * scale; |
| | | let deltaY = info.y * zoom - eleHeight / 2 //* scale; |
| | | const vpt = this.canvas.viewportTransform; |
| | | const oldX = vpt[4] |
| | | const oldY = vpt[5] |
| | | if (deltaX + this.eleWidth > this.workSpace.width) |
| | | deltaX = this.workSpace.width - this.eleWidth |
| | | if (deltaY + eleHeight > this.workSpace.height) |
| | | deltaY = this.workSpace.height - eleHeight |
| | | if (oldX + this.eleWidth >= info.x * zoom && info.x * zoom >= oldX) { |
| | | deltaX = -oldX |
| | | //console.log("move_canvas X", oldX) |
| | | } |
| | | if (oldY + eleHeight >= info.y * zoom && info.y * zoom >= oldY) { |
| | | // console.log("move_canvas Y", oldY) |
| | | deltaY = -oldY |
| | | } |
| | | this.canvas.absolutePan(new fabric.Point(deltaX, deltaY));*/ |
| | | |
| | | } else { |
| | | for (let i2 in list) { |
| | |
| | | this.canvas.add(ellipse) |
| | | const offX = 20 * Math.cos(angle) |
| | | const offY = 20 * Math.sin(angle) |
| | | console.log("angle", param.angle, offX, offY) |
| | | |
| | | if (this.objAgvLaser) { |
| | | this.canvas.remove(this.objAgvLaser) |
| | | } |
| | |
| | | ensurePointVisible(pt) { |
| | | var zoom = this.canvas.getZoom(); |
| | | var vpt = this.canvas.viewportTransform; // 当前变换矩阵 |
| | | |
| | | var newPanX = vpt[4]; |
| | | var newPanY = vpt[5]; |
| | | if (pt.x * zoom < vpt[4] + 80 || pt.x * zoom > vpt[4] + this.eleWidth - 80) { |
| | | if (pt.x * zoom - this.eleWidth / 2 < 80) { |
| | | newPanX = -80 |
| | | } else if (pt.x * zoom > this.mapInfo.img_x * zoom - 80) { |
| | | newPanX = this.mapInfo.img_x * zoom - this.eleWidth + 80 |
| | | } else { |
| | | |
| | | var newPanX = -vpt[4]; |
| | | var newPanY = -vpt[5]; |
| | | const offWidth = pt.width || 20 |
| | | const offHeight = pt.height || 20 |
| | | // console.log("ensurePointVisible",pt.x,pt.y,newPanX,newPanY, this.eleWidth,this.eleHeight) |
| | | if (pt.x * zoom < -vpt[4] + offWidth || pt.x * zoom > -vpt[4] + this.eleWidth - offWidth) { |
| | | if (pt.x * zoom - this.eleWidth / 2 <offWidth) { |
| | | newPanX = -offWidth |
| | | } |
| | | // else if (pt.x * zoom > this.mapInfo.img_x * zoom - 20) { |
| | | // newPanX = this.mapInfo.img_x * zoom - this.eleWidth + 20 |
| | | // } |
| | | else { |
| | | newPanX = pt.x * zoom - this.eleWidth / 2 |
| | | } |
| | | } |
| | | if (pt.y * zoom < vpt[5] + 80 || pt.y * zoom > vpt[5] + this.eleHeight - 200) { |
| | | if (pt.y * zoom < -vpt[5] +offHeight || pt.y * zoom > -vpt[5] + this.eleHeight - (120+offHeight)) { |
| | | |
| | | if (pt.y * zoom - this.eleHeight / 2 < 80) { |
| | | newPanY = -80 |
| | | } else if (pt.y * zoom > this.mapInfo.img_y * zoom - 200) { |
| | | newPanY = this.mapInfo.img_y * zoom - this.eleHeight + 200 |
| | | } else { |
| | | newPanY = pt.y * zoom - this.eleHeight / 2 |
| | | if (pt.y * zoom - this.eleHeight / 2 <offHeight) { |
| | | newPanY = -offHeight |
| | | } |
| | | // else if (pt.y * zoom > this.mapInfo.img_y * zoom - 180) { |
| | | // newPanY = this.mapInfo.img_y * zoom - this.eleHeight + 180 |
| | | // } |
| | | else { |
| | | newPanY = pt.y * zoom -(this.eleHeight - 120) / 2 |
| | | } |
| | | } |
| | | |
| | | // console.log("ensurePointVisible2",newPanX,newPanY) |
| | | // 只有在需要时才平移 |
| | | if (newPanX !== vpt[4] || newPanY !== vpt[5]) { |
| | | if (newPanX !== -vpt[4] || newPanY !== -vpt[5]) { |
| | | this.canvas.absolutePan({ |
| | | x: newPanX, |
| | | y: newPanY |
| | | }); |
| | | } |
| | | }, |
| | | |
| | | ensurePointCenter(pt){ |
| | | var zoom = this.canvas.getZoom(); |
| | | var newPanX = newPanX = pt.x * zoom - this.eleWidth / 2 |
| | | var newPanY = pt.y * zoom -(this.eleHeight - 150) / 2 |
| | | this.canvas.absolutePan({ |
| | | x: newPanX, |
| | | y: newPanY |
| | | }); |
| | | }, |
| | | setAllObjectSelectable(selectable) { |
| | | let flag = false |
| | | this.canvas.forEachObject(function(obj) { |
| | |
| | | } else if (item.method == "update_current_teaching") { |
| | | const info = item.param || [] |
| | | await _this.updateCurrentTeaching(info) |
| | | } else if (item.method == "move_canvas") { |
| | | } else if (item.method == "move_pt_visible") { |
| | | const info2 = item.param || {} |
| | | |
| | | const pt = { |
| | | x: this.getXOnImg(info2.x), |
| | | y: this.getYOnImg(info2.y) |
| | | y: this.getYOnImg(info2.y), |
| | | width: 20, |
| | | height: 20 |
| | | } |
| | | this.ensurePointVisible(pt) |
| | | |
| | | |
| | | |
| | | } else if (item.method == "add_station") { |
| | | } |
| | | else if (item.method == "move_pt_center") { |
| | | const info2 = item.param || {} |
| | | const pt = { |
| | | x: this.getXOnImg(info2.x), |
| | | y: this.getYOnImg(info2.y) |
| | | } |
| | | this.ensurePointCenter(pt) |
| | | } |
| | | else if (item.method == "add_station") { |
| | | const stationList = item.param || [] |
| | | let list = _this.canvas.getObjects() || [] |
| | | for (let i2 in stationList) { |
| | |
| | | } |
| | | }) |
| | | } else if (item.method == "public_teaching") { |
| | | _this.setAllObjectSelectable(false) |
| | | let list = _this.canvas.getObjects() || [] |
| | | list.forEach((obj) => { |
| | | if (obj.eleType == "public_teaching" || obj.eleType == |
| | | "station_teaching") { |
| | | if (obj.eleType == "public_teaching" || obj.eleType == "station_teaching") { |
| | | obj.set({ |
| | | hasControls: false, |
| | | selectable: false, |
| | | opacity: 1 |
| | | }) |
| | | // obj.set({ |
| | | // hasControls: false, |
| | | // selectable: false, |
| | | // }) |
| | | } else if (obj.eleType == "agv") |
| | | obj.set({ |
| | | opacity: 1 |
| | |
| | | for (let i2 in list) { |
| | | const obj = list[i2] |
| | | obj.set({ |
| | | selectable: false, |
| | | selectable: obj?.canSelect ?true:false, |
| | | opacity: 1 |
| | | }) |
| | | // if (obj.eleType == "station") { |
| | | // await _this.setMarkStation(obj, false) |
| | | // } |
| | | |
| | | } |
| | | _this.showTeachingPath(_this.showTeachPathFlag ? true : false) |
| | | |
| | | } else if (item.method == "public_teaching_path") { |
| | | } |
| | | else if (item.method == "clear_teaching_path") { |
| | | let list = _this.canvas.getObjects() || [] |
| | | list = list.filter((a) => a.eleType == "public_teaching") |
| | | list = list.filter((a) => a.eleType == "public_teaching" || a.eleType == "station_teaching") |
| | | for (let i2 in list) { |
| | | this.canvas.remove(list[i2]) |
| | | } |
| | | } |
| | | else if (item.method == "public_teaching_path") { |
| | | |
| | | const teachingPathList = item.param || [] |
| | | |
| | | for (let i2 in teachingPathList) { |
| | | const teachingPath = teachingPathList[i2] |
| | | const id = `public_teaching_${teachingPath.name}` |
| | | await this.addTeachingPath(teachingPath, id, "public_teaching") |
| | | } |
| | | } else if (item.method == "station_teaching_path") { |
| | | let list = _this.canvas.getObjects() || [] |
| | | list = list.filter((a) => a.eleType == "station_teaching") |
| | | for (let i2 in list) { |
| | | this.canvas.remove(list[i2]) |
| | | } |
| | | |
| | | const teachingPathList = item.param || [] |
| | | for (let i2 in teachingPathList) { |
| | | const teachingPath = teachingPathList[i2] |