修宁 7 months ago
parent
commit
13bcb7841c
  1. 2
      src/core/Constract.ts
  2. 18
      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', CursorModeMeasure: 'measure',
CursorModeConveyor: 'conveyor', CursorModeWay: 'way',
// 选择模式 // 选择模式
CursorModeSelectByRec: 'selectByRec' CursorModeSelectByRec: 'selectByRec'

18
src/core/base/BaseInteraction.ts

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

6
src/editor/Model2DEditor.vue

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

Loading…
Cancel
Save