Skip to content

Commit d776e6c

Browse files
committed
pipe style bug
1 parent 89c9763 commit d776e6c

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

NodeGraphQt/base/graph.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414
from NodeGraphQt.base.model import NodeGraphModel
1515
from NodeGraphQt.base.node import NodeObject
1616
from NodeGraphQt.base.port import Port
17-
from NodeGraphQt.constants import DRAG_DROP_ID
17+
from NodeGraphQt.constants import (DRAG_DROP_ID,
18+
PIPE_LAYOUT_CURVED,
19+
PIPE_LAYOUT_STRAIGHT)
1820
from NodeGraphQt.widgets.viewer import NodeViewer
1921

2022

@@ -381,15 +383,20 @@ def set_acyclic(self, mode=False):
381383
self._model.acyclic = mode
382384
self._viewer.acyclic = mode
383385

384-
def set_pipe_layout(self, layout='curved'):
386+
def set_pipe_style(self, style=None):
385387
"""
386388
Set node graph pipes to be drawn straight or curved by default
387-
all pipes are set curved. (default='curved')
389+
all pipes are set curved. (default=0)
390+
391+
PIPE_LAYOUT_CURVED = 0
392+
PIPE_LAYOUT_STRAIGHT = 1
388393
389394
Args:
390-
layout (str): 'straight' or 'curved'
395+
style (int): pipe style.
391396
"""
392-
self._viewer.set_pipe_layout(layout)
397+
pipe_default = max([PIPE_LAYOUT_CURVED, PIPE_LAYOUT_STRAIGHT])
398+
style = PIPE_LAYOUT_STRAIGHT if style > pipe_default else style
399+
self._viewer.set_pipe_layout(style)
393400

394401
def fit_to_selection(self):
395402
"""

NodeGraphQt/widgets/viewer.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
from NodeGraphQt import QtGui, QtCore, QtWidgets
66
from NodeGraphQt.constants import (IN_PORT, OUT_PORT,
77
PIPE_LAYOUT_CURVED,
8-
PIPE_LAYOUT_STRAIGHT,
98
PIPE_STYLE_DASHED,
109
SCENE_AREA,
1110
Z_VAL_NODE_WIDGET)
@@ -677,12 +676,8 @@ def center_selection(self, nodes=None):
677676
def get_pipe_layout(self):
678677
return self._pipe_layout
679678

680-
def set_pipe_layout(self, layout=''):
681-
layout_types = {
682-
'curved': PIPE_LAYOUT_CURVED,
683-
'straight': PIPE_LAYOUT_STRAIGHT
684-
}
685-
self._pipe_layout = layout_types.get(layout, 'curved')
679+
def set_pipe_layout(self, layout):
680+
self._pipe_layout = layout
686681
for pipe in self.all_pipes():
687682
pipe.draw_path(pipe.input_port, pipe.output_port)
688683

0 commit comments

Comments
 (0)