فهرست منبع

Merge branch 'dev' of http://192.168.0.115:3000/bill/fuse into dev

bill 2 سال پیش
والد
کامیت
b0593dce95

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

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

+ 38 - 1
src/views/draw-file/board/editCAD/Geometry/Circle.js

@@ -1,13 +1,50 @@
 import VectorType from '../enum/VectorType.js'
 import VectorType from '../enum/VectorType.js'
 import Geometry from './Geometry.js'
 import Geometry from './Geometry.js'
+import SelectState from '../enum/SelectState.js'
 
 
 export default class Circle extends Geometry {
 export default class Circle extends Geometry {
     constructor(position,radius, vectorId, floor) {
     constructor(position,radius, vectorId, floor) {
         super()
         super()
-        this.position = position
+        this.center = position
         this.radius = radius
         this.radius = radius
+        this.points = [];              //顺时针
         this.floor = floor?floor:0
         this.floor = floor?floor:0
         this.geoType = VectorType.Circle
         this.geoType = VectorType.Circle
         this.setId(vectorId)
         this.setId(vectorId)
     }
     }
+
+    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
+        }
+        this.points[2] = {
+            x:this.center + this.radius/2,
+            y:this.center - this.radius/2
+        }
+        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;
+    }
 }
 }

+ 35 - 0
src/views/draw-file/board/editCAD/Geometry/Rectangle.js

@@ -1,5 +1,8 @@
 import VectorType from '../enum/VectorType.js'
 import VectorType from '../enum/VectorType.js'
 import Geometry from './Geometry.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 {
 export default class Rectangle extends Geometry {
     constructor(position, vectorId, floor) {
     constructor(position, vectorId, floor) {
@@ -7,7 +10,39 @@ export default class Rectangle extends Geometry {
         this.position = position          //中心点
         this.position = position          //中心点
         this.points = []
         this.points = []
         this.floor = floor?floor:0
         this.floor = floor?floor:0
+        this.angle = 0;
         this.geoType = VectorType.Rectangle
         this.geoType = VectorType.Rectangle
         this.setId(vectorId)
         this.setId(vectorId)
     }
     }
+
+    isContain(position){
+        for(let i=0;i<this.points.length;++i){
+            const dis = mathUtil.getDistance(position, this.points[i])
+            if(dis < Constant.minAdsorb){
+                return {
+                    vertex:i
+                };
+            }
+        }
+
+        for(let i=0;i<this.points.length;++i){
+            let point1 = this.points[i];
+            let point2 = this.points[i+1];
+            if(i == this.points.length-1){
+                point2 = this.points[0]
+            }
+            let flag = mathUtil.isContainForSegment(position, point1, point2)
+            if (flag) {
+                return {
+                    side:i
+                };
+            }
+        }
+
+        let flag = mathUtil.isPointInPoly(position, this.points)
+        if(flag){
+            return SelectState.All
+        }
+        return null;
+    }
 }
 }

+ 94 - 31
src/views/draw-file/board/editCAD/ListenLayer.js

@@ -18,13 +18,33 @@ export default class ListenLayer {
             state: null,
             state: null,
         }
         }
 
 
-        this.componentInfo = {
-            componentId: null,
+        this.tagInfo = {
+            tagId: null,
             state: null,
             state: null,
         }
         }
 
 
-        this.tagInfo = {
-            tagId: null,
+        this.tableInfo = {
+            tableId: null,
+            state: null,
+        }
+
+        this.rectangleInfo = {
+            rectangleId: null,
+            state: null,
+        }
+
+        this.circleInfo = {
+            circleId: null,
+            state: null,
+        }
+
+        this.arrowInfo = {
+            arrowId: null,
+            state: null,
+        }
+
+        this.iconInfo = {
+            iconId: null,
             state: null,
             state: null,
         }
         }
 
 
