Browse Source

SGraphyScene增加属性view,用于保存展示场景的视图。

庞利祥 5 years ago
parent
commit
f77b9d4bd5

+ 3 - 1
saga-web-base/src/undo/SUndoCommand.ts

@@ -29,7 +29,9 @@ export abstract class SUndoCommand {
      * @param   command     合并的命令
      * @return  成功能返回true,否则返回false
      */
-    abstract mergeWith(command: SUndoCommand): boolean;
+    mergeWith(command: SUndoCommand): boolean {
+        return false;
+    } // Function mergeWith()
 
     /**
      * 命令ID。如果命令不能合并,则返回-1。如果支持合并则返回一个正整数。

+ 3 - 0
saga-web-graphy/src/SGraphyScene.ts

@@ -1,6 +1,7 @@
 import { SMouseEvent } from "@saga-web/base/lib";
 import { SPainter, SRect } from "@saga-web/draw/lib";
 import { SGraphyItem } from "./SGraphyItem";
+import { SGraphyView } from "./SGraphyView";
 
 /**
  * Graphy图形引擎场景类
@@ -8,6 +9,8 @@ import { SGraphyItem } from "./SGraphyItem";
  * @author  庞利祥(sybotan@126.com)
  */
 export class SGraphyScene {
+    /** 展示场景的视图 */
+    view: SGraphyView | null = null;
     /** 根节点 */
     protected root: SGraphyItem = new SGraphyItem();
     /** 当前捕获Item */

+ 13 - 1
saga-web-graphy/src/SGraphyView.ts

@@ -15,7 +15,19 @@ import { SGraphyScene } from "./SGraphyScene";
  */
 export class SGraphyView extends SCanvasView {
     /** 场景对象 */
-    scene: SGraphyScene | null = new SGraphyScene();
+    private _scene : SGraphyScene | null = null;
+    get scene(): SGraphyScene | null {
+        return this._scene;
+    } // Get scene
+    set scene(v: SGraphyScene | null) {
+        if (this._scene != null) {
+            this._scene.view = null;
+        }
+        this._scene = v;
+        if (this._scene != null) {
+            this._scene.view = this;
+        }
+    } // Set scene
 
     /**
      * 构造函数