소스 검색

big 注释添加

haojianlong 4 년 전
부모
커밋
53d2324a56

+ 5 - 2
persagy-web-big/src/items/SCircleCornerPolylineItem.ts

@@ -146,19 +146,20 @@ export default class SCircleCornerPolylineItem extends SGraphStyleItem {
     onDraw(painter: SPainter): void {
         // 绘制基本图形
         painter.pen.color = this.strokeColor;
-
+        // 线宽是否缩放
         if (this.widthIsPx) {
             painter.pen.lineWidth = painter.toPx(this.lineWidth);
         } else {
             painter.pen.lineWidth = this.lineWidth;
         }
-
+        // 虚线
         if (this.lineStyle == SLineStyle.Dashed) {
             painter.pen.lineDash = [
                 painter.toPx(this.lineWidth * 3),
                 painter.toPx(this.lineWidth * 7)
             ];
         } else if (this.lineStyle == SLineStyle.Dotted) {
+            // 点线
             painter.pen.lineDash = [
                 painter.toPx(this.lineWidth),
                 painter.toPx(this.lineWidth)
@@ -167,6 +168,7 @@ export default class SCircleCornerPolylineItem extends SGraphStyleItem {
 
         const temp = JSON.parse(JSON.stringify(this.pointList));
 
+        // 折线点数2个以上
         if (temp.length > 2) {
             let radius = this.radius;
             if (this.radiusIsPx) {
@@ -175,6 +177,7 @@ export default class SCircleCornerPolylineItem extends SGraphStyleItem {
             this.generatePath(temp, radius);
             painter.drawPath(this.path);
         } else {
+            // 否则
             painter.drawPolyline(temp);
         }
     }

+ 19 - 19
persagy-web-big/src/items/SEquipItem.ts

@@ -94,25 +94,25 @@ export class SEquipItem extends SIconTextItem {
      * @params index 文本索引
      */
     setTextItem(val: any, index: number): void {
-            let item = new STextItem(this);
-            item.data = val;
-            item.text = val.name;
-            if (val.pos) {
-                item.moveTo(val.pos.x, val.pos.y);
-            } else {
-                item.moveTo(
-                    this.img.width * 0.5,
-                    -(this.font.size * 1.25 * 0.5) + index * 10
-                );
-            }
+        let item = new STextItem(this);
+        item.data = val;
+        item.text = val.name;
+        if (val.pos) {
+            item.moveTo(val.pos.x, val.pos.y);
+        } else {
+            item.moveTo(
+                this.img.width * 0.5,
+                -(this.font.size * 1.25 * 0.5) + index * 10
+            );
+        }
 
-            item.font.size = val.font ? val.font : 12;
-            item.backgroundColor = val.backgroundColor ? new SColor(val.backgroundColor) : SColor.Transparent;
-            item.isTransform = false;
-            item.showSelect = false;
-            item.color = val.color
-                ? new SColor(val.color)
-                : new SColor("#000000");
-            this.textItemList.push(item);
+        item.font.size = val.font ? val.font : 12;
+        item.backgroundColor = val.backgroundColor
+            ? new SColor(val.backgroundColor)
+            : SColor.Transparent;
+        item.isTransform = false;
+        item.showSelect = false;
+        item.color = val.color ? new SColor(val.color) : new SColor("#000000");
+        this.textItemList.push(item);
     }
 }

+ 0 - 4
persagy-web-big/src/items/SIconTextItem.ts

@@ -349,8 +349,6 @@ export class SIconTextItem extends SObjectItem {
         }
     }
 
-
-
     /**
      * 宽高发发生变化
      *
@@ -361,8 +359,6 @@ export class SIconTextItem extends SObjectItem {
         console.log(arguments);
     }
 
-
-
     /**
      * Item 对象边界区域
      *

+ 1 - 0
persagy-web-big/src/items/SLineItem.ts

@@ -220,6 +220,7 @@ export class SLineItem extends SGraphStyleItem {
      */
     moveToOrigin(x: number, y: number): void {
         super.moveToOrigin(x, y);
+        // 遍历点集
         this.line = this.line.map(
             (t): SPoint => {
                 t.x = t.x + x;

+ 3 - 0
persagy-web-big/src/items/SMaskItem.ts

@@ -112,14 +112,17 @@ export default class SMaskItem extends SGraphRectItem {
             painter.pen.color = this.strokeColor;
             painter.brush.color = this.fillColor;
             const eachPx = painter.toPx(1);
+            // 宽度是否缩放
             if (this.widthIsPx) {
                 painter.pen.lineWidth = this.lineWidth * eachPx;
             } else {
                 painter.pen.lineWidth = this.lineWidth;
             }
+            // 虚线
             if (this.lineStyle == SLineStyle.Dashed) {
                 painter.pen.lineDash = [3 * eachPx, 7 * eachPx];
             } else if (this.lineStyle == SLineStyle.Dotted) {
+                // 点线
                 painter.pen.lineDash = [2 * eachPx, 2 * eachPx];
             }
             if (this.mask) {

+ 1 - 1
persagy-web-big/src/items/SPipeItem.ts

@@ -208,7 +208,7 @@ export class SPipeItem extends SPolylineItem {
         this.moveToOrigin(this.x, this.y);
         const data = this.relationData;
         if (!data) return;
-
+        // 折线点集存在
         if (this.pointList.length) {
             const Line = this.pointList.map(pos => {
                 return {

+ 17 - 47
persagy-web-big/src/items/SPolygonItem.ts

@@ -28,10 +28,9 @@ import {
     SGraphItem,
     SGraphPointListDelete,
     SGraphPointListInsert,
-    SGraphPointListUpdate,
     SLineStyle
 } from "@persagy-web/graph";
-import { SKeyCode, SMouseEvent, SUndoStack } from "@persagy-web/base/";
+import { SMouseEvent, SUndoStack } from "@persagy-web/base/";
 import {
     SColor,
     SLine,
@@ -43,13 +42,14 @@ import {
 } from "@persagy-web/draw";
 import { SItemStatus } from "..";
 import { SMathUtil } from "../utils/SMathUtil";
+import { SGraphStyleItem } from "@persagy-web/graph/lib";
 
 /**
  * 编辑多边形
  *
  * @author  郝建龙 <haojianlong@sagacloud.cn>
  */
-export class SPolygonItem extends SGraphItem {
+export class SPolygonItem extends SGraphStyleItem {
     /** X 坐标最小值 */
     private minX = Number.MAX_SAFE_INTEGER;
     /** X 坐标最大值 */
@@ -81,47 +81,6 @@ export class SPolygonItem extends SGraphItem {
         this.update();
     }
 
-    /** 边框颜色 */
-    _strokeColor: SColor = new SColor("#0091FF");
-    /** 画笔颜色 */
-    get strokeColor(): SColor {
-        return this._strokeColor;
-    }
-    set strokeColor(v: SColor) {
-        this._strokeColor = v;
-        this.update();
-    }
-
-    /** 填充颜色 */
-    _fillColor: SColor = new SColor("#1EE887");
-    get fillColor(): SColor {
-        return this._fillColor;
-    }
-    set fillColor(v: SColor) {
-        this._fillColor = v;
-        this.update();
-    }
-
-    /** 边框样式 */
-    _lineStyle: SLineStyle = SLineStyle.Solid;
-    get lineStyle(): SLineStyle {
-        return this._lineStyle;
-    }
-    set lineStyle(v: SLineStyle) {
-        this._lineStyle = v;
-        this.update();
-    }
-
-    /** 边框的宽 只可输入像素宽 */
-    _lineWidth: number = 4;
-    get lineWidth(): number {
-        return this._lineWidth;
-    }
-    set lineWidth(v: number) {
-        this._lineWidth = v;
-        this.update();
-    }
-
     /** 是否闭合 */
     closeFlag: boolean = false;
     /** 鼠标移动点 */
@@ -237,12 +196,14 @@ export class SPolygonItem extends SGraphItem {
         painter.pen.color = this.strokeColor;
         painter.brush.color = this.fillColor;
         painter.pen.lineWidth = painter.toPx(this.lineWidth);
+        // 虚线
         if (this.lineStyle == SLineStyle.Dashed) {
             painter.pen.lineDash = [
                 painter.toPx(this.lineWidth * 3),
                 painter.toPx(this.lineWidth * 7)
             ];
         } else if (this.lineStyle == SLineStyle.Dotted) {
+            // 点线
             painter.pen.lineDash = [
                 painter.toPx(this.lineWidth),
                 painter.toPx(this.lineWidth)
@@ -273,6 +234,7 @@ export class SPolygonItem extends SGraphItem {
         painter.pen.lineCapStyle = SLineCapStyle.Square;
         painter.pen.color = this.strokeColor;
         painter.pen.lineWidth = painter.toPx(this.lineWidth);
+        // 最后一个点存在且折线点集存在
         if (this.lastPoint && pointList.length) {
             painter.drawLine(
                 pointList[pointList.length - 1].x,
@@ -286,7 +248,7 @@ export class SPolygonItem extends SGraphItem {
         painter.pen.color = SColor.Transparent;
         painter.brush.color = new SColor(this.fillColor.value);
         painter.pen.lineWidth = painter.toPx(this.lineWidth);
-
+        // 最后一个点存在
         if (this.lastPoint) {
             painter.drawPolygon([...pointList, this.lastPoint]);
             // 绘制顶点块
@@ -525,11 +487,14 @@ export class SPolygonItem extends SGraphItem {
      * @return 处理后的事件
      */
     compare(event: SMouseEvent): SMouseEvent {
+        // 折线点集存在
         if (this.pointList.length) {
             let last = new SPoint(event.x, event.y);
             if (this.status == SItemStatus.Create) {
+                // 创建态
                 last = this.pointList[this.pointList.length - 1];
             } else if (this.status == SItemStatus.Edit) {
+                // 编辑态
                 if (this.curIndex > 0) {
                     last = this.pointList[this.curIndex - 1];
                 }
@@ -537,9 +502,11 @@ export class SPolygonItem extends SGraphItem {
 
             const dx = Math.abs(event.x - last.x);
             const dy = Math.abs(event.y - last.y);
+            // 纵轴方向偏移量大
             if (dy > dx) {
                 event.x = last.x;
             } else {
+                // 否则
                 event.y = last.y;
             }
         }
@@ -555,6 +522,7 @@ export class SPolygonItem extends SGraphItem {
      */
     moveToOrigin(x: number, y: number): void {
         super.moveToOrigin(x, y);
+        // 遍历点集
         this.pointList = this.pointList.map(
             (t): SPoint => {
                 t.x = t.x + x;
@@ -598,16 +566,17 @@ export class SPolygonItem extends SGraphItem {
      * @return 边界区域
      */
     boundingRect(): SRect {
+        // 点集存在
         if (this.pointList.length) {
             this.minX = this.pointList[0].x;
             this.maxX = this.pointList[0].x;
             this.minY = this.pointList[0].y;
             this.maxY = this.pointList[0].y;
+            // 遍历点集并计算最大最小值
             this.pointList.forEach((it): void => {
                 let x = it.x,
                     y = it.y;
-                if (x < this.minX) {
-                    this.minX = x;
+                if (x < this.minX) {this.minX = x;
                 }
 
                 if (y < this.minY) {
@@ -641,6 +610,7 @@ export class SPolygonItem extends SGraphItem {
      */
     contains(x: number, y: number): boolean {
         let arr = this.pointList;
+        // 点集不能围成多边形或点不在轮廓线内
         if (arr.length < 3 || !SPolygonUtil.pointIn(x, y, arr)) {
             return false;
         }

+ 25 - 4
persagy-web-big/src/items/SPolylineItem.ts

@@ -140,6 +140,7 @@ export class SPolylineItem extends SGraphItem {
      */
     constructor(parent: null | SGraphItem, list: SPoint | SPoint[]) {
         super(parent);
+        // 数据类型为 SPoint
         if (list instanceof SPoint) {
             this.pointList.push(list);
         } else {
@@ -154,6 +155,7 @@ export class SPolylineItem extends SGraphItem {
      * @param index     添加到的索引
      */
     private addPoint(p: SPoint, index?: number): void {
+        // 添加的索引存在且索引值有效
         if (index && this.canHandle(index)) {
             this.pointList.splice(index, 0, p);
             this.recordAction(SGraphPointListInsert, [
@@ -162,6 +164,7 @@ export class SPolylineItem extends SGraphItem {
                 index
             ]);
         } else {
+            // 否则
             this.pointList.push(p);
             this.recordAction(SGraphPointListInsert, [this.pointList, p]);
         }
@@ -185,6 +188,7 @@ export class SPolylineItem extends SGraphItem {
      * @param index     删除点
      */
     deletePoint(index: number): void {
+        // 索引值有效且折线列表有2个以上点
         if (this.canHandle(index) && this.pointList.length > 2) {
             const p = new SPoint(
                 this.pointList[this.curIndex].x,
@@ -210,6 +214,7 @@ export class SPolylineItem extends SGraphItem {
      */
     moveToOrigin(x: number, y: number): void {
         super.moveToOrigin(x, y);
+        // 遍历点集列表
         this.pointList = this.pointList.map(
             (t): SPoint => {
                 t.x = t.x + x;
@@ -228,6 +233,7 @@ export class SPolylineItem extends SGraphItem {
      */
     findNearestPoint(p: SPoint): void {
         let len = this.sceneDis;
+        // 遍历点集列表
         for (let i = 0; i < this.pointList.length; i++) {
             let dis = SMathUtil.pointDistance(
                 p.x,
@@ -235,6 +241,7 @@ export class SPolylineItem extends SGraphItem {
                 this.pointList[i].x,
                 this.pointList[i].y
             );
+            // 当前距离小于最短距离
             if (dis < len) {
                 len = dis;
                 this.curIndex = i;
@@ -253,10 +260,11 @@ export class SPolylineItem extends SGraphItem {
      */
     findAddPos(p: SPoint): void {
         let len = SMathUtil.pointToLine(
-            p,
-            new SLine(this.pointList[0], this.pointList[1])
-        ),
+                p,
+                new SLine(this.pointList[0], this.pointList[1])
+            ),
             index = 0;
+        // 折线点集多余2
         if (this.pointList.length > 2) {
             for (let i = 1; i < this.pointList.length - 1; i++) {
                 let dis = SMathUtil.pointToLine(
@@ -269,7 +277,7 @@ export class SPolylineItem extends SGraphItem {
                 }
             }
         }
-
+        // 最短距离在可吸附范围内且吸附点存在
         if (len.MinDis < this.sceneDis && len.Point) {
             this.addPoint(len.Point, index + 1);
         }
@@ -282,6 +290,7 @@ export class SPolylineItem extends SGraphItem {
      * @return 事件对象
      */
     compare(event: SMouseEvent): SMouseEvent {
+        // 点集列表存在
         if (this.pointList.length) {
             let last = new SPoint(event.x, event.y);
             if (this.status == SItemStatus.Create) {
@@ -294,9 +303,11 @@ export class SPolylineItem extends SGraphItem {
 
             const dx = Math.abs(event.x - last.x);
             const dy = Math.abs(event.y - last.y);
+            // 纵向变量更大
             if (dy > dx) {
                 event.x = last.x;
             } else {
+                // 否则
                 event.y = last.y;
             }
         }
@@ -322,6 +333,7 @@ export class SPolylineItem extends SGraphItem {
      * @return 外接矩阵
      */
     boundingRect(): SRect {
+        // 点集列表有值
         if (this.pointList.length) {
             this.minX = this.pointList[0].x;
             this.maxX = this.pointList[0].x;
@@ -370,6 +382,7 @@ export class SPolylineItem extends SGraphItem {
      */
     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,
@@ -380,6 +393,7 @@ export class SPolylineItem extends SGraphItem {
                     this.pointList[i].y
                 )
             );
+            // 点在吸附范围内
             if (PTL.MinDis < this.sceneDis) {
                 return true;
             }
@@ -391,6 +405,7 @@ export class SPolylineItem extends SGraphItem {
      * 撤销操作
      */
     undo(): void {
+        // 非正常态
         if (this._status != SItemStatus.Normal) {
             this.undoStack.undo();
         }
@@ -400,6 +415,7 @@ export class SPolylineItem extends SGraphItem {
      * 重做操作
      */
     redo(): void {
+        // 非正常态
         if (this._status != SItemStatus.Normal) {
             this.undoStack.redo();
         }
@@ -409,10 +425,12 @@ export class SPolylineItem extends SGraphItem {
      * 取消操作执行
      */
     cancelOperate(): void {
+        // 创建态
         if (this.status == SItemStatus.Create) {
             this.parent = null;
             this.releaseItem();
         } else if (this.status == SItemStatus.Edit) {
+            // 编辑态
             this.status = SItemStatus.Normal;
             this.releaseItem();
         }
@@ -426,11 +444,13 @@ export class SPolylineItem extends SGraphItem {
     drawBaseLine(painter: SPainter): void {
         // 绘制基本图形
         if (this.lineStyle == SLineStyle.Dashed) {
+            // 虚线
             painter.pen.lineDash = [
                 painter.toPx(this.lineWidth * 3),
                 painter.toPx(this.lineWidth * 7)
             ];
         } else if (this.lineStyle == SLineStyle.Dotted) {
+            // 点线
             painter.pen.lineDash = [
                 painter.toPx(this.lineWidth),
                 painter.toPx(this.lineWidth)
@@ -451,6 +471,7 @@ export class SPolylineItem extends SGraphItem {
         this.sceneDis = painter.toPx(this.dis);
         // 创建状态
         painter.pen.lineWidth = painter.toPx(this.lineWidth);
+        // 创建态且最后一个点存在
         if (this.status == SItemStatus.Create && this.lastPoint) {
             // 绘制基本图形
             this.drawBaseLine(painter);

+ 8 - 0
persagy-web-big/src/items/SSceneMaskItem.ts

@@ -88,6 +88,7 @@ export class SSceneMaskItem extends SGraphStyleItem {
      */
     constructor(parent: SGraphItem | null, data: SPoint[] | SPoint) {
         super(parent);
+        // 数据是数组类型
         if (data instanceof Array) {
             this.outline = data;
             this.createMask();
@@ -171,6 +172,7 @@ export class SSceneMaskItem extends SGraphStyleItem {
      * @return	boolean
      */
     onMouseDown(event: SMouseEvent): boolean {
+        // 创建态且为鼠标左键
         if (this.status == SItemStatus.Create && event.buttons == 1) {
             if (
                 this.lastPoint.x == this.outline[0].x &&
@@ -210,8 +212,10 @@ export class SSceneMaskItem extends SGraphStyleItem {
      * @return	boolean
      */
     onMouseMove(event: SMouseEvent): boolean {
+        // 创建态
         if (this.status == SItemStatus.Create) {
             this.lastPoint = new SPoint(event.x, event.y);
+            // 点集包含3个以上数量
             if (this.outline.length >= 3) {
                 let le = SMathUtil.pointDistance(
                     this.lastPoint.x,
@@ -237,6 +241,7 @@ export class SSceneMaskItem extends SGraphStyleItem {
      * @param	event         事件参数
      */
     onKeyUp(event: KeyboardEvent): void {
+        // 回车键被按下且轮廓线有3个以上点
         if (event.keyCode == 13 && this.outline.length >= 3) {
             this.createMask();
         }
@@ -251,14 +256,17 @@ export class SSceneMaskItem extends SGraphStyleItem {
         painter.pen.lineCapStyle = SLineCapStyle.Square;
         painter.pen.color = this.strokeColor;
         painter.brush.color = this.fillColor;
+        // 线宽是否需要转像素
         if (this.widthIsPx) {
             painter.pen.lineWidth = painter.toPx(this.lineWidth);
         } else {
             painter.pen.lineWidth = this.lineWidth;
         }
+        //正常态
         if (this.status == SItemStatus.Normal) {
             painter.drawPath(this.mask);
         } else if (this.status == SItemStatus.Create) {
+            // 创建态
             painter.drawPolyline(this.outline);
             painter.drawLine(
                 this.outline[this.outline.length - 1],

+ 1 - 0
persagy-web-big/src/items/floor/SBoardItem.ts

@@ -98,6 +98,7 @@ export class SBoardItem extends SGraphItem {
         painter.pen.lineWidth = painter.toPx(1);
         painter.brush.color = ItemColor.spaceColor;
         painter.pen.color = ItemColor.spaceBorderColor;
+        // 遍历路径列表
         this.pathList.forEach((t): void => {
             painter.drawPath(t);
         });

+ 1 - 0
persagy-web-big/src/items/floor/SColumnItem.ts

@@ -46,6 +46,7 @@ export class SColumnItem extends SGraphPolyGroupItem {
     constructor(parent: SGraphItem | null, data: Column) {
         let tempArr = data.OutLine;
         let outline: Point[][] = [];
+        // 判断并遍历轮廓线数据
         if (tempArr && tempArr.length) {
             outline = tempArr.map((t): any => {
                 return t.map((it): any => ({ x: it.X, y: -it.Y }));

+ 1 - 0
persagy-web-big/src/items/floor/SHighlightItem.ts

@@ -87,6 +87,7 @@ export class SHighlightItem extends SGraphItem {
      * @param painter   绘制对象
      */
     onDraw(painter: SPainter): void {
+        // 高亮线
         if (this.type == 2) {
             painter.pen.color = ItemColor.highLightLineColor;
             painter.pen.lineWidth = painter.toPx(6);

+ 1 - 0
persagy-web-big/src/items/floor/SSpaceItem.ts

@@ -168,6 +168,7 @@ export class SSpaceItem extends SGraphAreaGroupItem {
         if (this.showBaseName) {
             if (this.name && this.name != "null") {
                 painter.brush.color = new SColor(this.nameColor);
+                // 名字是否缩放
                 if (this.nameTransform) {
                     painter.font.size = this.nameSize;
                 } else {

+ 1 - 0
persagy-web-big/src/items/floor/SVirtualWallItem.ts

@@ -65,6 +65,7 @@ export class SVirtualWallItem extends SGraphItem {
             this.maxX = this.minX;
             this.minY = -tempArr[0][0].Y;
             this.maxY = this.minY;
+            // 遍历轮廓线
             this.pointArr = tempArr.map((t): SPoint[] => {
                 return t.map(
                     (it): SPoint => {

+ 1 - 0
persagy-web-big/src/items/floor/SWindowItem.ts

@@ -58,6 +58,7 @@ export class SWindowItem extends SGraphItem {
         super(parent);
         this.data = data;
         this.zOrder = ItemOrder.windowOrder;
+        // 轮廓线存在
         if (this.data.OutLine.length) {
             this.pointArr = this.data.OutLine[0].map(
                 (t): SPoint => {

+ 6 - 0
persagy-web-big/src/parser/SFloorParser.ts

@@ -66,36 +66,42 @@ export class SFloorParser extends SParser {
     parseData(data: FloorData): void {
         // 墙数据
         if (data.Walls) {
+            // 遍历墙列表
             data.Walls.forEach((t: Wall): void => {
                 this.addWall(t);
             });
         }
 
         if (data.Columns) {
+            // 遍历柱子列表
             data.Columns.forEach((t: Column): void => {
                 this.addColumn(t);
             });
         }
 
         if (data.Windows) {
+            // 遍历窗户列表
             data.Windows.forEach((t: Casement): void => {
                 this.addCasement(t);
             });
         }
 
         if (data.VirtualWalls) {
+            // 遍历虚拟墙列表
             data.VirtualWalls.forEach((t: VirtualWall): void => {
                 this.addVirtualWall(t);
             });
         }
 
         if (data.Doors) {
+            // 遍历门列表
             data.Doors.forEach((t: Door): void => {
                 this.addDoor(t);
             });
         }
 
         if (data.Spaces) {
+            // 遍历空间列表
             data.Spaces.forEach((t: Space): void => {
                 this.addSpace(t);
             });

+ 1 - 0
persagy-web-big/src/parser/SZoneParser.ts

@@ -44,6 +44,7 @@ export class SZoneParser extends SParser {
      */
     parseData(data: Zone[]): void {
         if (data && data.length) {
+            // 遍历业务空间列表
             data.forEach((z): void => this.addZone(z));
         }
     }