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

Added Backdrop Node for Meshroom graph #2574

Open
wants to merge 28 commits into
base: develop
Choose a base branch
from
Open

Conversation

waaake
Copy link
Contributor

@waaake waaake commented Oct 21, 2024

TCSR-1194

Feature Request

  • Added Backdrop Node
  • Notion of Region inside a Graph

Minor Fix

  • Added Key Press of Backspace to allow deletion in the graph.

@waaake waaake added the feature request feature request from the community label Oct 21, 2024
@waaake waaake self-assigned this Oct 21, 2024
@fabiencastan fabiencastan added majorFeature and removed feature request feature request from the community labels Oct 22, 2024
@cbentejac cbentejac added this to the Meshroom 2024.1.0 milestone Oct 23, 2024
Comment on lines 802 to 859
class Backdrop(InputNode):
""" A Backdrop for other nodes.
"""

# The internal inputs' of Backdrop Node needs a Integer Field to determine the font size for the comment
internalInputs = [
StringParam(
name="invalidation",
label="Invalidation Message",
description="A message that will invalidate the node's output folder.\n"
"This is useful for development, we can invalidate the output of the node when we modify the code.\n"
"It is displayed in bold font in the invalidation/comment messages tooltip.",
value="",
semantic="multiline",
advanced=True,
uidIgnoreValue="", # If the invalidation string is empty, it does not participate to the node's UID
),
StringParam(
name="comment",
label="Comments",
description="User comments describing this specific node instance.\n"
"It is displayed in regular font in the invalidation/comment messages tooltip.",
value="",
semantic="multiline",
invalidate=False,
),
IntParam(
name="fontSize",
label="Font Size",
description="The Font size for the User Comment on the Backdrop.",
value=12,
range=(6, 100, 1),
),
FloatParam(
name="nodeWidth",
label="Node Width",
description="The Backdrop Node's Width.",
value=600,
range=None,
enabled=False # Hidden always
),
FloatParam(
name="nodeHeight",
label="Node Height",
description="The Backdrop Node's Height.",
value=400,
range=None,
enabled=False # Hidden always
),
ColorParam(
name="color",
label="Color",
description="Custom color for the node (SVG name or hexadecimal code).",
value="",
invalidate=False,
)
]

Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason why we totally overwrite the internal inputs instead of using the ones from the parent class and adding "Font Size" to it?

With the current way, there's a lot of duplication and the "Node's Label" internal attribute is lost, which I think is a shame since we may want to name the backdrop itself, and not just use the "Comments" attribute. This would prevent having several backdrops named "Backdrop", "Backdrop2", "Backdrop3", and so on... if we want to name them. Similarly, the "Invalidation Message" is currently preserved although it has no impact anywhere so far.

@@ -135,7 +139,7 @@ Item {
Keys.onPressed: {
if (event.key === Qt.Key_F) {
fit()
} else if (event.key === Qt.Key_Delete) {
} else if (event.key === Qt.Key_Delete || event.key === Qt.Key_Backspace) { // Backspace supports both Windows and MacOS Keyboards
Copy link
Contributor

Choose a reason for hiding this comment

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

Not directly related to this, but when a backdrop contains nodes, is there no way to remove the background only and not the background AND everything it contains? (that's a real question, not necessarily a change request)

@waaake waaake marked this pull request as draft November 26, 2024 11:28
@waaake waaake force-pushed the dev/BackdropNode branch 2 times, most recently from 0a4bf9f to e73c4df Compare December 18, 2024 07:12
@waaake waaake marked this pull request as ready for review December 18, 2024 07:13
@waaake waaake requested a review from yann-lty December 18, 2024 07:13
Copy link

codecov bot commented Dec 18, 2024

Codecov Report

Attention: Patch coverage is 69.04762% with 26 lines in your changes missing coverage. Please review.

Project coverage is 69.90%. Comparing base (0586336) to head (6a97f48).
Report is 29 commits behind head on develop.

Files with missing lines Patch % Lines
meshroom/core/node.py 48.93% 24 Missing ⚠️
meshroom/core/desc/node.py 96.15% 1 Missing ⚠️
meshroom/core/graph.py 66.66% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #2574      +/-   ##
===========================================
- Coverage    69.93%   69.90%   -0.03%     
===========================================
  Files          121      122       +1     
  Lines         7088     7158      +70     
===========================================
+ Hits          4957     5004      +47     
- Misses        2131     2154      +23     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

waaake added 11 commits January 1, 2025 20:04
Attribute factory serves as a common place to initialize and group attributes and define an accessor to be able to retrieve the attributes
Backdrop Node serves as a Graphical Node allowing only internal attributes to be listed and can be serialized
Added Backdrop Node descriptor which is a derived Incomputable Node with Resizable Attribute Traits
The Loader allows loading Backdrop Component for backdrop nodes and Standard Node component for other nodes
waaake added 3 commits January 2, 2025 09:08
…at a given index

With the change in nodeRepeater to hold the Loader instead of active delegate, fetching the item at a given index involves getting the loader at index and then it's item. This function allows easy access to the item directly.
waaake added 6 commits January 7, 2025 06:13
When dragging a backdrop node from the left side the node has to be moved and resized at the same time and the same needs to be done when an undo is performed, in order to do that with a single undo, a grouping is necessary for the two operations
…UI Graph

The disableAnimation flag would be used in the UI to control when an Animation is to occur
The Grouped UI Modfications can be used to disabled overall animations for the UI Graph when commands get executed during both undo and redo operation.
…for qml elements

Used graph's disabledAnimation flag to halt the animations when a backdrop node is resized during an undo.
]

@classmethod
def getInternalParameters(cls, traits: Traits) -> List[Union[StringParam, ColorParam, IntParam, FloatParam]]:
Copy link
Member

@fabiencastan fabiencastan Jan 11, 2025

Choose a reason for hiding this comment

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

I don't see a reason to hardcode a list of specific param types. -> List[Attribute]

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 was hesitant to import Attribute just for this purpose, but it's updated now.

@fabiencastan
Copy link
Member

By default, when we move the backdrop, the elements within it are also moved. If we use Ctrl+Click, we only move the background, but when we stop dragging the backdrop, the elements in it are still moved!

pcoip_client_cli_THKCgNzfmI

@fabiencastan
Copy link
Member

The brightness of the node's default color should remain low for the links to be visible.

@fabiencastan
Copy link
Member

Minimal size for the backdrop is too large:
image

@fabiencastan
Copy link
Member

Copy-paste does not work:

pcoip_client_cli_RbRMhBQYbj.mp4

Comment on lines 771 to 775
# Get the Node Constructor which should be initialized for the given node type
# Node or Backdrop...
NodeType = getPreferredNodeConstructor(nodeType)

n = self.addNode(NodeType(nodeType, position=position, **kwargs), uniqueName=name)
Copy link
Member

Choose a reason for hiding this comment

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

Directly use a function to create the node, instead of a function to return the node type.

Suggested change
# Get the Node Constructor which should be initialized for the given node type
# Node or Backdrop...
NodeType = getPreferredNodeConstructor(nodeType)
n = self.addNode(NodeType(nodeType, position=position, **kwargs), uniqueName=name)
n = self.addNode(createNode(nodeType, position=position, **kwargs), uniqueName=name)

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 updated.

@@ -0,0 +1,12 @@
""" Defines the Built in Plugins.
Copy link
Member

@fabiencastan fabiencastan Jan 12, 2025

Choose a reason for hiding this comment

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

I would expect the embedded nodes to be in a folder loaded automatically by Meshroom, in the same way than we are doing for external nodes:
meshroom/nodes/utils/Backdrop.py

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Discussing with @yann-lty initially to have a way to register builtin plugins.
So have added this accordingly.
We can discuss and simplify this if needed 🙂

Comment on lines +365 to +368
def initBuiltinNodePlugins():
""" Registers the Builtin plugins for Meshroom.
"""
registerNodeType(builtins.Backdrop)
Copy link
Member

Choose a reason for hiding this comment

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

We can remove that if we move it to the standard folder.


cursorShape: drag.active ? Qt.ClosedHandCursor : Qt.ArrowCursor

/// Backdrop Resize Controls ???
Copy link
Member

Choose a reason for hiding this comment

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

Why "???"

}

///
/// Resize Bottom
Copy link
Member

Choose a reason for hiding this comment

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

Probably wants to be able to resize from the top too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Resize Top has been added.

Comment on lines 263 to 265
if (root.height < 300) {
root.height = 300;
}
Copy link
Member

Choose a reason for hiding this comment

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

Probably want to declare this constant somewhere else.
This value is too big.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

set as const value of 200, which seems more reasonable.

///
/// Resize Bottom
///
Rectangle {
Copy link
Member

Choose a reason for hiding this comment

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

It would be good to display a line on hover as we do between top widgets.

Would be used to save any node children for a given node, most likely a Backdrop node, could be extended in future for Group nodes or subGraph
[core] Graph: Updated addNode and pasteNode functions to refer to createNode method from core Node
…set to 200 by default

Backdrop has a darker color compared to the base color to make the edges of nodes inside it visible
The node children are referenced later during the copy of the node and can be pasted to allow copying of the contents of the backdrop along with it
@waaake
Copy link
Contributor Author

waaake commented Jan 13, 2025

Minimal size for the backdrop is too large: image

This is updated to be a const value set to 200 w and 200 h by default

@waaake
Copy link
Contributor Author

waaake commented Jan 13, 2025

Copy-paste does not work:

pcoip_client_cli_RbRMhBQYbj.mp4
Aah, I had missed to check this, my bad !!
This is updated to now copy-paste the backdrop along with the contents of it.

@waaake
Copy link
Contributor Author

waaake commented Jan 13, 2025

By default, when we move the backdrop, the elements within it are also moved. If we use Ctrl+Click, we only move the background, but when we stop dragging the backdrop, the elements in it are still moved!

pcoip_client_cli_THKCgNzfmI pcoip_client_cli_THKCgNzfmI

Currently the standard Nodes also have this behaviour, can be fixed in a separate one if you say or in this ?

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

Successfully merging this pull request may close these issues.

3 participants