修复不同group的结点不能连接的bug

This commit is contained in:
cjc 2022-03-18 20:37:02 +08:00
parent 62c7e91b97
commit d4066249c7
4 changed files with 207 additions and 56 deletions

View File

@ -36,6 +36,21 @@ SV.registerLayout('TriTree', {
} }
} }
}, },
parent: {
type: 'line',
sourceAnchor: 4,
targetAnchor: 6,
style: {
stroke: '#999',
lineAppendWidth: 10,
lineWidth: 1.6,
endArrow: 'default',
startArrow: {
path: G6.Arrow.circle(2, -1),
fill: '#999'
}
}
},
r_parent: { r_parent: {
type: 'quadratic', type: 'quadratic',
sourceAnchor: 4, sourceAnchor: 4,

View File

@ -8,10 +8,10 @@ const SOURCES_DATA = [{
"0x0" "0x0"
], ],
"child": [ "child": [
"0xb07ee0", "0xfd9ee0",
"0xb07f10" "0xfd9f10"
], ],
"id": "0xb07eb0", "id": "0xfd9eb0",
"name": "T", "name": "T",
"data": "A", "data": "A",
"root": true, "root": true,
@ -22,12 +22,12 @@ const SOURCES_DATA = [{
"0x0", "0x0",
"0x0" "0x0"
], ],
"id": "0xb07ee0", "id": "0xfd9ee0",
"name": "T->lchild", "name": "T->lchild",
"data": "B", "data": "B",
"type": "default", "type": "default",
"l_parent": [ "l_parent": [
"0x0" "0xfd9eb0"
], ],
"external": [ "external": [
"T1" "T1"
@ -38,12 +38,12 @@ const SOURCES_DATA = [{
"0x0", "0x0",
"0x0" "0x0"
], ],
"id": "0xb07f10", "id": "0xfd9f10",
"name": "T->rchild", "name": "T->rchild",
"data": "C", "data": "C",
"type": "default", "type": "default",
"r_parent": [ "r_parent": [
"0x0" "0xfd9eb0"
], ],
"external": [ "external": [
"T2" "T2"
@ -52,6 +52,144 @@ const SOURCES_DATA = [{
], ],
"layouter": "TriTree" "layouter": "TriTree"
}, },
"TriTree3": {
"data": [{
"external": [
"T3"
],
"parent": [
"0x0"
],
"child": [
"0x0",
"0x0"
],
"id": "0xfd9f40",
"name": "T3",
"data": "D",
"root": true,
"type": "default"
}],
"layouter": "TriTree"
},
"TriTree4": {
"data": [{
"external": [
"T4"
],
"parent": [
"0x0"
],
"child": [
"0x0",
"0x0"
],
"id": "0xfd9f70",
"name": "T4",
"data": "E",
"root": true,
"type": "default"
}],
"layouter": "TriTree"
},
"handleUpdate": {
"isEnterFunction": true,
"isFirstDebug": true
}
}, {
"TriTree0": {
"data": [{
"external": [
"T"
],
"parent": [
"0x0"
],
"child": [
"0xfd9ee0",
"0xfd9f10"
],
"id": "0xfd9eb0",
"name": "T",
"data": "A",
"root": true,
"type": "default"
},
{
"child": [
"0x0",
"0x0"
],
"id": "0xfd9ee0",
"name": "T->lchild",
"data": "B",
"type": "default",
"l_parent": [
"0xfd9eb0"
],
"external": [
"T1"
]
},
{
"child": [
"0x0",
"0x0"
],
"id": "0xfd9f10",
"name": "T->rchild",
"data": "C",
"type": "default",
"r_parent": [
"0xfd9eb0"
],
"external": [
"T2"
]
}
],
"layouter": "TriTree"
},
"TriTree3": {
"data": [{
"external": [
"T3"
],
"parent": [
"0x0"
],
"child": [
"0x0",
"0x0"
],
"id": "0xfd9f40",
"name": "T3",
"data": "D",
"root": true,
"type": "default"
}],
"layouter": "TriTree"
},
"TriTree4": {
"data": [{
"external": [
"T4"
],
"parent": [
"0xfd9f40"
],
"child": [
"0x0",
"0x0"
],
"id": "0xfd9f70",
"name": "T4",
"data": "E",
"root": true,
"type": "default"
}],
"layouter": "TriTree"
},
"handleUpdate": { "handleUpdate": {
"isEnterFunction": false, "isEnterFunction": false,
"isFirstDebug": false "isFirstDebug": false
@ -66,10 +204,10 @@ const SOURCES_DATA = [{
"0x0" "0x0"
], ],
"child": [ "child": [
"0xb07ee0", "0xfd9ee0",
"0xb07f10" "0xfd9f10"
], ],
"id": "0xb07eb0", "id": "0xfd9eb0",
"name": "T", "name": "T",
"data": "A", "data": "A",
"root": true, "root": true,
@ -80,12 +218,12 @@ const SOURCES_DATA = [{
"0x0", "0x0",
"0x0" "0x0"
], ],
"id": "0xb07ee0", "id": "0xfd9ee0",
"name": "T->lchild", "name": "T->lchild",
"data": "B", "data": "B",
"type": "default", "type": "default",
"l_parent": [ "l_parent": [
"0xb07eb0" "0xfd9eb0"
], ],
"external": [ "external": [
"T1" "T1"
@ -96,12 +234,12 @@ const SOURCES_DATA = [{
"0x0", "0x0",
"0x0" "0x0"
], ],
"id": "0xb07f10", "id": "0xfd9f10",
"name": "T->rchild", "name": "T->rchild",
"data": "C", "data": "C",
"type": "default", "type": "default",
"r_parent": [ "r_parent": [
"0x0" "0xfd9eb0"
], ],
"external": [ "external": [
"T2" "T2"
@ -110,26 +248,21 @@ const SOURCES_DATA = [{
], ],
"layouter": "TriTree" "layouter": "TriTree"
}, },
"handleUpdate": { "TriTree3": {
"isEnterFunction": false,
"isFirstDebug": false
}
}, {
"TriTree0": {
"data": [{ "data": [{
"external": [ "external": [
"T" "T3"
], ],
"parent": [ "parent": [
"0x0" "0x0"
], ],
"child": [ "child": [
"0xb07ee0", "0xfd9f70",
"0xb07f10" "0x0"
], ],
"id": "0xb07eb0", "id": "0xfd9f40",
"name": "T", "name": "T3",
"data": "A", "data": "D",
"root": true, "root": true,
"type": "default" "type": "default"
}, },
@ -138,31 +271,15 @@ const SOURCES_DATA = [{
"0x0", "0x0",
"0x0" "0x0"
], ],
"id": "0xb07ee0", "id": "0xfd9f70",
"name": "T->lchild", "name": "T3->lchild",
"data": "B", "data": "E",
"type": "default", "type": "default",
"l_parent": [ "l_parent": [
"0xb07eb0" "0xfd9f40"
], ],
"external": [ "external": [
"T1" "T4"
]
},
{
"child": [
"0x0",
"0x0"
],
"id": "0xb07f10",
"name": "T->rchild",
"data": "C",
"type": "default",
"r_parent": [
"0xb07eb0"
],
"external": [
"T2"
] ]
} }
], ],

View File

@ -444,14 +444,25 @@ export class ModelConstructor {
} }
} }
nodeList = layoutGroupTable.get(targetGroupName).node.filter(item => item.sourceType === sourceNodeType); // 为了可以连接到不同group的结点
for (let layoutGroup of layoutGroupTable.values()) {
nodeList = layoutGroup.node.filter(item => item.sourceType === sourceNodeType);
if (nodeList === undefined) {
continue;
}
targetNode = nodeList.find(item => item.sourceId === targetId);
if (targetNode) {
break;
}
}
// nodeList = layoutGroupTable.get(targetGroupName).node.filter(item => item.sourceType === sourceNodeType);
// 若目标node不存在返回null // // 若目标node不存在返回null
if (nodeList === undefined) { // if (nodeList === undefined) {
return null; // return null;
} // }
targetNode = nodeList.find(item => item.sourceId === targetId); // targetNode = nodeList.find(item => item.sourceId === targetId);
return targetNode || null; return targetNode || null;
} }

View File

@ -67,11 +67,18 @@ export default Util.registerShape(
draggable: true draggable: true
}); });
} }
let parent = cfg.parent || cfg.l_parent || cfg.r_parent;
const isLeftEmpty = const isLeftEmpty =
!cfg.child || cfg.child[0] === undefined || cfg.child[0] === undefined || cfg.child[0] == '0x0', !cfg.child || cfg.child[0] === undefined || cfg.child[0] === undefined || cfg.child[0] == '0x0',
isRightEmpty = isRightEmpty =
!cfg.child || cfg.child[1] === undefined || cfg.child[1] === undefined || cfg.child[1] == '0x0', !cfg.child || cfg.child[1] === undefined || cfg.child[1] === undefined || cfg.child[1] == '0x0',
isparentEmpty = cfg.parent == "0x0" || cfg.l_parent == "0x0" || cfg.r_parent == "0x0"; isparentEmpty = parent[0] == "0x0";
// console.log(cfg.id);
// console.log(parent);
// console.log(isparentEmpty);
if (isparentEmpty) { if (isparentEmpty) {
@ -140,6 +147,7 @@ export default Util.registerShape(
[0.5, 0], [0.5, 0],
[0.5, 0.125], [0.5, 0.125],
[0.6, 1], [0.6, 1],
[0.5,1]
]; ];
}, },
} }