Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions NodeGraphQt/base/commands.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/python
from NodeGraphQt import QtWidgets
from .. import QtWidgets

from NodeGraphQt.constants import IN_PORT, OUT_PORT
from ..constants import IN_PORT, OUT_PORT


class PropertyChangedCmd(QtWidgets.QUndoCommand):
Expand Down
2 changes: 1 addition & 1 deletion NodeGraphQt/base/factory.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/python

from NodeGraphQt.errors import NodeRegistrationError
from ..errors import NodeRegistrationError


class NodeFactory(object):
Expand Down
43 changes: 22 additions & 21 deletions NodeGraphQt/base/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,22 @@
import re
import copy

from NodeGraphQt import QtCore, QtWidgets, QtGui
from NodeGraphQt.base.commands import (NodeAddedCmd,
NodeRemovedCmd,
NodeMovedCmd,
PortConnectedCmd)
from NodeGraphQt.base.factory import NodeFactory
from NodeGraphQt.base.menu import NodeGraphMenu, NodesMenu
from NodeGraphQt.base.model import NodeGraphModel
from NodeGraphQt.base.node import NodeObject, BaseNode
from NodeGraphQt.base.port import Port
from NodeGraphQt.constants import (DRAG_DROP_ID,
PIPE_LAYOUT_CURVED,
PIPE_LAYOUT_STRAIGHT,
PIPE_LAYOUT_ANGLE,
IN_PORT, OUT_PORT)
from NodeGraphQt.widgets.viewer import NodeViewer
from .. import QtCore, QtWidgets, QtGui
from .commands import (NodeAddedCmd,
NodeRemovedCmd,
NodeMovedCmd,
PortConnectedCmd)
from .factory import NodeFactory
from .menu import NodeGraphMenu, NodesMenu
from .model import NodeGraphModel
from .node import NodeObject, BaseNode
from .port import Port
from ..constants import (DRAG_DROP_ID,
PIPE_LAYOUT_CURVED,
PIPE_LAYOUT_STRAIGHT,
PIPE_LAYOUT_ANGLE,
IN_PORT, OUT_PORT)
from ..widgets.viewer import NodeViewer


class QWidgetDrops(QtWidgets.QWidget):
Expand All @@ -43,7 +43,7 @@ def dropEvent(self, event):
for url in event.mimeData().urls():
self.import_session(url.toLocalFile())
else:
e.ignore()
event.ignore()


class NodeGraph(QtCore.QObject):
Expand Down Expand Up @@ -119,6 +119,7 @@ class NodeGraph(QtCore.QObject):
:parameters: :str
:emits: new session path
"""

def __init__(self, parent=None):
super(NodeGraph, self).__init__(parent)
self.setObjectName('NodeGraphQt')
Expand Down Expand Up @@ -204,7 +205,7 @@ def _on_property_bin_changed(self, node_id, prop_name, prop_value):
node = self.get_node_by_id(node_id)

# prevent signals from causing a infinite loop.
_exc = [float, int , str, bool, None]
_exc = [float, int, str, bool, None]
if node.get_property(prop_name) != prop_value:
if type(node.get_property(prop_name)) in _exc:
value = prop_value
Expand Down Expand Up @@ -351,8 +352,8 @@ def widget(self):
if self._widget is None:
self._widget = QWidgetDrops()
self._widget.import_session = self.import_session
layout = QtWidgets.QVBoxLayout(self._widget)

layout = QtWidgets.QVBoxLayout(self._widget)
layout.setContentsMargins(0, 0, 0, 0)
layout.addWidget(self._viewer)
return self._widget
Expand Down Expand Up @@ -1087,7 +1088,7 @@ def import_session(self, file_path):
Args:
file_path (str): path to the serialized layout file.
"""

file_path = file_path.strip()
if not os.path.isfile(file_path):
raise IOError('file does not exist.')
Expand Down
6 changes: 3 additions & 3 deletions NodeGraphQt/base/menu.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/usr/bin/python
from distutils.version import LooseVersion

