@@ -126,6 +126,15 @@ def __init__(self, parent=None, **kwargs):
126126 self .setObjectName ('NodeGraph' )
127127 self ._model = (
128128 kwargs .get ('model' ) or NodeGraphModel ())
129+
130+ layout_direction = kwargs .get ('layout_direction' )
131+ if layout_direction :
132+ if layout_direction not in [e .value for e in LayoutDirectionEnum ]:
133+ layout_direction = LayoutDirectionEnum .HORIZONTAL .value
134+ self ._model .layout_direction = layout_direction
135+ else :
136+ layout_direction = self ._model .layout_direction
137+
129138 self ._node_factory = (
130139 kwargs .get ('node_factory' ) or NodeFactory ())
131140
@@ -139,6 +148,7 @@ def __init__(self, parent=None, **kwargs):
139148
140149 self ._viewer = (
141150 kwargs .get ('viewer' ) or NodeViewer (undo_stack = self ._undo_stack ))
151+ self ._viewer .set_layout_direction (layout_direction )
142152
143153 self ._build_context_menu ()
144154 self ._register_builtin_nodes ()
@@ -802,6 +812,8 @@ def set_layout_direction(self, direction):
802812 This function will also override the layout direction on all
803813 nodes in the current node graph.
804814
815+ `Implemented in` ``v0.3.0``
816+
805817 Note:
806818 By default node graph direction is set to "NODE_LAYOUT_HORIZONTAL".
807819
@@ -1906,7 +1918,11 @@ def expand_group_node(self, node):
19061918
19071919 # build new sub graph.
19081920 node_factory = copy .deepcopy (self .node_factory )
1909- sub_graph = SubGraph (self , node = node , node_factory = node_factory )
1921+ layout_direction = self .layout_direction ()
1922+ sub_graph = SubGraph (self ,
1923+ node = node ,
1924+ node_factory = node_factory ,
1925+ layout_direction = layout_direction )
19101926
19111927 # populate the sub graph.
19121928 session = node .get_sub_graph_session ()
@@ -1958,14 +1974,17 @@ class SubGraph(NodeGraph):
19581974 -
19591975 """
19601976
1961- def __init__ (self , parent = None , node = None , node_factory = None ):
1977+ def __init__ (self , parent = None , node = None , node_factory = None , ** kwargs ):
19621978 """
19631979 Args:
19641980 parent (object): object parent.
19651981 node (GroupNode): group node related to this sub graph.
19661982 node_factory (NodeFactory): override node factory.
1983+ **kwargs (dict): additional kwargs.
19671984 """
1968- super (SubGraph , self ).__init__ (parent , node_factory = node_factory )
1985+ super (SubGraph , self ).__init__ (
1986+ parent , node_factory = node_factory , ** kwargs
1987+ )
19691988
19701989 # sub graph attributes.
19711990 self ._node = node
@@ -2329,7 +2348,10 @@ def expand_group_node(self, node):
23292348
23302349 # build new sub graph.
23312350 node_factory = copy .deepcopy (self .node_factory )
2332- sub_graph = SubGraph (self , node = node , node_factory = node_factory )
2351+ sub_graph = SubGraph (self ,
2352+ node = node ,
2353+ node_factory = node_factory ,
2354+ layout_direction = self .layout_direction ())
23332355
23342356 # populate the sub graph.
23352357 serialized_session = node .get_sub_graph_session ()
0 commit comments