haojianlong před 4 roky
rodič
revize
7db21145f7

+ 25 - 16
persagy-web-big/src/items/SIconTextItem.ts

@@ -41,7 +41,7 @@ import { Anchor } from "../types/topology/Anchor";
  *
  * */
 export class SIconTextItem extends SObjectItem {
-    /** item状态  */
+    /** item状态 */
     _status: SItemStatus = SItemStatus.Normal;
     get status(): SItemStatus {
         return this._status;
@@ -64,7 +64,7 @@ export class SIconTextItem extends SObjectItem {
         this.update();
     }
 
-    /** 是否显示文字  */
+    /** 是否显示文字 */
     _showText: boolean = true;
     get showText(): boolean {
         return this._showText;
@@ -101,7 +101,7 @@ export class SIconTextItem extends SObjectItem {
         this.update();
     } // Set selected
 
-    /** 是否激活  */
+    /** 是否激活 */
     _isActive: boolean = false;
     get isActive(): boolean {
         return this._isActive;
@@ -120,7 +120,7 @@ export class SIconTextItem extends SObjectItem {
         this.update();
     } // Set isActive
 
-    /** 激活显示颜色  */
+    /** 激活显示颜色 */
     _activeColor: SColor = new SColor("#00000033");
     get activeColor(): SColor {
         return this._activeColor;
@@ -156,22 +156,22 @@ export class SIconTextItem extends SObjectItem {
     set sWidth(v: number) {
         this.img.width = v;
         this.img.origin = new SPoint(this.img.width * 0.5, this.img.height * 0.5);
-        this.changeAhchorPoint();
+        this.changeAnchorPoint();
         this.update();
     }
 
-    /** icon */
+    /** icon */
     get sHeight(): number {
         return this.img.height;
     }
     set sHeight(v: number) {
         this.img.height = v;
         this.img.origin = new SPoint(this.img.width * 0.5, this.img.height * 0.5);
-        this.changeAhchorPoint();
+        this.changeAnchorPoint();
         this.update();
     }
 
-    /** 是否显示锚点  */
+    /** 是否显示锚点 */
     private _showAnchor: boolean = false;
     get showAnchor(): boolean {
         return this._showAnchor;
@@ -182,7 +182,7 @@ export class SIconTextItem extends SObjectItem {
             t.visible = v;
         });
     }
-
+    /** 文本内容 */
     get text(): string {
         return this.textItem.text;
     }
@@ -190,6 +190,7 @@ export class SIconTextItem extends SObjectItem {
         this.textItem.text = v;
         this.update();
     }
+    /** 文本颜色 */
     get color(): SColor {
         return this.textItem.color;
     }
@@ -197,6 +198,7 @@ export class SIconTextItem extends SObjectItem {
         this.textItem.color = v;
         this.update();
     }
+    /** 文本字体 */
     get font(): SFont {
         return this.textItem.font;
     }
@@ -204,22 +206,24 @@ export class SIconTextItem extends SObjectItem {
         this.textItem.font = v;
         this.update();
     }
-    /** img Item    */
+    /** img Item */
     img: SImageItem = new SImageItem(this);
 
-    /** text item   */
+    /** text item */
     textItem: STextItem = new STextItem(this);
 
     /**
      * 构造体
      *
+     * @param   parent  父类
+     * @param   data    锚点数据
      * */
     constructor(parent: SGraphItem | null, data?: Anchor[]) {
         super(parent);
         this.img.width = 32;
         this.img.height = 32;
         this.img.origin = new SPoint(this.img.width * 0.5, this.img.height * 0.5);
-        this.img.connect("onMove", this, this.changeAhchorPoint.bind(this));
+        this.img.connect("onMove", this, this.changeAnchorPoint.bind(this));
         let anchorPoint;
         if (data && data.length) {
             anchorPoint = data.map(t => {
@@ -253,7 +257,10 @@ export class SIconTextItem extends SObjectItem {
         this.textItem.text = "";
         this.textItem.font.size = 12;
         // 偏移二分之一文本高度
-        this.textItem.moveTo((this.img.width * 0.5), -(this.font.size * 1.25 * 0.5));
+        this.textItem.moveTo(
+            this.img.width * 0.5,
+            -(this.font.size * 1.25 * 0.5)
+        );
         this.moveable = true;
         this.selectable = true;
     }
@@ -262,7 +269,7 @@ export class SIconTextItem extends SObjectItem {
      * 计算并移动锚点的位置
      *
      * */
-    private changeAhchorPoint(): void {
+    private changeAnchorPoint(): void {
         // 判断是否有锚点
         if (this.anchorList.length) {
             let anchorPoint = [
@@ -279,11 +286,13 @@ export class SIconTextItem extends SObjectItem {
                 item.moveTo(anchorPoint[index].x, anchorPoint[index].y);
             });
         }
-    } // Function changeAhchorPoint()
+    } // Function changeAnchorPoint()
 
     /**
      * 鼠标按下事件
      *
+     * @param   event   事件对象
+     * @return  是否处理事件
      * */
     onMouseDown(event: SMouseEvent): boolean {
         if (this.status == SItemStatus.Normal) {
@@ -379,4 +388,4 @@ export class SIconTextItem extends SObjectItem {
             }
         }
     } // Function onDraw()
-}
+} // Class SIconTextItem

+ 27 - 27
persagy-web-big/src/items/SLineItem.ts

@@ -42,96 +42,96 @@ import {
  * */
 
 export class SLineItem extends SGraphItem {
-    /** X坐标最小值  */
+    /** X坐标最小值 */
     private minX = Number.MAX_SAFE_INTEGER;
-    /** X坐标最大值  */
+    /** X坐标最大值 */
     private maxX = Number.MIN_SAFE_INTEGER;
-    /** Y坐标最小值  */
+    /** Y坐标最小值 */
     private minY = Number.MAX_SAFE_INTEGER;
-    /** Y坐标最大值  */
+    /** Y坐标最大值 */
     private maxY = Number.MIN_SAFE_INTEGER;
 
-    /** 线段   */
+    /** 线段 */
     private _line: SPoint[] = [];
     get line(): SPoint[] {
         return this._line;
-    }
+    } // Get line
     set line(arr: SPoint[]) {
         this._line = arr;
         this.update();
-    }
+    } // Set line
 
-    /** 是否完成绘制  */
+    /** 是否完成绘制 */
     protected _status: SItemStatus = SItemStatus.Normal;
     get status(): SItemStatus {
         return this._status;
-    }
+    } // Get status
     set status(v: SItemStatus) {
         this._status = v;
         this.undoStack.clear();
         this.update();
-    }
+    } // Set status
 
-    /** 线条颜色    */
+    /** 线条颜色 */
     private _strokeColor: SColor = SColor.Black;
     get strokeColor(): SColor {
         return this._strokeColor;
-    }
+    } // Get strokeColor
     set strokeColor(v: SColor) {
         this._strokeColor = v;
         this.update();
-    }
+    } // Set strokeColor
 
-    /** 线条样式    */
+    /** 线条样式 */
     private _lineStyle: SLineStyle = SLineStyle.Solid;
     get lineStyle(): SLineStyle {
         return this._lineStyle;
-    }
+    } // Get lineStyle
     set lineStyle(v: SLineStyle) {
         this._lineStyle = v;
         this.update();
-    }
+    } // Set lineStyle
 
     /** 端点填充色 */
     private _fillColor: SColor = SColor.White;
     get fillColor(): SColor {
         return this._fillColor;
-    }
+    } // Get fillColor
     set fillColor(v: SColor) {
         this._fillColor = v;
         this.update();
-    }
+    } // Set fillColor
 
     /** 选中端点填充色 */
     private _activeFillColor: SColor = new SColor("#2196f3");
     get activeFillColor(): SColor {
         return this._activeFillColor;
-    }
+    } // Get activeFillColor
     set activeFillColor(v: SColor) {
         this._activeFillColor = v;
         this.update();
-    }
+    } // Set activeFillColor
 
