YaolongHan 4 vuotta sitten
vanhempi
commit
187b300971
1 muutettua tiedostoa jossa 82 lisäystä ja 28 poistoa
  1. 82 28
      src/components/mapClass/EditScence.ts

+ 82 - 28
src/components/mapClass/EditScence.ts

@@ -104,7 +104,7 @@ export class EditScence extends SGraphScene {
         ItemColor.virtualWallColor = new SColor("#d4d4d4")
         ItemColor.selectColor = new SColor("#f0f0f0")
         ItemColor.spaceBorderColor = new SColor("#d4d4d4");
-        console.log('isMac',this.isMac)
+        console.log('isMac', this.isMac)
     }
     /** 绘制图例样式 */
     _legend: any | null = null;
@@ -465,8 +465,8 @@ export class EditScence extends SGraphScene {
                 Url: '/serve/topology-wanda/Picture/query/' + this._legend.Url,
                 Num: 1, // 此num与信息工程化得num无关
                 Size: {
-                    Width: this._legend.Size?this._legend.Size.Width?this._legend.Size.Width:32:32,  //icon 的宽
-                    Height: this._legend.Size?this._legend.Size.Height?this._legend.Size.Height:32:32,   //icon 的高
+                    Width: this._legend.Size ? this._legend.Size.Width ? this._legend.Size.Width : 32 : 32,  //icon 的宽
+                    Height: this._legend.Size ? this._legend.Size.Height ? this._legend.Size.Height : 32 : 32,   //icon 的高
                 },
                 font: 16,    //font
                 color: "#1F2429",  //字体颜色
@@ -715,7 +715,7 @@ export class EditScence extends SGraphScene {
                 fillColorT = fillColor + Transparency[15];
                 if (this.focusItem instanceof SSCPZZoneLegendItem || this.focusItem instanceof SFHFQZoneLegendItem) {
                     const sc = new SColor(this.focusItem.fillColor);
-                    const alp = ((sc.alpha/255)*100).toFixed()
+                    const alp = ((sc.alpha / 255) * 100).toFixed()
                     fillColorT = fillColor + Transparency[alp];
                     // fillColorT = fillColor + Transparency[80];
                 }
@@ -779,7 +779,7 @@ export class EditScence extends SGraphScene {
     /**
      * 自定义多边形修改背景色
     */
-    updateCustomBgColor(val: string):void{
+    updateCustomBgColor(val: string): void {
         if (this.focusItem) {
             const newMsg = new SColor(val);
             const oldMsg = this.focusItem.fillColor;
@@ -791,7 +791,7 @@ export class EditScence extends SGraphScene {
     /**
      * 自定义多边形修改边框色
     */
-    updateCustomBdColor(val: string):void{
+    updateCustomBdColor(val: string): void {
         if (this.focusItem) {
             const newMsg = new SColor(val);
             const oldMsg = this.focusItem.strokeColor;
@@ -1091,7 +1091,7 @@ export class EditScence extends SGraphScene {
             this.highLight.visible = false;
             this.absorbSpace(event);
         }
-        if (this.grabItem){
+        if (this.grabItem) {
             if (this.grabItem instanceof TipelineItem) {
                 const anc = this.clickIsAnchor(event);
                 if (anc) {
@@ -1159,7 +1159,7 @@ export class EditScence extends SGraphScene {
             this.deleiteItem()
         }
         // 删除键功能--兼容苹果mac
-        if (event.code == 'Backspace' && this.isMac){
+        if (event.code == 'Backspace' && this.isMac) {
             this.deleiteItem()
         }
         // 复制粘贴
@@ -1179,7 +1179,7 @@ export class EditScence extends SGraphScene {
      * 复制
      *
      */
-    copy(){
+    copy() {
         if (this.selectContainer.itemList.length) {
             this.copyString = {
                 Nodes: [],
@@ -1207,7 +1207,7 @@ export class EditScence extends SGraphScene {
             document.body.appendChild(input);
             input.select()
             document.execCommand('copy');
-            input.style.display='none';
+            input.style.display = 'none';
             console.log(input.value, Date.now());
             document.body.removeChild(input)
         }
@@ -1217,7 +1217,7 @@ export class EditScence extends SGraphScene {
      * 粘贴
      *
      */
-    paste(){
+    paste() {
         const parserData = new STopologyParser(null);
         // 需要深拷贝
         parserData.parseData(JSON.parse(JSON.stringify(this.copyString)))
@@ -1297,7 +1297,7 @@ export class EditScence extends SGraphScene {
      * 跨页面粘贴
      *
      */
-    crossPagePaste(crossPageString: string){
+    crossPagePaste(crossPageString: string) {
         try {
             console.log(crossPageString);
             const pageObj = JSON.parse(crossPageString)
@@ -1381,7 +1381,7 @@ export class EditScence extends SGraphScene {
     }
 
     /** 类型转换    */
-    itemToType(obj:SGraphItem):String{
+    itemToType(obj: SGraphItem): String {
         if (obj instanceof STextMarkerItem) {
             return 'Markers'
         } else if (obj instanceof SImageMarkerItem) {
@@ -1623,7 +1623,7 @@ export class EditScence extends SGraphScene {
         this.Nodes.forEach(image => {
             // image.showAnchor = false;
             if (image.anchorList && image.anchorList.length) {
-                if(image.img && image.img instanceof SImageItem) {
+                if (image.img && image.img instanceof SImageItem) {
                     let scenePoint = image.img.mapFromScene(event.x, event.y);
                     if (image.img.contains(scenePoint.x, scenePoint.y)) {
                         let anchor = image.anchorList[0]
@@ -1644,8 +1644,8 @@ export class EditScence extends SGraphScene {
                             len = dis;
                         }
                     }
-                // let scenePoint = image.mapFromScene(event.x, event.y);
-                // if (image.contains(scenePoint.x, scenePoint.y)) {
+                    // let scenePoint = image.mapFromScene(event.x, event.y);
+                    // if (image.contains(scenePoint.x, scenePoint.y)) {
                     // image.anchorList.forEach(anchor => {
                     //     let anchorPoint = anchor.mapToScene(0, 0);
                     //     let dis = SMathUtil.pointDistance(
@@ -1654,13 +1654,13 @@ export class EditScence extends SGraphScene {
                     //         anchorPoint.x,
                     //         anchorPoint.y
                     //     );
-                        // if (len < 0) {
-                        //     len = anchor.sceneDis;
-                        // }
-                        // if (dis < len) {
-                        //     minAnchor = anchor;
-                        //     len = dis;
-                        // }
+                    // if (len < 0) {
+                    //     len = anchor.sceneDis;
+                    // }
+                    // if (dis < len) {
+                    //     minAnchor = anchor;
+                    //     len = dis;
+                    // }
                     // })
                 }
             }
@@ -1883,7 +1883,7 @@ export class EditScence extends SGraphScene {
      *
      * @param   ang 旋转角度
     */
-    updateItemAng(ang: number) :void{
+    updateItemAng(ang: number): void {
         if (this.focusItem) {
             if (this.focusItem instanceof SImageLegendItem) {
                 const oldMsg = this.focusItem.img.rotate;
@@ -1908,7 +1908,7 @@ export class EditScence extends SGraphScene {
     /**
      * 计算框选交集
     */
-    groupSelect(){
+    groupSelect() {
         this.selectContainer.clear()
         if (this.grabItem instanceof SRectSelectItem) {
             const rect = this.grabItem.boundingRect();
@@ -1920,19 +1920,73 @@ export class EditScence extends SGraphScene {
     /**
      * 选中item:框选
     */
-    private arrToSelect(arr: SGraphItem[], rect:SRect){
-        if(Array.isArray(arr) && arr.length) {
+    private arrToSelect(arr: SGraphItem[], rect: SRect) {
+        if (Array.isArray(arr) && arr.length) {
             arr.forEach(t => {
                 if (t.parent) {
                     let temp = t.boundingRect();
                     let lefttop = t.mapToScene(temp.left, temp.top)
                     let rightbottom = t.mapToScene(temp.right, temp.bottom)
                     let r = new SRect(lefttop, rightbottom)
-                    if (rect.isIn(r)){
+                    if (rect.isIn(r)) {
                         this.selectContainer.toggleItem(t)
                     }
                 }
             })
         }
     }
+    /**
+     * 修改item样式
+     */
+    changeLengendItem(legend:any,event:SMouseEvent){
+        if (this.focusItem) {
+                const SubType = legend.SubType ? legend.SubType : '';
+                const LegendData: Legend = {
+                    ID: uuid(),
+                    Name: legend.Name,
+                    GraphElementType: legend.Type,
+                    Num: 1,
+                    GraphElementId: legend.Id,
+                    AttachObjectIds: [],
+                    Type: "Zone",
+                    Pos: { X: event.x, Y: event.y },
+                    OutLine: [{ X: event.x, Y: event.y }],
+                    SubType: SubType,
+                    Properties: {
+                        IconUrl: '/serve/topology-wanda/Picture/query/' + legend.Url,
+                        StrokeColor: legend.Color,
+                        FillColor: legend.FillColor,
+                        LineDash: legend.LineDash,
+                        LineWidth: legend.LineWidth,
+                        font: 14,
+                        color: "#1F2429",
+                        TextPos: { X: 0, Y: 0 },
+                        InfoTypeId: legend.InfoTypeId.length ? legend.InfoTypeId : [],
+                        InfoSystemId: legend.InfoSystemId ? legend.InfoSystemId : '',
+                        InfoLocal: legend.InfoLocal.length ? legend.InfoLocal : [],
+                        lengendName: legend.Name, //图例名称
+                    },
+                }
+                let Polylines = null;
+                if (SubType == "SCPZ") {
+                    Polylines = new SSCPZZoneLegendItem(null, LegendData);
+                } else if (SubType == "FHFQ") {
+                    Polylines = new SFHFQZoneLegendItem(null, LegendData);
+                } else if (SubType == "CUSTOM") {
+                    Polylines = new SCustomLegendItem(null, LegendData);
+                } else {
+                    Polylines = new SZoneLegendItem(null, LegendData);
+                }
+                Polylines.selectable = true;
+                //设置状态
+                Polylines.status = SItemStatus.Create;
+                // Polylines.moveable = true;
+                this.addItem(Polylines);
+                Polylines.connect("finishCreated", this, this.finishCreated);
+                // 删除item
+                this.deleiteItem();
+                this.grabItem = Polylines;
+                this.focusItem = Polylines;
+        }
+    }
 }