Explorar o código

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

zhangyu %!s(int64=5) %!d(string=hai) anos
pai
achega
2be79c1077

+ 30 - 1
saga-web-base/src/SMatrix.ts

@@ -342,7 +342,36 @@ export class SMatrix {
      * @return  返回自身
      */
     rotate(rotX: number, rotY?: number, rotZ?: number): SMatrix {
-        return this;
+        const matZ = new SMatrix();
+        if (rotY != undefined && rotZ != undefined) {
+            const matX = new SMatrix();
+            matX.m22 = Math.cos((rotX * Math.PI) / 180);
+            matX.m32 = -Math.sin((rotX * Math.PI) / 180);
+            matX.m23 = Math.sin((rotX * Math.PI) / 180);
+            matX.m33 = Math.cos((rotX * Math.PI) / 180);
+            this.multiply(matX);
+
+            const matY = new SMatrix();
+            matY.m11 = Math.cos((rotY * Math.PI) / 180);
+            matY.m31 = Math.sin((rotY * Math.PI) / 180);
+            matY.m13 = -Math.sin((rotY * Math.PI) / 180);
+            matY.m33 = Math.cos((rotY * Math.PI) / 180);
+            this.multiply(matY);
+
+            matZ.m11 = Math.cos((rotZ * Math.PI) / 180);
+            matZ.m21 = -Math.sin((rotZ * Math.PI) / 180);
+            matZ.m12 = Math.sin((rotZ * Math.PI) / 180);
+            matZ.m22 = Math.cos((rotZ * Math.PI) / 180);
+            this.multiply(matZ);
+            return this;
+        } else {
+            matZ.m11 = Math.cos((rotX * Math.PI) / 180);
+            matZ.m21 = -Math.sin((rotX * Math.PI) / 180);
+            matZ.m12 = Math.sin((rotX * Math.PI) / 180);
+            matZ.m22 = Math.cos((rotX * Math.PI) / 180);
+            this.multiply(matZ);
+            return this;
+        }
     }
 
     /**

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

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

+ 2 - 2
saga-web-big/src/items/SPolylineItem.ts

@@ -264,7 +264,7 @@ export class SPolylineItem extends SGraphItem {
             this.status = SItemStatus.Normal;
             this.releaseItem();
         } else if (this.status == SItemStatus.Create) {
-            if (this.pointList.length > 2) {
+            if (this.pointList.length > 1) {
                 this.status = SItemStatus.Normal;
                 this.releaseItem();
                 this.$emit("finishCreated");
@@ -281,7 +281,7 @@ export class SPolylineItem extends SGraphItem {
      */
     onKeyUp(event: KeyboardEvent): void {
         if (event.keyCode == SKeyCode.Enter) {
-            if (this.pointList.length > 2) {
+            if (this.pointList.length > 1) {
                 if (this.status == SItemStatus.Create) {
                     this.$emit("finishCreated");
                 }

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

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

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

@@ -1,6 +1,6 @@
 {
     "name": "@saga-web/graph",
-    "version": "2.1.117",
+    "version": "2.1.118",
     "description": "上格云二维图形引擎。",
     "main": "lib/index.js",
     "types": "lib/index.d.js",

+ 33 - 25
saga-web-graph/src/SGraphItem.ts

@@ -188,23 +188,27 @@ export class SGraphItem extends SObject {
 
             // 保存画布状态
             painter.save();
-            // item位移到指定位置绘制
-            painter.translate(item.x, item.y);
-            painter.scale(item.scale, item.scale);
-            painter.rotate(item.rolate);
-
-            // 如果不进行变形处理,则取消painter的变型操作
-            if (!item.isTransform) {
-                let matrix = painter.worldTransform;
-                item._inverseScale = 1.0 / matrix.a;
-                painter.scale(item._inverseScale, item._inverseScale);
+            try {
+                // item位移到指定位置绘制
+                painter.translate(item.x, item.y);
+                painter.scale(item.scale, item.scale);
+                painter.rotate(item.rolate);
+
+                // 如果不进行变形处理,则取消painter的变型操作
+                if (!item.isTransform) {
+                    let matrix = painter.worldTransform;
+                    item._inverseScale = 1.0 / matrix.a;
+                    painter.scale(item._inverseScale, item._inverseScale);
+                }
+                // 设置绘制区域
+                // canvas.clip(item.boundingRect())
+
+                // rect 调整  宽度高度取最小值  根据pos位移
+                // 绘制item
+                item.onPaint(painter, rect);
+            } catch (e) {
+                console.log(e);
             }
-            // 设置绘制区域
-            // canvas.clip(item.boundingRect())
-
-            // rect 调整  宽度高度取最小值  根据pos位移
-            // 绘制item
-            item.onPaint(painter, rect);
             // 恢复画布状态
             painter.restore();
         }
@@ -397,14 +401,18 @@ export class SGraphItem extends SObject {
      */
     onMouseDown(event: SMouseEvent): boolean {
         for (let i = this.children.length - 1; i >= 0; i--) {
-            let item = this.children[i];
-            if (!this.acceptEvent() || !item.visible) {
-                continue;
-            }
-            let ce = SGraphItem.toChildMouseEvent(item, event);
-            if (item.contains(ce.x, ce.y) && item.onMouseDown(ce)) {
-                // 如果点在子项目上且子项目处理了事件
-                return true;
+            try {
+                let item = this.children[i];
+                if (!this.acceptEvent() || !item.visible) {
+                    continue;
+                }
+                let ce = SGraphItem.toChildMouseEvent(item, event);
+                if (item.contains(ce.x, ce.y) && item.onMouseDown(ce)) {
+                    // 如果点在子项目上且子项目处理了事件
+                    return true;
+                }
+            } catch (e) {
+                console.log(e);
             }
         }
         // 选择
@@ -616,9 +624,9 @@ export class SGraphItem extends SObject {
         event: SMouseEvent
     ): SMouseEvent {
         let ce = new SMouseEvent(event);
+        // ce.matrix.rotate(0, 0, child.rolate);
         ce.matrix.translate(child.x, child.y);
         ce.matrix.scale(child.scale, child.scale);
-        ce.matrix.rotate(0, 0, child.rolate);
 
         if (!child.isTransform) {
             ce.matrix.scale(child._inverseScale, child._inverseScale);

+ 1 - 0
saga-web-graph/src/SGraphScene.ts

@@ -282,6 +282,7 @@ export class SGraphScene {
         let se = { ...event };
         se.matrix = new SMatrix();
         if (this.view) {
+            // se.matrix.rotate(this.view.rotate);
             se.matrix.translate(this.view.origin.x, this.view.origin.y);
             se.matrix.scale(this.view.scale, this.view.scale);
         }

+ 5 - 1
saga-web-graph/src/SGraphView.ts

@@ -35,6 +35,8 @@ export class SGraphView extends SCanvasView {
     } // Set scene
     /** 背景色 */
     backgroundColor: SColor = SColor.Transparent;
+    /** 旋转角度    */
+    rotate: number = 0;
 
     /**
      * 构造函数
@@ -279,6 +281,7 @@ export class SGraphView extends SCanvasView {
 
         // 绘制场景
         painter.save();
+        // painter.rotate(this.rotate);
         painter.translate(this.origin.x, this.origin.y);
         painter.scale(this.scale, this.scale);
         this.scene.drawScene(painter, new SRect());
@@ -428,6 +431,7 @@ export class SGraphView extends SCanvasView {
      */
     private toSceneMotionEvent(event: MouseEvent): SMouseEvent {
         let se = new SMouseEvent(event);
+        // se.matrix.rotate(this.rotate);
         se.matrix.translate(this.origin.x, this.origin.y);
         se.matrix.scale(this.scale, this.scale);
 
@@ -439,4 +443,4 @@ export class SGraphView extends SCanvasView {
         se.y = mp.y;
         return se;
     } // Function toSceneMotionEvent()
-} // Class SGraphyView
+} // Class SGraphView