@@ -39,20 +59,6 @@ export default class ListenLayer {
     //开始监听,exceptPointId表示不考虑的点,exceptWallIds表示不考虑的墙
     //开始监听,exceptPointId表示不考虑的点,exceptWallIds表示不考虑的墙
     start(position, exceptPointId, exceptWallIds) {
     start(position, exceptPointId, exceptWallIds) {
         let nearest = this.getNearForVectors(position, exceptPointId, exceptWallIds)
         let nearest = this.getNearForVectors(position, exceptPointId, exceptWallIds)
-        /*
-        // getNearForWalls在一定的条件下必须执行两次!
-        // 如果吸附在墙面上,或者吸附在其余墙的顶点(x/y坐标),这时候因为抖动,可能会变成完全吸附在墙角,这时候是要再执行一次getNearForWalls
-        if (
-            nearest.modifyPoint &&
-            (nearest.modifyPoint.hasOwnProperty("linkedPointIdX") || 
-            nearest.modifyPoint.hasOwnProperty("linkedPointIdY") || 
-            nearest.modifyPoint.hasOwnProperty("linkedWallId"))
-        ) {
-            mathUtil.clonePoint(position, nearest.modifyPoint);
-            nearest = this.getNearForVectors(position, exceptPointId, exceptWallIds);
-        }
-        */
-
         if (
         if (
             nearest.modifyPoint &&
             nearest.modifyPoint &&
             (nearest.modifyPoint.hasOwnProperty('linkedPointId') ||
             (nearest.modifyPoint.hasOwnProperty('linkedPointId') ||
@@ -234,10 +240,15 @@ export default class ListenLayer {
                 _modifyPoint.linkedWallId = wallId
                 _modifyPoint.linkedWallId = wallId
             }
             }
         }
         }
+
         const result = {
         const result = {
             minPoint: min1,
             minPoint: min1,
             minWall: min2,
             minWall: min2,
-            componentInfo: {},
+            tableInfo: {},
+            rectangleInfo: {},
+            circleInfo: {},
+            arrowInfo: {},
+            iconInfo: {},
             tagInfo: {},
             tagInfo: {},
             signInfo: {},
             signInfo: {},
         }
         }
@@ -256,26 +267,78 @@ export default class ListenLayer {
             result.modifyPoint.y = modifyPoint.y
             result.modifyPoint.y = modifyPoint.y
         }
         }
 
 
-        const components = floorplanService.getComponents()
-        for (const componentId in components) {
-            const component = floorplanService.getComponent(componentId)
-            const location = component.isContain(position)
+        const tags = floorplanService.getTags()
+        for (const tagId in tags) {
+            const tag = floorplanService.getTag(tagId)
+            const location = tag.isContain(position)
+            if (location) {
+                result.tagInfo = {
+                    tagId: tagId,
+                    state: 'all',
+                }
+                break
+            }
+        }
+
+        // const tables = floorplanService.getTables()
+        // for (const tableId in tables) {
+        //     const table = floorplanService.getTable(tableId)
+        //     const location = table.isContain(position)
+        //     if (location) {
+        //         result.tableInfo = {
+        //             tableId: tableId,
+        //             state: 'all',
+        //         }
+        //         break
+        //     }
+        // }
+
+        const rectangles = floorplanService.getRectangles()
+        for (const rectangleId in rectangles) {
+            const rectangle = floorplanService.getRectangle(rectangleId)
+            const location = rectangle.isContain(position)
             if (location) {
             if (location) {
-                result.componentInfo = {
-                    componentId: componentId,
+                result.rectangleInfo = {
+                    rectangleId: rectangleId,
                     state: 'all',
                     state: 'all',
                 }
                 }
                 break
                 break
             }
             }
         }
         }
 
 
-        const tags = floorplanService.getTags()
-        for (const tagId in tags) {
-            const tag = floorplanService.getTag(tagId)
-            const location = tag.isContain(position)
+        const circles = floorplanService.getCircles()
+        for (const circleId in circles) {
+            const circle = floorplanService.getRectangle(circleId)
+            const location = circle.isContain(position)
             if (location) {
             if (location) {
-                result.tagInfo = {
-                    tagId: tagId,
+                result.circleInfo = {
+                    circleId: circleId,
+                    state: 'all',
+                }
+                break
+            }
+        }
+
+        const arrows = floorplanService.getArrows()
+        for (const arrowId in arrows) {
+            const arrow = floorplanService.getRectangle(arrowId)
+            const location = arrow.isContain(position)
+            if (location) {
+                result.arrowInfo = {
+                    arrowId: arrowId,
+                    state: 'all',
+                }
+                break
+            }
+        }
+
+        const icons = floorplanService.getIcons()
+        for (const iconId in icons) {
+            const icon = floorplanService.getRectangle(iconId)
+            const location = icon.isContain(position)
+            if (location) {
+                result.iconInfo = {
+                    iconId: iconId,
                     state: 'all',
                     state: 'all',
                 }
                 }
                 break
                 break

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

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