from NodeGraphQt import QtGui, QtCore
from NodeGraphQt.errors import NodeMenuError
from NodeGraphQt.widgets.actions import BaseMenu, GraphAction, NodeAction
from .. import QtGui, QtCore
from ..errors import NodeMenuError
from ..widgets.actions import BaseMenu, GraphAction, NodeAction


class NodeGraphMenu(object):
Expand Down
12 changes: 6 additions & 6 deletions NodeGraphQt/base/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
import json
from collections import defaultdict

from NodeGraphQt.constants import (NODE_PROP,
NODE_PROP_QLABEL,
NODE_PROP_QLINEEDIT,
NODE_PROP_QCHECKBOX,
NODE_PROP_COLORPICKER)
from NodeGraphQt.errors import NodePropertyError
from ..constants import (NODE_PROP,
NODE_PROP_QLABEL,
NODE_PROP_QLINEEDIT,
NODE_PROP_QCHECKBOX,
NODE_PROP_COLORPICKER)
from ..errors import NodePropertyError


class PortModel(object):
Expand Down
44 changes: 22 additions & 22 deletions NodeGraphQt/base/node.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
#!/usr/bin/python
from NodeGraphQt.base.commands import PropertyChangedCmd
from NodeGraphQt.base.model import NodeModel
from NodeGraphQt.base.port import Port
from NodeGraphQt.constants import (NODE_PROP,
NODE_PROP_QLINEEDIT,
NODE_PROP_QTEXTEDIT,
NODE_PROP_QCOMBO,
NODE_PROP_QCHECKBOX,
NODE_PROP_FILE,
NODE_PROP_FLOAT,
NODE_PROP_INT,
IN_PORT, OUT_PORT)
from NodeGraphQt.errors import PortRegistrationError
from NodeGraphQt.qgraphics.node_backdrop import BackdropNodeItem
from NodeGraphQt.qgraphics.node_base import NodeItem
from NodeGraphQt.widgets.node_widgets import (NodeComboBox,
NodeLineEdit,
NodeFloatEdit,
NodeIntEdit,
NodeCheckBox,
NodeFilePath)
from .commands import PropertyChangedCmd
from .model import NodeModel
from .port import Port
from ..constants import (NODE_PROP,
NODE_PROP_QLINEEDIT,
NODE_PROP_QTEXTEDIT,
NODE_PROP_QCOMBO,
NODE_PROP_QCHECKBOX,
NODE_PROP_FILE,
NODE_PROP_FLOAT,
NODE_PROP_INT,
IN_PORT, OUT_PORT)
from ..errors import PortRegistrationError
from ..qgraphics.node_backdrop import BackdropNodeItem
from ..qgraphics.node_base import NodeItem
from ..widgets.node_widgets import (NodeComboBox,
NodeLineEdit,
NodeFloatEdit,
NodeIntEdit,
NodeCheckBox,
NodeFilePath)


class classproperty(object):
Expand Down Expand Up @@ -709,7 +709,7 @@ def update_combo_menu(self, name, items):
return
old_value = self.get_property(name)
self.set_property(name, items)
_name = '_'+name+"_"
_name = '_' + name + "_"
if not self.has_property(_name):
self.create_property(_name, items)
else:
Expand Down
14 changes: 7 additions & 7 deletions NodeGraphQt/base/port.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#!/usr/bin/python
from NodeGraphQt.base.commands import (PortConnectedCmd,
PortDisconnectedCmd,
PortVisibleCmd,
NodeInputConnectedCmd,
NodeInputDisconnectedCmd)
from NodeGraphQt.base.model import PortModel
from NodeGraphQt.constants import IN_PORT, OUT_PORT
from .commands import (PortConnectedCmd,
PortDisconnectedCmd,
PortVisibleCmd,
NodeInputConnectedCmd,
NodeInputDisconnectedCmd)
from .model import PortModel
from ..constants import IN_PORT, OUT_PORT


class Port(object):
Expand Down
2 changes: 1 addition & 1 deletion NodeGraphQt/base/utils.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/python
from distutils.version import LooseVersion

from NodeGraphQt import QtGui, QtCore
from .. import QtGui, QtCore


def setup_context_menu(graph):
Expand Down
2 changes: 1 addition & 1 deletion NodeGraphQt/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# -*- coding: utf-8 -*-
import os
from .pkg_info import __version__
from NodeGraphQt import QtWidgets
from . import QtWidgets

#: Current version of the NodeGraphQt framework.
VERSION = __version__
Expand Down
10 changes: 10 additions & 0 deletions NodeGraphQt/errors.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-


class NodeMenuError(Exception): pass


class NodePropertyError(Exception): pass


class NodeWidgetError(Exception): pass


class NodeRegistrationError(Exception): pass


class PortRegistrationError(Exception): pass
7 changes: 4 additions & 3 deletions NodeGraphQt/qgraphics/node_abstract.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#!/usr/bin/python
from NodeGraphQt import QtCore, QtWidgets

from NodeGraphQt.constants import (Z_VAL_NODE, NODE_WIDTH, NODE_HEIGHT,
ITEM_CACHE_MODE)
from .. import QtCore, QtWidgets

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


class AbstractNodeItem(QtWidgets.QGraphicsItem):
Expand Down
14 changes: 7 additions & 7 deletions NodeGraphQt/qgraphics/node_backdrop.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#!/usr/bin/python

from NodeGraphQt import QtGui, QtCore, QtWidgets
from NodeGraphQt.constants import (Z_VAL_PIPE,
NODE_SEL_COLOR,
NODE_SEL_BORDER_COLOR)
from NodeGraphQt.qgraphics.node_abstract import AbstractNodeItem
from NodeGraphQt.qgraphics.pipe import Pipe
from NodeGraphQt.qgraphics.port import PortItem
from .. import QtGui, QtCore, QtWidgets
from ..constants import (Z_VAL_PIPE,
NODE_SEL_COLOR,
NODE_SEL_BORDER_COLOR)
from .node_abstract import AbstractNodeItem
from .pipe import Pipe
from .port import PortItem


class BackdropSizer(QtWidgets.QGraphicsItem):
Expand Down
27 changes: 14 additions & 13 deletions NodeGraphQt/qgraphics/node_base.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
#!/usr/bin/python

from NodeGraphQt import QtGui, QtCore, QtWidgets
from NodeGraphQt.constants import (IN_PORT, OUT_PORT,
NODE_WIDTH, NODE_HEIGHT,
NODE_ICON_SIZE, ICON_NODE_BASE,
NODE_SEL_COLOR, NODE_SEL_BORDER_COLOR,
PORT_FALLOFF, Z_VAL_NODE, Z_VAL_NODE_WIDGET,
ITEM_CACHE_MODE)
from NodeGraphQt.errors import NodeWidgetError
from NodeGraphQt.qgraphics.node_abstract import AbstractNodeItem
from NodeGraphQt.qgraphics.port import PortItem
from .. import QtGui, QtCore, QtWidgets
from ..constants import (IN_PORT, OUT_PORT,
NODE_WIDTH, NODE_HEIGHT,
NODE_ICON_SIZE, ICON_NODE_BASE,
NODE_SEL_COLOR, NODE_SEL_BORDER_COLOR,
PORT_FALLOFF, Z_VAL_NODE, Z_VAL_NODE_WIDGET,
ITEM_CACHE_MODE)
from ..errors import NodeWidgetError
from .node_abstract import AbstractNodeItem
from .port import PortItem


