zhangyu 4 лет назад
Родитель
Сommit
572bb0d919

+ 1 - 1
src/components/baseEditertest.vue

@@ -73,7 +73,7 @@ export default {
         new SPoint(0, 50)
       ];
       const Polylines = new SPolygonItem(null);
-      Polylines.setStatus = 3;
+      Polylines.status = 3;
       // Polylines.setPointList = PointList
       this.scene.addItem(Polylines);
       this.scene.grabItem = Polylines;

+ 2 - 2
src/components/baseEditerzy.vue

@@ -2,7 +2,7 @@
  * @Author: zhangyu
  * @Date: 2020-06-03 17:21:15
  * @Info: 
- * @LastEditTime: 2020-06-03 18:32:53
+ * @LastEditTime: 2020-06-20 14:33:27
 --> 
 <template>
   <div id="baseEditer">
@@ -83,7 +83,7 @@ export default {
         ]
       };
       const Polylines = new SPolygonItem(null);
-      Polylines.setStatus = 2;
+      Polylines.status = 2;
       this.scene.addItem(Polylines);
       this.scene.grabItem = Polylines;
     },

+ 6 - 3
src/components/edit/attr_select.vue

@@ -115,15 +115,15 @@
         <a-button type="link" class="edit-option-btn">{{editStatus[type]}}</a-button>
       </div>
       <div class="row">
-        <a-input />
+        <a-input v-model="textMsg" />
       </div>
       <div class="row">
         <div class="row-tit">字号</div>
         <div class="grid-content">
           <a-input-number
-            v-model="lineWidth"
+            v-model="fontSize"
             :min="1"
-            @change="changeLineWidth"
+            @change="changeFont"
             style="width: 168px"
           />
         </div>
@@ -331,6 +331,9 @@ export default {
         } else if (newval.itemType == "line") {
           this.lineWidth = Item.lineWidth;
           this.borderColor = Item.strokeColor;
+        } else if (newval.itemType == "position") {
+          this.textMsg = Item.text;
+          this.fontSize = Item.font.size;
         }
       }
     }

+ 2 - 1
src/components/mapClass/EditScence.ts

