|
@@ -1,108 +1,124 @@
|
|
-import VectorType from '../enum/VectorType.js'
|
|
|
|
-import Geometry from './Geometry'
|
|
|
|
-import { mathUtil } from '../MathUtil.js'
|
|
|
|
-import { coordinate } from '../Coordinate'
|
|
|
|
-import Constant from '../Constant.js'
|
|
|
|
|
|
+import VectorType from "../enum/VectorType.js";
|
|
|
|
+import Geometry from "./Geometry";
|
|
|
|
+// import { mathUtil } from '../MathUtil.js'
|
|
|
|
+import { coordinate } from "../Coordinate";
|
|
|
|
+import Constant from "../Constant.js";
|
|
|
|
|
|
//不靠墙
|
|
//不靠墙
|
|
export default class Tag extends Geometry {
|
|
export default class Tag extends Geometry {
|
|
- constructor(center, vectorId) {
|
|
|
|
- super()
|
|
|
|
- this.center = center
|
|
|
|
- this.points2d = []
|
|
|
|
- //this.title = KanKan.Config.i18n('cad.input')
|
|
|
|
- this.title = ''
|
|
|
|
- this.des = '' //面积
|
|
|
|
- this.unit = 'm' //或者ft
|
|
|
|
- this.name = '标注'
|
|
|
|
- this.adding = true
|
|
|
|
-
|
|
|
|
- this.sideWidth = 30 //像素
|
|
|
|
- this.sideThickness = 30 //像素
|
|
|
|
-
|
|
|
|
- this.geoType = VectorType.Tag
|
|
|
|
- this.setId(vectorId)
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- isContain(position) {
|
|
|
|
- let points = []
|
|
|
|
- points.push(this.points2d[0])
|
|
|
|
- points.push(this.points2d[1])
|
|
|
|
- points.push(this.points2d[2])
|
|
|
|
- points.push(this.points2d[3])
|
|
|
|
- return mathUtil.isPointInPoly(position, points)
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- setPoints2d() {
|
|
|
|
- this.points2d = []
|
|
|
|
- const minX = this.center.x - ((this.sideWidth / coordinate.res) * Constant.defaultZoom) / coordinate.zoom / 2
|
|
|
|
- const minY = this.center.y - ((this.sideThickness / coordinate.res) * Constant.defaultZoom) / coordinate.zoom / 2
|
|
|
|
- const maxX = this.center.x + ((this.sideWidth / coordinate.res) * Constant.defaultZoom) / coordinate.zoom / 2
|
|
|
|
- const maxY = this.center.y + ((this.sideThickness / coordinate.res) * Constant.defaultZoom) / coordinate.zoom / 2
|
|
|
|
-
|
|
|
|
- const point1 = {
|
|
|
|
- x: minX,
|
|
|
|
- y: maxY,
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- const point2 = {
|
|
|
|
- x: maxX,
|
|
|
|
- y: maxY,
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- const point3 = {
|
|
|
|
- x: maxX,
|
|
|
|
- y: minY,
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- const point4 = {
|
|
|
|
- x: minX,
|
|
|
|
- y: minY,
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- this.points2d.push(point1)
|
|
|
|
- this.points2d.push(point2)
|
|
|
|
- this.points2d.push(point3)
|
|
|
|
- this.points2d.push(point4)
|
|
|
|
-
|
|
|
|
- //-
|
|
|
|
- let dx = (point1.x - this.center.x) / 2
|
|
|
|
- //+
|
|
|
|
- let dy = (point1.y - this.center.y) / 2
|
|
|
|
-
|
|
|
|
- this.points2d.push({
|
|
|
|
- x: point1.x - dx,
|
|
|
|
- y: point1.y - dy,
|
|
|
|
- })
|
|
|
|
-
|
|
|
|
- this.points2d.push({
|
|
|
|
- x: point2.x + dx,
|
|
|
|
- y: point1.y - dy,
|
|
|
|
- })
|
|
|
|
-
|
|
|
|
- this.points2d.push({
|
|
|
|
- x: this.center.x,
|
|
|
|
- y: point1.y - dy,
|
|
|
|
- })
|
|
|
|
-
|
|
|
|
- this.points2d.push({
|
|
|
|
- x: this.center.x,
|
|
|
|
- y: point3.y + dy,
|
|
|
|
- })
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- setTitle(title) {
|
|
|
|
- this.title = title
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- setDes(des) {
|
|
|
|
- this.des = des
|
|
|
|
- }
|
|
|
|
- setUnit(unit) {
|
|
|
|
- this.unit = unit
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- setAdding(flag) {
|
|
|
|
- this.adding = flag
|
|
|
|
- }
|
|
|
|
|
|
+ constructor(center, vectorId) {
|
|
|
|
+ super();
|
|
|
|
+ this.center = center;
|
|
|
|
+ this.points2d = [];
|
|
|
|
+ //this.title = KanKan.Config.i18n('cad.input')
|
|
|
|
+ this.title = "";
|
|
|
|
+ this.des = ""; //面积
|
|
|
|
+ this.unit = "m"; //或者ft
|
|
|
|
+ this.name = "标注";
|
|
|
|
+ this.adding = true;
|
|
|
|
+
|
|
|
|
+ this.sideWidth = 30; //像素
|
|
|
|
+ this.sideThickness = 30; //像素
|
|
|
|
+
|
|
|
|
+ this.geoType = VectorType.Tag;
|
|
|
|
+ this.setId(vectorId);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ isContain(position) {
|
|
|
|
+ let points = [];
|
|
|
|
+ points.push(this.points2d[0]);
|
|
|
|
+ points.push(this.points2d[1]);
|
|
|
|
+ points.push(this.points2d[2]);
|
|
|
|
+ points.push(this.points2d[3]);
|
|
|
|
+ return mathUtil.isPointInPoly(position, points);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ setPoints2d() {
|
|
|
|
+ this.points2d = [];
|
|
|
|
+ const minX =
|
|
|
|
+ this.center.x -
|
|
|
|
+ ((this.sideWidth / coordinate.res) * Constant.defaultZoom) /
|
|
|
|
+ coordinate.zoom /
|
|
|
|
+ 2;
|
|
|
|
+ const minY =
|
|
|
|
+ this.center.y -
|
|
|
|
+ ((this.sideThickness / coordinate.res) * Constant.defaultZoom) /
|
|
|
|
+ coordinate.zoom /
|
|
|
|
+ 2;
|
|
|
|
+ const maxX =
|
|
|
|
+ this.center.x +
|
|
|
|
+ ((this.sideWidth / coordinate.res) * Constant.defaultZoom) /
|
|
|
|
+ coordinate.zoom /
|
|
|
|
+ 2;
|
|
|
|
+ const maxY =
|
|
|
|
+ this.center.y +
|
|
|
|
+ ((this.sideThickness / coordinate.res) * Constant.defaultZoom) /
|
|
|
|
+ coordinate.zoom /
|
|
|
|
+ 2;
|
|
|
|
+
|
|
|
|
+ const point1 = {
|
|
|
|
+ x: minX,
|
|
|
|
+ y: maxY,
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ const point2 = {
|
|
|
|
+ x: maxX,
|
|
|
|
+ y: maxY,
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ const point3 = {
|
|
|
|
+ x: maxX,
|
|
|
|
+ y: minY,
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ const point4 = {
|
|
|
|
+ x: minX,
|
|
|
|
+ y: minY,
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ this.points2d.push(point1);
|
|
|
|
+ this.points2d.push(point2);
|
|
|
|
+ this.points2d.push(point3);
|
|
|
|
+ this.points2d.push(point4);
|
|
|
|
+
|
|
|
|
+ //-
|
|
|
|
+ let dx = (point1.x - this.center.x) / 2;
|
|
|
|
+ //+
|
|
|
|
+ let dy = (point1.y - this.center.y) / 2;
|
|
|
|
+
|
|
|
|
+ this.points2d.push({
|
|
|
|
+ x: point1.x - dx,
|
|
|
|
+ y: point1.y - dy,
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ this.points2d.push({
|
|
|
|
+ x: point2.x + dx,
|
|
|
|
+ y: point1.y - dy,
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ this.points2d.push({
|
|
|
|
+ x: this.center.x,
|
|
|
|
+ y: point1.y - dy,
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ this.points2d.push({
|
|
|
|
+ x: this.center.x,
|
|
|
|
+ y: point3.y + dy,
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ setTitle(title) {
|
|
|
|
+ this.title = title;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ setDes(des) {
|
|
|
|
+ this.des = des;
|
|
|
|
+ }
|
|
|
|
+ setUnit(unit) {
|
|
|
|
+ this.unit = unit;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ setAdding(flag) {
|
|
|
|
+ this.adding = flag;
|
|
|
|
+ }
|
|
}
|
|
}
|