Route of disconnected links

Hi,

When the user drags a shape from the stencil, a new node is created with a disconnected link for each port of the node.

If the user changes the position of the node, the new route of the links keeps the point corresponding to the disconnected end

Is there some configuration so the new route of the link maintains the original relative position in relation to the node?

Thanks
Dario

Do you get the behavior that you want if you manually select those links in addition to the node(s) that you want to move?

If so, you could implement such behavior by overriding DraggingTool.computeEffectiveCollection to include partly connected Links that connect with selected Nodes.

I don’t know if there are any examples of exactly this case, but I do know that there are several examples of overriding that method for different purposes.

Hi Walter, you are right.
I overrode DraggingTool.computeEffectiveCollection to include the disconnected links of the nodes selected.

The code is

export function onDraggingParts(modelEditor: ModelEditorDiagramComponent, draggingTool: DraggingTool, parts) {
    let nodes: Node[] = [];
    let links: Link[] = [];
    var it = parts.iterator;
    while (it.next()) {
        var part = it.value;
        if (part instanceof Node) {
            nodes.push(part);
        }
        if (part instanceof Link) {
            links.push(part);
        }
    }
    let iterator;
    let link: Link;
    let linksToAdd: Link[] = [];
    for (let i = 0; i < nodes.length; i++) {
        iterator = nodes[i].findLinksConnected();
        while (iterator.next()) {
            link = iterator.value;
            // Only considers disconnected links that is not in the selection
            if ((!link.fromNode || !link.toNode) &&
                !isLinkInParts(parts, link, modelEditor.configuratorService.getLinkKeyProperty())) {
                linksToAdd.push(link);
            }
        }
    }
    var map = DraggingTool.prototype.computeEffectiveCollection.call(draggingTool, parts);
    for (let i = 0; i < linksToAdd.length; i++) {
        map.add(linksToAdd[i], { point: new Point() });
    }
    return map;
}

function isLinkInParts(parts, link: Link, idProperty): boolean {
    var it = parts.iterator;
    while (it.next()) {
        var part = it.value;
        if (part instanceof Link && part.data[idProperty] === link.data[idProperty]) {
            return true;
        }
    }
    return false;
}

Thanks