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

[ui] Graph Editor Update: Quick Node Coloring with the Color Selector Tool #2604

Merged
merged 5 commits into from
Nov 29, 2024

Conversation

waaake
Copy link
Contributor

@waaake waaake commented Nov 25, 2024

Description

Added Color Selector in the Graph Editor

Features list

  • The Color Selector Provides a really quick way to apply color onto selected nodes or to remove it.
  • Currently holds a limited set of frequently used colors.
  • Uses 'C' Key as the shortcut to toggle the Color Selector.

Implementation remarks

The color selector in the Graph Editor provides a quick way to color nodes with predefined palette of colors.

Added Command to allow the Coloring to be undone and redone using QUndoStack
@waaake waaake self-assigned this Nov 25, 2024
Copy link
Member

@yann-lty yann-lty left a comment

Choose a reason for hiding this comment

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

Implementation-wise: this should rely on the existing SetAttributeCommand.
UX-wise: I would suggest re-working the color palette for better contrast with the font color.

meshroom/ui/graph.py Outdated Show resolved Hide resolved
@@ -952,6 +952,17 @@ def selectFollowing(self, node):
""" Select all the nodes the depend on 'node'. """
self.selectNodes(self._graph.dfsOnDiscover(startNodes=[node], reverse=True, dependenciesOnly=True)[0])

@Slot(str)
def updateNodeColor(self, color):
Copy link
Member

Choose a reason for hiding this comment

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

As this method is working on the node selection (which makes sense), I would recommend:

Suggested change
def updateNodeColor(self, color):
def setSelectedNodesColor(self, color: str):

meshroom/ui/qml/Controls/ColorSelector.qml Show resolved Hide resolved
Current meshroom nodes have the FG text in gray and the background color needs to constrast well else the text becomes unreadable
Copy link
Member

@yann-lty yann-lty left a comment

Choose a reason for hiding this comment

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

Minor fixes left, but LGTM after that 👍.

@@ -556,6 +556,15 @@ def getColor(self):
return self.internalAttribute("color").value.strip()
return ""

def setColor(self, color: str):
Copy link
Member

Choose a reason for hiding this comment

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

With regards to what this PR is addressing, adding the setter for this property is not needed.

@@ -1386,7 +1395,7 @@ def has3DOutputAttribute(self):
internalAttributes = Property(BaseObject, getInternalAttributes, constant=True)
internalAttributesChanged = Signal()
label = Property(str, getLabel, notify=internalAttributesChanged)
color = Property(str, getColor, notify=internalAttributesChanged)
color = Property(str, getColor, setColor, notify=internalAttributesChanged)
Copy link
Member

Choose a reason for hiding this comment

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

(same as above) Adding the setter is not needed in this scope.

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 has been removed.

color (str): Hex code of the color to be set on the nodes.
"""
# Update the color attribute of the nodes which are currently selected
with self.groupedGraphModification("Update Color for Select Nodes"):
Copy link
Member

Choose a reason for hiding this comment

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

For the command name that appears in the undo stack:

Suggested change
with self.groupedGraphModification("Update Color for Select Nodes"):
with self.groupedGraphModification("Set Nodes Color"):

I think we could go with removing the notion of "selected" in those, as selection operations are not undoable - therefore, undoing "Set Selected Nodes Color" is a bit ambiguous if the selection has changed in between.
What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, makes sense, I probably did not notice this while working on the previous comments. Thanks for the suggestion.

meshroom/ui/qml/Controls/ColorSelector.qml Show resolved Hide resolved
Coloring the nodes now uses setAttribute command instead of relying on refrences to Nodes within the graph.
Copy link
Member

@yann-lty yann-lty left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@yann-lty yann-lty left a comment

Choose a reason for hiding this comment

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

The "C" shortcut is currently breaking the Copy action (Ctrl+C).

@@ -136,6 +136,8 @@ Item {
Keys.onPressed: function(event) {
if (event.key === Qt.Key_F) {
fit()
} else if (event.key === Qt.Key_C) {
Copy link
Member

Choose a reason for hiding this comment

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

This takes precedence over the copy shortcut (Ctrl+C).
We need better handling of keyboard shortcuts, but in the meantime, this should either test if no modifier are active, or be moved at after the copy action handling.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, it's my bad, I did not notice something as simple as this. Have updated the code to consider both cases.

Copy link
Member

@yann-lty yann-lty left a comment

Choose a reason for hiding this comment

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

👍

@yann-lty yann-lty merged commit e800cd4 into develop Nov 29, 2024
3 checks passed
@yann-lty yann-lty deleted the dev/NodeColoring branch November 29, 2024 10:16
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.

4 participants