-    /** 线条宽度    */
+    /** 线条宽度 */
     private _lineWidth: number = 1;
     get lineWidth(): number {
         return this._lineWidth;
-    }
+    } // Get lineWidth
     set lineWidth(v: number) {
         this._lineWidth = v;
         this.update();
-    }
+    } // Set lineWidth
 
-    /** 拖动灵敏度   */
+    /** 拖动灵敏度 */
     dis: number = 5;
 
-    /** 拖动灵敏度   */
+    /** 拖动灵敏度 */
     private sceneDis: number = 5;
 
-    /** 当前点索引   */
+    /** 当前点索引 */
     curIndex: number = -1;
 
-    /** 当前点坐标   */
+    /** 当前点坐标 */
     private curPoint: SPoint | null = null;
 
     /** undo/redo堆栈 */

+ 20 - 22
persagy-web-big/src/items/SPolygonItem.ts

@@ -50,16 +50,16 @@ import { SMathUtil } from "../utils/SMathUtil";
  * @author  韩耀龙
  */
 export class SPolygonItem extends SGraphItem {
-    /** X坐标最小值  */
+    /** X坐标最小值 */
     private minX = Number.MAX_SAFE_INTEGER;
-    /** X坐标最大值  */
+    /** X坐标最大值 */
     private maxX = Number.MIN_SAFE_INTEGER;
-    /** Y坐标最小值  */
+    /** Y坐标最小值 */
     private minY = Number.MAX_SAFE_INTEGER;
-    /** Y坐标最大值  */
+    /** Y坐标最大值 */
     private maxY = Number.MIN_SAFE_INTEGER;
 
-    /** 轮廓线坐标  */
+    /** 轮廓线坐标 */
     private pointList: SPoint[] = [];
     // 获取当前状态
     get getPointList(): SPoint[] {
@@ -71,13 +71,11 @@ export class SPolygonItem extends SGraphItem {
         this.update();
     }
 
-    // 当前状态
+    /** 当前状态 */
     protected _status: number = SItemStatus.Normal;
-    // 获取当前状态
     get status(): SItemStatus {
         return this._status;
     }
-    // 编辑当前状态
     set status(value: SItemStatus) {
         this._status = value;
         this.undoStack.clear();
@@ -89,45 +87,45 @@ export class SPolygonItem extends SGraphItem {
     /**  画笔颜色 */
     get strokeColor(): SColor {
         return this._strokeColor;
-    }
+    } // Get strokeColor
     set strokeColor(v: SColor) {
         this._strokeColor = v;
         this.update();
-    }
+    } // Set strokeColor
 
     /** 填充颜色 */
     _fillColor: SColor = new SColor("#1EE887");
     get fillColor(): SColor {
         return this._fillColor;
-    }
+    } // Get fillColor
     set fillColor(v: SColor) {
         this._fillColor = v;
         this.update();
-    }
+    } // Set fillColor
 
     /** 边框样式 */
     _lineStyle: SLineStyle = SLineStyle.Solid;
     get lineStyle(): SLineStyle {
         return this._lineStyle;
-    }
+    } // Get lineStyle
     set lineStyle(v: SLineStyle) {
         this._lineStyle = v;
         this.update();
-    }
+    } // Set lineStyle
 
