YaolongHan 4 роки тому
батько
коміт
c07353db8a

+ 5 - 0
src/components/baseEditer.vue

@@ -97,6 +97,11 @@ export default {
           this.scene.addItem(t);
           this.scene.Markers.push(t);
         });
+        // 增加直线
+        parserData.lineMarkerList.forEach(t => {
+          this.scene.addItem(t);
+          this.scene.Markers.push(t);
+        });
       });
       this.scene.emitChange = this.emitChange;
     },

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

@@ -11,6 +11,7 @@ import { SPoint, SFont } from '@saga-web/draw/lib';
 import { Legend } from '@/lib/types/Legend';
 import { uuid } from "@/components/mapClass/until";
 import { STextMarkerItem } from '@/lib/items/STextMarkerItem';
+import { SLineMarkerItem } from '@/lib/items/SLineMarkerItem';
 
 /**
  * 在线绘图
@@ -76,7 +77,7 @@ export class EditScence extends SGraphScene {
             itemType = 'text'
         } else if (obj.itemList[0] instanceof SImageMarkerItem) {
             itemType = 'images'
-        } else if (obj.itemList[0] instanceof SLineItem) {
+        } else if (obj.itemList[0] instanceof SLineMarkerItem) {
             itemType = 'line'
         } else if (obj.itemList[0] instanceof SPolylineItem) {
             itemType = 'pipeline'
@@ -105,15 +106,30 @@ export class EditScence extends SGraphScene {
      * 增加线段item
      */
     addLine(event: SMouseEvent): boolean {
+        const data = {
+            /** ID */
+            ID:'789',
+            /** 名称  */
+            Name: '直线',
+            /** 图标(Image),线类型(Line) */
+            Type: "Line",
+            /** 位置  */
+            Pos: {X: 0, Y: 0},
+            /** 由应用自己定义  */
+            Properties:{
+                Line: [new SPoint(event.x, event.y)]
+            }
+        }
 
-        const item = new SLineItem(null, new SPoint(event.x, event.y));
+        const item = new SLineMarkerItem(null, data);
         item.status = SItemStatus.Create;
         item.zOrder = ItemOrder.lineOrder;
         item.selectable = true;
         this.addItem(item);
         item.connect("finishCreated", this, this.finishCreated);
         this.grabItem = item;
-        this.undoStack.push(new SGraphAddCommand(this, item));
+        this.Markers.push(item)
+        // this.undoStack.push(new SGraphAddCommand(this, item));
         // item.connect("onMove", this, this.onItemMove.bind(this));
         return true
     }

+ 19 - 17
src/lib/items/SLineMarkerItem.ts

@@ -13,18 +13,6 @@ export class SLineMarkerItem extends SLineItem {
     /** 标识对象数据 */
     data: Marker;
 
-    set width(v: number) {
-        if (this.data.Size) {
-            this.data.Size.Width = v;
-        }
-    }
-
-    set height(v: number) {
-        if (this.data.Size) {
-            this.data.Size.Height = v;
-        }
-    }
-
     /**
      * 构造函数
      *
@@ -32,18 +20,32 @@ export class SLineMarkerItem extends SLineItem {
      * @param data      标识对象数据
      */
     constructor(parent: SGraphItem | null, data: Marker) {
-        super(parent,[]);
+        super(parent);
         this.data = data;
         this.id = data.ID;
         this.name = data.Name;
         this.moveTo(data.Pos.X, data.Pos.Y);
-        if (data.Size) {
-            this.width = data.Size.Width;
-            this.height = data.Size.Height;
-        }
         if (data.Properties && data.Properties.Line) {
             this.line = data.Properties.Line;
         }
+        if (data.Properties && data.Properties.LineWidth) {
+            this.lineWidth = data.Properties.LineWidth;
+        }
+        if (data.Properties && data.Properties.LineStyle) {
+            this.lineStyle = data.Properties.LineStyle;
+        }
+        if (data.Properties && data.Properties.StrokeColor) {
+            this.strokeColor = data.Properties.StrokeColor;
+        }
     } // Constructor
+
+    toData(): Marker {
+        this.data.Pos = {X: this.x, Y: this.y};
+        this.data.Properties.Line = this.line;
+        this.data.Properties.LineWidth = this.lineWidth;
+        this.data.Properties.StrokeColor = this.strokeColor;
+        this.data.Properties.LineStyle = this.lineStyle;
+        return this.data;
+    }
     
 } // Class SLineMarkerItem

+ 3 - 3
src/lib/parsers/STopologyParser.ts

@@ -88,13 +88,13 @@ export class STopologyParser extends SParser {
      * @param   t       标识对象数据
      * */
     private addMarker(t: Marker): void {
-        if (t.Type == 'Image') {
+        if (t.Type == "Image") {
             let item = new SImageMarkerItem(null, t);
             this.imageMarkerList.push(item);
-        } else if (t.Type == SMarkerType.Line) {
+        } else if (t.Type == "Line") {
             let item = new SLineMarkerItem(null, t);
             this.lineMarkerList.push(item);
-        } else if (t.Type == 'Text') {
+        } else if (t.Type == "Text") {
             let item = new STextMarkerItem(null, t);
             this.textMarkerList.push(item);
         }

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

@@ -35,7 +35,7 @@ export interface Marker {
     /** 名称  */
     Name: string;
     /** 图标(Image),线类型(Line) */
-    Type: SMarkerType;
+    Type: string;
     /** 位置  */
     Pos: Point;
     /** 缩放  */