Sfoglia il codice sorgente

添加设备与BIM坐标的关系

zhangyu 4 anni fa
parent
commit
bfd56f16bd

+ 1 - 1
src/components/editview/rightPropertyBar/BaseEquipment.vue

@@ -36,7 +36,7 @@
                             <el-input style="width: 78px; margin-left: 8px" size="mini" v-model="EquipItem.y" placeholder="请输入内容"></el-input>
                         </div>
                     </div>
-                    <el-checkbox v-model="showBimRelation">显示与BIM坐标关系</el-checkbox>
+                    <el-checkbox v-model="EquipItem.showLine">显示与BIM坐标关系</el-checkbox>
                 </div>
             </el-tab-pane>
             <el-tab-pane label="属性" name="second">

+ 50 - 3
src/lib/item/SPlanEquipment.ts

@@ -25,7 +25,7 @@
  */
 
 import { SGraphItem, SAnchorItem } from "@persagy-web/graph/lib";
-import { SPoint } from "@persagy-web/draw";
+import { SPoint, SPainter, SColor } from "@persagy-web/draw";
 import { Example } from "../index";
 import { SBaseIconTextEdit, SBaseTextEdit } from "@persagy-web/edit";
 import { svgTobase64, uuid } from "@persagy-web/big-edit/lib/until";
@@ -57,6 +57,29 @@ export class SPlanEquipment extends SBaseIconTextEdit {
         return this._url;
     } // get url()
 
+    /** 与BIM坐标关系连线的颜色 */
+    _lineColor: SColor = new SColor("#F54E45ff");
+    get lineColor(): SColor {
+        return this._lineColor;
+    }
+    set lineColor(v: SColor) {
+        this._lineColor = v;
+        this.update();
+    }
+
+    /** 是否显示与BIM坐标的关系 */
+    _showLine: boolean = false;
+    get showLine(): boolean {
+        return this._showLine;
+    }
+    set showLine(v: boolean) {
+        if (v === this._showLine) {
+            return;
+        }
+        this._showLine = v;
+        this.update();
+    }
+
     /** 公式 */
     private _formula: any[] = [];
     // private _formula: string = "";
@@ -120,6 +143,7 @@ export class SPlanEquipment extends SBaseIconTextEdit {
         this.isTransform = false;
         this.sWidth = 32;
         this.sHeight = 32;
+        this.img.showSelect = false;
         this.moveable = true;
         this.selectable = true;
         this.legendData = data;
@@ -156,9 +180,7 @@ export class SPlanEquipment extends SBaseIconTextEdit {
                 return item;
             });
         }
-
         this.id = this.legendData.id ? this.legendData.id : "";
-        // this.textItemList[0].text = this.legendData.codeName ? this.legendData.codeName : "";
         this.showAnchor = false;
         this.anotherMsg = this.legendData?.properties?.anotherMsg ? this.legendData.properties.anotherMsg : "";
         if (this.legendData.pos?.x && this.legendData.pos?.y) {
@@ -207,4 +229,29 @@ export class SPlanEquipment extends SBaseIconTextEdit {
         }
         return new Object();
     }
+
+    /**
+     * Item 绘制操作
+     *
+     * @param painter    绘制对象
+     */
+    onDraw(painter: SPainter): void {
+        if (this.showLine && this.legendData?.bimLocation && this.legendData?.locationJson) {
+            const bimX = (this.legendData.locationJson.x - this.x) / this.inverseScale;
+            const bimY = (-this.legendData.locationJson.y - this.y) / this.inverseScale;
+            const bimColor = new SColor(this.lineColor);
+            bimColor.alpha = 51;
+            painter.pen.color = this.lineColor;
+            painter.pen.lineWidth = 1
+            painter.drawLine(0, 0, bimX, bimY);
+            
+            painter.pen.color = SColor.Transparent;
+            painter.brush.color = bimColor;
+            painter.drawCircle(bimX, bimY, 5);
+            painter.brush.color = this.lineColor;
+            painter.drawCircle(bimX, bimY, 2);
+        }
+
+        super.onDraw(painter);
+    } // Function onDraw()
 }