-    /** 边框的宽 只可输入像素宽*/
+    /** 边框的宽 只可输入像素宽 */
     _lineWidth: number = 4;
     get lineWidth(): number {
         return this._lineWidth;
-    }
+    } // Get lineWidth
     set lineWidth(v: number) {
         this._lineWidth = v;
         this.update();
-    }
+    } // Set lineWidth
 
-    /** 是否闭合    */
+    /** 是否闭合 */
     closeFlag: boolean = false;
-    /** 鼠标移动点  */
+    /** 鼠标移动点 */
     private lastPoint: SPoint | null = null;
     /** 当前鼠标获取顶点对应索引 */
     private curIndex: number = -1;
@@ -135,11 +133,11 @@ export class SPolygonItem extends SGraphItem {
     private curPoint: null | SPoint = null;
     /** 灵敏像素 */
     private len: number = 10;
-    /** 场景像素 内部将灵敏像素换算为场景实际距离  */
+    /** 场景像素 内部将灵敏像素换算为场景实际距离 */
     private scenceLen: number = 15;
-    /** 场景像素  */
+    /** 场景像素 */
     private isAlt: boolean = false;
-    /** undoredo堆栈 */
+    /** undo/redo堆栈 */
     protected undoStack: SUndoStack = new SUndoStack();
 
     /**

+ 22 - 2
persagy-web-big/src/items/SPolylineItem.ts

@@ -32,7 +32,8 @@ import {
     SGraphItem,
     SGraphPointListDelete,
     SGraphPointListInsert,
-    SGraphPointListUpdate
+    SGraphPointListUpdate,
+    SLineStyle
 } from "@persagy-web/graph";
 
 /**
@@ -90,6 +91,15 @@ export class SPolylineItem extends SGraphItem {
         this._lineWidth = v;
         this.update();
     }
+    /** 边框样式 */
+    _lineStyle: SLineStyle = SLineStyle.Solid;
+    get lineStyle(): SLineStyle {
+        return this._lineStyle;
+    }
+    set lineStyle(v: SLineStyle) {
+        this._lineStyle = v;
+        this.update();
+    }
     /** 全局灵敏度   */
     dis: number = 10;
     /** 灵敏度转换为场景长度  */
@@ -541,6 +551,17 @@ 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)
+            ];
+        }
         painter.pen.color = this.strokeColor;
         painter.drawPolyline(this.pointList);
     } // Function drawBaseLine()
@@ -562,7 +583,6 @@ export class SPolylineItem extends SGraphItem {
                 this.pointList[this.pointList.length - 1],
                 this.lastPoint
             );
-            // 编辑状态
             this.pointList.forEach((t, i): void => {
                 painter.brush.color = SColor.White;
                 if (i == this.curIndex) {

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

@@ -33,8 +33,7 @@ import {
     STextAlign
 } from "@persagy-web/draw";
 import { Space } from "../../types/floor/Space";
-import { ItemOrder } from "../..";
-import { ItemColor } from "../..";
+import { ItemOrder, ItemColor } from "../..";
 import { SGraphItem } from "@persagy-web/graph";
 
 /**

+ 1 - 2
persagy-web-big/src/items/floor/SSpaceItemSS.ts

@@ -34,8 +34,7 @@ import {
     STextAlign
 } from "@persagy-web/draw";
 import { Space } from "../../types/floor/Space";
-import { ItemOrder } from "../..";
-import { ItemColor } from "../..";
+import { ItemOrder, ItemColor } from "../..";
 import { SGraphItem } from "@persagy-web/graph";
 
 /**