修宁 7 months ago
parent
commit
13bcb7841c
  1. 2
      src/core/Constract.ts
  2. 26
      src/core/base/BaseInteraction.ts
  3. 6
      src/editor/Model2DEditor.vue

2
src/core/Constract.ts

@ -13,7 +13,7 @@ export default Object.freeze({
// 测量相关的光标模式
CursorModeMeasure: 'measure',
CursorModeConveyor: 'conveyor',
CursorModeWay: 'way',
// 选择模式
CursorModeSelectByRec: 'selectByRec'

26
src/core/base/BaseInteraction.ts

@ -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()
}

6
src/editor/Model2DEditor.vue

@ -39,9 +39,9 @@
:type="state?.cursorMode===Constract.CursorModeMeasure?'primary':''"
@click="()=>state.cursorMode = Constract.CursorModeMeasure"></el-button>
<span class="section-toolbar-line"></span>
<el-button title="输送线" :icon="renderIcon('fa Line')" link
:type="state?.cursorMode===Constract.CursorModeConveyor?'primary':''"
@click="()=>state.cursorMode = Constract.CursorModeConveyor"></el-button>
<el-button title="AGV线路" :icon="renderIcon('fa Line')" link
:type="state?.cursorMode===Constract.CursorModeWay?'primary':''"
@click="()=>state.cursorMode = Constract.CursorModeWay"></el-button>
</div>
<div class="section-toolbar-right">
<el-input v-model="searchKeyword" size="small" style="width: 110px; margin-right: 5px;"

Loading…
Cancel
Save