123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172 |
- 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;
- }
- getWeight() {
- return this.weight;
- }
- setPhotoUrl(src) {
- this.photoUrl = src;
- }
- setPhotoImg(type) {
- this.photoImage = type;
- }
- 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;
- }
- }
|