xushiting 2 anni fa
parent
commit
6eb7ddf1b2

+ 2 - 1
src/views/draw-file/board/editCAD/Constant.js

@@ -8,8 +8,9 @@ const Constant = {
     minScreenDis: 2, //layer.js里,判断是否拖拽了,目前暂时不用
     minRealDis: 0.1,
     minAdsorb: 0.1,
-    minAngle: 15,
+    minAngle: 5,
     maxAngle: 175,
+    minMovePix:4,    //至少鼠标移动了4个像素才叫移动
     defaultZoom: 100,
     ratio: 3, //1,
 }

+ 5 - 12
src/views/draw-file/board/editCAD/Controls/UIControl.js

@@ -163,13 +163,6 @@ export default class UIControl {
         }
     }
 
-    saveAttributes(type, name) {
-        if (name == 'compass' || (type == 'compass' && name == 'default')) {
-            return
-        }
-        this.layer.history.save()
-    }
-
     showAttributes(type) {
         let item = stateService.getFocusItem()
         if (item == null) {
@@ -177,11 +170,11 @@ export default class UIControl {
         }
         if (item.type == VectorType.Tag) {
             let tag = floorplanService.getTag(item.vectorId)
-            this.layer.$xui.currentAttributes = {
-                name: item.type,
-                tag: tag.title,
-                area: tag.des,
-            }
+                                            this.layer.$xui.currentAttributes = {
+                                                name: item.type,
+                                                tag: tag.title,
+                                                area: tag.des,
+                                            }
         } else if (item.type == VectorType.Wall) {
             let wall = floorplanService.getWall(item.vectorId)
             this.layer.$xui.currentAttributes = {

+ 0 - 1
src/views/draw-file/board/editCAD/Coordinate.js

@@ -9,7 +9,6 @@ import Constant from './Constant'
 
 export default class Coordinate {
     constructor() {
-        this.defaultCenter = null
         this.center = {
             x:0,
             y:0

+ 16 - 15
src/views/draw-file/board/editCAD/Layer.js

@@ -20,7 +20,7 @@ import UIEvents from './enum/UIEvents.js'
 import SelectState from './enum/SelectState.js'
 import Constant from './Constant'
 import VectorType from './enum/VectorType'
-import { mathUtil } from './MathUtil'
+import MathUtil, { mathUtil } from './MathUtil'
 import { wallService } from './Service/WallService'
 import History from './History/History'
 import { signService } from './Service/SignService'
@@ -104,7 +104,7 @@ export default class Layer {
             const selectItem = stateService.getSelectItem()
             if (eventName == null && selectItem) {
                 stateService.setDraggingItem(selectItem)
-                stateService.setFocusItem(selectItem)
+                //stateService.setFocusItem(selectItem)
                 this.uiControl.showAttributes()
                 this.uiControl.currentUI = selectItem.type
             } else if (eventName == null) {
@@ -302,10 +302,6 @@ export default class Layer {
     }
 
     onMouseUp(e) {
-        if (coordinate.defaultCenter == null) {
-            return
-        }
-
         const X = e.offsetX || e.layerX
         const Y = e.offsetY || e.layerY
 
@@ -314,13 +310,21 @@ export default class Layer {
         let focusItem = null
      
         if (draggingItem && draggingItem.vectorId) {
-            focusItem = {
-                vectorId: draggingItem.vectorId,
-                type: draggingItem.type,
-                cursor: { x: this.lastX, y: this.lastY },
+            if(mathUtil.getDistance({
+                x:this.startX,
+                y:this.startY
+            }, {
+                x:X,
+                y:Y
+            })<Constant.minMovePix){
+                focusItem = {
+                    vectorId: draggingItem.vectorId,
+                    type: draggingItem.type,
+                    cursor: { x: this.lastX, y: this.lastY },
+                }
+                stateService.setFocusItem(focusItem)
+                this.uiControl.showAttributes()
             }
-            stateService.setFocusItem(focusItem)
-            this.uiControl.showAttributes()
         }
 
         let position = coordinate.getXYFromScreen({
@@ -432,9 +436,6 @@ export default class Layer {
     }
 
     onWheel(e) {
-        if (coordinate.defaultCenter == null) {
-            return
-        }
         e.preventDefault()
         const type = e.type
         if (type == 'DOMMouseScroll' || type == 'mousewheel') {

+ 2 - 2
src/views/draw-file/board/editCAD/Service/ElementService.js

@@ -200,9 +200,9 @@ export class ElementService {
         let newPosition = null
         for (let i = 0; i < points.length; ++i) {
             let angle = mathUtil.Angle(point, position, points[i])
-            if (Math.abs((angle / Math.PI) * 180 - 90) < 5) {
+            if (Math.abs((angle / Math.PI) * 180 - 90) < Constant.minAngle/2) {
                 newPosition = ajust(position, point, points[i], 1)
-            } else if (Math.abs((angle / Math.PI) * 180) < 5 || Math.abs((angle / Math.PI) * 180 - 180) < 5) {
+            } else if (Math.abs((angle / Math.PI) * 180) < Constant.minAngle/2 || Math.abs((angle / Math.PI) * 180 - 180) < Constant.minAngle/2) {
                 newPosition = ajust(position, point, points[i], 2)
             }
             if (newPosition != null) {