Forráskód Böngészése

Merge branch 'master' of http://39.106.8.246:3003/web/sagacloud-web

zhangyu 5 éve
szülő
commit
62baeb0fc3

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

@@ -1,6 +1,6 @@
 {
     "name": "@saga-web/big",
-    "version": "1.0.21",
+    "version": "1.0.23",
     "description": "上格云建筑信息化库",
     "main": "lib/index.js",
     "types": "lib/index.d.js",

+ 11 - 16
saga-web-big/src/items/SImageItem.ts

@@ -40,7 +40,6 @@ export class SImageItem extends SObjectItem {
      * 构造函数
      *
      * @param   parent      指向父Item
-     * @param   str         文本内容
      */
     constructor(parent: SGraphItem | null) {
         super(parent);
@@ -53,8 +52,8 @@ export class SImageItem extends SObjectItem {
      */
     boundingRect(): SRect {
         return new SRect(
-            0,
-            0,
+            -this.width / 2,
+            -this.height / 2,
             this.width,
             this.height
         );
@@ -66,7 +65,7 @@ export class SImageItem extends SObjectItem {
      * @param   oldSize 改之前的大小
      * @param   newSize 改之后大小
      * */
-    protected onResize(oldSize: SSize, newSize: SSize) {
+    protected onResize(oldSize: SSize, newSize: SSize): void {
         this.update();
     } // Function onResize()
 
@@ -78,15 +77,17 @@ export class SImageItem extends SObjectItem {
     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;
             // 原始图片的宽高比
-            let imgAspectRatio: number = (this.img.width as number) / (this.img.height as number);
+            let imgAspectRatio: number =
+                (this.img.width as number) / (this.img.height as number);
             // 原始图片的高宽比
-            let imgHwRatio: number = (this.img.height as number) / (this.img.width as number);
+            let imgHwRatio: number =
+                (this.img.height as number) / (this.img.width as number);
             if (this.showType == SImageShowType.Full) {
                 width = this.width;
                 height = this.height;
@@ -102,13 +103,7 @@ export class SImageItem extends SObjectItem {
                     height = this.height;
                 }
             }
-            painter.drawImage(
-                this.img,
-                0,
-                0,
-                width,
-                height
-            );
+            painter.drawImage(this.img, -width / 2, -height / 2, width, height);
         }
     } // Function onDraw()
-}// Class SImageItem
+} // Class SImageItem

+ 6 - 0
saga-web-big/src/items/SPolylineItem.ts

@@ -206,8 +206,14 @@ export class SPolylineItem extends SGraphItem {
     onDoubleClick(event: SMouseEvent): boolean {
         if (this.status == SItemStatus.Normal) {
             this.status = SItemStatus.Edit;
+            if (this.scene) {
+                this.scene.grabItem = this;
+            }
         } else if (this.status == SItemStatus.Edit) {
             this.status = SItemStatus.Normal;
+            if (this.scene) {
+                this.scene.grabItem = null;
+            }
         } else if (this.status == SItemStatus.Create) {
             this.status = SItemStatus.Edit;
         }

+ 32 - 18
saga-web-big/src/items/topology/SAnchorItem.ts

@@ -1,5 +1,5 @@
 import { SGraphItem } from "@saga-web/graph/lib";
-import { SPainter } from "@saga-web/draw/lib";
+import { SPainter, SColor } from "@saga-web/draw/lib";
 
 /**
  * 锚点item
@@ -7,21 +7,35 @@ import { SPainter } from "@saga-web/draw/lib";
  * @author  郝建龙(1061851420@qq.com)
  */
 export class SAnchorItem extends SGraphItem {
-    // private width: number;
-    // private height: number;
-    //
-    // /**
-    //  * Item绘制操作
-    //  *
-    //  * @param   painter       painter对象
-    //  */
-    // onDraw(painter: SPainter): void {
-    //     painter.pen.lineWidth = painter.toPx(1);
-    //     painter.drawRect(
-    //         -this.width / 2,
-    //         -this.height / 2,
-    //         this.width,
-    //         this.height
-    //     );
-    // } // Function onDraw()
+    /** 锚点宽 */
+    private width: number = 3;
+    /** 锚点高 */
+    private height: number = 3;
+    /** 是否被连接   */
+    isConnected: boolean = false;
+    /** 全局灵敏度   */
+    dis: number = 30;
+    /** 灵敏度转换为场景长度  */
+    sceneDis: number = 10;
+
+    /**
+     * Item绘制操作
+     *
+     * @param   painter       painter对象
+     */
+    onDraw(painter: SPainter): void {
+        this.sceneDis = painter.toPx(this.dis);
+        painter.pen.lineWidth = painter.toPx(1);
+        painter.pen.color = new SColor("#2196f3");
+        painter.brush.color = SColor.White;
+        if (this.isConnected) {
+            painter.brush.color = painter.pen.color;
+        }
+        painter.drawRect(
+            -this.width / 2,
+            -this.height / 2,
+            this.width,
+            this.height
+        );
+    } // Function onDraw()
 } // Class SAnchorItem