Prechádzať zdrojové kódy

底层新增todata;big结构调整 万达item等移出包至项目中

haojianlong 4 rokov pred
rodič
commit
d70bffe9a4

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

@@ -1,6 +1,6 @@
 {
     "name": "@saga-web/big",
-    "version": "1.0.35",
+    "version": "1.0.36",
     "description": "上格云建筑信息化库",
     "main": "lib/index.js",
     "types": "lib/index.d.js",
@@ -42,6 +42,6 @@
         "typescript": "^3.9.3"
     },
     "dependencies": {
-        "@saga-web/graph": "2.1.78"
+        "@saga-web/graph": "2.1.79"
     }
 }

+ 2 - 14
saga-web-big/src/index.ts

@@ -21,13 +21,7 @@ import { SPolylineItem } from "./items/SPolylineItem";
 import { SLineItem } from "./items/SLineItem";
 import { SRelationState } from "./enums/SRelationState";
 import { SItemStatus } from "./enums/SItemStatus";
-import { SNoneLegendItem } from "./items/topology/SNoneLegendItem";
-import { SLineLegendItem } from "./items/topology/SLineLegendItem";
-import { SZoneLegendItem } from "./items/topology/SZoneLegendItem";
-import { SImageLegendItem } from "./items/topology/SImageLegendItem";
-import { SImageMarkerItem } from "./items/topology/SImageMarkerItem";
-import { SLineMarkerItem } from "./items/topology/SLineMarkerItem";
-import { STextMarkerItem } from "./items/topology/STextMarkerItem";
+import { SPolygonItem } from "./items/SPolygonItem";
 
 export {
     SCompassItem,
@@ -53,11 +47,5 @@ export {
     SIconTextItem,
     SRelationState,
     SItemStatus,
-    SNoneLegendItem,
-    SLineLegendItem,
-    SZoneLegendItem,
-    SImageLegendItem,
-    SImageMarkerItem,
-    SLineMarkerItem,
-    STextMarkerItem
+    SPolygonItem
 };

+ 167 - 14
saga-web-big/src/items/SIconTextItem.ts

@@ -1,31 +1,184 @@
-import { SMouseEvent } from "@saga-web/base/lib";
-import { SGraphItem } from "@saga-web/graph/lib";
+import {
+    SObjectItem,
+    SImageItem,
+    STextItem,
+    SAnchorItem,
+    SGraphItem
+} from "@saga-web/graph/lib";
+import { SItemStatus } from "..";
+import { SMouseEvent } from "@saga-web/base";
+import { SSize, SRect, SPainter, SColor } from "@saga-web/draw";
 
 /**
- *  图标+文字item
+ * 图例item  icon
  *
- * * @author  郝建龙(1061851420@qq.com)
- */
-export class SIconTextItem extends SGraphItem {
+ * */
+export class SIconTextItem extends SObjectItem {
+    /** item状态  */
+    _status: SItemStatus = SItemStatus.Normal;
+    get status(): SItemStatus {
+        return this._status;
+    }
+    set status(v: SItemStatus) {
+        this._status = v;
+        this.update();
+    }
+
+    /** 是否显示文字  */
+    _showText: boolean = true;
+    get showText(): boolean {
+        return this._showText;
+    }
+    set showText(v: boolean) {
+        if (v === this._showText) {
+            return;
+        }
+        this._showText = v;
+        if (v) {
+            this.textItem.show();
+        } else {
+            this.textItem.hide();
+        }
+    }
+
+    /** X轴坐标 */
+    get x(): number {
+        return this.pos.x;
+    } // Get x
+    set x(v: number) {
+        this.pos.x = v;
+        this.$emit("changePos");
+        this.update();
+    } // Set x
+    /** Y轴坐标 */
+    get y(): number {
+        return this.pos.y;
+    } // Get y
+    set y(v: number) {
+        this.pos.y = v;
+        this.$emit("changePos");
+        this.update();
+    } // Set y
+
+    /** 是否显示锚点  */
+    _showAnchor: boolean = false;
+    get showAnchor(): boolean {
+        return this._showAnchor;
+    }
+    set showAnchor(v: boolean) {
+        this._showAnchor = v;
+        this.anchorList.forEach(t => {
+            t.visible = v;
+        });
+    }
+
+    get text(): string {
+        return this.textItem.text;
+    }
+    set text(v: string) {
+        this.textItem.text = v;
+        this.update();
+    }
+
+    /** img Item    */
+    img: SImageItem = new SImageItem(this);
+
+    /** text item   */
+    textItem: STextItem = new STextItem(this);
+
     /**
-     * 构造函数
+     * 构造
      *
-     *  @param parent    指向父对象
      * */
     constructor(parent: SGraphItem | null) {
         super(parent);
+        this.img.url = `http://adm.sagacloud.cn:8080/doc/assets/img/logo.png`;
+        this.img.width = 32;
+        this.img.height = 32;
+        let anchorPoint = [
+            { x: 0, y: this.img.height / 2 },
+            { x: 0, y: -this.img.height / 2 },
+            { x: -this.img.width / 2, y: 0 },
+            { x: this.img.width / 2, y: 0 }
+        ];
+        this.anchorList = anchorPoint.map(t => {
+            let item = new SAnchorItem(this);
+            item.moveTo(t.x, t.y);
+            return item;
+        });
+        this.update();
+        this.textItem.text = "请填写文本";
+        this.textItem.moveTo(16, -6);
+        this.moveable = true;
+        this.selectable = true;
+        this.isTransform = false;
+        this.textItem.enabled = false;
+        this.img.enabled = false;
     }
 
     /**
      * 鼠标按下事件
      *
-     * @param	event         事件参数
-     * @return	boolean
-     */
+     * */
     onMouseDown(event: SMouseEvent): boolean {
-        this.$emit("mousedown");
         console.log(this);
-        this.update();
+        if (this.status == SItemStatus.Normal) {
+            return super.onMouseDown(event);
+        } else if (this.status == SItemStatus.Edit) {
+            return super.onMouseDown(event);
+        }
         return true;
     } // Function onMouseDown()
-} // Class SImageItem
+
+    /**
+     * 宽高发发生变化
+     *
+     * @param   oldSize 改之前的大小
+     * @param   newSize 改之后大小
+     * */
+    onResize(oldSize: SSize, newSize: SSize) {
+        console.log(arguments);
+    } // Function onResize()
+
+    /**
+     * 鼠标双击事件
+     *
+     * @param   event   鼠标事件
+     * @return  是否处理事件
+     * */
+    onDoubleClick(event: SMouseEvent): boolean {
+        this.status = SItemStatus.Edit;
+        return true;
+    } // Function onDoubleClick()
+
+    /**
+     * 宽高发生变化
+     *
+     * @return  SRect   所有子对象的并集
+     * */
+    boundingRect(): SRect {
+        let rect = this.img
+            .boundingRect()
+            .adjusted(this.img.pos.x, this.img.pos.y, 0, 0);
+        if (this.showText) {
+            rect = rect.unioned(
+                this.textItem
+                    .boundingRect()
+                    .adjusted(this.textItem.pos.x, this.textItem.pos.y, 0, 0)
+            );
+        }
+        return rect;
+    } // Function boundingRect()
+
+    /**
+     * Item绘制操作
+     *
+     * @param   painter painter对象
+     */
+    onDraw(painter: SPainter): void {
+        painter.pen.lineWidth = painter.toPx(1);
+        painter.pen.color = new SColor("#00FF00");
+        painter.brush.color = SColor.Transparent;
+        painter.drawRect(this.boundingRect());
+    } // Function onDraw()
+}

+ 2 - 2
saga-web-big/src/items/topology/SImageLegendItem.ts

@@ -1,13 +1,13 @@
 import { Legend } from "../../types/topology/Legend";
 import { SGraphItem } from "@saga-web/graph/lib";
-import { SLineItem } from "../SLineItem"; // 图标item
+import { SIconTextItem } from "../SIconTextItem"; // 图标item
 
 /**
  * 图例节点Item(图标类型)
  *
  * * @author  张宇(taohuzy@163.com)
  */
-export class SImageLegendItem extends SGraphItem {
+export class SImageLegendItem extends SIconTextItem {
     /** 图例节点对象数据 */
     data: Legend;
 

+ 2 - 2
saga-web-big/src/items/topology/SImageMarkerItem.ts

@@ -116,9 +116,9 @@ export class SImageMarkerItem extends SImageItem {
     onDraw(painter: SPainter): void {
         if (this.img) {
             // 要绘制图片的宽度
-            let width: number = 0;
+            let width = 0;
             // 要绘制图片的宽度
-            let height: number = 0;
+            let height = 0;
             // 图片item的宽高比
             let itemAspectRatio: number = this.width / this.height;
             // 原始图片的宽高比

+ 1 - 1
saga-web-big/src/items/topology/SLineLegendItem.ts

@@ -1,7 +1,7 @@
 import { Legend } from "../../types/topology/Legend";
 import { SGraphItem } from "@saga-web/graph/lib";
 import { SLineItem } from "../SLineItem";
-import {SPoint} from "@saga-web/draw/lib";
+import { SPoint } from "@saga-web/draw/lib";
 
 /**
  * 图例节点Item(线类型)

+ 3 - 3
saga-web-big/src/items/topology/SLineMarkerItem.ts

@@ -1,14 +1,14 @@
 import { Marker } from "../../types/topology/Marker";
 import { SGraphItem } from "@saga-web/graph/lib";
-import { SLineItem } from "../SLineItem";
 import { SPoint } from "@saga-web/draw/lib";
+import { SPolylineItem } from "../SPolylineItem";
 
 /**
  * 标识对象Item(线类型)
  *
  * * @author  张宇(taohuzy@163.com)
  */
-export class SLineMarkerItem extends SLineItem {
+export class SLineMarkerItem extends SPolylineItem {
     /** 标识对象数据 */
     data: Marker;
 
@@ -88,7 +88,7 @@ export class SLineMarkerItem extends SLineItem {
      * @param data      标识对象数据
      */
     constructor(parent: SGraphItem | null, data: Marker) {
-        super(parent);
+        super(parent, []);
         this.data = data;
         this.moveTo(data.Pos.X, data.Pos.Y);
         if (this.data.Scale) {

+ 2 - 2
saga-web-big/src/items/topology/SZoneLegendItem.ts

@@ -1,13 +1,13 @@
 import { Legend } from "../../types/topology/Legend";
 import { SGraphItem } from "@saga-web/graph/lib";
-import { SLineItem } from "../SLineItem"; // 多边形item
+import { SPolygonItem } from "../SPolygonItem"; // 多边形item
 
 /**
  * 图例节点Item(区域类型)
  *
  * * @author  张宇(taohuzy@163.com)
  */
-export class SZoneLegendItem extends SGraphItem {
+export class SZoneLegendItem extends SPolygonItem {
     /** 图例节点对象数据 */
     data: Legend;
 

+ 2 - 109
saga-web-big/src/parser/STopologyParser.ts

@@ -1,114 +1,7 @@
-import { SParser } from "./SParser";
-import { ElementData } from "../types/ElementData";
-import { Legend } from "../types/topology/Legend";
-import { Marker } from "../types/topology/Marker";
-import { Relation } from "../types/topology/Relation";
-import {
-    SImageLegendItem,
-    SLineLegendItem,
-    SNoneLegendItem,
-    SRelation,
-    SZoneLegendItem,
-    SImageMarkerItem,
-    SLineMarkerItem,
-    STextMarkerItem
-} from "..";
-import { SGraphElementType } from "../enums/SGraphElementType";
-import { SMarkerType } from "../enums/SMarkerType";
-
 /**
  * 拓扑图信息解析器
  *
  */
-export class STopologyParser extends SParser {
-    /** 图例list(非图例类型)   */
-    noneLegendList: SNoneLegendItem[] = [];
-    /** 图例list(线类型)   */
-    lineLegendList: SLineLegendItem[] = [];
-    /** 图例list(区域类型)   */
-    zoneLegendList: SZoneLegendItem[] = [];
-    /** 图例list(图标类型)   */
-    imageLegendList: SImageLegendItem[] = [];
-
-    /** 标识list(图类型)   */
-    imageMarkerList: SImageMarkerItem[] = [];
-    /** 标识list(线类型)   */
-    lineMarkerList: SLineMarkerItem[] = [];
-    /** 标识list(文本类型)   */
-    textMarkerList: STextMarkerItem[] = [];
-
-    /** 管线关系对象关系list   */
-    relationList: SRelation[] = [];
-
-    /**
-     * 解析数据
-     *
-     * @param   data    系统图数据
-     * */
-    parseData(data: ElementData): void {
-        if (data.Nodes) {
-            data.Nodes.forEach((t: Legend): void => {
-                this.addLegend(t);
-            });
-        }
-        if (data.Markers) {
-            data.Markers.forEach((t: Marker): void => {
-                this.addMarker(t);
-            });
-        }
-        if (data.Relations) {
-            data.Relations.forEach((t: Relation): void => {
-                this.addRelation(t);
-            });
-        }
-    } // Function parseData()
-
-    /**
-     * 添加图例节点至场景中
-     *
-     * @param   t       图例节点数据
-     * */
-    private addLegend(t: Legend): void {
-        if (t.GraphElementType == SGraphElementType.None) {
-            let item = this.factory.createNoneLegend(t);
-            this.noneLegendList.push(item);
-        } else if (t.GraphElementType == SGraphElementType.Line) {
-            let item = this.factory.createLineLegend(t);
-            this.lineLegendList.push(item);
-        } else if (t.GraphElementType == SGraphElementType.Zone) {
-            let item = this.factory.createZoneLegend(t);
-            this.zoneLegendList.push(item);
-        } else if (t.GraphElementType == SGraphElementType.Image) {
-            let item = this.factory.createImageLegend(t);
-            this.imageLegendList.push(item);
-        }
-    } // Function addNode()
-
-    /**
-     * 添加标识对象至场景中
-     *
-     * @param   t       标识对象数据
-     * */
-    private addMarker(t: Marker): void {
-        if (t.Type == SMarkerType.Image) {
-            let item = this.factory.createImageMarker(t);
-            this.imageMarkerList.push(item);
-        } else if (t.Type == SMarkerType.Line) {
-            let item = this.factory.createLineMarker(t);
-            this.lineMarkerList.push(item);
-        } else if (t.Type == SMarkerType.Text) {
-            let item = this.factory.createTextMarker(t);
-            this.textMarkerList.push(item);
-        }
-    } // Function addMarker()
+import { SParser } from "./SParser";
 
-    /**
-     * 添加管线关系至场景中
-     *
-     * @param   t       管线关系对象数据
-     * */
-    private addRelation(t: Relation): void {
-        let item = this.factory.createRelation(t);
-        this.relationList.push(item);
-    } // Function addRelation()
-} // class STopologyParser
+export class STopologyParser extends SParser {} // class STopologyParser

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

@@ -1,6 +1,6 @@
 {
     "name": "@saga-web/feng-map",
-    "version": "1.0.7",
+    "version": "1.0.8",
     "description": "上格云Web平面图。",
     "main": "lib/index.js",
     "types": "lib/index.d.js",
@@ -32,6 +32,6 @@
         "typescript": "^3.9.3"
     },
     "dependencies": {
-        "@saga-web/big": "^1.0.17"
+        "@saga-web/big": "1.0.35"
     }
 }

+ 79 - 3
saga-web-fengmap/src/parser/SFengParser.ts

@@ -64,7 +64,44 @@ export class SFengParser extends SParser {
         120001: "CarPark",
         120008: "ParkingExit",
         120009: "ParkingEntrance",
-        120010: "ParkingExitAndEntrance"
+        120010: "ParkingExitAndEntrance",
+        300005: "SwitchingStation",
+        300006: "DistributionRoom",
+        300007: "StrongElectricWell",
+        300008: "WeakCurrentWell",
+        300009: "AirConditionerEngineRoom",
+        300010: "RefrigerationRoom",
+        300011: "FreshAirRoom",
+        300012: "CompressorRoom",
+        300013: "HeatSourceMachineRoom",
+        300014: "DomesticWaterPumpHouse",
+        300015: "HighLevelWaterTankRoom",
+        300016: "SewageTreatmentRoom",
+        300017: "FirePumpHouse",
+        300018: "WetAlarmValveChamber",
+        300019: "PreActionAlarmValveChamber",
+        300020: "AirSupplyRoom",
+        300021: "ExhaustFanRoom",
+        300022: "MakeUpAirRoom",
+        300023: "BusinessManagementOffice",
+        300024: "NetworkRoom",
+        300025: "Substation",
+        300026: "GeneratorRoom",
+        300027: "TrusteeshipRoom",
+        300028: "HuiyunMachineRoom",
+        300029: "AlarmValveChamber",
+        300030: "ReclaimedWaterMachineRoom",
+        300031: "FireControlRoom",
+        300032: "OilSeparator",
+        300033: "GasBoilerRoom",
+        300034: "GasMeterRoom",
+        300035: "ElevatorMachineRoom",
+        300036: "StaffRestaurant",
+        300037: "DryGarbageRoom",
+        300038: "WetGarbageRoom",
+        300039: "ExpansionWaterTankRoom",
+        200023: "MensBathroom",
+        200022: "WomensToilet"
     };
     /** 蜂鸟:底图应用名称   */
     appName: string = "";
@@ -120,7 +157,44 @@ export class SFengParser extends SParser {
         100003,
         140004,
         170005,
-        120001
+        120001,
+        300005,
+        300006,
+        300007,
+        300008,
+        300009,
+        300010,
+        300011,
+        300012,
+        300013,
+        300014,
+        300015,
+        300016,
+        300017,
+        300018,
+        300019,
+        300020,
+        300021,
+        300022,
+        300023,
+        300024,
+        300025,
+        300026,
+        300027,
+        300028,
+        300029,
+        300030,
+        300031,
+        300032,
+        300033,
+        300034,
+        300035,
+        300036,
+        300037,
+        300038,
+        300039,
+        200023,
+        200022
     ];
     /** 属于柱子类型的typeid   */
     columnType: number[] = [300002];
@@ -208,7 +282,9 @@ export class SFengParser extends SParser {
                                         // @ts-ignore
                                         Points: [this.getAverageVal([outline])]
                                     },
-                                    Type: t.typeID
+                                    Type: t.typeID,
+                                    // @ts-ignore
+                                    Tag: SFengParser.typeIdMap[t.typeID]
                                 });
                             } else if (this.columnType.indexOf(type) > -1) {
                                 // @ts-ignore

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

@@ -1,6 +1,6 @@
 {
     "name": "@saga-web/graph",
-    "version": "2.1.78",
+    "version": "2.1.79",
     "description": "上格云二维图形引擎。",
     "main": "lib/index.js",
     "types": "lib/index.d.js",

+ 8 - 0
saga-web-graph/src/SGraphItem.ts

@@ -526,6 +526,14 @@ export class SGraphItem extends SObject {
      * */
     cancelOperate(): void {} // Function cancelOperate()
 
+    /**
+     * 返回item对应的数据对象
+     *
+     * */
+    toData(): any | null {
+        return null;
+    } // Function toData()
+
     // =================================================================================================================
     // 私有方法
     /**

+ 1 - 1
saga-web-graph/tsconfig.json

@@ -1,6 +1,6 @@
 {
     "compilerOptions": {
-        "target": "es5",                            // Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'.
+        "target": "es6",                            // Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'.
         "module": "commonjs",                       // Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'.
         "outDir": "./lib",                          // 编译后生成的文件目录
         "strict": true,                             // 开启严格的类型检测