@@ -136,6 +136,17 @@ def __init__(self, parent=None, **kwargs):
136136 self .setObjectName ('NodeGraph' )
137137 self ._model = (
138138 kwargs .get ('model' ) or NodeGraphModel ())
139+ self ._node_factory = (
140+ kwargs .get ('node_factory' ) or NodeFactory ())
141+ self ._undo_view = None
142+ self ._undo_stack = (
143+ kwargs .get ('undo_stack' ) or QtWidgets .QUndoStack (self )
144+ )
145+ self ._widget = None
146+ self ._sub_graphs = {}
147+ self ._viewer = (
148+ kwargs .get ('viewer' ) or NodeViewer (undo_stack = self ._undo_stack )
149+ )
139150
140151 layout_direction = kwargs .get ('layout_direction' )
141152 if layout_direction :
@@ -144,22 +155,17 @@ def __init__(self, parent=None, **kwargs):
144155 self ._model .layout_direction = layout_direction
145156 else :
146157 layout_direction = self ._model .layout_direction
147-
148- self ._node_factory = (
149- kwargs .get ('node_factory' ) or NodeFactory ())
150-
151- self ._undo_view = None
152- self ._undo_stack = (
153- kwargs .get ('undo_stack' ) or QtWidgets .QUndoStack (self ))
154-
155- self ._widget = None
156-
157- self ._sub_graphs = {}
158-
159- self ._viewer = (
160- kwargs .get ('viewer' ) or NodeViewer (undo_stack = self ._undo_stack ))
161158 self ._viewer .set_layout_direction (layout_direction )
162159
160+ pipe_style = kwargs .get ('pipe_style' )
161+ if pipe_style is not None :
162+ if pipe_style not in [e .value for e in PipeLayoutEnum ]:
163+ pipe_style = PipeLayoutEnum .CURVED .value
164+ self ._model .pipe_style = pipe_style
165+ else :
166+ pipe_style = self ._model .pipe_style
167+ self ._viewer .set_pipe_layout (pipe_style )
168+
163169 # viewer needs a reference to the model port connection constrains
164170 # for the user interaction with the live pipe.
165171 self ._viewer .accept_connection_types = self ._model .accept_connection_types
@@ -953,6 +959,18 @@ def set_pipe_slicing(self, mode=True):
953959 self ._model .pipe_slicing = mode
954960 self ._viewer .pipe_slicing = self ._model .pipe_slicing
955961
962+ def pipe_style (self ):
963+ """
964+ Returns the current pipe layout style.
965+
966+ See Also:
967+ :meth:`NodeGraph.set_pipe_style`
968+
969+ Returns:
970+ int: pipe style value. :attr:`NodeGraphQt.constants.PipeLayoutEnum`
971+ """
972+ return self ._model .pipe_style
973+
956974 def set_pipe_style (self , style = PipeLayoutEnum .CURVED .value ):
957975 """
958976 Set node graph pipes to be drawn as curved `(default)`, straight or angled.
@@ -976,6 +994,7 @@ def set_pipe_style(self, style=PipeLayoutEnum.CURVED.value):
976994 PipeLayoutEnum .STRAIGHT .value ,
977995 PipeLayoutEnum .ANGLE .value ])
978996 style = style if 0 <= style <= pipe_max else PipeLayoutEnum .CURVED .value
997+ self ._model .pipe_style = style
979998 self ._viewer .set_pipe_layout (style )
980999
9811000 def layout_direction (self ):
@@ -990,7 +1009,7 @@ def layout_direction(self):
9901009 Returns:
9911010 int: layout direction.
9921011 """
993- return self .model .layout_direction
1012+ return self ._model .layout_direction
9941013
9951014 def set_layout_direction (self , direction ):
9961015 """
@@ -1624,6 +1643,7 @@ def _serialize(self, nodes):
16241643 serial_data ['graph' ]['acyclic' ] = self .acyclic ()
16251644 serial_data ['graph' ]['pipe_collision' ] = self .pipe_collision ()
16261645 serial_data ['graph' ]['pipe_slicing' ] = self .pipe_slicing ()
1646+ serial_data ['graph' ]['pipe_style' ] = self .pipe_style ()
16271647
16281648 # connection constrains.
16291649 serial_data ['graph' ]['accept_connection_types' ] = self .model .accept_connection_types
@@ -1692,6 +1712,8 @@ def _deserialize(self, data, relative_pos=False, pos=None):
16921712 self .set_pipe_collision (attr_value )
16931713 elif attr_name == 'pipe_slicing' :
16941714 self .set_pipe_slicing (attr_value )
1715+ elif attr_name == 'pipe_style' :
1716+ self .set_pipe_style (attr_value )
16951717
16961718 # connection constrains.
16971719 elif attr_name == 'accept_connection_types' :
@@ -2316,10 +2338,14 @@ def expand_group_node(self, node):
23162338 # build new sub graph.
23172339 node_factory = copy .deepcopy (self .node_factory )
23182340 layout_direction = self .layout_direction ()
2341+ kwargs = {
2342+ 'layout_direction' : self .layout_direction (),
2343+ 'pipe_style' : self .pipe_style (),
2344+ }
23192345 sub_graph = SubGraph (self ,
23202346 node = node ,
23212347 node_factory = node_factory ,
2322- layout_direction = layout_direction )
2348+ ** kwargs )
23232349
23242350 # populate the sub graph.
23252351 session = node .get_sub_graph_session ()
0 commit comments