|
@@ -19,141 +19,141 @@ export default class Load {
|
|
|
|
|
|
async load(dataLocal, data3d) {
|
|
|
this.layer.initLocation();
|
|
|
- // if (dataLocal) {
|
|
|
- // if (dataLocal.backgroundImg) {
|
|
|
- // let bgImg = imageService.create(
|
|
|
- // dataLocal.backgroundImg.src,
|
|
|
- // dataLocal.backgroundImg.vectorId
|
|
|
- // );
|
|
|
- // bgImg.setCenter(dataLocal.backgroundImg.center);
|
|
|
- // bgImg.setDisplay(dataLocal.backgroundImg.display);
|
|
|
- // bgImg.setAngle(dataLocal.backgroundImg.angle);
|
|
|
- // try {
|
|
|
- // if (dataLocal.backgroundImg.src) {
|
|
|
- // 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.setSrc(dataLocal.magnifiers[key].photoUrl);
|
|
|
- // magnifier.setDisplay(dataLocal.magnifiers[key].display);
|
|
|
- // try {
|
|
|
- // if (dataLocal.magnifiers[key].photoUrl) {
|
|
|
- // 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 (dataLocal.points) {
|
|
|
- // 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.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
|
|
|
- // );
|
|
|
- // if (dataLocal.lines[key].arrowColor) {
|
|
|
- // line.setArrowColor(dataLocal.lines[key].arrowColor);
|
|
|
- // }
|
|
|
- // line.setDisplay(dataLocal.lines[key].display);
|
|
|
- // if (line.getCategory() == VectorCategory.Line.BaseLine) {
|
|
|
- // Settings.baseLineId = key;
|
|
|
- // }
|
|
|
- // }
|
|
|
- // }
|
|
|
- // if (dataLocal.hasOwnProperty("currentId")) {
|
|
|
- // dataService.setCurrentId(dataLocal.currentId);
|
|
|
- // }
|
|
|
- // }
|
|
|
- // if (data3d) {
|
|
|
- // if (data3d.backImage) {
|
|
|
- // let bgImg = imageService.create(data3d.backImage, data3d.vectorId);
|
|
|
- // bgImg.setCenter(coordinate.center);
|
|
|
- // try {
|
|
|
- // if (bgImg.src) {
|
|
|
- // await bgImg.setImageData();
|
|
|
- // }
|
|
|
- // } catch (e) {}
|
|
|
- // if (data3d.meterPerPixel) {
|
|
|
- // const width = bgImg.imageData.width;
|
|
|
- // const height = bgImg.imageData.height;
|
|
|
- // coordinate.setRes(data3d.meterPerPixel);
|
|
|
- // 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
|
|
|
- // );
|
|
|
- // Settings.baseLineId = baseLine.vectorId;
|
|
|
- // }
|
|
|
- // }
|
|
|
- // if (data3d.measures) {
|
|
|
- // for (let i = 0; i < data3d.measures.length; ++i) {
|
|
|
- // //理论上基准线只能有一条
|
|
|
- // lineService.create(
|
|
|
- // this.getXY(width, height, data3d.measures[i][0]),
|
|
|
- // this.getXY(width, height, data3d.measures[i][1]),
|
|
|
- // VectorCategory.Line.MeasureLine
|
|
|
- // );
|
|
|
- // }
|
|
|
- // }
|
|
|
- // if (data3d.basePoints) {
|
|
|
- // for (let i = 0; i < data3d.basePoints.length; ++i) {
|
|
|
- // let point = pointService.create(
|
|
|
- // this.getXY(width, height, data3d.basePoints[i])
|
|
|
- // );
|
|
|
- // point.setCategory(VectorCategory.Point.BasePoint);
|
|
|
- // }
|
|
|
- // }
|
|
|
- // if (data3d.fixPoints) {
|
|
|
- // for (let i = 0; i < data3d.fixPoints.length; ++i) {
|
|
|
- // let point = pointService.create(
|
|
|
- // this.getXY(width, height, data3d.fixPoints[i])
|
|
|
- // );
|
|
|
- // point.setCategory(VectorCategory.Point.FixPoint);
|
|
|
- // }
|
|
|
- // }
|
|
|
- // }
|
|
|
- // }
|
|
|
- // }
|
|
|
+ if (dataLocal) {
|
|
|
+ if (dataLocal.backgroundImg) {
|
|
|
+ let bgImg = imageService.create(
|
|
|
+ dataLocal.backgroundImg.src,
|
|
|
+ dataLocal.backgroundImg.vectorId
|
|
|
+ );
|
|
|
+ bgImg.setCenter(dataLocal.backgroundImg.center);
|
|
|
+ bgImg.setDisplay(dataLocal.backgroundImg.display);
|
|
|
+ bgImg.setAngle(dataLocal.backgroundImg.angle);
|
|
|
+ try {
|
|
|
+ if (dataLocal.backgroundImg.src) {
|
|
|
+ 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.setSrc(dataLocal.magnifiers[key].photoUrl);
|
|
|
+ magnifier.setDisplay(dataLocal.magnifiers[key].display);
|
|
|
+ try {
|
|
|
+ if (dataLocal.magnifiers[key].photoUrl) {
|
|
|
+ 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 (dataLocal.points) {
|
|
|
+ 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.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
|
|
|
+ );
|
|
|
+ if (dataLocal.lines[key].arrowColor) {
|
|
|
+ line.setArrowColor(dataLocal.lines[key].arrowColor);
|
|
|
+ }
|
|
|
+ line.setDisplay(dataLocal.lines[key].display);
|
|
|
+ if (line.getCategory() == VectorCategory.Line.BaseLine) {
|
|
|
+ Settings.baseLineId = key;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (dataLocal.hasOwnProperty("currentId")) {
|
|
|
+ dataService.setCurrentId(dataLocal.currentId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (data3d) {
|
|
|
+ if (data3d.backImage) {
|
|
|
+ let bgImg = imageService.create(data3d.backImage, data3d.vectorId);
|
|
|
+ bgImg.setCenter(coordinate.center);
|
|
|
+ try {
|
|
|
+ if (bgImg.src) {
|
|
|
+ await bgImg.setImageData();
|
|
|
+ }
|
|
|
+ } catch (e) {}
|
|
|
+ if (data3d.meterPerPixel) {
|
|
|
+ const width = bgImg.imageData.width;
|
|
|
+ const height = bgImg.imageData.height;
|
|
|
+ coordinate.setRes(data3d.meterPerPixel);
|
|
|
+ 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
|
|
|
+ );
|
|
|
+ Settings.baseLineId = baseLine.vectorId;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (data3d.measures) {
|
|
|
+ for (let i = 0; i < data3d.measures.length; ++i) {
|
|
|
+ //理论上基准线只能有一条
|
|
|
+ lineService.create(
|
|
|
+ this.getXY(width, height, data3d.measures[i][0]),
|
|
|
+ this.getXY(width, height, data3d.measures[i][1]),
|
|
|
+ VectorCategory.Line.MeasureLine
|
|
|
+ );
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (data3d.basePoints) {
|
|
|
+ for (let i = 0; i < data3d.basePoints.length; ++i) {
|
|
|
+ let point = pointService.create(
|
|
|
+ this.getXY(width, height, data3d.basePoints[i])
|
|
|
+ );
|
|
|
+ point.setCategory(VectorCategory.Point.BasePoint);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (data3d.fixPoints) {
|
|
|
+ for (let i = 0; i < data3d.fixPoints.length; ++i) {
|
|
|
+ let point = pointService.create(
|
|
|
+ this.getXY(width, height, data3d.fixPoints[i])
|
|
|
+ );
|
|
|
+ point.setCategory(VectorCategory.Point.FixPoint);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
if (Settings.baseLineId) {
|
|
|
this.layer.updateForLocation();
|
|
|
}
|