浏览代码

修改sgraphview报错问题

haojianlong 5 年之前
父节点
当前提交
fda5df9ecc
共有 4 个文件被更改,包括 33 次插入265 次删除
  1. 2 46
      src/lib/FloorScene.js
  2. 0 32
      src/lib/FloorScene.ts
  3. 31 84
      src/lib/FloorView.js
  4. 0 103
      src/lib/FloorView.ts

+ 2 - 46
src/lib/FloorScene.js

@@ -1,46 +1,2 @@
-var __extends = (this && this.__extends) || (function () {
-    var extendStatics = function (d, b) {
-        extendStatics = Object.setPrototypeOf ||
-            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
-            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
-        return extendStatics(d, b);
-    };
-    return function (d, b) {
-        extendStatics(d, b);
-        function __() { this.constructor = d; }
-        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
-    };
-})();
-import { SGraphScene } from "@saga-web/graph/lib";
-import { SPoint } from "@saga-web/draw/lib";
-import { SPolylineItem } from "@saga-web/big";
-var FloorScene = /** @class */ (function (_super) {
-    __extends(FloorScene, _super);
-    function FloorScene() {
-        var _this = _super.call(this) || this;
-        _this.isLining = false;
-        return _this;
-        // this.selectContainer.connect("listChange", this, this.listChange)
-    }
-    // listChange(item, list) {
-    // console.log(arguments)
-    // }
-    FloorScene.prototype.onMouseDown = function (event) {
-        if (this.isLining) {
-            if (this.grabItem instanceof SPolylineItem) {
-                return _super.prototype.onMouseDown.call(this, event);
-            }
-            else {
-                var item = new SPolylineItem(null, new SPoint(event.x, event.y));
-                this.addItem(item);
-                this.grabItem = item;
-                return true;
-            }
-        }
-        else {
-            return _super.prototype.onMouseDown.call(this, event);
-        }
-    };
-    return FloorScene;
-}(SGraphScene));
-export { FloorScene };
+import { SGraphScene } from "@saga-web/graph/lib"
+export class FloorScene extends SGraphScene {}

+ 0 - 32
src/lib/FloorScene.ts

@@ -1,32 +0,0 @@
-import { SGraphScene } from "@saga-web/graph/lib"
-import { SMouseEvent } from "@saga-web/base/lib"
-import { SPoint } from "@saga-web/draw/lib"
-import { SFloorParser, SImageItem, STextItem, SLineItem, SPolylineItem } from "@saga-web/big"
-
-export class FloorScene extends SGraphScene {
-    isLining: boolean = false
-
-    constructor() {
-        super()
-        // this.selectContainer.connect("listChange", this, this.listChange)
-    }
-
-    // listChange(item, list) {
-    // console.log(arguments)
-    // }
-
-    onMouseDown(event: SMouseEvent): boolean {
-        if (this.isLining) {
-            if (this.grabItem instanceof SPolylineItem) {
-                return super.onMouseDown(event)
-            } else {
-                const item = new SPolylineItem(null, new SPoint(event.x, event.y))
-                this.addItem(item)
-                this.grabItem = item
-                return true
-            }
-        } else {
-            return super.onMouseDown(event)
-        }
-    }
-}

+ 31 - 84
src/lib/FloorView.js

@@ -1,54 +1,20 @@
-var __extends = (this && this.__extends) || (function () {
-    var extendStatics = function (d, b) {
-        extendStatics = Object.setPrototypeOf ||
-            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
-            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
-        return extendStatics(d, b);
-    };
-    return function (d, b) {
-        extendStatics(d, b);
-        function __() { this.constructor = d; }
-        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
-    };
-})();
-import { SGraphView } from '@saga-web/graph/lib';
-import { SMouseButton, SMouseEvent, SNetUtil } from '@saga-web/base/lib';
-import { SPoint } from '@saga-web/draw/lib';
-/**
- * 楼层场景
- *
- * @author  郝建龙
- */
-var FloorView = /** @class */ (function (_super) {
-    __extends(FloorView, _super);
-    function FloorView() {
-        var _this = _super !== null && _super.apply(this, arguments) || this;
-        /** 鼠标左键键按下时位置 */
-        _this._leftKeyPos = new SPoint();
-        /** 空格是否被按下 */
-        _this.spaceKey = false;
-        return _this;
+import { SGraphView } from "@saga-web/graph/lib";
+import { SMouseButton, SMouseEvent, SNetUtil } from "@saga-web/base/lib";
+import { SPoint } from "@saga-web/draw/lib";
+export class FloorView extends SGraphView {
+    constructor() {
+        super(...arguments);
+        this._leftKeyPos = new SPoint();
+        this.spaceKey = false;
     }
-    /**
-     * 保存底图json
-     *
-     * @param   name    文件名
-     */
-    FloorView.prototype.saveFloorJson = function (name) {
-        // @ts-ignore
+    saveFloorJson(name) {
         if (!this.scene || !this.scene.json)
             return;
-        // @ts-ignore
-        var url = URL.createObjectURL(new Blob([this.scene.json]));
+        let url = URL.createObjectURL(new Blob([this.scene.json]));
         SNetUtil.downLoad(name, url);
-    }; // Function saveSceneSvg()
-    /**
-     * 按键按下事件
-     *
-     * @param   event       事件参数
-     */
-    FloorView.prototype.onKeyDown = function (event) {
-        var keyCode = event.keyCode;
+    }
+    onKeyDown(event) {
+        let keyCode = event.keyCode;
         this.spaceKey = false;
         switch (keyCode) {
             case 32:
@@ -67,52 +33,33 @@ var FloorView = /** @class */ (function (_super) {
                 this.origin.x -= 10;
                 break;
             default:
-                _super.prototype.onKeyDown.call(this, event);
+                super.onKeyDown(event);
                 break;
         }
-        this.update();
-    }; // Function onKeyDown()
-    /**
-     * 按键松开事件
-     *
-     * @param   event       事件参数
-     */
-    FloorView.prototype.onKeyUp = function (event) {
+    }
+    onKeyUp(event) {
         this.spaceKey = false;
-        _super.prototype.onKeyUp.call(this, event);
-    }; // Function onKeyUp()
-    /**
-     * 鼠标按下事件
-     *
-     * @param   event       事件参数
-     */
-    FloorView.prototype.onMouseDown = function (event) {
-        var se = new SMouseEvent(event);
+        super.onKeyUp(event);
+    }
+    onMouseDown(event) {
+        let se = new SMouseEvent(event);
         if (se.buttons & SMouseButton.LeftButton) {
             this._leftKeyPos.x = se.x;
             this._leftKeyPos.y = se.y;
         }
-        _super.prototype.onMouseDown.call(this, event);
-    }; // Function onMouseDown()
-    /**
-     * 鼠标移动事件
-     *
-     * @param   event       事件参数
-     */
-    FloorView.prototype.onMouseMove = function (event) {
-        // 按左键移动
-        var se = new SMouseEvent(event);
+        super.onMouseDown(event);
+    }
+    onMouseMove(event) {
+        let se = new SMouseEvent(event);
         if (se.buttons & SMouseButton.LeftButton) {
-            // if (this.spaceKey) {
-            this.origin.x += se.x - this._leftKeyPos.x;
-            this.origin.y += se.y - this._leftKeyPos.y;
-            // }
+            if (this.spaceKey) {
+                this.origin.x += se.x - this._leftKeyPos.x;
+                this.origin.y += se.y - this._leftKeyPos.y;
+            }
             this._leftKeyPos.x = se.x;
             this._leftKeyPos.y = se.y;
             this.update();
         }
-        _super.prototype.onMouseMove.call(this, event);
-    }; // Function onMouseMove()
-    return FloorView;
-}(SGraphView)); // Class FloorScene
-export { FloorView };
+        super.onMouseMove(event);
+    }
+}

+ 0 - 103
src/lib/FloorView.ts

@@ -1,103 +0,0 @@
-import { SGraphItem, SGraphView } from '@saga-web/graph/lib'
-import { SMouseButton, SMouseEvent, SNetUtil } from '@saga-web/base/lib'
-import { SPoint } from '@saga-web/draw/lib'
-
-/**
- * 楼层场景
- *
- * @author  郝建龙
- */
-export class FloorView extends SGraphView {
-    /** 鼠标左键键按下时位置 */
-    private _leftKeyPos = new SPoint()
-    /** 空格是否被按下 */
-    private spaceKey: boolean = false
-
-    /**
-     * 保存底图json
-     *
-     * @param   name    文件名
-     */
-    saveFloorJson(name: string): void {
-        // @ts-ignore
-        if (!this.scene || !this.scene.json) return
-        // @ts-ignore
-        let url = URL.createObjectURL(new Blob([this.scene.json]))
-        SNetUtil.downLoad(name, url)
-    } // Function saveSceneSvg()
-
-    /**
-     * 按键按下事件
-     *
-     * @param   event       事件参数
-     */
-    protected onKeyDown(event: KeyboardEvent): void {
-        let keyCode = event.keyCode
-        this.spaceKey = false
-        switch (keyCode) {
-            case 32:
-                this.spaceKey = true
-                break
-            case 87:
-                this.origin.y -= 10
-                break
-            case 83:
-                this.origin.y += 10
-                break
-            case 68:
-                this.origin.x += 10
-                break
-            case 65:
-                this.origin.x -= 10
-                break
-            default:
-                super.onKeyDown(event)
-                break
-        }
-        this.update()
-    } // Function onKeyDown()
-
-    /**
-     * 按键松开事件
-     *
-     * @param   event       事件参数
-     */
-    protected onKeyUp(event: KeyboardEvent): void {
-        this.spaceKey = false
-        super.onKeyUp(event)
-    } // Function onKeyUp()
-
-    /**
-     * 鼠标按下事件
-     *
-     * @param   event       事件参数
-     */
-    protected onMouseDown(event: MouseEvent): void {
-        let se = new SMouseEvent(event)
-        if (se.buttons & SMouseButton.LeftButton) {
-            this._leftKeyPos.x = se.x
-            this._leftKeyPos.y = se.y
-        }
-        super.onMouseDown(event)
-    } // Function onMouseDown()
-
-    /**
-     * 鼠标移动事件
-     *
-     * @param   event       事件参数
-     */
-    protected onMouseMove(event: MouseEvent): void {
-        // 按左键移动
-        let se = new SMouseEvent(event)
-        if (se.buttons & SMouseButton.LeftButton) {
-            // if (this.spaceKey) {
-            this.origin.x += se.x - this._leftKeyPos.x
-            this.origin.y += se.y - this._leftKeyPos.y
-            // }
-            this._leftKeyPos.x = se.x
-            this._leftKeyPos.y = se.y
-            this.update()
-        }
-        super.onMouseMove(event)
-    } // Function onMouseMove()
-} // Class FloorScene