|
@@ -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;
|