Skip to content

Commit 0c65743

Browse files
authored
Merge pull request #183 from jchanvfx/connection_bug_fix_#173
addressed issue #173
2 parents 771665e + 736dad0 commit 0c65743

File tree

14 files changed

+131
-10
lines changed

14 files changed

+131
-10
lines changed

NodeGraphQt/base/graph.py

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ def close(self):
502502

503503
def viewer(self):
504504
"""
505-
Returns the view interface used by the node graph.
505+
Returns the internal view interface used by the node graph.
506506
507507
Warnings:
508508
Methods in the ``NodeViewer`` are used internally
@@ -572,8 +572,17 @@ def set_grid_mode(self, mode=VIEWER_GRID_LINES):
572572
"""
573573
Set node graph grid mode.
574574
575+
Note:
576+
By default grid mode is set to "VIEWER_GRID_LINES".
577+
578+
Node graph background types:
579+
580+
* :attr:`NodeGraphQt.constants.VIEWER_GRID_NONE`
581+
* :attr:`NodeGraphQt.constants.VIEWER_GRID_DOTS`
582+
* :attr:`NodeGraphQt.constants.VIEWER_GRID_LINES`
583+
575584
Args:
576-
mode: VIEWER_GRID_LINES/VIEWER_GRID_DOTS/VIEWER_GRID_NONE.
585+
mode (int): background styles.
577586
"""
578587
self.scene().grid_mode = mode
579588
self._viewer.force_update()
@@ -734,8 +743,11 @@ def set_pipe_style(self, style=PIPE_LAYOUT_CURVED):
734743
"""
735744
Set node graph pipes to be drawn as straight, curved or angled.
736745
746+
.. image:: _images/pipe_layout_types.gif
747+
:width: 80%
748+
737749
Note:
738-
By default all pipes are set curved.
750+
By default pipe layout is set to "PIPE_LAYOUT_CURVED".
739751
740752
Pipe Layout Styles:
741753
@@ -1239,6 +1251,7 @@ def _deserialize(self, data, relative_pos=False, pos=None, set_parent=True):
12391251
Args:
12401252
data (dict): node data.
12411253
relative_pos (bool): position node relative to the cursor.
1254+
pos (tuple or list): custom x, y position.
12421255
set_parent (bool): set node parent to current node space.
12431256
12441257
Returns:
@@ -1280,7 +1293,10 @@ def _deserialize(self, data, relative_pos=False, pos=None, set_parent=True):
12801293
self.add_node(node, n_data.get('pos'), unique_name=set_parent)
12811294

12821295
if n_data.get('dynamic_port', None):
1283-
node.set_ports({'input_ports': n_data['input_ports'], 'output_ports': n_data['output_ports']})
1296+
node.set_ports({
1297+
'input_ports': n_data['input_ports'],
1298+
'output_ports': n_data['output_ports']
1299+
})
12841300

12851301
# build the connections.
12861302
for connection in data.get('connections', []):

NodeGraphQt/base/port.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,9 @@ def connect_to(self, port=None):
145145
if not port:
146146
return
147147

148+
if self in port.connected_ports():
149+
return
150+
148151
graph = self.node().graph
149152
viewer = graph.viewer()
150153

NodeGraphQt/constants.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,11 @@
8888

8989
# === NODE VIEWER ===
9090

91+
#: Style to render the node graph background with nothing.
9192
VIEWER_GRID_NONE = 0
93+
#: Style to render the node graph background with dots.
9294
VIEWER_GRID_DOTS = 1
95+
#: Style to render the node graph background with grid lines.
9396
VIEWER_GRID_LINES = 2
9497

9598
VIEWER_BG_COLOR = (35, 35, 35)

NodeGraphQt/widgets/node_publish_widget.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
import os
2+
13
from .properties import PropFileSavePath
24
from .. import QtWidgets
3-
import os
45

56

67
class _element_widget(QtWidgets.QWidget):

NodeGraphQt/widgets/viewer.py

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class NodeViewer(QtWidgets.QGraphicsView):
2323
"""
2424
The widget interface used for displaying the scene and nodes.
2525
26-
functions in this class are called by the
26+
functions in this class should mainly be called by the
2727
class:`NodeGraphQt.NodeGraph` class.
2828
"""
2929

@@ -665,6 +665,13 @@ def apply_live_connection(self, event):
665665
self.end_live_connection()
666666
return
667667

668+
# end connection if starting port is already connected.
669+
if self._start_port.multi_connection and \
670+
self._start_port in end_port.connected_ports:
671+
self._detached_port = None
672+
self.end_live_connection()
673+
return
674+
668675
# register as disconnected if not acyclic.
669676
if self.acyclic and not self.acyclic_check(self._start_port, end_port):
670677
if self._detached_port:
@@ -814,6 +821,16 @@ def message_dialog(text, title='Node Graph'):
814821
BaseDialog.message_dialog(text, title)
815822

816823
def load_dialog(self, current_dir=None, ext=None):
824+
"""
825+
Prompt node viewer file load dialog widget.
826+
827+
Args:
828+
current_dir (str): directory path starting point. (optional)
829+
ext (str): custom file extension filter type. (optional)
830+
831+
Returns:
832+
str: selected file path.
833+
"""
817834
ext = '*{} '.format(ext) if ext else ''
818835
ext_filter = ';;'.join([
819836
'Node Graph ({}*json)'.format(ext), 'All Files (*)'
@@ -824,6 +841,16 @@ def load_dialog(self, current_dir=None, ext=None):
824841
return file
825842

826843
def save_dialog(self, current_dir=None, ext=None):
844+
"""
845+
Prompt node viewer file save dialog widget.
846+
847+
Args:
848+
current_dir (str): directory path starting point. (optional)
849+
ext (str): custom file extension filter type. (optional)
850+
851+
Returns:
852+
str: selected file path.
853+
"""
827854
ext_label = '*{} '.format(ext) if ext else ''
828855
ext_type = '.{}'.format(ext) if ext else '.json'
829856
ext_map = {'Node Graph ({}*json)'.format(ext_label): ext_type,
@@ -924,6 +951,14 @@ def remove_node(node):
924951
node.delete()
925952

926953
def move_nodes(self, nodes, pos=None, offset=None):
954+
"""
955+
Globally move specified nodes.
956+
957+
Args:
958+
nodes (list[AbstractNodeItem]): node items.
959+
pos (tuple or list): custom x, y position.
960+
offset (tuple or list): x, y position offset.
961+
"""
927962
group = self.scene().createItemGroup(nodes)
928963
group_rect = group.boundingRect()
929964
if pos:

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,11 @@ applications that supports PySide2.
3838
<img src="/docs/_images/prop_bin.png" width="600" title="Properties Bin">
3939

4040
#### Vertical Layout
41-
<img src="/docs/_images/vertical_layout.png" width="600" title="Vertical Layout">
41+
<img src="/docs/_images/vertical_layout.png" width="400" title="Vertical Layout">
42+
43+
#### Pipe Layout
44+
45+
<img src="/docs/_images/pipe_layout_types.gif" width="600" title="Pipe Layout">
4246

4347
#### Example
4448

docs/_images/menu_hotkeys.png

0 Bytes
Loading

docs/_images/pipe_layout_menu.png

4.12 KB
Loading

docs/_images/pipe_layout_types.gif

36.2 KB
Loading

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@
162162
# author, documentclass [howto, manual, or own class]).
163163
latex_documents = [
164164
(master_doc, 'NodeGraphQT.tex', 'NodeGraphQt Documentation',
165-
'Johnny Chan', 'manual'),
165+
author, 'manual'),
166166
]
167167

168168

0 commit comments

Comments
 (0)