xushiting 1 rok pred
rodič
commit
6357b9a8d9

+ 4 - 0
src/view/case/draw/board/editCAD/Controls/UIControl.js

@@ -153,6 +153,9 @@ export default class UIControl {
           else if(value.hasOwnProperty('scale')){
             customImage.setScale(value.scale)
           }
+          else if(value.hasOwnProperty('ratio')){
+            customImage.setRatio(floor.customImages[key].ratio)
+          }
         }
         else if(signService.isSign(type)){
           const sign = floorplanService.getSign(item.vectorId)
@@ -270,6 +273,7 @@ export default class UIControl {
               type: type,
               url: customImage.url,
               rotate:customImage.angle,
+              ratio:customImage.ratio,
               scale:customImage.scale
           };
           break;

+ 11 - 4
src/view/case/draw/board/editCAD/Geometry/Compass.js

@@ -24,13 +24,20 @@ export default class Compass extends Geometry {
         this.angle = angle
     }
 
+    //center是左上角,宽是56,高是36
     isContain(position) {
         const point = coordinate.getScreenXY(position)
-        const dis = mathUtil.getDistance(this.center,point)
-        if(dis < this.radius){
+        // const dis = mathUtil.getDistance(this.center,point)
+        // if(dis < this.radius){
+        //     return true
+        // }
+        // else{
+        //     return false;
+        // }
+        //console.log('xy:'+(point.x - this.center.x)+','+(point.y - this.center.y))
+        if(point.x - this.center.x > -5 && point.x - this.center.x < 40 && point.y - this.center.y > -5 && point.y - this.center.y < 60){
             return true
-        }
-        else{
+        }else{
             return false;
         }
     }

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

@@ -14,12 +14,13 @@ export default class CustomImage extends Geometry {
         this.height = 30;
         this.angle = 0 //逆时针为负,顺时针为正。单位是:°
         this.scale = 1 //缩放比例
+        this.ratio = 1;
         this.geoType = VectorType.CustomImage
         this.setId(vectorId)
     }
 
     isContain(position) {
-        if(Math.abs(position.x - this.center.x)* coordinate.res * coordinate.zoom/ 100 <this.width/2 && Math.abs(position.y - this.center.y)* coordinate.res * coordinate.zoom/ 100<this.height/2)
+        if(Math.abs(position.x - this.center.x)* coordinate.res * coordinate.zoom/ 100 <this.ratio*this.width/2 && Math.abs(position.y - this.center.y)* coordinate.res * coordinate.zoom/ 100<this.ratio*this.height/2)
         {
             return SelectState.Select
         } else {
@@ -42,4 +43,9 @@ export default class CustomImage extends Geometry {
     setScale(scale){
         this.scale = scale;
     }
+
+    setRatio(ratio){
+        this.ratio = ratio;
+    }
+    
 }

+ 2 - 1
src/view/case/draw/board/editCAD/History/HistoryUtil.js

@@ -146,7 +146,7 @@ export default class HistoryUtil {
     }
 
     isDifferentForCustomImages(customImage1, customImage2) {
-        if (customImage1.angle == customImage2.angle && customImage1.scale == customImage2.scale && customImage1.url == customImage2.url) {
+        if (customImage1.angle == customImage2.angle && customImage1.scale == customImage2.scale && customImage1.url == customImage2.url&& customImage1.ratio == customImage2.ratio) {
             return false
         } else {
             return true
@@ -436,6 +436,7 @@ export default class HistoryUtil {
         data.angle = customImage.angle
         data.scale = customImage.scale
         data.url = customImage.url
+        data.ratio = customImage.ratio
         return data
     }
 }

+ 0 - 18
src/view/case/draw/board/editCAD/Layer.js

@@ -518,24 +518,6 @@ export default class Layer {
           mathUtil.clonePoint(sign.center, position);
         }
         break;
-      // case LayerEvents.AddCustomImage:
-      //   needAutoRedraw = true;
-      //   if (draggingItem == null) {
-      //     const customImage = customImageService.createCustomImage(position)
-      //     if (customImage.vectorId) {
-      //       stateService.setSelectItem(
-      //         customImage.vectorId,
-      //         VectorType.CustomImage,
-      //         SelectState.All
-      //       );
-      //       stateService.setDraggingItem(stateService.selectItem);
-      //     }
-      //   } else {
-      //     moveCustomImage.moveFullCustomImage(dx, dy, draggingItem.vectorId);
-      //   }
-      //   this.lastX = X;
-      //   this.lastY = Y;
-      //   break;
       case LayerEvents.MoveCustomImage:
         needAutoRedraw = true;
         if (draggingItem != null) {

+ 1 - 0
src/view/case/draw/board/editCAD/Load.js

@@ -62,6 +62,7 @@ export default class Load {
                 customImage.setUrl(floor.customImages[key].url)
                 customImage.setAngle(floor.customImages[key].angle)
                 customImage.setScale(floor.customImages[key].scale)
+                customImage.setRatio(floor.customImages[key].ratio)
             }
 
             for (let key in floor.tables) {

+ 2 - 6
src/view/case/draw/board/editCAD/Renderer/Draw.js

@@ -240,8 +240,6 @@ export default class Draw {
         const fontWidth1 = geometry.sideWidth
         //let dy = (points[3].y - points[0].y)/fontInfo.textValues.length/2
         let dy = geometry.sideThickness/fontInfo.height/2
-        console.log('dy:'+dy)
-        console.log('(points[3].y - points[0].y):'+(points[3].y - points[0].y));
         for(let i=0;i<fontInfo.textValues.length;++i){
             // const line1 = mathUtil.createLine1({ x: (points[0].x + points[3].x) / 2, y: (points[0].y + points[3].y) / 2 }, { x: (points[2].x + points[1].x) / 2, y: (points[2].y + points[1].y) / 2 })
             // const fontStart1 = mathUtil.getDisPointsLine(line1, pt, fontWidth1 / 2, fontWidth1 / 2)
@@ -254,7 +252,6 @@ export default class Draw {
             //let count = (2*(i-(fontInfo.textValues.length-1))+1)
             let count = 1 * (fontInfo.textValues.length-i)
             count = 2* count  - fontInfo.textValues.length
-            console.log('count:'+count)
             this.context.fillText(fontInfo.textValues[i], pt.x - fontWidth1/2, pt.y + dy*count)
         }
 
@@ -911,11 +908,11 @@ export default class Draw {
             else{
                 if(geometry.hasOwnProperty('width')){
                     //this.context.drawImage(geometry.image, pt.x-geometry.width/2, pt.y-geometry.height/2, geometry.width, geometry.height)
-                    this.context.drawImage(geometry.image, -geometry.width / 2, -geometry.height / 2)
+                    this.context.drawImage(geometry.image, -geometry.ratio * geometry.width / 2, -geometry.ratio * geometry.height / 2,geometry.ratio * geometry.width / 2, geometry.ratio * geometry.height / 2)
                 }
                 else{
                     //this.context.drawImage(geometry.image, pt.x-geometry.width/2, pt.y-geometry.height/2, geometry.image.width, geometry.image.height)
-                    this.context.drawImage(geometry.image, -geometry.width / 2, -geometry.height / 2)
+                    this.context.drawImage(geometry.image, -geometry.ratio * geometry.width / 2, -geometry.ratio * geometry.height / 2,geometry.ratio * geometry.width / 2, geometry.ratio * geometry.height / 2)
                 }
                 
             }
@@ -1035,7 +1032,6 @@ export default class Draw {
         this.context.closePath();
         this.context.fill();
         this.context.stroke();
-        
         this.context.restore();
     }
 

+ 3 - 0
src/view/case/draw/board/editCAD/Service/CustomImageService.js

@@ -6,6 +6,7 @@ import Constant from '../Constant'
 
 export default class CustomImageService {
     constructor() {
+        this.defaultPix = 30;  //默认是30像素
         this.url = null;
     }
 
@@ -20,6 +21,8 @@ export default class CustomImageService {
             customImage.setImageData(imageData)
             customImage.width = imageData.width;
             customImage.height = imageData.height;
+            let maxPix = Math.max(imageData.width,imageData.height)
+            customImage.ratio = this.defaultPix/maxPix
         }
 
         floorplanService.addCustomImage(customImage)