xushiting 2 years ago
parent
commit
6bb6be85e6

+ 0 - 26
src/views/draw-file/board/editCAD/Controls/UIControl.js

@@ -20,32 +20,6 @@ export default class UIControl {
         this.selectUI = null;
     }
 
-    /**
-     * 获取选中要添加的UI
-     */
-    get selectUI() {
-
-    }
-
-    /**
-     * 设置选中要添加的UI
-     */
-    set selectUI(value) {
-        this.updateEventNameForSelectUI()
-    }
-
-    /**
-     * 获取当前楼层Id
-     */
-    get currentFloor() {
-    }
-
-    /**
-     * 设置当前楼层Id
-     */
-    set currentFloor(value) {
-    }
-
     //点击左侧栏后,更新事件
     updateEventNameForSelectUI() {
         elementService.hideAll()

+ 33 - 9
src/views/draw-file/board/editCAD/Geometry/Circle.js

@@ -1,26 +1,50 @@
 import VectorType from '../enum/VectorType.js'
 import Geometry from './Geometry.js'
+import SelectState from '../enum/SelectState.js'
 
 export default class Circle extends Geometry {
     constructor(position,radius, vectorId, floor) {
         super()
-        this.position = position
+        this.center = position
         this.radius = radius
+        this.points = [];              //顺时针
         this.floor = floor?floor:0
         this.geoType = VectorType.Circle
         this.setId(vectorId)
     }
 
-    isContain(position){
-        const dis = mathUtil.getDistance(position, this.position)
-        if(Math.abs(this.radius - dis)<Constant.minAdsorb){
-            return 'side'
+    setPoints(){
+        this.points[0] = {
+            x:this.center - this.radius/2,
+            y:this.center + this.radius/2
+        }
+        this.points[1] = {
+            x:this.center + this.radius/2,
+            y:this.center + this.radius/2
         }
-        else if((dis-this.radius)>Constant.minAdsorb){
-            return null;
+        this.points[2] = {
+            x:this.center + this.radius/2,
+            y:this.center - this.radius/2
         }
-        else if((this.radius - dis)>Constant.minAdsorb){
-            return 'all'
+        this.points[3] = {
+            x:this.center - this.radius/2,
+            y:this.center - this.radius/2
         }
     }
+
+    isContain(position){
+        for(let i=0;i<this.points.length;++i){
+            const dis = mathUtil.getDistance(position, this.points[i])
+            if(dis < Constant.minAdsorb){
+                return SelectState.Scale
+            }
+        }
+
+        const dis = mathUtil.getDistance(position, this.center)
+        if(Math.abs(this.radius - dis)<Constant.minAdsorb){
+            return SelectState.All
+        }
+
+        return null;
+    }
 }

+ 3 - 1
src/views/draw-file/board/editCAD/Geometry/Rectangle.js

@@ -2,6 +2,7 @@ import VectorType from '../enum/VectorType.js'
 import Geometry from './Geometry.js'
 import Constant from '../Constant.js'
 import { mathUtil } from '../MathUtil.js'
+import SelectState from '../enum/SelectState.js'
 
 export default class Rectangle extends Geometry {
     constructor(position, vectorId, floor) {
@@ -9,6 +10,7 @@ export default class Rectangle extends Geometry {
         this.position = position          //中心点
         this.points = []
         this.floor = floor?floor:0
+        this.angle = 0;
         this.geoType = VectorType.Rectangle
         this.setId(vectorId)
     }
@@ -39,7 +41,7 @@ export default class Rectangle extends Geometry {
 
         let flag = mathUtil.isPointInPoly(position, this.points)
         if(flag){
-            return 'all'
+            return SelectState.All
         }
         return null;
     }

+ 2 - 0
src/views/draw-file/board/editCAD/enum/SelectState.js

@@ -2,6 +2,8 @@ const SelectState = {
     All: 'all',
     Start: 'start',
     End: 'end',
+    Side: 'side',
+    Scale: 'scale',
     Select: 'select',
 }
 export default SelectState