|
@@ -28,6 +28,7 @@ import { SGraphItem, SAnchorItem } from "@persagy-web/graph/lib";
|
|
|
import { Example } from "../index";
|
|
|
import { SBaseIconTextEdit, SBaseTextEdit } from "@persagy-web/edit";
|
|
|
import { svgTobase64, uuid } from "@persagy-web/big-edit/lib/until";
|
|
|
+import { SColor, SFont } from "@persagy-web/draw/lib";
|
|
|
|
|
|
* 编辑基础设备类
|
|
|
*
|
|
@@ -60,6 +61,45 @@ export class SPlanEquipment extends SBaseIconTextEdit {
|
|
|
private _formula: string = "";
|
|
|
set formula(val) {
|
|
|
this._formula = val;
|
|
|
+ try {
|
|
|
+ const textList = JSON.parse(this._formula);
|
|
|
+ const font = this.textItemList[0]?.font ? this.textItemList[0]?.font : new SFont("sans-serif", 12);
|
|
|
+ const color = this.textItemList[0]?.color ? this.textItemList[0]?.color : new SColor("#1F2429");
|
|
|
+ if (this.scene) {
|
|
|
+ this.textItemList.forEach((textItem) => {
|
|
|
+ this.scene.removeItem(textItem);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if (textList.length) {
|
|
|
+ const textItemList: any[] = [];
|
|
|
+ textList.forEach((item: any, index: number) => {
|
|
|
+ let obj = new SBaseTextEdit(this, null);
|
|
|
+
|
|
|
+ obj.text = item;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ obj.moveTo(this.img.width * 0.5, this.font.size * (index - 0.125 - 0.5 * textList.length));
|
|
|
+ obj.font = font;
|
|
|
+ obj.color = color;
|
|
|
+ obj.isTransform = false;
|
|
|
+ obj.showSelect = false;
|
|
|
+ textItemList.push(obj);
|
|
|
+ });
|
|
|
+ this.textItemList = textItemList;
|
|
|
+ } else {
|
|
|
+ this.textItemList = [];
|
|
|
+ }
|
|
|
+ this.update();
|
|
|
+ } catch (error) {
|
|
|
+ console.error("公式数据错误", error);
|
|
|
+ }
|
|
|
}
|
|
|
get formula(): string {
|
|
|
return this._formula;
|
|
@@ -80,12 +120,6 @@ export class SPlanEquipment extends SBaseIconTextEdit {
|
|
|
this.isTransform = false;
|
|
|
this.sWidth = 32;
|
|
|
this.sHeight = 32;
|
|
|
- const textItem = new SBaseTextEdit(this, null);
|
|
|
- textItem.text = "";
|
|
|
- textItem.font.size = 12;
|
|
|
-
|
|
|
- textItem.moveTo(this.img.width * 0.5, -(this.font.size * 1.25 * 0.5));
|
|
|
- this.textItemList.push(textItem);
|
|
|
this.moveable = true;
|
|
|
this.selectable = true;
|
|
|
this.legendData = data;
|