-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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] add support for selecting multiple nodes at once #1227
Conversation
cursor is only 'closed hand' when scrolling the graph
I often get this error when manipulating nodes in the GraphEditor:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the really cool PR!
I have added few notes to clean the code before integration.
meshroom/ui/graph.py
Outdated
for node in self._selectedNodes: | ||
position = Position(node.x + deltaX, node.y + deltaY) | ||
self.push(commands.MoveNodeCommand(self._graph, node, position)) | ||
|
||
@Slot(Node) | ||
def removeNode(self, node): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The check on locked
makes sense, but should we really care about the notion of selection here?
The function is called removeNode
and takes a node in parameter, so it should just do the action.
meshroom/ui/graph.py
Outdated
if not node.locked: | ||
self.push(commands.RemoveNodeCommand(self._graph, node)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if not node.locked: | |
self.push(commands.RemoveNodeCommand(self._graph, node)) | |
self.removeNode(node) |
meshroom/ui/graph.py
Outdated
if not node.locked: | ||
self.removeNode(node) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if not node.locked: | |
self.removeNode(node) | |
self.removeNode(node) |
Already checked in the function.
meshroom/ui/graph.py
Outdated
@@ -569,19 +599,33 @@ def duplicateNode(self, srcNode, duplicateFollowingNodes=False): | |||
Returns: | |||
[Nodes]: the list of duplicated nodes | |||
""" | |||
title = "Duplicate Nodes from {}" if duplicateFollowingNodes else "Duplicate {}" | |||
if duplicateFollowingNodes: title = "Duplicate Nodes from {}" | |||
elif self.nodeSelection(srcNode): title = "Duplicate selected nodes" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should not have links with the notion of node selection at this level. The UI use the selection to determine the list of nodes. Then we have the list of nodes and perform actions on it. But the low-level functions should not check the notion of selection again.
The function is explicit: duplicateNode(srcNode, duplicateFollowingNodes=False)
. We don't expect that to check the notion of selection.
meshroom/ui/graph.py
Outdated
# enable updates between duplication and layout to get correct depths during layout | ||
with self.groupedGraphModification(title.format(srcNode.name), disableUpdates=False): | ||
# disable graph updates during duplication | ||
with self.groupedGraphModification("Node duplication", disableUpdates=True): | ||
duplicates = self.push(commands.DuplicateNodeCommand(self._graph, srcNode, duplicateFollowingNodes)) | ||
if self.nodeSelection(srcNode) and not duplicateFollowingNodes: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same, no notion of selection here.
meshroom/ui/graph.py
Outdated
# move nodes below the bounding box formed by the duplicated node(s) | ||
bbox = self._layout.boundingBox(duplicates) | ||
for n in duplicates: | ||
self.moveNode(n, Position(n.x, bbox[3] + self.layout.gridSpacing + n.y)) | ||
|
||
return duplicates | ||
|
||
@Slot(QObject) | ||
def clearData(self, node): | ||
if self.nodeSelection(node): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same, no notion of selection here.
meshroom/ui/graph.py
Outdated
def clearNodeSelection(self): | ||
""" Clear node selection. """ | ||
self.selectedNode = None | ||
|
||
@Slot() | ||
def clearNodesSelections(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def clearNodesSelections(self): | |
def clearNodesSelection(self): |
meshroom/ui/commands.py
Outdated
for nodeName in self.duplicates: | ||
self.graph.removeNode(nodeName) | ||
|
||
class DuplicateNodeListCommand(_DuplicateNodes): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't need to have 2 classes to do it with one of multiple nodes and inheritance, etc.
Either we keep DuplicateNodeListCommand
and always use it (even for a single node) or keep DuplicateNodeCommand
and group the commands for multiple nodes.
It would be great the replace the "Alt+click" to select all the nodes after (instead of duplicating the nodes). |
Regarding the selection, I think we should clear the selection and select all the newly created nodes. |
Really great PR, this is a life changer! |
…on alt + left click
I agree that this does not behave right. Should I remove the options '_ from here' or should I rework them to include the other selected nodes? I think that removing those options and relying on alt + click to select the following nodes is more intuitive than having these options that operate on some nodes that are not selected. What do you think @fabiencastan? |
Good question. I agree that's redundant and makes two ways to do the same. |
Love it :) Only a few minor layout issues #1389 (nodes overlap and auto layout problems), but it might be too much for this PR |
@ChemicalXandco Is it ready for review? Or are you still working on it? |
It is ready |
Great work! |
Description
The ability to select multiple nodes at once improves the efficiency of using the graph editor. I have tried to make the node selection behave similar to blender. The box select widget is used by dragging with the left mouse button. The main selected node is slightly brighter than the other selected nodes and has a blue border.
Features list
(Resolves some points on #269)