xushiting 1 rok temu
rodzic
commit
6514ab332b

+ 110 - 69
src/view/case/draw/board/editCAD/Controls/UIControl.js

@@ -133,8 +133,6 @@ export default class UIControl {
             else{
                 floorplanService.updateTitle(value);
             }
-
-            text
         }
         else if(type == VectorType.BgImage){
             await floorplanService.updateBgImage(value);
@@ -142,93 +140,136 @@ export default class UIControl {
         else if(type == VectorType.Compass){
             floorplanService.updateCompass(value);
         }
+        else if(type == VectorType.CustomImage){
+          const customImage = floorplanService.getCustomImage(item.vectorId)
+          if(value.hasOwnProperty('rotate')){
+            customImage.setAngle(value.rotate)
+          }
+          else if(value.hasOwnProperty('scale')){
+            customImage.setScale(value.scale)
+          }
+        }
+        else if(signService.isSign(type)){
+          const sign = floorplanService.getSign(item.vectorId)
+          if(value.hasOwnProperty('rotate')){
+            sign.setAngle(value.rotate)
+          }
+          else if(value.hasOwnProperty('scale')){
+            sign.setScale(value.scale)
+          }
+        }
         break;
       case "upload":
         if(type == VectorType.CustomImage){
           customImageService.setCustomImageUrl(value.url);
-          customImageService.createCustomImage({
+          const customImage = await customImageService.createCustomImage({
             x:0,
             y:0
           })
           stateService.setEventName(LayerEvents.MoveCustomImage);
+          let focusItem = {
+            vectorId: customImage.vectorId,
+            type: VectorType.CustomImage,
+          };
+          stateService.setFocusItem(focusItem);
+          this.showAttributes(focusItem);
         }  
         break;
     }
     history.save();
-    stateService.clearFocusItem();
-    // this.bus.emit('hideAttribute')
-    // this.bus.emit('hideUI')
+    //stateService.clearFocusItem();
     this.layer.renderer.autoRedraw();
   }
 
   showAttributes(item) {
     let type = item.type;
     let value = null;
-    switch (item.type) {
-      case VectorType.Tag:
-        const tag = floorplanService.getTag(item.vectorId);
-        if (!tag) {
-          return;
-        }
-        value = {
-            version:'2.0',
-            text:tag.value,
-            color: tag.color,
-            fontSize: tag.fontSize,
-        };
-        break;
-      case VectorType.Table:
-        const table = floorplanService.getTable(item.vectorId);
-        if (!table) {
-          return;
-        }
-        const cellIds = table.cells;
-        let content = [];
-        for (let i = 0; i < cellIds.length; ++i) {
-          for (let j = 0; j < cellIds[i].length; ++j) {
-            const cell = floorplanService.getCell(cellIds[i][j]);
-            content.push({
-              width: cell.width,
-              height: cell.height,
-              value: cell.value,
-              colIndex: cell.colIndex,
-              rowIndex: cell.rowIndex,
-            });
+
+    if(signService.isSign(type)){
+      const sign = floorplanService.getSign(item.vectorId);
+      if (!sign) {
+        return;
+      }
+      value = {
+          version:'2.0',
+          type: type,
+          rotate:sign.angle,
+          scale:sign.scale
+      };
+    }
+    else{
+      switch (item.type) {
+        case VectorType.Tag:
+          const tag = floorplanService.getTag(item.vectorId);
+          if (!tag) {
+            return;
           }
-        }
-        value = {
-            version:'2.0',
-            content: content,
-        };
-        break;
-      case VectorType.Title:
-        const title = floorplanService.getTitle();
-        if (!title) {
-          return;
-        }
-        value = {
-            version:'2.0',
-            text: title.value,
-        };
-        break;
-      case VectorType.Compass:
-        const compass = floorplanService.getCompass();
-        if (!compass) {
-          return;
-        }
-        value = compass.angle;
-        break;
-      // case VectorType.CustomImage:
-      //   const customImage = floorplanService.getCustomImage(item.vectorId);
-      //   if (!customImage) {
-      //     return;
-      //   }
-      //   value = {
-      //       version:'2.0',
-      //       url: customImage.url,
-      //   };
-      //   break;
+          value = {
+              version:'2.0',
+              type: type,
+              text:tag.value,
+              color: tag.color,
+              fontSize: tag.fontSize,
+          };
+          break;
+        case VectorType.Table:
+          const table = floorplanService.getTable(item.vectorId);
+          if (!table) {
+            return;
+          }
+          const cellIds = table.cells;
+          let content = [];
+          for (let i = 0; i < cellIds.length; ++i) {
+            for (let j = 0; j < cellIds[i].length; ++j) {
+              const cell = floorplanService.getCell(cellIds[i][j]);
+              content.push({
+                width: cell.width,
+                height: cell.height,
+                value: cell.value,
+                colIndex: cell.colIndex,
+                rowIndex: cell.rowIndex,
+              });
+            }
+          }
+          value = {
+              version:'2.0',
+              type: type,
+              content: content,
+          };
+          break;
+        case VectorType.Title:
+          const title = floorplanService.getTitle();
+          if (!title) {
+            return;
+          }
+          value = {
+              version:'2.0',
+              type: type,
+              text: title.value,
+          };
+          break;
+        case VectorType.Compass:
+          const compass = floorplanService.getCompass();
+          if (!compass) {
+            return;
+          }
+          value = compass.angle;
+          break;
+        case VectorType.CustomImage:
+          const customImage = floorplanService.getCustomImage(item.vectorId);
+          if (!customImage) {
+            return;
+          }
+          value = {
+              version:'2.0',
+              type: type,
+              url: customImage.url,
+              rotate:customImage.angle,
+              scale:customImage.scale
+          };
+      }
     }
+    
     this.bus.emit("showAttribute", {
       type: type,
       value: value,

+ 9 - 1
src/view/case/draw/board/editCAD/Geometry/CustomImage.js

@@ -13,7 +13,7 @@ export default class CustomImage extends Geometry {
         this.width = 40;
         this.height = 30;
         this.angle = 0 //逆时针为负,顺时针为正。单位是:°
-        //this.scale = 1 //缩放比例
+        this.scale = 1 //缩放比例
         this.geoType = VectorType.CustomImage
         this.setId(vectorId)
     }
@@ -34,4 +34,12 @@ export default class CustomImage extends Geometry {
     setUrl(url){
         this.url = url;
     }
+
+    setAngle(angle){
+        this.angle = angle;
+    }
+
+    setScale(scale){
+        this.scale = scale;
+    }
 }

+ 8 - 0
src/view/case/draw/board/editCAD/Geometry/Sign.js

@@ -46,4 +46,12 @@ export default class Sign extends Geometry {
         // }
         return 0.2;
     }
+
+    setAngle(angle){
+        this.angle = angle;
+    }
+
+    setScale(scale){
+        this.scale = scale;
+    }
 }

+ 4 - 9
src/view/case/draw/board/editCAD/Layer.js

@@ -816,30 +816,25 @@ export default class Layer {
       case LayerEvents.AddSign:
         needAutoRedraw = true;
         this.uiControl.clearUI();
+        this.uiControl.showAttributes(focusItem);
         history.save();
         break;
       case LayerEvents.MoveSign:
-        needAutoRedraw = true;
         if (focusItem != null && signService.isSign(focusItem.type)) {
-          this.uiControl.selectUI = focusItem.type;
-          history.save();
+          //history.save();
+          this.uiControl.showAttributes(focusItem);
         } else {
+          needAutoRedraw = true;
           history.save();
         }
         break;
       case LayerEvents.MoveCustomImage:
         if (focusItem == null) {
-          needAutoRedraw = true;
           history.save();
         } else {
           this.uiControl.showAttributes(focusItem);
         }
         break;
-      case LayerEvents.AddCustomImage:
-        needAutoRedraw = true;
-        this.uiControl.showAttributes(focusItem);
-        history.save();
-        break;
     }
     this.lastX = null;
     this.lastY = null;

Plik diff jest za duży
+ 1842 - 3112
src/view/case/draw/board/editCAD/Renderer/Draw.js