Jelajahi Sumber

Merge branch 'develop' of http://39.106.8.246:3003/web/persagy_topo_editer into develop

YaolongHan 4 tahun lalu
induk
melakukan
2d02c26644

+ 11 - 1
src/components/editClass/big-edit/BigEditFactory.ts

@@ -32,7 +32,7 @@ import {
     SBaseRectEdit,
     SBaseTextEdit
 } from "./../edit/";
-import { Marker, Legend, SBaseArrow, SBaseExpainEdit, SBaseEquipment } from "./"
+import {Marker, SBaseArrow, SBaseExpainEdit, SBaseArrowPolyEdit, SBaseEquipment, Legend} from "./"
 import { SItemFactory } from "@persagy-web/big"
 
 /**
@@ -129,6 +129,16 @@ export class BigEditFactory extends SItemFactory {
     } // Function createBasePolygonEdit()
 
     /**
+     * 创建基础基础箭头(折线)
+     *
+     * @param data     数据
+     * @return  注释
+     */
+    createBasePolygonArrowEdit(data: Marker): SBaseArrowPolyEdit {
+        return new SBaseArrowPolyEdit(null, data);
+    } // Function SBaseArrowPolyEdit()
+    
+    /*
     * 创建基础设备
     *
     * @param data     数据

+ 7 - 0
src/components/editClass/big-edit/SBaseEditScene.ts

@@ -406,6 +406,7 @@ export class SBaseEditScene extends SGraphEditScene {
      * @param event   鼠标事件参数
      */
     onMouseUp(event: SMouseEvent): boolean {
+        console.log('-----baseEditScene');
         if (this.grabItem) {
             // 鼠标抬起时,如果grabItem为框选则删除框选item
             if (this.grabItem instanceof SRectSelectItem) {
@@ -416,10 +417,16 @@ export class SBaseEditScene extends SGraphEditScene {
                 if (this.view) {
                     this.view.update()
                 }
+                console.log(1);
+                
                 return true;
             }
+            console.log(2);
+            
             return this.grabItem.onMouseUp(event);
         }
+        console.log(3);
+        
         return super.onMouseUp(event)
     } // Function onMouseUp()
 

+ 2 - 1
src/components/editClass/big-edit/index.ts

@@ -10,4 +10,5 @@ import { Marker } from "./types/Marker"
 import { Relation } from "./types/Relation"
 import { BigEditFactory } from "./BigEditFactory"
 import { SBaseEquipment } from "./items/SBaseEquipment"
-export { SBaseArrow, SBasePipe, SBasePipeUninTool, SBaseEquipment, BigEditFactory, Anchor, Legend, Marker, Relation, ElementData, SBaseEditScene, SBaseExpainEdit }
+import { SBaseArrowPolyEdit } from './items/SBaseArrowPolyEdit'
+export { SBaseArrow, SBasePipe, SBasePipeUninTool, SBaseEquipment, BigEditFactory, Anchor, Legend, Marker, Relation, ElementData, SBaseEditScene, SBaseExpainEdit, SBaseArrowPolyEdit }

+ 27 - 2
src/components/editClass/big-edit/items/SBaseArrowPolyEdit.ts

@@ -28,6 +28,8 @@ import { SMathUtil } from "@persagy-web/graph/lib/utils/SMathUtil";
 import { SColor, SLine, SPainter, SPoint } from '@persagy-web/draw/lib';
 import { SBaseLineEdit } from '../../edit';
 import { SItemStatus } from '@persagy-web/big/lib';
+import { Marker } from '..';
+import { SGraphItem } from '@persagy-web/graph/lib';
 
 /**
  * 箭头编辑(多边形)
@@ -63,6 +65,17 @@ export class SBaseArrowPolyEdit extends SBaseLineEdit {
 	} // Set polyFillColor
 
 	/**
+		 * 构造函数
+		 *
+		 * @param parent    父级
+		 * @param data      坐标集合|第一个点坐标
+		 */
+	constructor(parent: SGraphItem | null, data: Marker) {
+		super(parent, data);
+		this.pointChange();
+	} // Constructor
+
+	/**
 	 * 根据两个顶点生成多边形数组
 	 */
 	pointChange(): void {
@@ -80,7 +93,6 @@ export class SBaseArrowPolyEdit extends SBaseLineEdit {
 			} else {
 				this._ang = line.dy > 0 ? Math.PI / 2 : (3 * Math.PI) / 2;
 			}
-
 			if (this.isSingle) {
 				this.pointList = [
 					new SPoint(0, this.arrowWidth / 2),
@@ -116,11 +128,24 @@ export class SBaseArrowPolyEdit extends SBaseLineEdit {
 	onDraw(painter: SPainter): void {
 		if (this.line.length) {
 			painter.save();
-			painter.pen.lineWidth = painter.toPx(this.lineWidth);
+
+			const lw = painter.toPx(this.lineWidth);
+			painter.pen.lineWidth = lw;
+			this.sceneDis = painter.toPx(this.dis);
+
 			painter.translate(this.line[0].x, this.line[0].y);
 			painter.rotate((this._ang * 180) / Math.PI);
 			painter.pen.color = this.strokeColor;
 			painter.brush.color = this.polyFillColor;
+
+			if (this.selected && this.status == SItemStatus.Normal) {
+				painter.pen.lineWidth = 2 * lw;
+				painter.shadow.shadowBlur = 10;
+				painter.shadow.shadowColor = new SColor(`#00000033`);
+				painter.shadow.shadowOffsetX = 5;
+				painter.shadow.shadowOffsetY = 5;
+			}
+
 			painter.drawPolygon(this.pointList);
 			painter.restore();
 

+ 3 - 1
src/components/editClass/edit/items/SBaseCircleEdit.ts

@@ -195,7 +195,9 @@ export class SBaseCircleEdit extends SGraphEdit {
         this.addPoint(new SPoint(event.x, event.y));
         return true;
       } else {
-        return super.onMouseDown(event);
+        // return super.onMouseDown(event);
+        super.onMouseDown(event);
+        return true;
       }
     }
 

+ 10 - 11
src/components/editClass/edit/items/SBaseLineEdit.ts

@@ -69,7 +69,7 @@ export class SBaseLineEdit extends SGraphEdit {
         this._line = arr;
         this.update();
     } // Set line
-
+    
     /** 是否垂直水平绘制 */
     private _verAndLeve: Boolean = false;
     get verAndLeve(): Boolean {
@@ -144,7 +144,7 @@ export class SBaseLineEdit extends SGraphEdit {
     /** 拖动灵敏度 */
     dis: number = 5;
     /** 拖动灵敏度 */
-    private sceneDis: number = 5;
+    protected sceneDis: number = 5;
     /** 当前点索引 */
     curIndex: number = -1;
     /** 当前点坐标 */
@@ -162,18 +162,15 @@ export class SBaseLineEdit extends SGraphEdit {
         super(parent);
         this.showSelect = false;
         this.data = data;
-        if (data.style) {
+        if (data.style && data.style.default) {
             // 关于顶点
-            if (data.style.line) {
+            if (data.style.default.line) {
                 let setPointList: SPoint[];
-                setPointList = data.style.line.map(i => {
+                setPointList = data.style.default.line.map((i: { x: number; y: number; }) => {
                     return new SPoint(i.x, i.y)
                 });
                 this.line = setPointList;
             }
-        }
-
-        if (data.style && data.style.default) {
             // 颜色
             if (data.style.default.strokeColor) {
                 this.strokeColor = new SColor(data.style.default.strokeColor)
@@ -246,7 +243,9 @@ export class SBaseLineEdit extends SGraphEdit {
 
         if (event.buttons == SMouseButton.LeftButton) {
             if (this.status == SItemStatus.Normal) {
-                return super.onMouseDown(event);
+                // return super.onMouseDown(event);
+                super.onMouseDown(event);
+                return true;
             } else if (this.status == SItemStatus.Edit) {
                 // 判断是否点击到端点上(获取端点索引值)
                 this.findNearestPoint(new SPoint(event.x, event.y));
@@ -438,10 +437,10 @@ export class SBaseLineEdit extends SGraphEdit {
      */
     contains(x: number, y: number): boolean {
         if (this.line.length == 2) {
-            let p = new SPoint(x, y);
+            let p = new SPoint(x, y);            
             if (
                 SMathUtil.pointToLine(p, new SLine(this.line[0], this.line[1]))
-                    .MinDis < this.dis
+                    .MinDis < this.sceneDis
             ) {
                 return true;
             }

+ 21 - 2
src/components/editClass/edit/items/SBasePolygonEdit.ts

@@ -39,7 +39,8 @@ import {
     SPainter,
     SPoint,
     SPolygonUtil,
-    SRect
+    SRect,
+    SSize
 } from "@persagy-web/draw";
 import { SItemStatus, ItemOrder } from "@persagy-web/big";
 import { Marker } from "../type/Marker";
@@ -154,6 +155,7 @@ export class SBasePolygonEdit extends SGraphEdit {
         this.zOrder = ItemOrder.polygonOrder;
         this.data = data;
         this.name = data.name;
+        this.showSelect = false;
         // this.text = data.Name;
         if (data.style) {
             this.setPointList = [];
@@ -685,7 +687,8 @@ export class SBasePolygonEdit extends SGraphEdit {
             // 对多边形数组做编辑操作
             this.editPolygonPoint(event);
         } else {
-            return super.onMouseDown(event);
+            // return super.onMouseDown(event);
+            super.onMouseDown(event);
         }
 
         return true;
@@ -920,6 +923,22 @@ export class SBasePolygonEdit extends SGraphEdit {
     } // Function toData()
 
     /**
+     * 选择器放缩控制大小变化'
+     * 
+     * @param old    旧的大小
+     * @param newS   新的大小
+    */
+    resize(old: SSize, newS: SSize): void {
+        const xs = newS.width / old.width;
+        const ys = newS.height / old.height;
+        this.pointList = this.pointList.map(item => {
+            item.x = item.x * xs;
+            item.y = item.y * ys;
+            return item
+        });
+    }
+
+    /**
      * Item 绘制操作
      *
      * @param painter    绘制对象

+ 2 - 0
src/components/editClass/persagy-edit/PTopoParser.ts

@@ -99,6 +99,8 @@ export class PTopoParser extends SParser {
                 case "BasePolygon":
                     this.markers.push(this.factory.createBasePolygonEdit(data));
                     break;
+                case "BaseArrowPolygon": 
+                    this.markers.push(this.factory.createBasePolygonArrowEdit(data));
             }
         }
     } // Function addMarker()