def __init__(self, source, destination, canvas): QGraphicsPathItem.__init__(self) self.setAcceptedMouseButtons(QtCore.Qt.LeftButton) self.setAcceptHoverEvents(True) self.setFlag(QGraphicsPathItem.ItemIsSelectable) self._menu = QMenu() self.actionDisconnect = self._menu.addAction("Disconnect") self.actionDisconnect.triggered.connect(self.kill) self._uid = uuid4() self.canvasRef = weakref.ref(canvas) self.source = weakref.ref(source) self.destination = weakref.ref(destination) self.drawSource = self.source() self.drawDestination = self.destination() # Overrides for getting endpoints positions # if None - pin centers will be used self.sourcePositionOverride = None self.destinationPositionOverride = None self.mPath = QtGui.QPainterPath() self.cp1 = QtCore.QPointF(0.0, 0.0) self.cp2 = QtCore.QPointF(0.0, 0.0) self.setZValue(NodeDefaults().Z_LAYER - 1) self.color = self.source().color() self.selectedColor = self.color.lighter(150) self.thickness = 1 if source.isExec(): self.thickness = 2 self.pen = QtGui.QPen(self.color, self.thickness, QtCore.Qt.SolidLine, QtCore.Qt.RoundCap, QtCore.Qt.RoundJoin) points = self.getEndPoints() self.updateCurve(points[0], points[1]) self.setPen(self.pen) self.source().update() self.destination().update() self.fade = 0.0 self.source().uiConnectionList.append(self) self.destination().uiConnectionList.append(self) self.source().pinConnected(self.destination()) self.destination().pinConnected(self.source())
def __init__(self, scene, name, parent=None): super(UIPinGroup, self).__init__(parent) self.setAcceptHoverEvents(True) self.borderPen = QtGui.QPen(Colors.DarkGray, 0.5, QtCore.Qt.SolidLine) self._scene = scene self.layout = QGraphicsLinearLayout(QtCore.Qt.Vertical) self.layout.setContentsMargins(0, 0, 0, 0) self.layout.setSpacing(NodeDefaults().LAYOUTS_SPACING) self.setLayout(self.layout) headerBtn = QPushButton(name) headerBtn.setStyleSheet(headerBtnStyle) headerBtn.setFlat(True) headerBtn.setContentsMargins(0, 0, 0, 0) headerBtn.setMaximumHeight(10) headerBtn.clicked.connect(self.toggleCollapsed) self.headerWidget = self._scene.addWidget(headerBtn) self.layout.addItem(self.headerWidget) self._pins = set() self.bCollapsed = False
def __init__(self, source, destination, canvas): QGraphicsPathItem.__init__(self) self.setAcceptedMouseButtons(QtCore.Qt.LeftButton) self.setAcceptHoverEvents(True) self.setFlag(QGraphicsPathItem.ItemIsSelectable) self._menu = QMenu() self.actionDisconnect = self._menu.addAction("Disconnect") self.actionDisconnect.triggered.connect(self.kill) self._uid = uuid4() self.canvasRef = weakref.ref(canvas) self.source = weakref.ref(source) self.destination = weakref.ref(destination) self.drawSource = self.source() self.drawDestination = self.destination() # Overrides for getting endpoints positions # if None - pin centers will be used self.sourcePositionOverride = None self.destinationPositionOverride = None self.mPath = QtGui.QPainterPath() self.cp1 = QtCore.QPointF(0.0, 0.0) self.cp2 = QtCore.QPointF(0.0, 0.0) self.setZValue(NodeDefaults().Z_LAYER - 1) self.color = self.source().color() self.selectedColor = self.color.lighter(150) self.thickness = 1 self.thicknessMultiplier = 1 if source.isExec(): self.thickness = 2 self.pen = QtGui.QPen(self.color, self.thickness, QtCore.Qt.SolidLine, QtCore.Qt.RoundCap, QtCore.Qt.RoundJoin) points = self.getEndPoints() self.updateCurve(points[0], points[1]) self.setPen(self.pen) self.source().update() self.destination().update() self.fade = 0.0 self.source().uiConnectionList.append(self) self.destination().uiConnectionList.append(self) self.source().pinConnected(self.destination()) self.destination().pinConnected(self.source()) if self.source().isExec(): self.bubble = QGraphicsEllipseItem(-2.5, -2.5, 5, 5, self) self.bubble.setBrush(self.color) self.bubble.setPen(self.pen) point = self.mPath.pointAtPercent(0.0) self.bubble.setPos(point) self.bubble.hide() self.source()._rawPin.onExecute.connect(self.performEvaluationFeedback) self.shouldAnimate = False self.timeline = QtCore.QTimeLine(2000) self.timeline.setFrameRange(0, 100) self.timeline.frameChanged.connect(self.timelineFrameChanged) self.timeline.setLoopCount(0)