zhangyu 4 anni fa
parent
commit
0dae051ad4

+ 4 - 0
src/components/baseEditer.vue

@@ -638,6 +638,10 @@ export default {
       bus.$on("toggleItem", item => {
         this.scene.toggleItem(item);
       });
+      // 
+      bus.$on('itemAngle', ang => {
+        this.scene.updateItemAng(ang);
+      })
     },
     // 读取数据
     readGroup() {

+ 18 - 3
src/components/edit/right_toolbar.vue

@@ -57,10 +57,10 @@ const msgList = [
     unit: "y"
   },
   {
-    msg: "0°",
+    msg: "0",
     disable: true,
-    name: "",
-    unit: ""
+    name: "Angle",
+    unit: "°"
   },
   {
     msg: "",
@@ -173,6 +173,10 @@ export default {
           }
         });
         bus.$emit("itemPositon", x, y);
+      } else if (item.name == 'Angle') {
+        if (item.msg.length > 0 && !isNaN(Number(item.msg))) {
+          bus.$emit('itemAngle', item.msg)
+        }
       }
     },
     // 点击选中元素
@@ -197,6 +201,9 @@ export default {
           if (item.name == "Height") {
             item.msg = 0;
           }
+          if (item.name == 'Angle') {
+            item.msg = '0'
+          }
         });
         this.aspectRatio = 1;
       } else {
@@ -246,6 +253,14 @@ export default {
             }
             inputH = item.msg;
           }
+          if (item.name == "Angle") {
+            if (Item instanceof SImageLegendItem) {
+              item.disable = false
+            } else {
+              item.disable = true
+            }
+            item.msg = Item.img.rotate
+          }
         });
         this.aspectRatio = inputW / inputH;
       }

+ 17 - 0
src/components/mapClass/EditScence.ts

@@ -1851,4 +1851,21 @@ export class EditScence extends SGraphScene {
         this.selectContainer.clear()
         this.selectContainer.toggleItem(item)
     }
+
+    /**
+     * 图标旋转更新角度
+     * 
+     * @param   ang 旋转角度
+    */
+    updateItemAng(ang: number) :void{
+        if (this.focusItem) {
+            if (this.focusItem instanceof SImageLegendItem) {
+                const oldMsg = this.focusItem.img.rotate;
+                const newMsg = ang;
+                this.focusItem.img.rotate = ang;
+                this.undoStack.push(new SGraphPropertyCommand(this, this.focusItem.img, "rotate", oldMsg, newMsg));
+                this.scenceUpdate(this);
+            }
+        }
+    }
 }

+ 4 - 0
src/lib/items/SImageLegendItem.ts

@@ -101,6 +101,9 @@ export class SImageLegendItem extends SIconTextItem {
         if (data.Properties.ImgPos) {
             this.img.moveTo(data.Properties.ImgPos.X, data.Properties.ImgPos.Y);
         }
+        if (data.Properties && data.Properties.ImgRotate) {
+            this.img.rotate = data.Properties.ImgRotate;
+        }
         if (data.Properties && data.Properties.font) {
             this.font = new SFont("sans-serif", data.Properties.font);
         }
@@ -144,6 +147,7 @@ export class SImageLegendItem extends SIconTextItem {
         this.data.Properties.Url = this.img.url;
         this.data.Properties.TextPos = { X: this.textItem.x, Y: this.textItem.y };
         this.data.Properties.ImgPos = { X: this.img.x, Y: this.img.y };
+        this.data.Properties.ImgRotate = this.img.rotate;
         this.data.Properties.Size = {
             Width: this.sWidth,
             Height: this.sHeight