Sfoglia il codice sorgente

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	saga-web-draw/package.json
#	saga-web-graphy/package.json
sybotan 5 anni fa
parent
commit
6d2e7673cc

+ 1 - 1
saga-web-base/package.json

@@ -30,7 +30,7 @@
         "prettier": "^1.18.2",
         "@types/jest": "^24.0.15",
         "ts-jest": "^24.0.2",
-        "typescript": "^3.5.3"
+        "typescript": "^3.9.3"
     },
     "dependencies": {}
 }

+ 5 - 5
saga-web-big/package.json

@@ -1,7 +1,7 @@
 {
     "name": "@saga-web/big",
-    "version": "1.0.7",
-    "description": "上格云Web平面图。",
+    "version": "1.0.9",
+    "description": "上格云建筑信息化库",
     "main": "lib/index.js",
     "types": "lib/index.d.js",
     "remote": {
@@ -38,10 +38,10 @@
         "prettier": "^1.18.2",
         "@types/jest": "^24.0.15",
         "ts-jest": "^24.0.2",
-        "typedoc": "^0.17.4",
-        "typescript": "^3.5.3"
+        "typedoc": "0.17.7",
+        "typescript": "^3.9.3"
     },
     "dependencies": {
-        "@saga-web/graphy": "2.1.53"
+        "@saga-web/graphy": "2.1.54"
     }
 }

+ 3 - 1
saga-web-big/src/enums/SRelationState.ts

@@ -9,5 +9,7 @@ export enum SRelationState {
     /** 动画撞他    */
     Animation,
     /** 编辑状态    */
-    Edit
+    Edit,
+    /** 创建态 */
+    Create
 } // Enum SRelationState

+ 2 - 2
saga-web-big/src/factories/SItemFactory.ts

@@ -104,7 +104,7 @@ export class SItemFactory {
      * @param   data    图片数据
      * */
     createImage(data: ImageData): SImageItem {
-        return new SImageItem(null, data);
+        return new SImageItem(null);
     } // Function createImage()
 
     /**
@@ -113,6 +113,6 @@ export class SItemFactory {
      * @param   data    文本数据
      * */
     createText(data: TextData): STextItem {
-        return new STextItem(null, data);
+        return new STextItem(null);
     } // Function createImage()
 } // class SItemFactory

+ 33 - 21
saga-web-big/src/items/SImageItem.ts

@@ -1,6 +1,5 @@
 import { SObjectItem } from "./SObjectItem";
 import { SGraphyItem } from "@saga-web/graphy/lib";
