YaolongHan 4 years ago
parent
commit
2a363b307b

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

@@ -10,6 +10,7 @@ import { SImageMarkerItem } from "@/lib/items/SImageMarkerItem"
 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';
 
 /**
  * 在线绘图
@@ -71,9 +72,9 @@ export class EditScence extends SGraphScene {
      */
     listChange(obj: any) {
         let itemType: string = 'equipment'
-        if (obj.itemList[0] instanceof STextItem) {
+        if (obj.itemList[0] instanceof STextMarkerItem) {
             itemType = 'text'
-        } else if (obj.itemList[0] instanceof SImageItem) {
+        } else if (obj.itemList[0] instanceof SImageMarkerItem) {
             itemType = 'images'
         } else if (obj.itemList[0] instanceof SLineItem) {
             itemType = 'line'
@@ -208,7 +209,21 @@ export class EditScence extends SGraphScene {
      * 增加文字item
      */
     addTextItem(event: SMouseEvent): void {
-        const item = new SImageLegendItem(null, '请在右侧属性栏输入文字!');
+        const data = {
+            /** ID */
+            ID:'456',
+            /** 名称  */
+            Name: '文本',
+            /** 图标(Image),线类型(Line) */
+            Type: "Text",
+            /** 位置  */
+            Pos: {X: event.x, Y: event.y},
+            /** 由应用自己定义  */
+            Properties:{
+                Text: '请在右侧属性栏输入文字!'
+            }
+        }
+        const item = new STextMarkerItem(null, data);
         item.moveTo(event.x, event.y);
         item.selectable = true;
         item.moveable = true;

+ 3 - 66
src/lib/items/SLineMarkerItem.ts

@@ -1,7 +1,7 @@
 
 import { SGraphItem } from "@saga-web/graph/lib";
 import { SPoint } from "@saga-web/draw/lib";
-import { SPolylineItem } from '@saga-web/big/lib';
+import { SLineItem } from '@saga-web/big/lib';
 import { Marker } from '../types/Marker';
 
 /**
@@ -9,67 +9,10 @@ import { Marker } from '../types/Marker';
  *
  * * @author  张宇(taohuzy@163.com)
  */
-export class SLineMarkerItem extends SPolylineItem {
+export class SLineMarkerItem extends SLineItem {
     /** 标识对象数据 */
     data: Marker;
 
-    /** x轴缩放属性 */
-    // _scaleX: number = 1;
-    // get scaleX(): number {
-    //     return this._scaleX;
-    // }
-    // set scaleX(v: number) {
-    //     this._scaleX = v;
-    //     if (this.data.Scale) {
-    //         this.data.Scale.X = v;
-    //     }
-    //     this.update();
-    // }
-
-    /** y轴缩放属性 */
-    // _scaleY: number = 1;
-    // get scaleY(): number {
-    //     return this._scaleY;
-    // }
-    // set scaleY(v: number) {
-    //     this._scaleY = v;
-    //     if (this.data.Scale) {
-    //         this.data.Scale.Y = v;
-    //     }
-    //     this.update();
-    // }
-
-    /** y轴旋转属性 */
-    // _rolate: number = 0;
-    // get rolate(): number {
-    //     return this._rolate;
-    // }
-    // set rolate(v: number) {
-    //     this._rolate = v;
-    //     if (this.data.Rolate) {
-    //         this.data.Rolate.Z = v;
-    //     }
-    //     this.update();
-    // }
-
-    set name(v: string) {
-        this.data.Name = v;
-    }
-
-    set line(arr: SPoint[]) {
-        if (this.data.Properties) {
-            this.data.Properties.Line = arr;
-        }
-    }
-
-    set x(v: number) {
-        this.data.Pos.X = v;
-    }
-
-    set y(v: number) {
-        this.data.Pos.Y = v;
-    }
-
     set width(v: number) {
         if (this.data.Size) {
             this.data.Size.Width = v;
@@ -92,14 +35,8 @@ export class SLineMarkerItem extends SPolylineItem {
         super(parent,[]);
         this.data = data;
         this.id = data.ID;
+        this.name = data.Name;
         this.moveTo(data.Pos.X, data.Pos.Y);
-        // if (data.Scale) {
-        //     this.scaleX = data.Scale.X;
-        //     this.scaleY = data.Scale.Y;
-        // }
-        // if (data.Rolate && data.Rolate.Z) {
-        //     this.rolate = data.Rolate.Z;
-        // }
         if (data.Size) {
             this.width = data.Size.Width;
             this.height = data.Size.Height;

+ 9 - 81
src/lib/items/STextMarkerItem.ts

@@ -32,75 +32,6 @@ export class STextMarkerItem extends STextItem {
         this.update();
     }
 
-    /** x轴缩放属性 */
-    // _scaleX: number = 1;
-    // get scaleX(): number {
-    //     return this._scaleX;
-    // }
-    // set scaleX(v: number) {
-    //     this._scaleX = v;
-    //     if (this.data.Scale) {
-    //         this.data.Scale.X = v;
-    //     }
-    //     this.update();
-    // }
-
-    /** y轴缩放属性 */
-    // _scaleY: number = 1;
-    // get scaleY(): number {
-    //     return this._scaleY;
-    // }
-    // set scaleY(v: number) {
-    //     this._scaleY = v;
-    //     if (this.data.Scale) {
-    //         this.data.Scale.Y = v;
-    //     }
-    //     this.update();
-    // }
-
-    /** y轴旋转属性 */
-    // _rolate: number = 0;
-    // get rolate(): number {
-    //     return this._rolate;
-    // }
-    // set rolate(v: number) {
-    //     this._rolate = v;
-    //     if (this.data.Rolate) {
-    //         this.data.Rolate.Z = v;
-    //     }
-    //     this.update();
-    // }
-
-    set name(v: string) {
-        this.data.Name = v;
-    }
-
-    set text(v: string) {
-        if (this.data.Properties) {
-            this.data.Properties.Text = v;
-        }
-    }
-
-    set x(v: number) {
-        this.data.Pos.X = v;
-    }
-
-    set y(v: number) {
-        this.data.Pos.Y = v;
-    }
-
-    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;
-        }
-    }
-
     /**
      * 构造函数
      *
@@ -111,25 +42,24 @@ export class STextMarkerItem extends STextItem {
         super(parent);
         this.data = data;
         this.id = data.ID;
+        this.name = data.Name;
         this.moveTo(data.Pos.X, data.Pos.Y);
-        // if (data.Scale) {
-        //     this.scaleX = data.Scale.X;
-        //     this.scaleY = data.Scale.Y;
-        // }
-        // if (data.Rolate && data.Rolate.Z) {
-        //     this.rolate = data.Rolate.Z;
-        // }
         if (data.Size) {
             this.width = data.Size.Width;
             this.height = data.Size.Height;
         }
         if (data.Properties && data.Properties.Text) {
-            if (data.Properties.Text instanceof String) {
-                this.text = data.Properties.Text;
-            }
+            this.text = data.Properties.Text;
         }
     } // Constructor
 
+    toData(): Marker {
+        this.data.Pos = {X: this.x, Y: this.y};
+        this.data.Size = {Width: this.width, Height: this.height};
+        this.data.Properties.Text = this.text;
+        return this.data;
+    }
+
     /**
      * Item绘制操作
      *
@@ -139,8 +69,6 @@ export class STextMarkerItem extends STextItem {
         // 绘制文本
         painter.brush.color = new SColor(this.color);
         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),

+ 2 - 2
src/lib/items/TipelineItem.ts

@@ -3,7 +3,7 @@ import { SPainter, SColor } from '@saga-web/draw';
 import { SAnchorItem, SGraphItem } from '@saga-web/graph/lib';
 import { Relation } from '../types/Relation';
 import { SPoint } from "@saga-web/draw/lib";
-import {Point} from "@saga-web/big/lib/types/Point";
+import { Point } from "@saga-web/big/lib/types/Point";
 
 /**
  * 管道item
@@ -115,7 +115,7 @@ export class TipelineItem extends SPolylineItem {
   }
 
   /** 获取data数据  */
-  getData(): Relation | null {
+  toData(): Relation | null {
     let pointList:Point[] = this.pointList.map(item => {
       return {
         X: item.x,