@@ -167,6 +167,7 @@ export class EditScence extends SGraphScene {
             Pos: { X: event.x, Y: event.y },
             OutLine: [[new SPoint(event.x, event.y)]],
             Properties: {
+                Text: "区域类型",
                 strokeColor: this._legend.Color,
                 fillColor: this._legend.FillColor,
                 LineDash: this._legend.LineDash,
@@ -177,7 +178,7 @@ export class EditScence extends SGraphScene {
         const Polylines = new SZoneLegendItem(null, LegendData);
         Polylines.selectable = true;
         //设置状态
-        Polylines.setStatus = SItemStatus.Create;
+        Polylines.status = SItemStatus.Create;
         Polylines.zOrder = ItemOrder.polygonOrder;
         // Polylines.moveable = true;
         this.addItem(Polylines);

+ 25 - 26
src/components/mapClass/SPolygonItem.ts

@@ -59,13 +59,13 @@ export class SPolygonItem extends SGraphItem {
     /** 是否闭合    */
     closeFlag: boolean = false;
     // 当前状态
-    _status: number = SItemStatus.Normal;
+    protected _status: number = SItemStatus.Normal;
     // 获取当前状态
-    get getStatus(): number {
+    get status(): SItemStatus {
         return this._status;
     }
     // 编辑当前状态
-    set setStatus(value: number) {
+    set status(value: SItemStatus) {
         this._status = value;
         // 如果状态为show则需清栈
         if (value == SItemStatus.Normal) {
@@ -101,7 +101,6 @@ export class SPolygonItem extends SGraphItem {
     }
     set lineWidth(v: number) {
         this._lineWidth = v;
-        alert(v)
         this.update();
     };
     /** 鼠标移动点  */
@@ -117,7 +116,7 @@ export class SPolygonItem extends SGraphItem {
     /** 场景像素  */
     private isAlt: boolean = false;
     /** undoredo堆栈 */
-    private undoStack: SUndoStack | null = new SUndoStack();
+    protected undoStack: SUndoStack | null = new SUndoStack();
 
     /**
     * 构造函数
@@ -386,7 +385,7 @@ export class SPolygonItem extends SGraphItem {
      * 执行取消操作执行
      */
     undo(): void {
-        if (this._status == SItemStatus.Normal) {
+        if (this.status == SItemStatus.Normal) {
             return
         }
         if (this.undoStack) {
@@ -398,7 +397,7 @@ export class SPolygonItem extends SGraphItem {
      * 执行重做操作执行
      */
     redo(): void {
-        if (this._status == SItemStatus.Normal) {
+        if (this.status == SItemStatus.Normal) {
             return
         }
         if (this.undoStack) {
@@ -417,11 +416,11 @@ export class SPolygonItem extends SGraphItem {
      */
     onDoubleClick(event: SMouseEvent): boolean {
         // 如果位show状态 双击改对象则需改为编辑状态
-        if (SItemStatus.Normal == this._status) {
-            this._status = SItemStatus.Edit;
+        if (SItemStatus.Normal == this.status) {
+            this.status = SItemStatus.Edit;
             this.grabItem(this);
-        } else if (SItemStatus.Edit == this._status) {
-            this._status = SItemStatus.Normal;
+        } else if (SItemStatus.Edit == this.status) {
+            this.status = SItemStatus.Normal;
             this.releaseItem();
             if (this.undoStack) {
                 this.undoStack.clear()
@@ -440,13 +439,13 @@ export class SPolygonItem extends SGraphItem {
      */
 
     onKeyDown(event: KeyboardEvent): boolean {
-        if (this._status == SItemStatus.Normal) {
+        if (this.status == SItemStatus.Normal) {
             return false;
-        } else if (this._status == SItemStatus.Create) {
+        } else if (this.status == SItemStatus.Create) {
             if (event.code == 'Enter') {
                 // 当顶点大于二个时才又条件执行闭合操作并清空堆栈
                 if (this.pointList.length > 2) {
-                    this._status = SItemStatus.Normal;
+                    this.status = SItemStatus.Normal;
                     //3 传递完成事件状态
                     this.$emit('finishCreated')
                     //1 grabItem 置为null
@@ -457,7 +456,7 @@ export class SPolygonItem extends SGraphItem {
                     }
                 }
             }
-        } else if (this._status == SItemStatus.Edit) {
+        } else if (this.status == SItemStatus.Edit) {
             if (event.key == 'Alt') {
                 this.isAlt = true;
             }
@@ -474,7 +473,7 @@ export class SPolygonItem extends SGraphItem {
      * @return	boolean
      */
     onKeyUp(event: KeyboardEvent): void {
-        if (this._status == SItemStatus.Edit) {
+        if (this.status == SItemStatus.Edit) {
             if (event.key == 'Alt') {
                 this.isAlt = false;
             }
@@ -490,13 +489,13 @@ export class SPolygonItem extends SGraphItem {
      */
     onMouseDown(event: SMouseEvent): boolean {
         // 如果状态为编辑状态则添加点
-        if (this._status == SItemStatus.Create) {
+        if (this.status == SItemStatus.Create) {
             // 新增顶点
             this.insertPoint(event.x, event.y);
             // 记录新增顶点操作记录压入堆栈
             let pos = new SPoint(event.x, event.y);
             this.recordAction(SGraphPointListInsert, [this.pointList, pos]);
-        } else if (this._status == SItemStatus.Edit) {
+        } else if (this.status == SItemStatus.Edit) {
             // 对多边形数组做编辑操作
             this.editPolygonPoint(event);
         } else {
@@ -536,12 +535,12 @@ export class SPolygonItem extends SGraphItem {
      */
 
     onMouseMove(event: SMouseEvent): boolean {
-        if (this._status == SItemStatus.Create) {
+        if (this.status == SItemStatus.Create) {
             this.lastPoint = new SPoint
             this.lastPoint.x = event.x;
             this.lastPoint.y = event.y;
             this.update();
-        } else if (this._status == SItemStatus.Edit) {
+        } else if (this.status == SItemStatus.Edit) {
             if (-1 != this.curIndex) {
                 this.pointList[this.curIndex].x = event.x;
                 this.pointList[this.curIndex].y = event.y;
@@ -562,7 +561,7 @@ export class SPolygonItem extends SGraphItem {
      * @return	boolean
      */
     onMouseUp(event: SMouseEvent): boolean {
-        if (this._status == SItemStatus.Edit) {
+        if (this.status == SItemStatus.Edit) {
             if (-1 != this.curIndex) {
                 const pos = new SPoint(this.pointList[this.curIndex].x, this.pointList[this.curIndex].y)
                 this.recordAction(SGraphPointListUpdate, [this.pointList, this.curPoint, pos, this.curIndex])
@@ -593,12 +592,12 @@ export class SPolygonItem extends SGraphItem {
      */
     cancelOperate(): void {
         // 当状态为展示状态
-        if (this._status == SItemStatus.Create) {
+        if (this.status == SItemStatus.Create) {
             // 闭合多边形
             this.parent = null
-        } else if (this._status == SItemStatus.Edit) {
+        } else if (this.status == SItemStatus.Edit) {
             // 编辑状态
-            this._status = SItemStatus.Normal
+            this.status = SItemStatus.Normal
         }
         this.update()
     } // Function cancelOperate()
@@ -661,10 +660,10 @@ export class SPolygonItem extends SGraphItem {
     onDraw(painter: SPainter): void {
         this.scenceLen = painter.toPx(this.len)
         // 当状态为展示状态
-        if (this._status == SItemStatus.Normal) {
+        if (this.status == SItemStatus.Normal) {
             // 闭合多边形
             this.drawShowPolygon(painter, this.pointList);
-        } else if (this._status == SItemStatus.Create) {
+        } else if (this.status == SItemStatus.Create) {
             // 创建状态
             this.drawCreatePolygon(painter, this.pointList)
         } else {

+ 36 - 2
src/lib/items/SZoneLegendItem.ts

@@ -5,6 +5,7 @@ import { Legend } from '../types/Legend';
 import { SPainter, SColor, SFont, SPoint } from "@saga-web/draw";
 import { STextItem } from '@saga-web/graph/lib';
 import { hexify } from "@/components/mapClass/until"
+import { SItemStatus, ItemOrder } from '@saga-web/big/lib';
 /**
  * 图例节点Item(区域类型)
  *
@@ -36,6 +37,35 @@ export class SZoneLegendItem extends SPolygonItem {
     set font(v: SFont) {
         this.textItem.font = v
     }
+
+    get status(): SItemStatus {
+        return this._status;
+    }
+    // 编辑当前状态
+    set status(value: SItemStatus) {
+        this._status = value;
+        // 如果状态为show则需清栈
+        if (value == SItemStatus.Normal) {
+            // 计算文本位置
+            let x: number = this.getPointList.reduce((pre, cur, index, arr) => {
+                                return pre + (cur.x / arr.length)
+                            }, 0),
+                y: number = this.getPointList.reduce((pre, cur, index, arr) => {
+                                return pre + (cur.y / arr.length)
+                            }, 0);
+            this.textItem.moveTo(x, y);
+            this.showText = true;
+            if (this.undoStack) {
+                this.undoStack.clear();
+            }
+        } else if (value == SItemStatus.Edit) {
+            this.showText = true;
+        } else if (value == SItemStatus.Create) {
+            this.showText = false;
+        }
+        this.update();
+    };
+
     /** 是否显示文字  */
     _showText: boolean = true;
     get showText(): boolean {
@@ -63,6 +93,8 @@ export class SZoneLegendItem extends SPolygonItem {
         super(parent);
         this.data = data;
         this.id = data.ID;
+        this.name = data.Name;
+        this.font = new SFont("sans-serif", 2);
         if (data) {
             this.setPointList = [];
             let setPointList: SPoint[];
@@ -76,7 +108,9 @@ export class SZoneLegendItem extends SPolygonItem {
                     this.setPointList = setPointList;
                 }
             }
-
+            if (data.Properties.Text) {
+                this.text = data.Properties.Text;
+            }
             // 设置线宽
             if (data.Properties.LineWidth) {
                 this.lineWidth = data.Properties.LineWidth
@@ -90,7 +124,7 @@ export class SZoneLegendItem extends SPolygonItem {
             //    if( data.Properties.LineDash){
             //     this.LineDash =this._legend.Properties.LineDash
             //    }
-
+            console.log(this);
         }
     }
     toData(): any {