import VectorType from "../enum/VectorType.js"; import { dataService } from "../Service/DataService.js"; import { elementService } from "../Service/ElementService.js"; import { coordinate } from "../Coordinate.js"; import { draw } from "./Draw.js"; import { listenLayer } from "../ListenLayer.js"; import Settings from "../Settings.js"; export default class Render { constructor(layer) { this.layer = layer; this.displayPanos = false; } //绘制户型 drawGeometry(vector, styleType, flag) { if (draw.context == null || vector == null) { return; } switch (vector.geoType) { case VectorType.BackgroundImg: draw.drawBackGroundImg(vector); break; case VectorType.Img: draw.drawBackGroundImg(vector); break; case VectorType.Road: draw.drawRoad(vector, false); return; case VectorType.CurveRoad: draw.drawCurveRoad(vector, false); return; case VectorType.RoadPoint: draw.drawRoadPoint(vector); return; case VectorType.CrossPoint: draw.drawCrossPoint(vector); return; case VectorType.Point: draw.drawPoint(vector); break; case VectorType.Line: draw.drawLine(vector); //需要修改,有几种情况:测量,校准,基准 break; case VectorType.CurveLine: //draw.drawCurveLine(vector); break; case VectorType.Text: draw.drawText(vector, styleType, flag); break; case VectorType.Circle: draw.drawCircle(vector); break; case VectorType.Magnifier: draw.drawMagnifier(vector); break; } } //绘制交互的元素 drawElement(vector) { if (draw.context == null) { return; } switch (vector.geoType) { case VectorType.Point: draw.drawPoint(vector); break; case VectorType.RoadPoint: draw.drawPoint(vector); break; case VectorType.Line: draw.drawElementLine(vector); //需要修改,有几种情况:测量,校准,基准 break; case VectorType.Road: draw.drawRoad(vector, true); break; } } redrawElements() { if (elementService.vCheckLines.X && elementService.vCheckLines.X.display) { this.drawElement(elementService.vCheckLines.X); } if (elementService.vCheckLines.Y && elementService.vCheckLines.Y.display) { this.drawElement(elementService.vCheckLines.Y); } if (elementService.point && elementService.point.display) { this.drawElement(elementService.point); } if (elementService.newRoad && elementService.newRoad.display) { this.drawElement(elementService.newRoad); } if (elementService.checkLines.X && elementService.checkLines.X.display) { this.drawElement(elementService.checkLines.X); } if (elementService.checkLines.Y && elementService.checkLines.Y.display) { this.drawElement(elementService.checkLines.Y); } } autoRedraw() { // console.log("重绘"); draw.clear(); if (dataService.getGridDisplay()) { const grid = dataService.getGrid(); draw.drawGrid( grid.startX, grid.startY, coordinate.width, coordinate.height, grid.step1, grid.step2 ); } this.drawGeometry(dataService.getBackgroundImg()); let roads = dataService.getRoads(); for (let key in roads) { this.drawGeometry(roads[key]); } let roadPoints = dataService.getRoadPoints(); for (let key in roadPoints) { this.drawGeometry(roadPoints[key]); } let curveRoads = dataService.getCurveRoads(); for (let key in curveRoads) { this.drawGeometry(curveRoads[key]); } let crossPoints = dataService.getCrossPoints(); for (let key in crossPoints) { this.drawGeometry(crossPoints[key]); } let points = dataService.getPoints(); for (let key in points) { this.drawGeometry(points[key]); } let lines = dataService.getLines(); for (let key in lines) { this.drawGeometry(lines[key]); } let circles = dataService.getCircles(); for (let key in circles) { this.drawGeometry(circles[key]); } let texts = dataService.getTexts(); for (let key in texts) { this.drawGeometry(texts[key]); } const magnifiers = dataService.getMagnifiers(); for (let magnifiersKey in magnifiers) { this.drawGeometry(magnifiers[magnifiersKey]); } //this.drawGeometry(dataService.getImg()); this.redrawElements(); // if (listenLayer.testStart != null && listenLayer.testEnd != null) { // draw.drawTestLine( // listenLayer.testStart, // listenLayer.testEnd, // listenLayer.testHit // ); // } } //下载图片 autoRedrawForDownLoadImg() { draw.clear(); let roads = dataService.getRoads(); for (let key in roads) { this.drawGeometry(roads[key]); } let points = dataService.getRoadPoints(); for (let key in points) { this.drawGeometry(points[key]); } let texts = dataService.getTexts(); for (let key in texts) { this.drawGeometry(texts[key]); } } clear() { draw.clear(); } getContext() { return draw.context; } }