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