|
@@ -1,19 +1,19 @@
|
|
|
-import { dataService } from "./Service/DataService.js";
|
|
|
-import { lineService } from "./Service/LineService.js";
|
|
|
-import { pointService } from "./Service/PointService.js";
|
|
|
-import { imageService } from "./Service/ImageService.js";
|
|
|
-import VectorCategory from "./enum/VectorCategory.js";
|
|
|
-import { coordinate } from "./Coordinate.js";
|
|
|
-import Settings from "./Settings";
|
|
|
-import { circleService } from "./Service/CircleService.js";
|
|
|
-import { magnifierService } from "./Service/MagnifierService.js";
|
|
|
-import { textService } from "./Service/TextService.js";
|
|
|
-import { mathUtil } from "./Util/MathUtil.js";
|
|
|
+import { dataService } from './Service/DataService.js';
|
|
|
+import { lineService } from './Service/LineService.js';
|
|
|
+import { pointService } from './Service/PointService.js';
|
|
|
+import { imageService } from './Service/ImageService.js';
|
|
|
+import VectorCategory from './enum/VectorCategory.js';
|
|
|
+import { coordinate } from './Coordinate.js';
|
|
|
+import Settings from './Settings';
|
|
|
+import { circleService } from './Service/CircleService.js';
|
|
|
+import { magnifierService } from './Service/MagnifierService.js';
|
|
|
+import { textService } from './Service/TextService.js';
|
|
|
+import { mathUtil } from './Util/MathUtil.js';
|
|
|
|
|
|
export default class Load {
|
|
|
constructor(layer) {
|
|
|
this.layer = layer;
|
|
|
- this.version = "v1.0";
|
|
|
+ this.version = 'v1.0';
|
|
|
this.vectorsJson = null;
|
|
|
this.newVectorId = null;
|
|
|
}
|
|
@@ -22,10 +22,7 @@ export default class Load {
|
|
|
this.layer.initLocation();
|
|
|
if (dataLocal) {
|
|
|
if (dataLocal.backgroundImg) {
|
|
|
- let bgImg = imageService.createBackgroundImg(
|
|
|
- dataLocal.backgroundImg.src,
|
|
|
- dataLocal.backgroundImg.vectorId
|
|
|
- );
|
|
|
+ let bgImg = imageService.createBackgroundImg(dataLocal.backgroundImg.src, dataLocal.backgroundImg.vectorId);
|
|
|
bgImg.setCenter(dataLocal.backgroundImg.center);
|
|
|
bgImg.setDisplay(dataLocal.backgroundImg.display);
|
|
|
bgImg.setAngle(dataLocal.backgroundImg.angle);
|
|
@@ -38,11 +35,7 @@ export default class Load {
|
|
|
}
|
|
|
if (dataLocal.circles) {
|
|
|
for (let key in dataLocal.circles) {
|
|
|
- let circle = circleService.create(
|
|
|
- dataLocal.circles[key].center,
|
|
|
- dataLocal.circles[key].radius,
|
|
|
- key
|
|
|
- );
|
|
|
+ let circle = circleService.create(dataLocal.circles[key].center, dataLocal.circles[key].radius, key);
|
|
|
circle.setPoints(dataLocal.circles[key].points);
|
|
|
circle.setColor(dataLocal.circles[key].color);
|
|
|
circle.setDisplay(dataLocal.circles[key].display);
|
|
@@ -50,10 +43,7 @@ export default class Load {
|
|
|
}
|
|
|
if (dataLocal.magnifiers) {
|
|
|
for (let key in dataLocal.magnifiers) {
|
|
|
- let magnifier = magnifierService.create(
|
|
|
- dataLocal.magnifiers[key].position,
|
|
|
- key
|
|
|
- );
|
|
|
+ let magnifier = magnifierService.create(dataLocal.magnifiers[key].position, key);
|
|
|
magnifier.setSrc(dataLocal.magnifiers[key].photoUrl);
|
|
|
magnifier.setDisplay(dataLocal.magnifiers[key].display);
|
|
|
try {
|
|
@@ -67,21 +57,21 @@ export default class Load {
|
|
|
for (let key in dataLocal.points) {
|
|
|
let point = pointService.create(dataLocal.points[key], key);
|
|
|
point.setCategory(dataLocal.points[key].category);
|
|
|
- point.setParent(
|
|
|
- JSON.parse(JSON.stringify(dataLocal.points[key].parent))
|
|
|
- );
|
|
|
+ point.setParent(JSON.parse(JSON.stringify(dataLocal.points[key].parent)));
|
|
|
point.setDisplay(dataLocal.points[key].display);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (dataLocal.lines) {
|
|
|
for (let key in dataLocal.lines) {
|
|
|
- let line = lineService.createByPointId(
|
|
|
- dataLocal.lines[key].startId,
|
|
|
- dataLocal.lines[key].endId,
|
|
|
- dataLocal.lines[key].category,
|
|
|
- key
|
|
|
- );
|
|
|
+ let line = lineService.createByPointId(dataLocal.lines[key].startId, dataLocal.lines[key].endId, dataLocal.lines[key].category, key);
|
|
|
+
|
|
|
+ if (dataLocal.lines[key].style) {
|
|
|
+ line.setStyle(dataLocal.lines[key].style);
|
|
|
+ }
|
|
|
+ if (dataLocal.lines[key].weight) {
|
|
|
+ line.setWeight(dataLocal.lines[key].weight);
|
|
|
+ }
|
|
|
if (dataLocal.lines[key].color) {
|
|
|
line.setColor(dataLocal.lines[key].color);
|
|
|
}
|
|
@@ -107,18 +97,15 @@ export default class Load {
|
|
|
text.setAngle(dataLocal.texts[key].angle || 0);
|
|
|
}
|
|
|
}
|
|
|
- if (dataLocal.hasOwnProperty("currentId")) {
|
|
|
+ if (dataLocal.hasOwnProperty('currentId')) {
|
|
|
dataService.setCurrentId(dataLocal.currentId);
|
|
|
}
|
|
|
- if (dataLocal.hasOwnProperty("res")) {
|
|
|
+ if (dataLocal.hasOwnProperty('res')) {
|
|
|
coordinate.setRes(dataLocal.res);
|
|
|
}
|
|
|
} else if (data3d) {
|
|
|
if (data3d.backImage) {
|
|
|
- let bgImg = imageService.createBackgroundImg(
|
|
|
- data3d.backImage,
|
|
|
- data3d.vectorId
|
|
|
- );
|
|
|
+ let bgImg = imageService.createBackgroundImg(data3d.backImage, data3d.vectorId);
|
|
|
bgImg.setCenter(coordinate.center);
|
|
|
try {
|
|
|
if (bgImg.src) {
|
|
@@ -135,20 +122,13 @@ export default class Load {
|
|
|
if (data3d.baseLines) {
|
|
|
for (let i = 0; i < data3d.baseLines.length; ++i) {
|
|
|
//理论上基准线只能有一条
|
|
|
- let baseLine = lineService.create(
|
|
|
- this.getXY(width, height, data3d.baseLines[i][0]),
|
|
|
- this.getXY(width, height, data3d.baseLines[i][1]),
|
|
|
- VectorCategory.Line.BaseLine
|
|
|
- );
|
|
|
+ let baseLine = lineService.create(this.getXY(width, height, data3d.baseLines[i][0]), this.getXY(width, height, data3d.baseLines[i][1]), VectorCategory.Line.BaseLine);
|
|
|
Settings.baseLineId = baseLine.vectorId;
|
|
|
- const geometryBaseLine = mathUtil.createLine1(
|
|
|
- dataService.getPoint(baseLine.startId),
|
|
|
- dataService.getPoint(baseLine.endId)
|
|
|
- );
|
|
|
+ const geometryBaseLine = mathUtil.createLine1(dataService.getPoint(baseLine.startId), dataService.getPoint(baseLine.endId));
|
|
|
//文字要和基准线的方向一致
|
|
|
- if (typeof geometryBaseLine.a != "undefined") {
|
|
|
+ if (typeof geometryBaseLine.a != 'undefined') {
|
|
|
angle = Math.atan(geometryBaseLine.a);
|
|
|
- } else if (geometryBaseLine.hasOwnProperty("x")) {
|
|
|
+ } else if (geometryBaseLine.hasOwnProperty('x')) {
|
|
|
angle = Math.PI / 2;
|
|
|
} else {
|
|
|
angle = 0;
|
|
@@ -159,19 +139,13 @@ export default class Load {
|
|
|
for (let i = 0; i < data3d.measures.length; ++i) {
|
|
|
//理论上基准线只能有一条
|
|
|
//
|
|
|
- const line = lineService.create(
|
|
|
- this.getXY(width, height, data3d.measures[i].pos[0]),
|
|
|
- this.getXY(width, height, data3d.measures[i].pos[1]),
|
|
|
- VectorCategory.Line.MeasureLine
|
|
|
- );
|
|
|
+ const line = lineService.create(this.getXY(width, height, data3d.measures[i].pos[0]), this.getXY(width, height, data3d.measures[i].pos[1]), VectorCategory.Line.MeasureLine);
|
|
|
line.value = data3d.measures[i].dis;
|
|
|
}
|
|
|
}
|
|
|
if (data3d.basePoints) {
|
|
|
for (let i = 0; i < data3d.basePoints.length; ++i) {
|
|
|
- let point = pointService.create(
|
|
|
- this.getXY(width, height, data3d.basePoints[i])
|
|
|
- );
|
|
|
+ let point = pointService.create(this.getXY(width, height, data3d.basePoints[i]));
|
|
|
point.setCategory(VectorCategory.Point.BasePoint);
|
|
|
}
|
|
|
}
|
|
@@ -181,18 +155,9 @@ export default class Load {
|
|
|
// this.getXY(width, height, data3d.fixPoints[i].pos)
|
|
|
// );
|
|
|
// point.setCategory(VectorCategory.Point.FixPoint);
|
|
|
- console.log(
|
|
|
- "001-fixPoints-" +
|
|
|
- i +
|
|
|
- ":" +
|
|
|
- JSON.stringify(data3d.fixPoints[i].pos)
|
|
|
- );
|
|
|
- let text = textService.create(
|
|
|
- this.getXY(width, height, data3d.fixPoints[i].pos)
|
|
|
- );
|
|
|
- console.log(
|
|
|
- "002-fixPoints-" + i + ":" + JSON.stringify(text.center)
|
|
|
- );
|
|
|
+ console.log('001-fixPoints-' + i + ':' + JSON.stringify(data3d.fixPoints[i].pos));
|
|
|
+ let text = textService.create(this.getXY(width, height, data3d.fixPoints[i].pos));
|
|
|
+ console.log('002-fixPoints-' + i + ':' + JSON.stringify(text.center));
|
|
|
text.setValue(data3d.fixPoints[i].text);
|
|
|
text.setAngle(angle);
|
|
|
}
|
|
@@ -225,6 +190,6 @@ export default class Load {
|
|
|
// 退出页面清除缓存及其他操作
|
|
|
clear() {
|
|
|
this.layer.uiControl.menu_clear();
|
|
|
- console.warn("clear");
|
|
|
+ console.warn('clear');
|
|
|
}
|
|
|
}
|