ソースを参照

工具类修改

haojianlong 4 年 前
コミット
a17544873d

+ 3 - 0
persagy-web-big/README.md

@@ -6,6 +6,9 @@ item 展示类及楼层平面图展示
     无特殊说明单版本为跟随依赖版本升级
     |
     |
+    |-- 2.2.51 | -- 获取json文件和解压工具增加传参,是否返回的是原始数据
+    |
+    |
     |-- 2.2.50 | -- 数学计算工具类 计算数组中每一项的交集,并返回外轮廓与内轮廓 算法修改
     |
     |

+ 1 - 1
persagy-web-big/package.json

@@ -1,6 +1,6 @@
 {
     "name": "@persagy-web/big",
-    "version": "2.2.50",
+    "version": "2.2.51",
     "description": "博锐尚格建筑信息化库",
     "main": "lib/index.js",
     "types": "lib/index.d.js",

+ 11 - 11
persagy-web-big/src/items/SPolygonItem.ts

@@ -92,8 +92,8 @@ export class SPolygonItem extends SGraphStyleItem {
     /** 灵敏像素 */
     private len: number = 10;
     /** 场景像素 内部将灵敏像素换算为场景实际距离 */
-    private scenceLen: number = 15;
-    /** 场景像素 */
+    private sceneLen: number = 15;
+    /** shift键是否按下 */
     private isAlt: boolean = false;
     /** undo/redo 堆栈 */
     protected undoStack: SUndoStack = new SUndoStack();
@@ -265,7 +265,7 @@ export class SPolygonItem extends SGraphStyleItem {
                         this.lastPoint.y,
                         this.pointList[0].x,
                         this.pointList[0].y
-                    ) < this.scenceLen
+                    ) < this.sceneLen
                 ) {
                     // 绘制第一个点的顶点块
                     painter.pen.color = SColor.Black;
@@ -318,7 +318,7 @@ export class SPolygonItem extends SGraphStyleItem {
         if (this.isAlt) {
             // 1 判断是否点击在多边形顶点
             let lenIndex = -1; // 当前点击到的点位索引;
-            let curenLen = this.scenceLen; // 当前的灵敏度
+            let curLen = this.sceneLen; // 当前的灵敏度
             this.pointList.forEach((item, index): void => {
                 let dis = SMathUtil.pointDistance(
                     event.x,
@@ -326,8 +326,8 @@ export class SPolygonItem extends SGraphStyleItem {
                     item.x,
                     item.y
                 );
-                if (dis < curenLen) {
-                    curenLen = dis;
+                if (dis < curLen) {
+                    curLen = dis;
                     lenIndex = index;
                 }
             });
@@ -354,7 +354,7 @@ export class SPolygonItem extends SGraphStyleItem {
             this.curIndex = -1;
             this.curPoint = null;
             let lenIndex = -1; // 当前点击到的点位索引;
-            let curenLen = this.scenceLen; // 当前的灵敏度
+            let curLen = this.sceneLen; // 当前的灵敏度
             this.pointList.forEach((item, index): void => {
                 let dis = SMathUtil.pointDistance(
                     event.x,
@@ -362,8 +362,8 @@ export class SPolygonItem extends SGraphStyleItem {
                     item.x,
                     item.y
                 );
-                if (dis < curenLen) {
-                    curenLen = dis;
+                if (dis < curLen) {
+                    curLen = dis;
                     lenIndex = index;
                 }
             });
@@ -398,7 +398,7 @@ export class SPolygonItem extends SGraphStyleItem {
                 // 判断是否有点
                 if (len.Point) {
                     // 点在了多边形的边上
-                    if (len.MinDis <= this.scenceLen) {
+                    if (len.MinDis <= this.sceneLen) {
                         this.pointList.splice(index + 1, 0, len.Point);
                         // 记录新增顶点操作记录压入堆栈
                         this.recordAction(SGraphPointListInsert, [
@@ -625,7 +625,7 @@ export class SPolygonItem extends SGraphStyleItem {
      * @param painter   绘制对象
      */
     onDraw(painter: SPainter): void {
-        this.scenceLen = painter.toPx(this.len);
+        this.sceneLen = painter.toPx(this.len);
         // 当状态为展示状态
         if (this.status == SItemStatus.Normal) {
             // 闭合多边形

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

@@ -25,23 +25,23 @@
  */
 
 import { SColor, SLine, SPainter, SPoint, SRect } from "@persagy-web/draw";
-import { SKeyCode, SMouseEvent, SUndoStack } from "@persagy-web/base";
+import { SMouseEvent, SUndoStack } from "@persagy-web/base";
 import { SItemStatus } from "..";
 import { SMathUtil } from "../utils/SMathUtil";
 import {
     SGraphItem,
     SGraphPointListDelete,
     SGraphPointListInsert,
-    SGraphPointListUpdate,
     SLineStyle
 } from "@persagy-web/graph";
+import { SGraphStyleItem } from "@persagy-web/graph/lib";
 
 /**
  * 折线 item
  *
  * @author  郝建龙 <haojianlong@sagacloud.cn>
  */
-export class SPolylineItem extends SGraphItem {
+export class SPolylineItem extends SGraphStyleItem {
     /** X 坐标最小值 */
     private minX = Number.MAX_SAFE_INTEGER;
     /** X 坐标最大值 */
@@ -65,45 +65,6 @@ export class SPolylineItem extends SGraphItem {
 
     /** 鼠标移动时的点 */
     protected lastPoint: SPoint | null = null;
-    /** 线条颜色 */
-    _strokeColor: SColor = SColor.Black;
-    get strokeColor(): SColor {
-        return this._strokeColor;
-    }
-    set strokeColor(v: SColor) {
-        this._strokeColor = v;
-        this.update();
-    }
-
-    /** 填充色 */
-    _fillColor: SColor = new SColor("#2196f3");
-    get fillColor(): SColor {
-        return this._fillColor;
-    }
-    set fillColor(v: SColor) {
-        this._fillColor = v;
-        this.update();
-    }
-
-    /** 线条宽度 */
-    _lineWidth: number = 1;
-    get lineWidth(): number {
-        return this._lineWidth;
-    }
-    set lineWidth(v: number) {
-        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;
@@ -146,6 +107,7 @@ export class SPolylineItem extends SGraphItem {
         } else {
             this.pointList = list;
         }
+        this.fillColor = new SColor("#2196f3");
     }
 
     /**

+ 8 - 2
persagy-web-big/src/utils/getJsonz.ts

@@ -27,7 +27,13 @@
 import Axios from "axios";
 import unzip from "./unzip";
 
-export default function getJsonz(url: string) {
+/**
+ * 通过路径获取文件
+ *
+ * @param url 文件的路径
+ * @param flag 是否为原始数据
+ */
+export default function getJsonz(url: string, flag = false) {
     return new Promise((resolve, reject): void => {
         Axios({
             method: "get",
@@ -37,7 +43,7 @@ export default function getJsonz(url: string) {
         })
             .then((res: any) => {
                 let blob = res.data;
-                unzip(blob)
+                unzip(blob, flag)
                     .then((jsonData: any) => {
                         resolve(jsonData);
                     })

+ 4 - 3
persagy-web-big/src/utils/unzip.ts

@@ -29,10 +29,11 @@ import unzipBase64 from "./unzipBase64";
 /**
  * 解压数据
  *
- * @param blob     文件
+ * @param blob 文件
+ * @param flag 是否返回原始文件数据
  * @return 解压后的数据
  */
-export default function unzip(blob: any): any {
+export default function unzip(blob: any, flag = false): any {
     let reader = new FileReader();
     reader.readAsBinaryString(blob);
     return new Promise(resolve => {
@@ -45,7 +46,7 @@ export default function unzip(blob: any): any {
                 const data = unGzipData.entityList
                     ? unGzipData.entityList[0].Elements
                     : unGzipData.EntityList[0].Elements;
-                resolve(data);
+                resolve(flag ? unGzipData : data);
             } catch (e) {
                 console.log(e);
                 resolve("error");

+ 1 - 0
persagy-web-graph/src/types/SGraphRect.ts

@@ -32,6 +32,7 @@ import { Style } from "./Style";
  */
 export interface SGraphRect {
     /** item 风格 */
+
     style?: Style;
     /** 矩形左上角 X 坐标 */
     x: number;