import VectorType from "../enum/VectorType.js"; import { dataService } from "../Service/DataService.js"; import { elementService } from "../Service/ElementService.js"; import { measureService } from "../Service/MeasureService"; import { coordinate } from "../Coordinate.js"; import { draw } from "./Draw.js"; import { listenLayer } from "../ListenLayer.js"; export default class Render { constructor(layer) { this.layer = layer; this.displayPanos = false; } //绘制户型 drawGeometry(vector, styleType, flag) { if (draw.context == null || vector == null) { return; } //console.log(vector) switch (vector.geoType) { case VectorType.Road: draw.drawRoad(vector, false); return; case VectorType.CurveRoad: draw.drawCurveRoad(vector, false); return; case VectorType.Point: draw.drawPoint(vector); return; case VectorType.ControlPoint: draw.drawControlPoint(vector); return; case VectorType.Tag: draw.drawTag(vector, styleType, flag); return; case VectorType.MeasureLine: draw.drawMeasures(vector, styleType); return; case VectorType.BackgroundImg: draw.drawBackGroundImg(); } } //绘制交互的元素 drawElement(vector) { if (draw.context == null) { return; } switch (vector.geoType) { case VectorType.Point: draw.drawCircle(vector); break; case VectorType.Line: draw.drawLine(vector); break; case VectorType.Road: draw.drawRoad(vector, true); break; case VectorType.MeasureLine: draw.drawMeasureLine(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.newMeasureLine && elementService.newMeasureLine.display ) { this.drawElement(elementService.newMeasureLine); } 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(); this.drawGeometry(dataService.getBackgroundImg()); let roads = dataService.getRoads(); for (let key in roads) { this.drawGeometry(roads[key]); } let points = dataService.getPoints(); for (let key in points) { this.drawGeometry(points[key]); } let curveRoads = dataService.getCurveRoads(); for (let key in curveRoads) { this.drawGeometry(curveRoads[key]); } let controlPoints = dataService.getControlPoints(); for (let key in controlPoints) { this.drawGeometry(controlPoints[key]); } let tags = dataService.getTags(); for (let key in tags) { this.drawGeometry(tags[key]); } //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.getPoints(); for (let key in points) { this.drawGeometry(points[key]); } let tags = dataService.getTags(); for (let key in tags) { this.drawGeometry(tags[key]); } } clear() { draw.clear(); } getContext() { return draw.context; } }