import { dataService } from "../Service/DataService"; import { mathUtil } from "../Util/MathUtil"; export default class Geometry { constructor() { this.display = true; } setId(vectorId) { if (vectorId == null || typeof vectorId === "undefined") { vectorId = dataService.getCurrentId(); dataService.updateCurrentId(); this.vectorId = this.geoType + vectorId; } else { this.vectorId = vectorId; } } getIndex() { return this.index; } setIndex(index) { this.index = index; } getPoints() { return this.points; } setPoints(points) { this.points = JSON.parse(JSON.stringify(points)); } setPointParent(parentId, dir) { if (this.parent == null) { this.parent = {}; } this.parent[parentId] = dir; } setEdgeParent(parentId) { if (this.parent == null) { this.parent = {}; } this.parent = parentId; } setLeftEdge(edgeId) { this.leftEdgeId = edgeId; } setRightEdge(edgeId) { this.rightEdgeId = edgeId; } setDisplay(value) { this.display = value; } setParent(value) { this.parent = value; } getParent() { return this.parent; } setValue(value) { this.value = value; } getValue() { return this.value; } getCenter() { return this.center; } setCenter(center) { if (center) { this.center = {}; this.center.x = center.x; this.center.y = center.y; } } setColor(value) { this.color = value; } getColor() { return this.color; } getStyle() { return this.style; } setStyle(style) { this.style = style; } getStyle() { return this.weight; } setWeight(weight) { this.weight = weight; } getType() { return this.type; } setType(type) { this.type = type; } getCategory() { return this.category; } setLocationMode(value) { this.locationMode = value; } setLinkedBasePointId(id){ this.linkedBasePointId = id; } setLinkedTestPointId(id){ this.linkedTestPointId = id; } getLocationMode() { return this.locationMode; } // ptSrc: 圆上某点(初始点); // ptRotationCenter: 圆心点; // angle: 旋转角度° -- [angle * M_PI / 180]:将角度换算为弧度 // 【注意】angle 逆时针为正,顺时针为负 rotatePoint(ptSrc, ptRotationCenter, angle) { angle = -1 * angle; //设计是逆时针为负,顺时针为正 var a = ptRotationCenter.x; var b = ptRotationCenter.y; var x0 = ptSrc.x; var y0 = ptSrc.y; var rx = a + (x0 - a) * Math.cos((angle * Math.PI) / 180) - (y0 - b) * Math.sin((angle * Math.PI) / 180); var ry = b + (x0 - a) * Math.sin((angle * Math.PI) / 180) + (y0 - b) * Math.cos((angle * Math.PI) / 180); var json = { x: rx, y: ry }; return json; } }