Open aloytag opened 9 months ago
I found the problem in NodeGraph._serialize()
and NodeGraph._deserialize()
methods.
Remove this line in NodeGraph._serialize()
:
serial_data['graph']['layout_direction'] = self.layout_direction()
With that line, the graph layout setting overwrites every node layout. But instead, we want to respect particular node layouts.
And add this line in NodeGraph._deserialize()
when building the nodes:
node.set_layout_direction(n_data['layout_direction'])
This way, the new (deserialized) nodes copy the layout direction from the original (serialized) nodes.
Attached is a file with the modified methods. modified_graph.zip
If the layout direction in a node is changed to vertical, then duplicating that node causes a strange behavior. For example, consider
node_a
in vertical layout. Then use theNodeGraph.duplicate_nodes()
method to duplicate it. The result: The duplicated node and the original node (node_a
) are both in horizontal layout.Basic example case:
I think the problem may be in one of the
NodeGraph._serialize()
orNodeGraph._deserialize()
methods. I've been using these methods in my application in order to save and load a graph into/from a file, and have been experiencing some errors with layout directions.Regards.
NodeGraphQt version: 0.6.29 Qt.py version: 1.3.7 PySide2 version: 5.15.2.1 Python version: 3.9.2