浏览代码

修改场景方法 去掉static

haojianlong 5 年之前
父节点
当前提交
f7693bdccb

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

@@ -1,6 +1,6 @@
 {
 {
     "name": "@saga-web/big",
     "name": "@saga-web/big",
-    "version": "1.0.90",
+    "version": "1.0.92",
     "description": "上格云建筑信息化库",
     "description": "上格云建筑信息化库",
     "main": "lib/index.js",
     "main": "lib/index.js",
     "types": "lib/index.d.js",
     "types": "lib/index.d.js",
@@ -42,6 +42,6 @@
         "typescript": "^3.9.3"
         "typescript": "^3.9.3"
     },
     },
     "dependencies": {
     "dependencies": {
-        "@saga-web/graph": "2.1.115"
+        "@saga-web/graph": "2.1.117"
     }
     }
 }
 }

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

@@ -1,6 +1,6 @@
 {
 {
     "name": "@saga-web/draw",
     "name": "@saga-web/draw",
-    "version": "2.1.104",
+    "version": "2.1.105",
     "description": "上格云绘制引擎。",
     "description": "上格云绘制引擎。",
     "main": "lib/index.js",
     "main": "lib/index.js",
     "types": "lib/index.d.js",
     "types": "lib/index.d.js",

+ 8 - 4
saga-web-draw/src/engines/SCanvasPaintEngine.ts

@@ -357,10 +357,14 @@ export class SCanvasPaintEngine extends SPaintEngine {
         height?: number
         height?: number
     ): void {
     ): void {
         this.setMatrix();
         this.setMatrix();
-        if (width == undefined) {
-            this._canvas.drawImage(img, x, y);
-        } else {
-            this._canvas.drawImage(img, x, y, width, height as number);
+        try {
+            if (width == undefined) {
+                this._canvas.drawImage(img, x, y);
+            } else {
+                this._canvas.drawImage(img, x, y, width, height as number);
+            }
+        } catch (e) {
+            console.log(e);
         }
         }
     } // Function drawImage()
     } // Function drawImage()
 
 

+ 2 - 2
saga-web-fengmap/package.json

@@ -1,6 +1,6 @@
 {
 {
     "name": "@saga-web/feng-map",
     "name": "@saga-web/feng-map",
-    "version": "1.0.26",
+    "version": "1.0.27",
     "description": "上格云Web平面图。",
     "description": "上格云Web平面图。",
     "main": "lib/index.js",
     "main": "lib/index.js",
     "types": "lib/index.d.js",
     "types": "lib/index.d.js",
@@ -32,7 +32,7 @@
         "typescript": "^3.9.3"
         "typescript": "^3.9.3"
     },
     },
     "dependencies": {
     "dependencies": {
-        "@saga-web/big": "1.0.87",
+        "@saga-web/big": "1.0.92",
         "axios": "^0.18.0"
         "axios": "^0.18.0"
     }
     }
 }
 }

+ 2 - 2
saga-web-graph/package.json

@@ -1,6 +1,6 @@
 {
 {
     "name": "@saga-web/graph",
     "name": "@saga-web/graph",
-    "version": "2.1.115",
+    "version": "2.1.117",
     "description": "上格云二维图形引擎。",
     "description": "上格云二维图形引擎。",
     "main": "lib/index.js",
     "main": "lib/index.js",
     "types": "lib/index.d.js",
     "types": "lib/index.d.js",
@@ -40,7 +40,7 @@
         "typescript": "^3.5.3"
         "typescript": "^3.5.3"
     },
     },
     "dependencies": {
     "dependencies": {
-        "@saga-web/draw": "2.1.104",
+        "@saga-web/draw": "2.1.105",
         "@types/uuid": "^8.0.0"
         "@types/uuid": "^8.0.0"
     }
     }
 }
 }

+ 17 - 9
saga-web-graph/src/SGraphScene.ts

@@ -1,5 +1,5 @@
-import { SMouseEvent } from "@saga-web/base/lib";
-import { SPainter, SRect } from "@saga-web/draw/lib";
+import { SMouseEvent, SMatrix } from "@saga-web/base/lib";
+import {SPainter, SPoint, SRect} from "@saga-web/draw/lib";
 import { SGraphItem } from "./SGraphItem";
 import { SGraphItem } from "./SGraphItem";
 import { SGraphView } from "./SGraphView";
 import { SGraphView } from "./SGraphView";
 import { SGraphSelectContainer } from "./SGraphSelectContainer";
 import { SGraphSelectContainer } from "./SGraphSelectContainer";
@@ -163,7 +163,7 @@ export class SGraphScene {
     onDoubleClick(event: SMouseEvent): boolean {
     onDoubleClick(event: SMouseEvent): boolean {
         if (this.grabItem != null) {
         if (this.grabItem != null) {
             return this.grabItem.onDoubleClick(
             return this.grabItem.onDoubleClick(
-                SGraphScene.toGrabItemMotionEvent(this.grabItem, event)
+                this.toGrabItemMotionEvent(this.grabItem, event)
             );
             );
         }
         }
         return this.root.onDoubleClick(event);
         return this.root.onDoubleClick(event);
@@ -178,7 +178,7 @@ export class SGraphScene {
     onMouseDown(event: SMouseEvent): boolean {
     onMouseDown(event: SMouseEvent): boolean {
         if (this.grabItem != null) {
         if (this.grabItem != null) {
             return this.grabItem.onMouseDown(
             return this.grabItem.onMouseDown(
-                SGraphScene.toGrabItemMotionEvent(this.grabItem, event)
+                this.toGrabItemMotionEvent(this.grabItem, event)
             );
             );
         }
         }
         const flag = this.root.onMouseDown(event);
         const flag = this.root.onMouseDown(event);
@@ -197,7 +197,7 @@ export class SGraphScene {
     onMouseMove(event: SMouseEvent): boolean {
     onMouseMove(event: SMouseEvent): boolean {
         if (this.grabItem != null) {
         if (this.grabItem != null) {
             return this.grabItem.onMouseMove(
             return this.grabItem.onMouseMove(
-                SGraphScene.toGrabItemMotionEvent(this.grabItem, event)
+                this.toGrabItemMotionEvent(this.grabItem, event)
             );
             );
         }
         }
         return this.root.onMouseMove(event);
         return this.root.onMouseMove(event);
@@ -212,7 +212,7 @@ export class SGraphScene {
     onMouseUp(event: SMouseEvent): boolean {
     onMouseUp(event: SMouseEvent): boolean {
         if (this.grabItem != null) {
         if (this.grabItem != null) {
             return this.grabItem.onMouseUp(
             return this.grabItem.onMouseUp(
-                SGraphScene.toGrabItemMotionEvent(this.grabItem, event)
+                this.toGrabItemMotionEvent(this.grabItem, event)
             );
             );
         }
         }
         return this.root.onMouseUp(event);
         return this.root.onMouseUp(event);
@@ -226,7 +226,7 @@ export class SGraphScene {
     onContextMenu(event: SMouseEvent): boolean {
     onContextMenu(event: SMouseEvent): boolean {
         if (this.grabItem != null) {
         if (this.grabItem != null) {
             return this.grabItem.onContextMenu(
             return this.grabItem.onContextMenu(
-                SGraphScene.toGrabItemMotionEvent(this.grabItem, event)
+                this.toGrabItemMotionEvent(this.grabItem, event)
             );
             );
         }
         }
 
 
@@ -275,12 +275,20 @@ export class SGraphScene {
      * @param   event       场景事件
      * @param   event       场景事件
      * @return  {}
      * @return  {}
      */
      */
-    private static toGrabItemMotionEvent(
+    private toGrabItemMotionEvent(
         item: SGraphItem,
         item: SGraphItem,
         event: SMouseEvent
         event: SMouseEvent
     ): SMouseEvent {
     ): SMouseEvent {
         let se = { ...event };
         let se = { ...event };
-        let p = item.mapFromScene(event.x, event.y);
+        se.matrix = new SMatrix();
+        if (this.view) {
+            se.matrix.translate(this.view.origin.x, this.view.origin.y);
+            se.matrix.scale(this.view.scale, this.view.scale);
+        }
+        se.matrix.multiply(item.scene2itemMattrix());
+        let p = new SPoint(event.offsetX, event.offsetY).matrixTransform(
+            se.matrix.inversed()
+        );
         se.x = p.x;
         se.x = p.x;
         se.y = p.y;
         se.y = p.y;
         return se;
         return se;