Skip to content

Commit 07fc03f

Browse files
committed
Merge remote-tracking branch 'upstream/master' into develop
2 parents ac3ab4c + bb30186 commit 07fc03f

29 files changed

+270
-190
lines changed

NodeGraphQt/__init__.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,8 @@ def __init__(self):
7676
try:
7777
from Qt import QtWidgets, QtGui, QtCore, QtCompat, QtOpenGL
7878
except ImportError as ie:
79-
from Qt import __version__ as qtpy_ver
80-
from Qt import QtWidgets, QtGui, QtCore, QtCompat ,QtOpenGL
81-
print('NodeGraphQt: Can\'t import "Qt.py" module falling back on '
82-
'"Qt ({})"'.format(qtpy_ver))
79+
print('NodeGraphQt: Please install "Qt.py" : pip install Qt.py')
80+
raise ImportError(ie)
8381

8482
from .base.graph import NodeGraph, SubGraph
8583
from .base.menu import NodesMenu, NodeGraphMenu, NodeGraphCommand

NodeGraphQt/base/commands.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/python
2+
from Qt import QtWidgets
3+
24
from .utils import minimize_node_ref_count
3-
from .. import QtWidgets
45
from ..constants import IN_PORT, OUT_PORT
56

67

NodeGraphQt/base/graph.py

Lines changed: 40 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
#!/usr/bin/python
22
# -*- coding: utf-8 -*-
3+
import copy
34
import gc
45
import json
56
import os
67
import re
78

8-
import copy
9+
from Qt import QtCore, QtWidgets, QtGui
910

1011
from .commands import (NodeAddedCmd,
1112
NodeRemovedCmd,
@@ -16,7 +17,6 @@
1617
from .model import NodeGraphModel
1718
from .node import NodeObject, BaseNode
1819
from .port import Port
19-
from .. import QtCore, QtWidgets, QtGui
2020
from ..constants import (DRAG_DROP_ID,
2121
PIPE_LAYOUT_CURVED,
2222
PIPE_LAYOUT_STRAIGHT,
@@ -648,7 +648,7 @@ def context_menu(self):
648648
649649
Note:
650650
This is a convenience function to
651-
:meth:`NodeGraphQt.NodeGraph.get_context_menu`
651+
:meth:`NodeGraph.get_context_menu`
652652
with the arg ``menu="graph"``
653653
654654
Returns:
@@ -662,7 +662,7 @@ def context_nodes_menu(self):
662662
663663
Note:
664664
This is a convenience function to
665-
:meth:`NodeGraphQt.NodeGraph.get_context_menu`
665+
:meth:`NodeGraph.get_context_menu`
666666
with the arg ``menu="nodes"``
667667
668668
Returns:
@@ -719,7 +719,7 @@ def acyclic(self):
719719
Returns true if the current node graph is acyclic.
720720
721721
See Also:
722-
:meth:`NodeGraphQt.NodeGraph.set_acyclic`
722+
:meth:`NodeGraph.set_acyclic`
723723
724724
Returns:
725725
bool: true if acyclic (default: ``True``).
@@ -731,7 +731,7 @@ def set_acyclic(self, mode=False):
731731
Enable the node graph to be a acyclic graph. (default: ``False``)
732732
733733
See Also:
734-
:meth:`NodeGraphQt.NodeGraph.acyclic`
734+
:meth:`NodeGraph.acyclic`
735735
736736
Args:
737737
mode (bool): true to enable acyclic.
@@ -1333,6 +1333,11 @@ def serialize_session(self):
13331333
"""
13341334
Serializes the current node graph layout to a dictionary.
13351335
1336+
See Also:
1337+
:meth:`NodeGraph.deserialize_session`,
1338+
:meth:`NodeGraph.save_session`,
1339+
:meth:`NodeGraph.load_session`
1340+
13361341
Returns:
13371342
dict: serialized session of the current node layout.
13381343
"""
@@ -1342,6 +1347,11 @@ def deserialize_session(self, layout_data):
13421347
"""
13431348
Load node graph session from a dictionary object.
13441349
1350+
See Also:
1351+
:meth:`NodeGraph.serialize_session`,
1352+
:meth:`NodeGraph.load_session`,
1353+
:meth:`NodeGraph.save_session`
1354+
13451355
Args:
13461356
layout_data (dict): dictionary object containing a node session.
13471357
"""
@@ -1353,6 +1363,11 @@ def save_session(self, file_path):
13531363
"""
13541364
Saves the current node graph session layout to a `JSON` formatted file.
13551365
1366+
See Also:
1367+
:meth:`NodeGraph.serialize_session`,
1368+
:meth:`NodeGraph.deserialize_session`,
1369+
:meth:`NodeGraph.load_session`,
1370+
13561371
Args:
13571372
file_path (str): path to the saved node layout.
13581373
"""
@@ -1384,6 +1399,11 @@ def load_session(self, file_path):
13841399
"""
13851400
Load node graph session layout file.
13861401
1402+
See Also:
1403+
:meth:`NodeGraph.deserialize_session`,
1404+
:meth:`NodeGraph.serialize_session`,
1405+
:meth:`NodeGraph.save_session`
1406+
13871407
Args:
13881408
file_path (str): path to the serialized layout file.
13891409
"""
@@ -1429,8 +1449,12 @@ def copy_nodes(self, nodes=None):
14291449
"""
14301450
Copy nodes to the clipboard.
14311451
1452+
See Also:
1453+
:meth:`NodeGraph.cut_nodes`
1454+
14321455
Args:
1433-
nodes (list[NodeGraphQt.BaseNode]): list of nodes (default: selected nodes).
1456+
nodes (list[NodeGraphQt.BaseNode]):
1457+
list of nodes (default: selected nodes).
14341458
"""
14351459
nodes = nodes or self.selected_nodes()
14361460
if not nodes:
@@ -1447,8 +1471,12 @@ def cut_nodes(self, nodes=None):
14471471
"""
14481472
Cut nodes to the clipboard.
14491473
1474+
See Also:
1475+
:meth:`NodeGraph.copy_nodes`
1476+
14501477
Args:
1451-
nodes (list[NodeGraphQt.BaseNode]): list of nodes (default: selected nodes).
1478+
nodes (list[NodeGraphQt.BaseNode]):
1479+
list of nodes (default: selected nodes).
14521480
"""
14531481
self._undo_stack.beginMacro('cut nodes')
14541482
nodes = nodes or self.selected_nodes()
@@ -1531,7 +1559,7 @@ def question_dialog(self, text, title='Node Graph'):
15311559
15321560
Note:
15331561
Convenience function to
1534-
:meth:`NodeGraphQt.NodeGraph.viewer().question_dialog`
1562+
:meth:`NodeGraph.viewer().question_dialog`
15351563
15361564
Args:
15371565
text (str): question text.
@@ -1548,7 +1576,7 @@ def message_dialog(self, text, title='Node Graph'):
15481576
15491577
Note:
15501578
Convenience function to
1551-
:meth:`NodeGraphQt.NodeGraph.viewer().message_dialog`
1579+
:meth:`NodeGraph.viewer().message_dialog`
15521580
15531581
Args:
15541582
text (str): message text.
@@ -1562,7 +1590,7 @@ def load_dialog(self, current_dir=None, ext=None):
15621590
15631591
Note:
15641592
Convenience function to
1565-
:meth:`NodeGraphQt.NodeGraph.viewer().load_dialog`
1593+
:meth:`NodeGraph.viewer().load_dialog`
15661594
15671595
Args:
15681596
current_dir (str): path to a directory.
@@ -1579,7 +1607,7 @@ def save_dialog(self, current_dir=None, ext=None):
15791607
15801608
Note:
15811609
Convenience function to
1582-
:meth:`NodeGraphQt.NodeGraph.viewer().save_dialog`
1610+
:meth:`NodeGraph.viewer().save_dialog`
15831611
15841612
Args:
15851613
current_dir (str): path to a directory.

NodeGraphQt/base/menu.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
#!/usr/bin/python
22
from distutils.version import LooseVersion
33

4-
from .. import QtGui, QtCore
4+
from Qt import QtGui, QtCore
5+
56
from ..errors import NodeMenuError
67
from ..widgets.actions import BaseMenu, GraphAction, NodeAction
78

NodeGraphQt/base/node.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1218,6 +1218,15 @@ def auto_size(self):
12181218
"""
12191219
self.view.auto_resize()
12201220

1221+
def wrap_nodes(self, nodes):
1222+
"""
1223+
Wrap backdrop size to fit around specified nodes.
1224+
1225+
Args:
1226+
nodes (list[NodeGraphQt.NodeObject]): list of nodes.
1227+
"""
1228+
self.view.auto_resize([n.view for n in nodes])
1229+
12211230
def nodes(self):
12221231
"""
12231232
Returns nodes wrapped within the backdrop node.

NodeGraphQt/base/port.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ def lock(self):
141141
This is the same as calling :meth:`Port.set_locked` with the arg
142142
set to ``True``
143143
"""
144-
self.set_locked(True)
144+
self.set_locked(True, connected_ports=True)
145145

146146
def unlock(self):
147147
"""
@@ -151,18 +151,22 @@ def unlock(self):
151151
This is the same as calling :meth:`Port.set_locked` with the arg
152152
set to ``False``
153153
"""
154-
self.set_locked(False)
154+
self.set_locked(False, connected_ports=True)
155155

156-
def set_locked(self, locked=False):
156+
def set_locked(self, state=False, connected_ports=True):
157157
"""
158158
Sets the port locked state. When locked pipe connections can't be
159159
connected or disconnected from this port.
160160
161161
Args:
162-
locked (Bool): true if locked.
162+
state (Bool): port lock state.
163+
connected_ports (Bool): apply to lock state to connected ports.
163164
"""
164-
self.model.locked = locked
165-
self.__view.locked = locked
165+
self.model.locked = state
166+
self.__view.locked = state
167+
if connected_ports:
168+
for port in self.connected_ports():
169+
port.set_locked(state, connected_ports=False)
166170

167171
def connected_ports(self):
168172
"""

NodeGraphQt/base/utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
#!/usr/bin/python
22
from distutils.version import LooseVersion
33

4-
from .. import QtGui, QtCore
4+
from Qt import QtGui, QtCore
5+
56
from ..constants import (PIPE_LAYOUT_CURVED,
67
PIPE_LAYOUT_STRAIGHT,
78
PIPE_LAYOUT_ANGLE,

NodeGraphQt/qgraphics/node_abstract.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/python
22

3-
from .. import QtCore, QtWidgets
3+
from Qt import QtCore, QtWidgets
44

55
from ..constants import (Z_VAL_NODE, NODE_WIDTH, NODE_HEIGHT, ITEM_CACHE_MODE)
66

NodeGraphQt/qgraphics/node_backdrop.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
#!/usr/bin/python
2+
from Qt import QtGui, QtCore, QtWidgets
23

3-
from .. import QtGui, QtCore, QtWidgets
4-
from ..constants import (Z_VAL_PIPE,
5-
NODE_SEL_COLOR,
6-
NODE_SEL_BORDER_COLOR)
74
from .node_abstract import AbstractNodeItem
85
from .pipe import Pipe
96
from .port import PortItem
7+
from ..constants import (Z_VAL_PIPE,
8+
NODE_SEL_COLOR,
9+
NODE_SEL_BORDER_COLOR)
1010

1111

1212
class BackdropSizer(QtWidgets.QGraphicsItem):

0 commit comments

Comments
 (0)