-import { ImageData } from "../types/ImageData";
 import { SPainter, SRect } from "@saga-web/draw/lib";
 
 /**
@@ -10,37 +9,50 @@ import { SPainter, SRect } from "@saga-web/draw/lib";
  */
 export class SImageItem extends SObjectItem {
     /** 标志宽度 */
-    private width: number = 20;
+    _width: number = 20;
+    get width(): number {
+        return this._width;
+    }
+    set width(v: number) {
+        this._width = v;
+        this.update();
+    }
     /** 标志高度 */
-    private height: number = 20;
+    _height: number = 20;
+    get height(): number {
+        return this._height;
+    }
+    set height(v: number) {
+        this._height = v;
+        this.update();
+    }
     /** 图片地址    */
-    url: string = "";
+    _url: string = "";
+    get url(): string {
+        return this._url;
+    }
+    set url(v: string) {
+        this._url = v;
+        this.Img = new Image();
+        this.Img.src = v;
+        this.Img.onload = (): void => {
+            // @ts-ignore
+            this.width = this.Img.width;
+            // @ts-ignore
+            this.height = this.Img.height;
+            this.update();
+        };
+    }
     /** 图片dom */
     Img: CanvasImageSource | undefined;
-    /** 图片item所有数据  */
-    private data: ImageData;
 
     /**
      * 构造函数
      *
      *  @param parent    指向父对象
-     *  @param data      图片数据
      * */
-    constructor(parent: SGraphyItem | null, data: ImageData) {
+    constructor(parent: SGraphyItem | null) {
         super(parent);
-        this.data = data;
-        if (data.Url) {
-            this.Img = new Image();
-            this.url = data.Url;
-            this.Img.src = this.url;
-            this.Img.onload = (): void => {
-                // @ts-ignore
-                this.width = data.Width ? data.Width : this.Img.width;
-                // @ts-ignore
-                this.height = data.Height ? data.Height : this.Img.height;
-                this.update();
-            };
-        }
         this.isTransform = false;
     }
 

+ 63 - 3
saga-web-big/src/items/SLineItem.ts

@@ -1,6 +1,7 @@
 import { SGraphyItem } from "@saga-web/graphy/lib";
 import { SLine, SPainter, SPoint } from "@saga-web/draw/lib";
 import { SMouseEvent } from "@saga-web/base";
+import { SMathUtil } from "../utils/SMathUtil";
 
 /**
  * 直线item
@@ -12,6 +13,42 @@ export class SLineItem extends SGraphyItem {
     p1: SPoint | undefined;
     /** 线段终止点   */
     p2: SPoint | undefined;
+    /** 是否完成绘制  */
+    private isFinish: boolean = true;
+    /** 拖动灵敏度   */
+    dis: number = 10;
+
+    /**
+     * 构造函数
+     *
+     * @param   parent  父级
+     * @param   line    线段
+     * */
+    constructor(parent: SGraphyItem | null, line: SLine);
+
+    /**
+     * 构造函数
+     *
+     * @param   parent  父级
+     * @param   point   线段起点
+     * */
+    constructor(parent: SGraphyItem | null, point: SPoint);
+
+    /**
+     * 构造函数
+     *
+     * @param   parent  父级
+     * @param   l       线段or线段起点
+     * */
+    constructor(parent: SGraphyItem | null, l: SPoint | SLine) {
+        super(parent);
+        if (l instanceof SPoint) {
+            this.p1 = l;
+        } else {
+            this.p1 = l.p1;
+            this.p2 = l.p2;
+        }
+    }
 
     /**
      * 鼠标按下事件
@@ -30,7 +67,17 @@ export class SLineItem extends SGraphyItem {
      * @return  是否处理事件
      * */
     onMouseMove(event: SMouseEvent): boolean {
-        return false;
+        if (!this.isFinish) {
+            if (!this.p2) {
+                this.p2 = new SPoint(event.x, event.y);
+            } else {
+                this.p2.x = event.x;
+                this.p2.y = event.y;
+            }
+            return true;
+        } else {
+            return super.onMouseMove(event);
+        }
     } // Function onMouseMove()
 
     /**
@@ -40,7 +87,12 @@ export class SLineItem extends SGraphyItem {
      * @return  是否处理事件
      * */
     onMouseUp(event: SMouseEvent): boolean {
-        return false;
+        if (!this.isFinish) {
+            this.isFinish = true;
+            return true;
+        } else {
+            return super.onMouseUp(event);
+        }
     } // Function onMouseUp()
 
     /**
@@ -51,7 +103,15 @@ export class SLineItem extends SGraphyItem {
      * @return  true-是
      */
     contains(x: number, y: number): boolean {
-
+        if (this.p1 instanceof SPoint && this.p2 instanceof SPoint) {
+            let p = new SPoint(x, y);
+            if (
+                SMathUtil.pointToLine(p, new SLine(this.p1, this.p2)).MinDis <
+                this.dis
+            ) {
+                return true;
+            }
+        }
         return false;
     } // Function contains()
 

+ 239 - 0
saga-web-big/src/items/SPolylineItem.ts

@@ -0,0 +1,239 @@
+import { SGraphyItem } from "@saga-web/graphy/lib";
+import { SColor, SLine, SPainter, SPoint } from "@saga-web/draw/lib";
+import { SMouseEvent } from "@saga-web/base";
+import { SRelationState } from "../enums/SRelationState";
+import { SMathUtil } from "../utils/SMathUtil";
+
+/**
+ * 直线item
+ *
+ * */
+
+export class SPolylineItem extends SGraphyItem {
+    /** 折点信息    */
+    pointList: SPoint[] = [];
+    /** 是否绘制完成  */
+    status: SRelationState = SRelationState.Create;
+    /** 鼠标移动时的点 */
+    lastPoint: SPoint | null = null;
+    /** 线条颜色    */
+    _strokeColor: string = "#000000";
+    get strokeColor(): string {
+        return this._strokeColor;
+    }
+    set strokeColor(v: string) {
+        this._strokeColor = v;
+        this.update();
+    }
+    /** 填充色 */
+    _fillColor: string = "#ffffff";
+    get fillColor(): string {
+        return this._fillColor;
+    }
+    set fillColor(v: string) {
+        this._fillColor = v;
+    }
+    /** 线条宽度    */
+    _lineWidth: number = 1;
+    get lineWidth(): number {
+        return this._lineWidth;
+    }
+    set lineWidth(v: number) {
+        this._lineWidth = v;
+        this.update();
+    }
+    /** 全局灵敏度   */
+    dis: number = 10;
+    /** 灵敏度转换为场景长度  */
+    sceneDis: number = 10;
+    /** 当前点索引   */
+    curIndex: number = -1;
+
+    /**
+     * 构造函数
+     *
+     * @param   parent  父级
+     * @param   list    坐标集合
+     * */
+    constructor(parent: null | SGraphyItem, list: SPoint[]);
+
+    /**
+     * 构造函数
+     *
+     * @param   parent  父级
+     * @param   list    第一个坐标
+     * */
+    constructor(parent: null | SGraphyItem, list: SPoint);
+
+    /**
+     * 构造函数
+     *
+     * @param   parent  父级
+     * @param   list    第一个坐标|坐标集合
+     * */
+    constructor(parent: null | SGraphyItem, list: SPoint | SPoint[]) {
+        super(parent);
+        if (list instanceof SPoint) {
+            this.pointList.push(list);
+        } else {
+            this.pointList = list;
+        }
+    } // Constructor
+
+    /**
+     * 添加点至数组中
+     *
+     * @param   p       添加的点
+     * @param   index   添加到的索引
+     * */
+    private addPoint(p: SPoint, index?: number): void {
+        if (index && this.canHandle(index)) {
+            this.pointList.splice(index, 0, p);
+        } else {
+            this.pointList.push(p);
+        }
+    } // Function addPoint()
+
+    /**
+     * 是否可以添加点到数组中
+     *
+     * @param   index   要添加到的索引
+     * @return  boolean 是否可添加
+     * */
+    private canHandle(index: number): boolean {
+        return index >= 0 && index <= this.pointList.length;
+    } // Function canHandle()
+
+    /**
+     * 添加点至数组中
+     *
+     * @param   index   添加到的索引
+     * */
+    private delPoint(index: number): void {
+        if (this.canHandle(index)) {
+            this.pointList.splice(index, 0);
+        }
+    } // Function delPoint
+
+    /**
+     * 鼠标按下事件
+     *
+     * @param   event   鼠标事件
+     * @return  boolean 是否处理事件
+     * */
+    onMouseDown(event: SMouseEvent): boolean {
+        if (event.buttons == 1) {
+            if (this.status == SRelationState.Create) {
+                this.addPoint(new SPoint(event.x, event.y));
+                return true;
+            } else {
+                //拖动点
+            }
+        }
+        return super.onMouseDown(event);
+    } // Function onMouseDown()
+
+    /**
+     * 鼠标移动事件
+     *
+     * @param   event   鼠标事件
+     * @return  boolean 是否处理事件
+     * */
+    onMouseMove(event: SMouseEvent): boolean {
+        if (event.buttons == 1) {
+            if (this.status == SRelationState.Create) {
+                if (this.lastPoint) {
+                    this.lastPoint.x = event.x;
+                    this.lastPoint.y = event.y;
+                } else {
+                    this.lastPoint = new SPoint(event.x, event.y);
+                }
+                return true;
+            } else {
+                return super.onMouseMove(event);
+            }
+        } else {
+            return super.onMouseMove(event);
+        }
+    } // Function onMouseMove()
+
+    /**
+     * 鼠标双击事件
+     *
+     * @param	event         事件参数
+     * @return	boolean
+     */
+    onDoubleClick(event: SMouseEvent): boolean {
+        if (this.status == SRelationState.Create) {
+            this.status = SRelationState.Normal;
+        }
+        return true;
+    } // Function onDoubleClick()
+
+    /***
+     * 键盘按键弹起事件
+     *
+     * @param	event         事件参数
+     */
+    onKeyUp(event: KeyboardEvent): void {
+        if (event.keyCode == 13) {
+            this.status = SRelationState.Normal;
+        }
+    } // Function onKeyUp()
+
+    /**
+     * 判断点是否在区域内
+     *
+     * @param   x
+     * @param   y
+     * @return  true-是
+     */
+    contains(x: number, y: number): boolean {
+        let p = new SPoint(x, y);
+        for (let i = 1; i < this.pointList.length; i++) {
+            let PTL = SMathUtil.pointToLine(
+                p,
+                new SLine(
+                    this.pointList[i - 1].x,
+                    this.pointList[i - 1].y,
+                    this.pointList[i].x,
+                    this.pointList[i].y
+                )
+            );
+            if (PTL.MinDis < this.sceneDis) {
+                return true;
+            }
+        }
+        return false;
+    } // Function contains()
+
+    /**
+     * Item绘制操作
+     *
+     * @param   painter painter对象
+     */
+    onDraw(painter: SPainter): void {
+        // 缓存场景长度
+        this.sceneDis = painter.toPx(this.dis);
+        // 绘制基本图形
+        painter.pen.lineWidth = painter.toPx(this.lineWidth);
+        painter.pen.color = new SColor(this.strokeColor);
+        painter.drawPolyline(this.pointList);
+        // 创建状态
+        if (this.status == SRelationState.Create && this.lastPoint) {
+            painter.drawLine(
+                this.pointList[this.pointList.length - 1],
+                this.lastPoint
+            );
+        } else if (this.status == SRelationState.Edit) {
+            // 编辑状态
+            this.pointList.forEach((t, i): void => {
+                painter.brush.color = SColor.White;
+                if (i == this.curIndex) {
+                    painter.brush.color = new SColor(this.fillColor);
+                }
+                painter.drawCircle(t.x, t.y, painter.toPx(5));
+            });
+        }
+    } // Function onDraw()
+} // Class SPolylineItem

+ 6 - 7
saga-web-big/src/items/STextItem.ts

@@ -1,10 +1,5 @@
 import { SObjectItem } from "./SObjectItem";
-import {
-    SPainter,
-    SRect,
-    SColor,
-    SFont
-} from "@saga-web/draw/lib";
+import { SPainter, SRect, SColor, SFont } from "@saga-web/draw/lib";
 import { SMouseEvent } from "@saga-web/base/lib";
 
 /**
@@ -106,7 +101,11 @@ export class STextItem extends SObjectItem {
     onDraw(painter: SPainter): void {
         this.width = painter.toPx(painter.textWidth(this.text));
         this.height = painter.toPx(this.font.size);
-        painter.font = this.font;
+        painter.font.textBaseLine = this.font.textBaseLine;
+        painter.font.textDirection = this.font.textDirection;
+        painter.font.textAlign = this.font.textAlign;
+        painter.font.name = this.font.name;
+        painter.font.size = painter.toPx(this.font.size);
         painter.brush.color = new SColor(this.color);
         painter.drawText(this.text, 0, 0, this.maxWidth);
     } // Function onDraw()

+ 2 - 2
saga-web-big/src/items/floor/SColumnItem.ts

@@ -1,8 +1,8 @@
 import { Column } from "../../types/floor/Column";
 import { SGraphyItem } from "@saga-web/graphy/lib";
 import { SPainter, SPoint, SRect } from "@saga-web/draw/lib";
-import { ItemOrder } from "../../config/ItemOrder";
-import { ItemColor } from "../../config/ItemColor";
+import { ItemOrder } from "../..";
+import { ItemColor } from "../..";
 
 /**
  * 柱子item

+ 28 - 28
saga-web-big/src/items/topology/SRelation.ts

@@ -9,32 +9,32 @@ import { SAnchorItem } from "./SAnchorItem";
  * * @author  郝建龙(1061851420@qq.com)
  */
 export abstract class SRelation extends SGraphyItem {
-    /** 起始端点线帽样式(枚举)    */
-    beginCap: SRelationState = SArrowStyleType.None;
-    /** 终止端点线帽样式(枚举)    */
-    endCap: SRelationState = SArrowStyleType.None;
-    /** 线帽填充色   */
-    capColor: SColor;
-    /** 外线颜色    */
-    color: SColor;
-    /** 起始锚点对象  */
-    startAnchor: SAnchorItem | null = null;
-    /** 终止锚点对象  */
-    endAnchor: SAnchorItem | null = null;
-    /** 内线颜色    */
-    innerLineColor: SColor;
-    /** 内线宽度    */
-    innerLineWidth: number = -1;
-    /** 虚线样式    */
-    lineDash: number[] = [];
-    /** 虚线偏移量   */
-    lineDashOffset: number = 0;
-    /** 动画速度    */
-    speed: number = 0;
-    /** 线宽  */
-    lineWidth: number;
-    /** 线状态 */
-    state: SRelationState = SRelationState.Normal;
-    /** 折点list  */
-    pointList: SPoint[] = [];
+    // /** 起始端点线帽样式(枚举)    */
+    // beginCap: SRelationState = SArrowStyleType.None;
+    // /** 终止端点线帽样式(枚举)    */
+    // endCap: SRelationState = SArrowStyleType.None;
+    // /** 线帽填充色   */
+    // capColor: SColor;
+    // /** 外线颜色    */
+    // color: SColor;
+    // /** 起始锚点对象  */
+    // startAnchor: SAnchorItem | null = null;
+    // /** 终止锚点对象  */
+    // endAnchor: SAnchorItem | null = null;
+    // /** 内线颜色    */
+    // innerLineColor: SColor;
+    // /** 内线宽度    */
+    // innerLineWidth: number = -1;
+    // /** 虚线样式    */
+    // lineDash: number[] = [];
+    // /** 虚线偏移量   */
+    // lineDashOffset: number = 0;
+    // /** 动画速度    */
+    // speed: number = 0;
+    // /** 线宽  */
+    // lineWidth: number;
+    // /** 线状态 */
+    // state: SRelationState = SRelationState.Normal;
+    // /** 折点list  */
+    // pointList: SPoint[] = [];
 } // Class SRelation

+ 1 - 1
saga-web-big/typedoc.json

@@ -1,5 +1,5 @@
 {
-    "name": "上格云Web基础库",
+    "name": "上格云建筑信息化库",
     "mode": "file",
     "out": "doc",
     "exclude": ["**/*+(index|.test).ts"]

+ 1 - 1
saga-web-draw/src/SCanvasView.ts

@@ -190,9 +190,9 @@ export class SCanvasView extends SObject {
         /** painter对象 */
         let ctx = this.canvas;
         if (null != ctx && this._needDraw) {
+            this._needDraw = false;
             let painter = new SPainter(this);
             this.onDraw(painter);
-            this._needDraw = false;
         }
         this.requestAnimationFrame(this.loop.bind(this));
     } // Function loop()

+ 1 - 1
saga-web-draw/src/SPainter.ts

@@ -600,7 +600,7 @@ export class SPainter extends SObject {
      */
     drawPolygon(points: SPoint[]): void {
         this.engine.drawPolygon(points);
-    } // Functin drawPolygon()
+    } // Function drawPolygon()
 
     /**
      * 绘制路径

+ 3 - 3
saga-web-fengmap/package.json

@@ -1,6 +1,6 @@
 {
     "name": "@saga-web/feng-map",
-    "version": "1.0.4",
+    "version": "1.0.6",
     "description": "上格云Web平面图。",
     "main": "lib/index.js",
     "types": "lib/index.d.js",
@@ -29,9 +29,9 @@
         "fengmap": "^2.5.3",
         "prettier": "^1.18.2",
         "ts-jest": "^24.0.2",
-        "typescript": "^3.5.3"
+        "typescript": "^3.9.3"
     },
     "dependencies": {
-        "@saga-web/big": "1.0.6"
+        "@saga-web/big": "1.0.9"
     }
 }

+ 2 - 0
saga-web-fengmap/src/parser/SFengParser.ts

@@ -170,6 +170,8 @@ export class SFengParser extends SParser {
         });
         this.fmap.on("loadComplete", () => {
             let obj = {};
+            // 切换至当前楼层才可查询
+            this.fmap.focusGroupID = groupId;
             // 创建搜索分析对象
             let searchAnalyser = new fengmap.FMSearchAnalyser(this.fmap);
             // 创建搜索请求体对象

+ 2 - 2
saga-web-graphy/package.json

@@ -1,6 +1,6 @@
 {
     "name": "@saga-web/graphy",
-    "version": "2.1.54",
+    "version": "2.1.53",
     "description": "上格云二维图形引擎。",
     "main": "lib/index.js",
     "types": "lib/index.d.js",
@@ -41,6 +41,6 @@
         "typescript": "^3.5.3"
     },
     "dependencies": {
-        "@saga-web/draw": "2.1.83"
+        "@saga-web/draw": "2.1.81"
     }
 }