class XDisabledItem(QtWidgets.QGraphicsItem):
"""
Expand Down Expand Up @@ -493,11 +494,11 @@ def post_init(self, viewer=None, pos=None):
def auto_switch_mode(self):
if ITEM_CACHE_MODE is QtWidgets.QGraphicsItem.ItemCoordinateCache:
return
rect= self.sceneBoundingRect()
rect = self.sceneBoundingRect()
l = self.viewer().mapToGlobal(self.viewer().mapFromScene(rect.topLeft()))
r = self.viewer().mapToGlobal(self.viewer().mapFromScene( rect.topRight()))
r = self.viewer().mapToGlobal(self.viewer().mapFromScene(rect.topRight()))
# with is the node with in screen
width = r.x()-l.x()
width = r.x() - l.x()

self.set_proxy_mode(width < self._porxy_mode_threshold)

Expand Down
6 changes: 3 additions & 3 deletions NodeGraphQt/qgraphics/pipe.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
#!/usr/bin/python
import math

from NodeGraphQt import QtCore, QtGui, QtWidgets
from NodeGraphQt.constants import (
from .. import QtCore, QtGui, QtWidgets
from ..constants import (
PIPE_DEFAULT_COLOR, PIPE_ACTIVE_COLOR,
PIPE_HIGHLIGHT_COLOR, PIPE_DISABLED_COLOR,
PIPE_STYLE_DASHED, PIPE_STYLE_DEFAULT, PIPE_STYLE_DOTTED,
PIPE_LAYOUT_STRAIGHT, PIPE_WIDTH, IN_PORT, OUT_PORT, Z_VAL_PIPE,
Z_VAL_NODE_WIDGET,
PIPE_LAYOUT_ANGLE, PIPE_LAYOUT_CURVED,
ITEM_CACHE_MODE)
from NodeGraphQt.qgraphics.port import PortItem
from .port import PortItem

PIPE_STYLES = {
PIPE_STYLE_DEFAULT: QtCore.Qt.SolidLine,
Expand Down
4 changes: 2 additions & 2 deletions NodeGraphQt/qgraphics/port.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/python
from NodeGraphQt import QtGui, QtCore, QtWidgets
from .. import QtGui, QtCore, QtWidgets

from NodeGraphQt.constants import (
from ..constants import (
IN_PORT, OUT_PORT,
PORT_DEFAULT_COLOR,
PORT_DEFAULT_BORDER_COLOR,
Expand Down
4 changes: 2 additions & 2 deletions NodeGraphQt/qgraphics/slicer.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/python
from NodeGraphQt import QtCore, QtGui, QtWidgets
from NodeGraphQt.constants import Z_VAL_NODE_WIDGET, PIPE_SLICER_COLOR
from .. import QtCore, QtGui, QtWidgets
from ..constants import Z_VAL_NODE_WIDGET, PIPE_SLICER_COLOR


class SlicerPipe(QtWidgets.QGraphicsPathItem):
Expand Down
4 changes: 2 additions & 2 deletions NodeGraphQt/widgets/actions.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/python
from NodeGraphQt import QtCore, QtWidgets
from NodeGraphQt.widgets.stylesheet import STYLE_QMENU
from .. import QtCore, QtWidgets
from .stylesheet import STYLE_QMENU


class BaseMenu(QtWidgets.QMenu):
Expand Down
4 changes: 2 additions & 2 deletions NodeGraphQt/widgets/file_dialog.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from NodeGraphQt import QtWidgets
from NodeGraphQt.widgets.stylesheet import STYLE_MESSAGEBOX
from .. import QtWidgets
from .stylesheet import STYLE_MESSAGEBOX
import os

current_dir = os.path.expanduser('~')
Expand Down
4 changes: 2 additions & 2 deletions NodeGraphQt/widgets/node_tree.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
from NodeGraphQt import QtWidgets, QtCore
from NodeGraphQt.constants import DRAG_DROP_ID
from .. import QtWidgets, QtCore
from ..constants import DRAG_DROP_ID


TYPE_NODE = QtWidgets.QTreeWidgetItem.UserType + 1
Expand Down
Loading