Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamic ports in v3 #404

Open
RValner opened this issue Dec 5, 2023 · 0 comments
Open

Dynamic ports in v3 #404

RValner opened this issue Dec 5, 2023 · 0 comments

Comments

@RValner
Copy link

RValner commented Dec 5, 2023

There are quite a few resolved issues that touch the subject of "dynamic ports", but I wasn't able to find the solution.

I'm trying to do something very similar as shown in this video, i.e., whenever an input connection is created, +1 input port is added. I've seen the dynamic_ports example, but it's built on top of AbstractGraphModel, which to me seemed unnecessarily complex. Thus decided to use NodeDelegateModel instead, keeping the code on node level.

The issue i'm having is that if I have for example 3 connections and then remove the middle one, the connections will not be shifted, as shown in the video below:

dynamic_ports_bug_1.mp4

If I add portsAboutToBeDeleted and portsDeleted calls (as instructed here) to the overridden inputConnectionDeleted method:

void UmrfNodeModel::inputConnectionDeleted(QtNodes::ConnectionId const &ci)
{
    std::cout << ci.inPortIndex << std::endl;
    portsAboutToBeDeleted(PortType::In, ci.inPortIndex, ci.inPortIndex);
    input_connections_.erase(input_connections_.begin() + ci.inPortIndex);
    portsDeleted();
}

then deleting any connection above other connections will result removing all connections below it, as shown in the video:

dynamic_ports_bug_2.mp4

The std::cout << ci.inPortIndex << std::endl; also shows that inputConnectionDeleted is indeed called for each deleted connection, hinting a recursive behavior. My gut feeling says i've added portsAboutToBeDeleted and portsDeleted to a wrong place, but atm I'm out of ideas, as there is not much to play with in the NodeDelegateModel API. I did skim throuh one of the older commits in a dynamic ports related fork that implemented the desired behavior, but the API seems to have changed quite a bit in v3.

Any help is much appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant