Commit graph

65 commits

Author SHA1 Message Date
Yann Lanthony
4aec741a89 [core] Graph: add importGraphContent API
Extract the logic of importing the content of a graph within a graph instance from
the graph loading logic.
Add `Graph.importGraphContent` and `Graph.importGraphContentFromFile`
methods.
Use the deserialization API to load the content in another temporary graph instance,
to handle the renaming of nodes using the Graph API, rather than manipulating
entries in a raw dictionnary.
2025-02-06 16:46:04 +01:00
Yann Lanthony
c883c53397 [core] Refactor nodeFactory function
Rewrite `nodeFactory` to reduce cognitive complexity,
while preserving the current behavior.
2025-02-06 16:46:04 +01:00
Yann Lanthony
025e0e3322 [core] Move nodeFactory to its own module 2025-02-06 16:46:04 +01:00
Candice Bentéjac
579371fd7c [qt6] Replace all PySide2/shiboken2 imports by PySide6/shiboken6 2024-11-07 18:08:54 +01:00
Fabien Castan
54bf61cc5c [ui] commands: When we undo a node upgrade we enforce uidConflict=True as there was a uid conflict before 2024-06-15 18:05:25 +02:00
Fabien Castan
020dbecc68 [core] attribute: new initValue, independant from the resetToDefaultValue
Avoid to evaluate the default value if we don't need to.
2024-06-15 18:05:24 +02:00
Candice Bentéjac
e9ee9f2315 Update ListAttributes identically when removing edges or nodes
The behaviour regarding `ListAttributes` was different depending on
whether an edge or a node was removed:
- if an edge was removed, the `ListAttribute` that was the destination
of that edge had its corresponding element completely removed;
- if a node was removed, the `ListAttribute` that was the destination
of one of the node's edges had its corresponding element reset, but not
removed.

With this behaviour, a user had different UIDs depending on whether
a single edge or the whole node had been removed where the UID should
always be identical.
2024-02-02 15:23:44 +01:00
Candice Bentéjac
66ffe017a4 [ui] Rename "Clear Images" actions into "Remove All Images"
Update the names of the commands that remove images in the "File"
menu to match with those in the Image Gallery menu.

"Clear Images" becomes "Remove All Images" and "Clear All Images" becomes
"Remove Images From All CameraInit Nodes".
2023-10-11 18:07:18 +02:00
Candice Bentéjac
8f6f3eec08 [ui] Clear Images: Request graph update after resetting the attributes 2023-03-13 10:08:28 +01:00
Fabien Castan
ce2085faad
Merge pull request #1744 from alicevision/dev/internalAttributes
Add internal attributes in "Notes" tab
2023-03-05 13:46:47 +01:00
Candice Bentéjac
43f439be88 [ui] Add a "Clear All Images" action and update "Clear Images"'s behaviour
"Clear Images" used to clear the intrinsics and viewpoints for all the
existing CameraInit nodes in the graph. There was no-user friendly way
to clear the images of a specific CameraInit node.

This commit modifies the behaviour of "Clear Images" so that it only
deletes the intrinsics and viewpoints of the current CameraInit. A new menu
action, "Clear All Images", is added in the "Advanced" sub-menu, and
deletes all the intrinsics and viewpoints for all the CameraInit nodes.

The way images are cleared is also modified: instead of removing the
intrinsics and viewpoints attributes, they are reset. To be undone
properly, a corresponding "ClearImagesCommand" has been added. This offers
a great performance increase (clearing 1000 images now takes 1s).

Tooltips have been added to make the distinction clearer for users.
2023-02-22 13:24:32 +01:00
Candice Bentéjac
9bc9e2c129 Add "Notes" tab with "comment"/"invalid comment" attributes
Add two internal attributes, "Comment" and "Invalid comment", in
a specific "Notes" tab, which will contain any further internal
attribute. Internal attributes exist for all nodes.
2023-02-15 08:36:10 +00:00
Candice Bentéjac
6a36da61cf [ui] GraphEditor: select pipelines imported through the node menu
Add all the nodes from a pipeline imported through the node menu to the
node selection.
This involves changing the return value of ImportProjectCommand from a
boolean to a list of imported nodes.
2022-12-02 18:19:56 +01:00
Candice Bentéjac
c2570ca0fb [ui] GraphEditor: Import pipeline on the mouse's position with the node menu
If a pipeline is imported with the node menu instead of the "Import
Project" action from the File menu, the top-left "corner" of the graph
should be placed on the mouse's position.
The position of pipelines imported with the "Import Project" menu
remains unchanged: they are automatically placed below the lowest
node in the current graph.
2022-12-02 18:13:17 +01:00
Loïc Vital
d0fcb67d1c [ui] rename Import Scene to Import Project for coherent naming 2022-09-23 11:22:36 +02:00
Candice Bentéjac
d06acf6722 Reconnect copied/pasted nodes together but not to the graph
If several nodes are described in the clipboard and are supposed to
be connected with each other, reconnect them together, but do not
attempt to reconnect them to the graph they were copied from, even if
it is the current graph.
2022-09-06 11:13:29 +02:00
Candice Bentéjac
a33f79e4d7 Import a scene from an .mg file into the current graph
Add an "Import Scene" (Ctrl+Shift+I) option in the File menu
that allows to select an existing .mg file and import it in the
current graph.

The imported scene will automatically be placed below the lowest
existing node along the Y axis.
2022-08-31 10:50:35 +02:00
Candice Bentéjac
5b65866e49 [ui] Paste a node on the mouse's position
When creating a node with a "paste" operation, place the node
on the mouse's position in the graph instead of default position (0,0).

If the mouse is placed on an existing node, the pasted node will be
placed on the mouse's position plus an offset so that the pasted node
does not directly overlap with the existing node.
2022-08-19 12:02:09 +02:00
Candice Bentéjac
ddda62a652 Add node to graph with Ctrl+V if valid node content is in the clipboard
Attempt to paste the clipboard's content in the graph when Ctrl+V is
pressed. If the clipboard contains a valid node description, add the
corresponding node to the graph.
Otherwise, do nothing.
2022-08-19 12:00:16 +02:00
Candice Bentéjac
b77274a027 Store all duplicates of a node correctly upon their creation
Duplicates used to be stored in a dictionary with an entry being
"parent node": "duplicated node". On occasions where a single
parent node was duplicated more than once, the latest duplicated
 node erased the previous one(s), and these older ones were
"lost": after being created, there was no trace left of their
existence in the duplication operation. Undoing that duplication
operation was thus leaving these duplicated nodes out and not
removing them.

Duplicated nodes are now stored as "parent node": [list of
duplicated nodes] to keep track of all the created nodes,
effectively removing them upon an "undo".
2022-07-28 14:13:31 +02:00
Landrodie
79955ddae6 [core] Change attribute name and label properties
Adding new properties and updating the call to previous ones.
Properties are now :
* label : getLabel
* fullLabel : getFullLabel
* fullLabelToNode : getFullLabelToNode
* fullLabelToGraph : getFullLabelToGraph

Same for the name.
2021-08-23 17:52:40 +02:00
ChemicalXandco
acf1bf2116 [ui] grapheditor: explicitly pass selected nodes argument 2021-01-26 21:13:16 +00:00
ChemicalXandco
c253e7d363 [ui] add support for selecting multiple nodes at once 2021-01-15 18:16:45 +00:00
Fabien Castan
5fb6a5fb0f [ui] GraphEditor: only connect compatible attributes 2020-12-28 16:18:51 +01:00
Julien-Haudegond
5f444e6810 [ui] Commands: handle undo stack while computing and submitting
Computing: lock the undo stack at the current index to avoid going back too far and potentially alter computing process.
Submitting: clear the undo stack.
2020-09-02 11:30:12 +02:00
Yann Lanthony
400835d8f8 [core] Attribute: expose 'fullName' as property 2018-11-19 15:17:36 +01:00
Yann Lanthony
f415745a4a [ui] make Nodes moves undoable
Handle nodes move and auto-layout on Python side by using GraphLayout and MoveNodeCommand.

* Node QML component relies on underlying core.Node object's position
* MoveNodeCommand is called after a Node has been dragged
* partial/full auto-layout for specific graph operations (Duplication, Augmentation...) are now part of those operations
* serialized position in node data allows to properly restore nodes coordinates on undo/redo
* remove all layout/node moving code from QML
2018-07-26 22:46:22 +02:00
Yann Lanthony
830173047c [ui][commands] Duplicate/UpgradeNode: return created Node instances 2018-07-26 22:43:48 +02:00
Yann Lanthony
ac4772fc57 [ui][commands] add MoveNodeCommand
add undoable command to move a Node to a target position
2018-07-26 18:01:11 +02:00
Yann Lanthony
93dd055f72 [clean] fix variable names and typos
* node_factory & attribute_factory to camelCase
* fix depths variable in updateNodesTopologicalData
2018-07-26 12:11:43 +02:00
Yann Lanthony
dd3d9cd54b [core][ui] add upgradeAllNodes methods
+ check if node is upgradable in UpgradeNodeCommand
2018-07-20 17:55:30 +02:00
Yann Lanthony
2952e11691 [core] move duplicateNode methods to core.graph
handle this low-level operation engine side

* fix ListAttribute children links duplication
* handle CompatibilityNode duplication
* move corresponding unit test in test_graph.py
* [ui] add DuplicateNodeCommand
2018-07-19 13:50:45 +02:00
Yann Lanthony
a18d75c0f9 [ui][commands] expose UpgradeNode command 2018-07-19 13:50:45 +02:00
Yann Lanthony
33eb7f3a7f [core] introduce CompatibilityNode for improved scene compatibilities
Improve node serialization/deserialization to be able to recreate the exact same node in the graph when loading a meshroom project, even if the corresponding node's description has changed or does not exist anymore. This allows to recover already computed data on disk, without being impacted by changed uids. CompatibilityNode also provides an on-demand upgrade system to turn into a Node that meets the current node description (if possible).
 
* new abstract class BaseNode, base class for Node and CompatibiliyNode 
* Node: serialize everything needed to spawn a CompatibilityNode with precomputed outputs: inputs, uids, parallelization settings, unresolved internal folders and outputs
* node_factory: handles node deserialization and compatibility issues to create either a Node or a CompatibilityNode
* add compatibility unit tests
2018-07-19 13:50:45 +02:00
Yann Lanthony
1f675a0e42 [core] split graph.py into separate modules
core.graph is now splitted into: 
  * graph.py
  * node.py
  * attribute.py
2018-06-26 12:19:14 +02:00
Yann Lanthony
48ef285267 [commands] AddNode: convert list children attributes as link expression 2018-06-18 14:58:38 +02:00
Yann Lanthony
27555b1e7f [command] SetAttribute: use getExportValue to store previous value
keep track of link expressions
2018-06-18 14:58:37 +02:00
Yann Lanthony
d4c0d4cb36 [commands] AddNode: serialize links to other Attributes
avoid storing a reference to Attribute objects that might get deleted
2018-03-21 15:53:34 +01:00
Yann Lanthony
4f392a310b [commands] GroupedGraphModification: add 'disableUpdates' option
gives control over whether graph updates should be disabled during this grouped modification
2018-03-21 15:53:34 +01:00
Yann Lanthony
4ea793be74 [ui] return command result after pushing it to the undo stack
this allows to directly retrieve, for instance, the node created by UIGraph.addNode method
2018-01-12 13:59:07 +01:00
Yann Lanthony
614ef3a5d1 [graph] improve Node constructor arguments naming 2018-01-05 19:18:40 +01:00
Yann Lanthony
8c7a4bcc0f [commands] use addNewNode on RemoveNode.undo
use addNewNode to ensure node's internals are updated after creation
2017-12-19 15:02:45 +01:00
Yann Lanthony
06303c5773 [commands] add GraphModification on RemoveNode.undo
Avoid multiple graph updates on node/edges creation
2017-11-28 22:37:48 +01:00
Yann Lanthony
c3a1f05fdf [commands] introduce GroupedGraphModification
* allow to group graph modifications at undo/redo level
* add new EnableGraphUpdateCommand to change graph update behavior as a undoable command
2017-11-14 16:17:22 +01:00
Yann Lanthony
5f49e26216 [commands] ListAttributeAppendCommand: handle 'None' as value 2017-11-14 15:14:12 +01:00
Yann Lanthony
8b2224609c [commands] add higher-level error catching on undo/redo 2017-11-14 15:13:17 +01:00
Yann Lanthony
5d549e9155 [commands] SetAttribute: store previous primitive value 2017-11-14 14:56:19 +01:00
Yann Lanthony
f6ae3ae057 [ui] support for appending multiple elements to a ListAttribute at once 2017-11-07 20:34:33 +01:00
Yann Lanthony
9bc8eaeb1b [commands] improve AddNodeCommand
use node name instead of a direct reference to the Node
2017-11-07 20:27:52 +01:00
Yann Lanthony
e38f112c55 [core] fix memory management
* parent Nodes, Edges and Attributes to their respective models
* use weakrefs for those objects to avoid cyclic references
* add 'root' property on Attribute for parenting to List/GroupAttribute (parent still exists for Qt-style parenting)
* UI: update commands to match those changes
2017-11-07 20:18:17 +01:00