-
Notifications
You must be signed in to change notification settings - Fork 5
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 #7
Comments
This looks good, I'm glad you were able to improve on my attempt. I'd like to see this merged if the load issue can be fixed. |
thank you @matthew-reid. If at any moment you could look at the code I'd be glad, 4 eyes are better of two. |
The bug about loading has been fixed, now feature should be complete. |
* send adding/removing signal by port index. * shift ports when middle port is removed. * dynamic load and save of the ports. * added MinModel and MaxModel in calculator example. * added method hasDynamicPorts(PortType) to NodeDataModel. * added a .flow sample for calculator.
The code looks good. The only thing I would suggest is to add static helper functions readNumInputs(obj), readNumOutputs(obj) to NodeDataModel to parse the number of ports from the json object, so that the implementation of restore() doesn't need to know about the "dynamic_inputs" and "dynamic_outputs" string. An example restore override would look like:
|
I agree with your idea, yet don't know how to put it down without complicate the library or doing something very situational. Maybe a whole helper class for serialized information could be useful since there are several hardcoded key string. Need to think a bit about that. |
* send adding/removing signal by port index. * shift ports when middle port is removed. * dynamic load and save of the ports. * added MinModel and MaxModel in calculator example. * added method hasDynamicPorts(PortType) to NodeDataModel. * added a .flow sample for calculator.
* send adding/removing signal by port index. * shift ports when middle port is removed. * dynamic load and save of the ports. * added MinModel and MaxModel in calculator example. * added method hasDynamicPorts(PortType) to NodeDataModel. * added a .flow sample for calculator.
* send adding/removing signal by port index. * shift ports when middle port is removed. * dynamic load and save of the ports. * added MinModel and MaxModel in calculator example. * added method hasDynamicPorts(PortType) to NodeDataModel. * added a .flow sample for calculator.
Hello, @Daguerreo. Cool feature! I'm trying to implement dynamic outputs, and have faced several issues. To add outputs dynamically, I have implemented two slots:
The issue happens on delete.
However, there is still a problem with consequent connections. If I remove a child node - everything is file. If I just click on in port of a child node, the app will remove the connection and will try to add it again. At the same time, the app will shift other nodes, which will lead to the following issue: dynamic_outputs.mp4Maybe I do not understand something. Is there a better way to handle dynamic outputs? |
Hello @Sarrasor. Calculator example do contains an example node with dynamic ports. Have you looked at it? |
Yep. The thing is - the example considers dynamic input ports, not dynamic output ports. For example, consider the The logic of the dynamic port increments and signals is implemented in the Is there an example of dynamic output ports, which I missed? |
I'm going to take a look into it. I could not do it in a very short time though. At first glance seems you're going to remove the port when the connection does still exists in the graphics object. |
@Sarrasor I've noticed NodeDataModel::outputConnectionDeleted() and NodeDataModel::ConnectionDeleted() are called twice when a node is deleted. There are a few of double call in the library, this one could affect the behaviour. I'm going to investigate |
Ok, I've should fixed the multiple delete connection call and added some nullptr check. In addition, I added a node using dynamic outputs in calculator example dynoutput-.5.mp4 |
Great, thank you! Now my code works too: example.mp4The only thing I can suggest is to explicitly cast Line 76 in 69149b3
|
* send adding/removing signal by port index. * shift ports when middle port is removed. * dynamic load and save of the ports. * added MinModel and MaxModel in calculator example. * added method hasDynamicPorts(PortType) to NodeDataModel. * added a .flow sample for calculator.
* send adding/removing signal by port index. * shift ports when middle port is removed. * dynamic load and save of the ports. * added MinModel and MaxModel in calculator example. * added method hasDynamicPorts(PortType) to NodeDataModel. * added a .flow sample for calculator.
EDIT: I just realized that this issue thread is on a fork of nodeeditor. Opened a new issue here @Daguerreo I'm trying to do something very similar as shown in the video above, i.e., whenever an input connection is created, +1 input port is added. I've seen the 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.mp4If I add 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.mp4The Any help is much appreciated. |
There are several try of implementation of dynamic ports. The current status is:
paceholder#209, paceholder#212
paceholder#251 is an improvement to 202 and 219, yet not completed because do not handle remotion of middle ports.
paceholder#268 try to make a patch to the dynamic loading of 209.
However the best implementation has not a pull request and it's from @matthew-reid dynamicInterface branch
However the issues with that branch are:
Based on those previous attempt I've made a branch dynamic-ports with these features:
To deal with dynamic loading/saving I added a method
hasDynamicPorts(PortType) const
toNodeDataModel
. If a model is marked as dynamic for port(s) type, when serializing it automatically add an entrydynamic_inputs
and/ordynamic_outputs
to write the number of ports at save time because they can be different from when they are created.2020-12-20-17-39-01.mp4
The text was updated successfully, but these errors were encountered: