xushiting 1 년 전
부모
커밋
535c3671e5

+ 6 - 14
src/view/case/draw/board/editCAD/Geometry/CustomImage.js

@@ -21,22 +21,14 @@ export default class CustomImage extends Geometry {
     }
 
     isContain(position) {
-        // 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 {
-        //     return null
-        // }
-        // this.context.arc(pt.x-geometry.ratio * geometry.width/4*geometry.scale, pt.y-geometry.ratio * geometry.height/4*geometry.scale, 2 * coordinate.ratio, 0, Math.PI * 2, true)
-    
         let p0 = {
-            x:this.center.x - this.ratio*this.width/2/coordinate.res*this.scale,
-            y:this.center.y + this.ratio*this.height/2/coordinate.res*this.scale
+            x:this.center.x - this.ratio*this.width/coordinate.res*this.scale,
+            y:this.center.y + this.ratio*this.height/coordinate.res*this.scale
         }
 
         let p1 = {
             x:this.center.x,
-            y:this.center.y + this.ratio*this.height/2/coordinate.res*this.scale
+            y:this.center.y + this.ratio*this.height/coordinate.res*this.scale
         }
 
         let p2 = {
@@ -45,12 +37,12 @@ export default class CustomImage extends Geometry {
         }
 
         let p3 = {
-            x:this.center.x- this.ratio*this.width/2/coordinate.res*this.scale,
+            x:this.center.x- this.ratio*this.width/coordinate.res*this.scale,
             y:this.center.y
         }
         let center = {
-            x:this.center.x - this.ratio*this.width/4/coordinate.res*this.scale,
-            y:this.center.y + this.ratio*this.height/4/coordinate.res*this.scale
+            x:this.center.x - this.ratio*this.width/2/coordinate.res*this.scale,
+            y:this.center.y + this.ratio*this.height/2/coordinate.res*this.scale
         }
 
         p0 = this.rotatePoint(p0, center, this.angle)

+ 7 - 16
src/view/case/draw/board/editCAD/Renderer/Draw.js

@@ -879,20 +879,14 @@ export default class Draw {
 
     drawCustomImage(geometry){
         if(geometry.url != null){
-            // const focusItem = stateService.getFocusItem();
-            // if (focusItem && focusItem.type == VectorType.CustomImage) {
-            //     if (geometry.vectorId == focusItem.vectorId) {
-                
-            //     }
-            // }
             const pt = coordinate.getScreenXY(geometry.center)
             this.context.save()
 
             this.context.translate(pt.x, pt.y)
             this.context.scale(geometry.scale,geometry.scale)
-            this.context.translate(-1*geometry.ratio*geometry.width/4, -1*geometry.ratio*geometry.height/4)
+            this.context.translate(-1*geometry.ratio*geometry.width/2, -1*geometry.ratio*geometry.height/2)
             this.context.rotate((geometry.angle / 180) * Math.PI)
-            this.context.translate(geometry.ratio*geometry.width/4, geometry.ratio*geometry.height/4)
+            this.context.translate(geometry.ratio*geometry.width/2, geometry.ratio*geometry.height/2)
             
 
             if(geometry.image == null)
@@ -901,19 +895,16 @@ export default class Draw {
                 img.src = geometry.url;
                 img.crossOrigin=""
                 img.onload = function () {
-                    //this.context.drawImage(img, pt.x-img.width/2, pt.y-img.height/2, img.width, img.height)
-                    this.context.drawImage(img, -img.width / 2*coordinate.ratio, -img.height / 2*coordinate.ratio)
+                    this.context.drawImage(img, -img.width*coordinate.ratio, -img.height*coordinate.ratio)
                 }.bind(this)
                 geometry.image = img;
             }
             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.ratio * geometry.width / 2*coordinate.ratio, -geometry.ratio * geometry.height / 2*coordinate.ratio,geometry.ratio * geometry.width / 2*coordinate.ratio, geometry.ratio * geometry.height / 2*coordinate.ratio)
+                    this.context.drawImage(geometry.image, -geometry.ratio * geometry.width*coordinate.ratio, -geometry.ratio * geometry.height*coordinate.ratio,geometry.ratio * geometry.width*coordinate.ratio, geometry.ratio * geometry.height*coordinate.ratio)
                 }
                 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.ratio * geometry.width / 2*coordinate.ratio, -geometry.ratio * geometry.height / 2*coordinate.ratio,geometry.ratio * geometry.width / 2*coordinate.ratio, geometry.ratio * geometry.height / 2*coordinate.ratio)
+                    this.context.drawImage(geometry.image, -geometry.ratio * geometry.width*coordinate.ratio, -geometry.ratio * geometry.height*coordinate.ratio,geometry.ratio * geometry.width*coordinate.ratio, geometry.ratio * geometry.height*coordinate.ratio)
                 }
                 
             }
@@ -924,7 +915,7 @@ export default class Draw {
                     this.context.lineWidth = 2/geometry.scale;
                     this.context.strokeStyle = Style.Select.Tag.strokeStyle
                     this.context.fillStyle = Style.Select.Tag.fillStyle
-                    this.context.strokeRect( -geometry.ratio * geometry.width/2, -geometry.ratio * geometry.height/2, geometry.ratio * geometry.width/2, geometry.ratio * geometry.height/2)
+                    this.context.strokeRect( -geometry.ratio * geometry.width, -geometry.ratio * geometry.height, geometry.ratio * geometry.width, geometry.ratio * geometry.height)
                 }
             }
             else if (selectItem && selectItem.type == VectorType.CustomImage) {
@@ -932,7 +923,7 @@ export default class Draw {
                     this.context.lineWidth = 2/geometry.scale;
                     this.context.strokeStyle = Style.Select.Tag.strokeStyle
                     this.context.fillStyle = Style.Select.Tag.fillStyle
-                    this.context.strokeRect( -geometry.ratio * geometry.width/2, -geometry.ratio * geometry.height/2, geometry.ratio * geometry.width/2, geometry.ratio * geometry.height/2)
+                    this.context.strokeRect( -geometry.ratio * geometry.width, -geometry.ratio * geometry.height, geometry.ratio * geometry.width, geometry.ratio * geometry.height)
                 }
             }
 

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

@@ -6,7 +6,7 @@ import Constant from '../Constant'
 
 export default class CustomImageService {
     constructor() {
-        this.defaultPix = 60;  //默认是30像素
+        this.defaultPix = 60;  
         this.url = null;
     }