|
@@ -24,11 +24,11 @@
|
|
|
* *********************************************************************************************************************
|
|
|
*/
|
|
|
|
|
|
-import { SGraphItem, SAnchorItem } from "@persagy-web/graph/lib";
|
|
|
+import { SAnchorItem, SGraphItem } from "@persagy-web/graph/lib";
|
|
|
import { SBaseIconTextEdit, SBaseTextEdit } from "@persagy-web/edit";
|
|
|
import { SColor } from "@persagy-web/draw/lib";
|
|
|
import { v1 as uuidv1 } from "uuid";
|
|
|
-import { Legend, svgTobase64,ItemOrder } from "@persagy-web/big/lib";
|
|
|
+import { ItemOrder, Legend, svgTobase64 } from "@persagy-web/big/lib";
|
|
|
|
|
|
|
|
|
* 编辑基础设备类
|
|
@@ -86,7 +86,7 @@ export class SBaseEquipment extends SBaseIconTextEdit {
|
|
|
|
|
|
* 设置 legendData 时对 item 做设置
|
|
|
*/
|
|
|
- initData() {
|
|
|
+ initData(): void {
|
|
|
|
|
|
if (!this.legendData) return;
|
|
|
|
|
@@ -166,7 +166,7 @@ export class SBaseEquipment extends SBaseIconTextEdit {
|
|
|
|
|
|
* 根据 url 获取图片
|
|
|
*/
|
|
|
- initUrl() {
|
|
|
+ initUrl(): void {
|
|
|
|
|
|
svgTobase64(this.url)
|
|
|
.then(res => {
|
|
@@ -256,16 +256,17 @@ export class SBaseEquipment extends SBaseIconTextEdit {
|
|
|
|
|
|
if (this.legendData) {
|
|
|
|
|
|
- const list = this.anchorList.map(item => {
|
|
|
+ this.legendData.anchorList = this.anchorList.map(item => {
|
|
|
+ const temp = item.mapToScene(0, 0);
|
|
|
+ const anchorPos = this.img.mapFromScene(temp.x, temp.y);
|
|
|
return {
|
|
|
anchorId: item.id,
|
|
|
pos: {
|
|
|
- x: item.x,
|
|
|
- y: item.y
|
|
|
+ x: anchorPos.x,
|
|
|
+ y: anchorPos.y
|
|
|
}
|
|
|
};
|
|
|
});
|
|
|
- this.legendData.anchorList = list;
|
|
|
|
|
|
if (this.legendData.size) {
|
|
|
this.legendData.size.width = this.sWidth;
|
|
@@ -277,18 +278,21 @@ export class SBaseEquipment extends SBaseIconTextEdit {
|
|
|
};
|
|
|
}
|
|
|
|
|
|
+ const poi = this.img.mapToScene(0, 0);
|
|
|
|
|
|
this.legendData.pos = {
|
|
|
- x: this.x,
|
|
|
- y: this.y
|
|
|
+ x: poi.x,
|
|
|
+ y: poi.y
|
|
|
};
|
|
|
|
|
|
|
|
|
const infoPoinList: any[] = [];
|
|
|
|
|
|
this.textItemList.forEach(item => {
|
|
|
+ const temp = item.mapToScene(0, 0);
|
|
|
+ const textPos = this.img.mapFromScene(temp.x, temp.y);
|
|
|
let obj = Object.assign(item.propertyData, {
|
|
|
- pos: { x: item.x, y: item.y },
|
|
|
+ pos: { x: textPos.x, y: textPos.y },
|
|
|
font: item.font.size,
|
|
|
color: item.color.value,
|
|
|
backgroundColor: item.backgroundColor.value,
|
|
@@ -309,4 +313,21 @@ export class SBaseEquipment extends SBaseIconTextEdit {
|
|
|
return this.legendData;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ * 计算并移动锚点的位置
|
|
|
+ */
|
|
|
+ changeAnchorPoint(): void {
|
|
|
+ if (this.anchorList.length) {
|
|
|
+ let anchorPoint = [
|
|
|
+ { x: this.img.x, y: this.img.y },
|
|
|
+ { x: this.img.x, y: this.img.y },
|
|
|
+ { x: this.img.x, y: this.img.y },
|
|
|
+ { x: this.img.x, y: this.img.y }
|
|
|
+ ];
|
|
|
+ this.anchorList.forEach((item, index) => {
|
|
|
+ item.moveTo(anchorPoint[index].x, anchorPoint[index].y);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|