Ver código fonte

feat:新增图片item

YaolongHan 4 anos atrás
pai
commit
d04238ae4a

+ 22 - 17
src/components/mapClass/SPolygonItem.ts

@@ -455,12 +455,16 @@ export class SPolygonItem extends SGraphItem {
                 // 当顶点大于二个时才又条件执行闭合操作并清空堆栈
                 if (this.pointList.length > 2) {
                     this._status = SRelationState.Normal;
+                    //1 grabItem 置为null
                     if (this.scene) {
                         this.scene.grabItem = null;
                     }
+                    //2 清空undo
                     if (this.undoStack) {
                         this.undoStack.clear();
                     }
+                    //3 传递完成事件状态
+                    this.$emit('finishItemCreated')
                 }
             }
         } else if (this._status == SRelationState.Edit) {
@@ -468,7 +472,7 @@ export class SPolygonItem extends SGraphItem {
                 this.isAlt = true;
             }
         }
-        this.update()
+        this.update();
         return true;
     } // Function onKeyDown()
 
@@ -588,6 +592,23 @@ export class SPolygonItem extends SGraphItem {
     } // Function onResize()
 
     /**
+     * 取消操作
+     *
+     * @param   painter       painter对象
+     */
+    cancelOperate(): void {
+        // 当状态为展示状态
+        if (this._status == SRelationState.Create) {
+            // 闭合多边形
+            this.parent = null
+        } else if (this._status == SRelationState.Edit) {
+            // 编辑状态
+            this._status = SRelationState.Normal
+        }
+        this.update()
+    } // Function cancelOperate()
+
+    /**
      * Item对象边界区域
      *
      * @return SRect
@@ -621,21 +642,5 @@ export class SPolygonItem extends SGraphItem {
         }
     } // Function onDraw()
 
-    /**
-     * 取消操作
-     *
-     * @param   painter       painter对象
-     */
-    cancelOperate(): void {
-        // 当状态为展示状态
-        if (this._status == SRelationState.Create) {
-            // 闭合多边形
-            this.parent = null
-        } else if (this._status == SRelationState.Edit) {
-            // 编辑状态
-            this._status = SRelationState.Normal
-        }
-    } // Function cancelOperate()
-
 
 }

+ 18 - 11
src/components/mapClass/editScence.ts

@@ -1,5 +1,5 @@
 import { SMouseEvent, SUndoStack } from "@saga-web/base";
-import { SGraphScene,SGraphyItem } from '@saga-web/graph/lib';
+import { SGraphScene, SGraphyItem } from '@saga-web/graph/lib';
 import { SPoint } from '@saga-web/draw/lib';
 import { SFloorParser, SImageItem, STextItem, SLineItem, SPolylineItem } from "@saga-web/big";
 import { SGraphItem, SGraphPointListInsert, SGraphPointListDelete, SGraphPointListUpdate, SGraphAddCommand } from "@saga-web/graph/lib";
@@ -24,18 +24,17 @@ export class EditScence extends SGraphScene {
     set setCmd(cmd: number) {
         if (cmd == 0) {
             this.grabItem = null;
-            this.focusItem = null;
         }
         this.cmd = cmd;
-        if(this.focusItem){
+        if (this.focusItem) {
             // 取消操作
             this.focusItem.cancelOperate();
             this.focusItem = null;
-
         }
+        this.view.update();
     };
     /** 当前选中焦点Item */
-    focusItem:SGraphyItem:null = null;
+    focusItem: SGraphyItem: null = null;
 
     constructor() {
         super();
@@ -77,20 +76,28 @@ export class EditScence extends SGraphScene {
         Polylines.setPointList = [point];
         this.addItem(Polylines);
         this.grabItem = Polylines;
-        this.focusItem = Polylines
+        this.focusItem = Polylines;
     }
 
     /**
-     * 增加textItem
+     * 增加图片Item
      */
-    addImgItem() {
+    addImgItem(event: SMouseEvent) {
+        const url = require('./../../assets/logo.png')
+        const item = new SImageItem(null);
+        item.url = url;
+        item.moveTo(event.x, event.y);
+        this.addItem(item);
+        this.grabItem == null;
+        this.focusItem = item;
+        this.cmd = 0;
     }
 
     /**
      * 增加管道
      */
     addTextItem(event: SMouseEvent): void {
-        const item =  new STextItem(null, '请在右侧属性栏输入文字!');
+        const item = new STextItem(null, '请在右侧属性栏输入文字!');
         item.moveTo(event.x, event.y);
         this.addItem(item);
         this.grabItem == null
@@ -141,7 +148,6 @@ export class EditScence extends SGraphScene {
      */
     redo(): void {
         this.undoStack.undo();
-
     }
 
     /**
@@ -165,7 +171,8 @@ export class EditScence extends SGraphScene {
                 this.addTextItem(event);
                 break;
             case 3:
-                this.addPolygonItem(event);
+                this.addImgItem(event)
+                // this.addPolygonItem(event);
                 break;
             default:
                 return super.onMouseDown(event);

+ 0 - 1
src/lib/FloorScene.ts

@@ -8,7 +8,6 @@ export class FloorScene extends SGraphScene {
 
   constructor(){
     super();
-    console.log(999999999)
     this.selectContainer.connect('listChange',this,this.listChange)
   }