瀏覽代碼

提取功能 及item 调整

haojianlong 4 年之前
父節點
當前提交
21ae548a7e

+ 0 - 3
src/components/baseEditer.vue

@@ -122,11 +122,9 @@ export default {
       bus.$on("changebackColor", val => {
         this.scene.updatedbackColor(val);
       });
-<<<<<<< HEAD
       bus.$on("deleiteItem", () => {
         this.scene.deleiteItem();
       });
-=======
       bus.$on("extractItem", () => {
         const map = {}
         this.fParser.spaceList.forEach(t => {
@@ -148,7 +146,6 @@ export default {
         }
         bus.$emit('exportItem',data)
       })
->>>>>>> 21575eaae2b540d7cb1e3e4401e1dbc90a7d279a
     }
   },
   watch: {

+ 3 - 3
src/components/mapClass/EditScence.ts

@@ -1,11 +1,11 @@
 import { SMouseEvent, SUndoStack } from "@saga-web/base";
 import { SGraphScene,SGraphLayoutType } from '@saga-web/graph/lib';
-import { SPoint, SFont } from '@saga-web/draw/lib';
 import { SFloorParser, SLineItem, SPolylineItem, SItemStatus, ItemOrder } from "@saga-web/big";
 import { SGraphItem, SImageItem, STextItem, SGraphPointListInsert, SGraphPointListDelete, SGraphPointListUpdate, SGraphAddCommand } from "@saga-web/graph/lib";
 import { SPolygonItem } from "./SPolygonItem";
-import { TipelineItem } from "@/lib/TipelineItem";
-import { SImgTextItem } from "@/lib/SImgTextItem"
+import { TipelineItem } from "@/lib/items/TipelineItem";
+import { SImgTextItem } from "@/lib/items/SImgTextItem"
+import { SPoint, SFont } from '@saga-web/draw/lib';
 
 
 /**

+ 5 - 5
src/lib/FloorScene.ts

@@ -1,10 +1,10 @@
-import { SGraphScene } from '@saga-web/graph/lib';
+import { SGraphScene, SAnchorItem } from '@saga-web/graph/lib';
 import { SMouseEvent } from '@saga-web/base/lib';
-import { SPoint, SPainter, SRect, SColor } from '@saga-web/draw/lib';
-import { SFloorParser, SImageItem, STextItem, SLineItem, SPolylineItem, SAnchorItem, SItemStatus } from "@saga-web/big";
+import { SPoint, SPainter, SRect, SColor } from '@saga-web/draw';
+import { SFloorParser, SLineItem, SPolylineItem, SItemStatus } from "@saga-web/big";
 import { SMathUtil } from '@saga-web/big/lib/utils/SMathUtil';
-import { SImgTextItem } from './SImgTextItem';
-import { TipelineItem } from './TipelineItem';
+import { SImgTextItem } from './items/SImgTextItem';
+import { TipelineItem } from './items/TipelineItem';
 
 export class FloorScene extends SGraphScene {
 

+ 13 - 0
src/lib/enums/SLineStyle.ts

@@ -0,0 +1,13 @@
+/**
+ * 线样式
+ *
+ * @author  张宇
+ */
+export enum SLineStyle {
+    /** 实线    */
+    Soild,
+    /** 虚线    */
+    Dashed,
+    /** 点线    */
+    Dotted
+} // Enum SLineStyle

+ 5 - 5
src/lib/SImgTextItem.ts

@@ -1,11 +1,11 @@
 import { SItemStatus } from "@saga-web/big/lib/enums/SItemStatus";
 import { SGraphItem } from '@saga-web/graph/lib/SGraphItem';
-import { STextBaseLine } from '@saga-web/draw/lib/enums/STextBaseLine';
+import { STextBaseLine } from '@saga-web/draw/lib';
 import { SMouseEvent } from '@saga-web/base/lib/SMouseEvent';
-import { SSize } from '@saga-web/draw/lib/types/SSize';
-import { SPainter } from '@saga-web/draw/lib/SPainter';
-import { SColor } from '@saga-web/draw/lib/SColor';
-import { SRect } from '@saga-web/draw/lib/types/SRect';
+import { SSize } from '@saga-web/draw/lib';
+import { SPainter } from '@saga-web/draw/lib';
+import { SColor } from '@saga-web/draw/lib';
+import { SRect } from '@saga-web/draw/lib';
 import { SObjectItem, SImageItem, STextItem, SAnchorItem } from '@saga-web/graph/lib';
 
 /**

+ 32 - 0
src/lib/items/STextMarkerItem.ts

@@ -1,6 +1,7 @@
 import { SGraphItem, STextItem } from "@saga-web/graph/lib";
 import { SPainter, SColor } from "@saga-web/draw";
 import { Marker } from '../types/Marker';
+import { SLineStyle } from '../enums/SLineStyle';
 
 /**
  * 标识对象Item(文本类型)
@@ -11,6 +12,26 @@ export class STextMarkerItem extends STextItem {
     /** 标识对象数据 */
     data: Marker;
 
+    /** 边框宽度 */
+    private _lineWidth: number = 1;
+    get lineWidth(): number {
+        return this._lineWidth;
+    }
+    set lineWidth(v: number) {
+        this._lineWidth = v;
+        this.update();
+    }
+    
+    /** 边框样式    */
+    private _borderStyle: SLineStyle = SLineStyle.Soild;
+    get borderStyle(): SLineStyle {
+        return this._borderStyle;
+    }
+    set borderStyle(v: SLineStyle) {
+        this._borderStyle = v;
+        this.update();
+    }
+
     /** x轴缩放属性 */
     _scaleX: number = 1;
     get scaleX(): number {
@@ -119,6 +140,17 @@ export class STextMarkerItem extends STextItem {
         painter.font = this.font;
         painter.scale(this.scaleX, this.scaleY);
         painter.rotate(this.rolate);
+        if (this.borderStyle == SLineStyle.Dashed) {
+            painter.pen.lineDash = [
+                painter.toPx(this.lineWidth * 3),
+                painter.toPx(this.lineWidth * 7)
+            ];
+        } else if (this.borderStyle == SLineStyle.Dotted) {
+            painter.pen.lineDash = [
+                painter.toPx(this.lineWidth),
+                painter.toPx(this.lineWidth)
+            ];
+        }
         this.drawFormatText(painter);
     } // Function onDraw()
 } // Class STextMarkerItem

+ 10 - 8
src/lib/TipelineItem.ts

@@ -1,5 +1,7 @@
-import { SPolylineItem, SAnchorItem } from '@saga-web/big/lib';
-import { SPainter, SColor } from '@saga-web/draw/lib';
+import { SPolylineItem } from '@saga-web/big/lib';
+import { SPainter, SColor } from '@saga-web/draw';
+import { SAnchorItem, SGraphItem } from '@saga-web/graph/lib';
+import { Relation } from '../types/Relation';
 
 /**
  * 管道item
@@ -10,7 +12,9 @@ export class TipelineItem extends SPolylineItem {
   startAnchor: SAnchorItem | null = null;
   /** 结束锚点  */
   endAnchor: SAnchorItem | null = null;
-
+  /** 数据存储  */
+  data: Relation | null = null;
+  /** 接收事件作出修改  */
   changePos() {
     if (this.startAnchor) {
       // 判断删除equip后,不移动
@@ -28,10 +32,8 @@ export class TipelineItem extends SPolylineItem {
     }
   }
 
-  // onDraw(painter:SPainter){
-  //   if (this.startAnchor) {
-
-  //   }
-  //   if (this.endAnchor) 
+  // constructor(parent: SGraphItem | null, data: Relation) {
+  //   super(parent, data.PointList);
+  //   this.data = data;
   // }
 }

+ 9 - 8
src/lib/parsers/STopologyParser.ts

@@ -12,6 +12,7 @@ import { SImageLegendItem } from '../items/SImageLegendItem';
 import { SImageMarkerItem } from '../items/SImageMarkerItem';
 import { SLineMarkerItem } from '../items/SLineMarkerItem';
 import { STextMarkerItem } from '../items/STextMarkerItem';
+import { TipelineItem } from '../items/TipelineItem';
 
 /**
  * 拓扑图信息解析器
@@ -67,16 +68,16 @@ export class STopologyParser extends SParser {
      * */
     private addLegend(t: Legend): void {
         if (t.GraphElementType == SGraphElementType.None) {
-            let item = this.factory.createNoneLegend(t);
+            let item = new SNoneLegendItem(null, t);
             this.noneLegendList.push(item);
         } else if (t.GraphElementType == SGraphElementType.Line) {
-            let item = this.factory.createLineLegend(t);
+            let item = new SLineLegendItem(null, t)
             this.lineLegendList.push(item);
         } else if (t.GraphElementType == SGraphElementType.Zone) {
-            let item = this.factory.createZoneLegend(t);
+            let item = new SZoneLegendItem(null, t);
             this.zoneLegendList.push(item);
         } else if (t.GraphElementType == SGraphElementType.Image) {
-            let item = this.factory.createImageLegend(t);
+            let item = new SImageLegendItem(null, t);
             this.imageLegendList.push(item);
         }
     } // Function addNode()
@@ -88,13 +89,13 @@ export class STopologyParser extends SParser {
      * */
     private addMarker(t: Marker): void {
         if (t.Type == SMarkerType.Image) {
-            let item = this.factory.createImageMarker(t);
+            let item = new SImageMarkerItem(null, t);
             this.imageMarkerList.push(item);
         } else if (t.Type == SMarkerType.Line) {
-            let item = this.factory.createLineMarker(t);
+            let item = new SLineMarkerItem(null, t);
             this.lineMarkerList.push(item);
         } else if (t.Type == SMarkerType.Text) {
-            let item = this.factory.createTextMarker(t);
+            let item = new STextMarkerItem(null, t);
             this.textMarkerList.push(item);
         }
     } // Function addMarker()
@@ -105,7 +106,7 @@ export class STopologyParser extends SParser {
      * @param   t       管线关系对象数据
      * */
     private addRelation(t: Relation): void {
-        let item = this.factory.createRelation(t);
+        let item = new TipelineItem(null, t);
         this.relationList.push(item);
     } // Function addRelation()
 } // class STopologyParser

+ 1 - 1
src/lib/types/Relation.ts

@@ -49,5 +49,5 @@ export interface Relation {
     /** 线的顶点坐标 */
     PointList: Point[];
     /** 线的绘图样式 */
-    Style?: string;
+    Style?: any;
 } // Interface Relation