|
|
|
@ -119,7 +119,7 @@ export default abstract class BaseInteraction { |
|
|
|
|
|
|
|
this.viewerDom = this.viewport.viewerDom |
|
|
|
this.canvas = this.viewport.renderer.domElement |
|
|
|
if (option.startPoint) { |
|
|
|
if (option?.startPoint) { |
|
|
|
this.linkStartPointId = option.startPoint |
|
|
|
} |
|
|
|
if (this.linkStartPointId) { |
|
|
|
@ -264,15 +264,18 @@ export default abstract class BaseInteraction { |
|
|
|
} |
|
|
|
this.lastClickTime = now |
|
|
|
|
|
|
|
const from = this.viewport.stateManager.findItemById(this.linkStartPointId) |
|
|
|
if (!from) { |
|
|
|
system.showErrorDialog(`Cannot find state item: ${this.linkStartPointId}`) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
// 如果正式的点命中到同类型的节点上,则不添加新的点,只牵线到该点
|
|
|
|
let catchPoint: ItemJson | null = this.viewport.stateManager.findItemByPosition(point, this.itemTypeName) |
|
|
|
|
|
|
|
let from: ItemJson | undefined = undefined |
|
|
|
if (this.linkStartPointId) { |
|
|
|
from = this.viewport.stateManager.findItemById(this.linkStartPointId) |
|
|
|
if (!from) { |
|
|
|
system.showErrorDialog(`Cannot find state item: ${this.linkStartPointId}`) |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (catchPoint) { |
|
|
|
// 连线到目标点
|
|
|
|
if (this.linkStartPointId === catchPoint.id) { |
|
|
|
@ -323,8 +326,13 @@ export default abstract class BaseInteraction { |
|
|
|
stateManager.beginStateUpdate({ createFromInteraction: true }) |
|
|
|
// 关联2个点
|
|
|
|
stateManager.vdata.items.push(catchPoint) |
|
|
|
catchPoint.dt.center.push(this.linkStartPointId) |
|
|
|
from.dt.center.push(catchPoint.id) |
|
|
|
if (from) { |
|
|
|
catchPoint.dt.center.push(this.linkStartPointId) |
|
|
|
from.dt.center.push(catchPoint.id) |
|
|
|
|
|
|
|
} else { |
|
|
|
stateManager.vdata.items.push(catchPoint) |
|
|
|
} |
|
|
|
stateManager.endStateUpdate() |
|
|
|
} |
|
|
|
|
|
|
|
|