|
@@ -4,6 +4,9 @@ import { pointService } from "./Service/PointService.js";
|
|
|
import { imageService } from "./Service/ImageService.js";
|
|
|
import VectorCategory from "./enum/VectorCategory.js";
|
|
|
import { coordinate } from "./Coordinate.js";
|
|
|
+import { circleService } from "./Service/CircleService.js";
|
|
|
+import { magnifierService } from "./Service/MagnifierService.js";
|
|
|
+import { textService } from "./Service/TextService.js";
|
|
|
|
|
|
export default class Load {
|
|
|
constructor(layer) {
|
|
@@ -15,11 +18,97 @@ export default class Load {
|
|
|
|
|
|
async load(dataLocal, data3d) {
|
|
|
if (dataLocal) {
|
|
|
- dataService.vectorData = JSON.parse(JSON.stringify(dataLocal));
|
|
|
+ if (dataLocal.backgroundImg) {
|
|
|
+ let bgImg = imageService.create(
|
|
|
+ dataLocal.backgroundImg.src,
|
|
|
+ dataLocal.vectorId
|
|
|
+ );
|
|
|
+ bgImg.setCenter(dataLocal.backgroundImg.center);
|
|
|
+ bgImg.setDisplay(dataLocal.backgroundImg.display);
|
|
|
+ bgImg.setAngle(dataLocal.backgroundImg.angle);
|
|
|
+ try {
|
|
|
+ await bgImg.setImageData();
|
|
|
+ } catch (e) {}
|
|
|
+ }
|
|
|
+ if (dataLocal.circles) {
|
|
|
+ for (let key in dataLocal.circles) {
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (dataLocal.magnifiers) {
|
|
|
+ for (let key in dataLocal.magnifiers) {
|
|
|
+ let magnifier = magnifierService.create(
|
|
|
+ dataLocal.magnifiers[key].position,
|
|
|
+ key
|
|
|
+ );
|
|
|
+ magnifier.setPopPosition(dataLocal.magnifiers[key].popPosition);
|
|
|
+ magnifier.setSrc(dataLocal.magnifiers[key].photoUrl);
|
|
|
+ magnifier.setDisplay(dataLocal.magnifiers[key].display);
|
|
|
+ try {
|
|
|
+ await magnifier.setImageData();
|
|
|
+ } catch (e) {}
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (dataLocal.texts) {
|
|
|
+ for (let key in dataLocal.texts) {
|
|
|
+ let text = textService.create(dataLocal.texts[key].center, key);
|
|
|
+ text.setValue(dataLocal.texts[key].value);
|
|
|
+ text.setFontSize(dataLocal.texts[key].fontSize);
|
|
|
+ text.setColor(dataLocal.texts[key].color);
|
|
|
+ text.setDisplay(dataLocal.texts[key].display);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // if (data3d.baseLines) {
|
|
|
+ // for (let i = 0; i < data3d.baseLines.length; ++i) {
|
|
|
+ // //理论上基准线只能有一条
|
|
|
+ // lineService.create(
|
|
|
+ // data3d.baseLines[i][0],
|
|
|
+ // data3d.baseLines[i][1],
|
|
|
+ // VectorCategory.Line.BaseLine
|
|
|
+ // );
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // if (data3d.measures) {
|
|
|
+ // for (let i = 0; i < data3d.measures.length; ++i) {
|
|
|
+ // //理论上基准线只能有一条
|
|
|
+ // lineService.create(
|
|
|
+ // data3d.measures[i][0],
|
|
|
+ // data3d.measures[i][1],
|
|
|
+ // VectorCategory.Line.MeasureLine
|
|
|
+ // );
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // if (data3d.basePoints) {
|
|
|
+ // for (let i = 0; i < data3d.basePoints.length; ++i) {
|
|
|
+ // let point = pointService.create(
|
|
|
+ // data3d.basePoints[i],
|
|
|
+ // data3d.basePoints[i].category,
|
|
|
+ // data3d.basePoints[i].vectorId
|
|
|
+ // );
|
|
|
+ // point.setParent(data3d.basePoints[i].parent);
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // if (data3d.fixPoints) {
|
|
|
+ // for (let i = 0; i < data3d.fixPoints.length; ++i) {
|
|
|
+ // let point = pointService.create(
|
|
|
+ // data3d.fixPoints[i],
|
|
|
+ // data3d.fixPoints[i].category,
|
|
|
+ // data3d.fixPoints[i].vectorId
|
|
|
+ // );
|
|
|
+ // point.setParent(data3d.fixPoints[i].parent);
|
|
|
+ // }
|
|
|
+ // }
|
|
|
}
|
|
|
if (data3d) {
|
|
|
if (data3d.backImage) {
|
|
|
- let bgImg = imageService.create(data3d.backImage);
|
|
|
+ let bgImg = imageService.create(data3d.backImage, data3d.vectorId);
|
|
|
bgImg.setCenter(coordinate.center);
|
|
|
try {
|
|
|
await bgImg.setImageData();
|
|
@@ -63,6 +152,7 @@ export default class Load {
|
|
|
}
|
|
|
}
|
|
|
this.layer.history.init();
|
|
|
+ this.layer.renderer.autoRedraw();
|
|
|
}
|
|
|
|
|
|
save() {
|