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

Update link connections by dragging between ports #1569

Conversation

erikaharrison-adsk
Copy link
Contributor

Currently, one must explicitly delete an existing link before adding a new link for a given node. This change enables dragging to update a link connection, and automatically deletes the existing link on the input pin if one exists.

Note: An output pin on a node may have many outgoing links, but an input pin may only have one incoming link. This behaviour is unchanged.

Example video: https://github.com/AcademySoftwareFoundation/MaterialX/assets/85182970/7a825225-09f7-4936-abb9-f294978ebaaf

Also:

  • Renames a few variables for consistency on start/end and input/output pins
  • Ensures you can't add a link from an input to an input, or from an output to an output
  • Can also drag from an output to an input and have it correctly delete existing link

Original issue/sub-issue: #1398 (comment)

…n over the port (replace the connection) from Issue 1398.
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Oct 13, 2023

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: erikaharrison-adsk / name: Erika Harrison (e5c332f, 173a7de)

@@ -2483,12 +2483,22 @@ void Graph::setDefaults(mx::InputPtr input)
}
}

void Graph::addLink(ed::PinId inputPinId, ed::PinId outputPinId)
void Graph::addLink(ed::PinId startPinId, ed::PinId endPinId)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found input vs. output, start vs. end a bit confusing. Have tried to make this more accurate by checking the input pin is actually an input pin.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for making that change! It's a lot clearer now.

@@ -2505,187 +2515,206 @@ void Graph::addLink(ed::PinId inputPinId, ed::PinId outputPinId)
return;
}

if (inputPin->_connected == false)
// Perform kind check
bool kindsMatch = (outputPin->_kind == inputPin->_kind);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added check that the output and input pins are not the same kinds (eg. not both Output and not both Input).

if (ed::AcceptNewItem())
{
// If the accepting node already has a link, remove it
if (inputPin->_connected)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the crux of the new work - if we do have a connection for our input pin, we remove the existing link associated with it.

@@ -2505,187 +2515,206 @@ void Graph::addLink(ed::PinId inputPinId, ed::PinId outputPinId)
return;
}

if (inputPin->_connected == false)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We no longer skip if the input pin has a connection. Note: This resulted in the rest of the work being tabbed back (and likely caused the resulting ugly diff - it looked better on my computer, sorry).

@@ -4045,12 +4074,12 @@ void Graph::drawGraph(ImVec2 mousePos)
// Add new link
if (ed::BeginCreate())
{
ed::PinId inputPinId, outputPinId, filterPinId;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also tweaked the terminology here. imgui's node editor simply returns a start/end -- could be output to input or input to output. Changed the terminology here to reflect that.

Copy link
Contributor

@lfl-eholthouser lfl-eholthouser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @erikaharrison-adsk ! This looks great, looking forward to trying it out.

Copy link
Member

@jstone-lucasfilm jstone-lucasfilm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work on this improvement, thanks @erikaharrison-adsk!

@jstone-lucasfilm jstone-lucasfilm changed the title Autodesk: Update links connections by dragging between ports Update links connections by dragging between ports Oct 13, 2023
@jstone-lucasfilm jstone-lucasfilm changed the title Update links connections by dragging between ports Update links by dragging between ports Oct 13, 2023
@jstone-lucasfilm jstone-lucasfilm changed the title Update links by dragging between ports Update link connections by dragging between ports Oct 13, 2023
@jstone-lucasfilm jstone-lucasfilm merged commit eb52ec2 into AcademySoftwareFoundation:main Oct 13, 2023
31 checks passed
Michaelredaa pushed a commit to Michaelredaa/MaterialX that referenced this pull request Oct 21, 2023
…ndation#1569)

Currently, one must explicitly delete an existing link before adding a new link for a given node. This change enables dragging to update a link connection, and automatically deletes the existing link on the input pin if one exists.

Note: An output pin on a node may have many outgoing links, but an input pin may only have one incoming link. This behaviour is unchanged.

Also:

- Renames a few variables for consistency on start/end and input/output pins
- Ensures you can't add a link from an input to an input, or from an output to an output
- Can also drag from an output to an input and have it correctly delete existing link
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

Successfully merging this pull request may close these issues.

None yet

3 participants