示例#1
0
    def __init__(self, parent=None, **kwargs):
        QGraphicsItem.__init__(self, parent=parent)

        self.enabled = kwargs.get('enabled', True)
        self.color = kwargs.get('color', QColor(31, 32, 33, 255))
        self.disabled_color = kwargs.get('disabled_color', QColor(125, 125, 125, 255))
        self.selected_color = kwargs.get('selected_color', QColor(30, 35, 40, 255))
        self.disabled_border_width = kwargs.get('disabled_border_width', 1.5)
        self.selected_border_width = kwargs.get('selected_border_width', 1.5)
        self.disabled_border_color = kwargs.get('disabled_border_color', QColor(40, 40, 40, 255))
        self.selected_border_color = kwargs.get('selected_border_color', QColor(250, 210, 90, 255))
        self.disabled_shadow_color = kwargs.get('disabled_shadow_color', QColor(35, 35, 35, 60))
        self.selected_shadow_color = kwargs.get('selected_shadow_color', QColor(105, 55, 0, 60))
        self.disabled_border_style = kwargs.get('disabled_border_style', Qt.DashDotLine)
        self.selected_border_style = kwargs.get('selected_border_style', Qt.DashLine)

        self._border_width = kwargs.get('border_width', 1.5)
        self._shadow_color = kwargs.get('shadow_color', QColor(0, 0, 0, 60))
        self._border_color = kwargs.get('border_color', QColor(10, 10, 10, 255))
        self._border_type = kwargs.get('border_type', Qt.SolidLine)

        self._current_pos = QPointF(0, 0)
        self._new_pos = QPointF(0, 0)

        self._width = kwargs.get('width', 120)
        self._height = kwargs.get('height', 40)
        self._sizes = [0, 0, self._width, self._height, 7, 7]  # [x, y, width, height, radius_x, radius_x]
        self._is_hovered = False

        self._render_effects = True
示例#2
0
    def __init__(self,
                 name,
                 graph,
                 w=8000,
                 color=Colors.NodeBackgrounds,
                 headColor=Colors.NodeNameRect,
                 bUseTextureBg=False):
        QGraphicsItem.__init__(self)
        NodeBase.__init__(self, name, graph)
        self.setCacheMode(QGraphicsItem.DeviceCoordinateCache)
        self.opt_node_base_color = Colors.NodeBackgrounds
        self.opt_selected_pen_color = Colors.NodeSelectedPenColor
        self.opt_pen_selected_type = QtCore.Qt.SolidLine
        self._left_stretch = 0
        self.color = color
        self.height_offset = 3
        self.nodeMainGWidget = QGraphicsWidget(self)
        self.nodeMainGWidget.setObjectName('{0}MainLayout'.format(name))
        self._w = 0
        self.h = 40
        self.sizes = [0, 0, self.w, self.h, 10, 10]
        self.w = w
        self.setFlag(QGraphicsItem.ItemIsMovable)
        self.setFlag(QGraphicsItem.ItemIsFocusable)
        self.setFlag(QGraphicsItem.ItemIsSelectable)
        self.setFlag(QGraphicsItem.ItemSendsGeometryChanges)
        self.custom_widget_data = {}
        # node name
        self.label = weakref.ref(NodeName(self, bUseTextureBg, headColor))
        # set node layouts
        self.nodeMainGWidget.setParentItem(self)
        # main
        self.portsMainLayout = QGraphicsLinearLayout(QtCore.Qt.Horizontal)
        self.portsMainLayout.setSizePolicy(QSizePolicy.Maximum,
                                           QSizePolicy.Maximum)
        self.portsMainLayout.setContentsMargins(1, 1, 1, 1)
        self.nodeMainGWidget.setLayout(self.portsMainLayout)
        self.nodeMainGWidget.setX(self.nodeMainGWidget.x())
        # inputs layout
        self.inputsLayout = QGraphicsLinearLayout(QtCore.Qt.Vertical)
        self.inputsLayout.setSizePolicy(QSizePolicy.Expanding,
                                        QSizePolicy.Maximum)
        self.inputsLayout.setContentsMargins(1, 1, 1, 1)
        self.portsMainLayout.addItem(self.inputsLayout)
        # outputs layout
        self.outputsLayout = QGraphicsLinearLayout(QtCore.Qt.Vertical)
        self.outputsLayout.setSizePolicy(QSizePolicy.Expanding,
                                         QSizePolicy.Maximum)
        self.outputsLayout.setContentsMargins(1, 1, 1, 1)
        self.portsMainLayout.addItem(self.outputsLayout)

        self.setZValue(1)

        self.tweakPosition()
        self.icon = None

        self._Constraints = {}
        self.asGraphSides = False
        self.isTemp = False