def mouseMoveEvent(self, event): if event.buttons() & Qt.LeftButton: downPos = event.buttonDownPos(Qt.LeftButton) if not self.__tmpLine and self.__dragStartItem and \ (downPos - event.pos()).manhattanLength() > \ QApplication.instance().startDragDistance(): # Start a line drag line = QGraphicsLineItem(self) start = self.__dragStartItem.boundingRect().center() start = self.mapFromItem(self.__dragStartItem, start) line.setLine(start.x(), start.y(), event.pos().x(), event.pos().y()) pen = QPen(self.palette().color(QPalette.Foreground), 4) pen.setCapStyle(Qt.RoundCap) line.setPen(pen) line.show() self.__tmpLine = line if self.__tmpLine: # Update the temp line line = self.__tmpLine.line() line.setP2(event.pos()) self.__tmpLine.setLine(line) QGraphicsWidget.mouseMoveEvent(self, event)
def mouseMoveEvent(self, event): if event.buttons() & Qt.LeftButton: downPos = event.buttonDownPos(Qt.LeftButton) if not self.__tmpLine and self.__dragStartItem and \ (downPos - event.pos()).manhattanLength() > \ QApplication.instance().startDragDistance(): # Start a line drag line = QGraphicsLineItem(self) start = self.__dragStartItem.boundingRect().center() start = self.mapFromItem(self.__dragStartItem, start) line.setLine(start.x(), start.y(), event.pos().x(), event.pos().y()) pen = QPen(Qt.black, 4) pen.setCapStyle(Qt.RoundCap) line.setPen(pen) line.show() self.__tmpLine = line if self.__tmpLine: # Update the temp line line = self.__tmpLine.line() line.setP2(event.pos()) self.__tmpLine.setLine(line) QGraphicsWidget.mouseMoveEvent(self, event)
def mouseMoveEvent(self, event): if event.buttons() & Qt.LeftButton: downPos = event.buttonDownPos(Qt.LeftButton) if not self.__tmpLine and self.__dragStartItem and \ (downPos - event.pos()).manhattanLength() > \ QApplication.instance().startDragDistance(): # Start a line drag line = LinkLineItem(self) start = self.__dragStartItem.boundingRect().center() start = self.mapFromItem(self.__dragStartItem, start) eventPos = event.pos() line.setLine(start.x(), start.y(), eventPos.x(), eventPos.y()) pen = QPen(self.palette().color(QPalette.Foreground), 4) pen.setCapStyle(Qt.RoundCap) line.setPen(pen) line.show() self.__tmpLine = line if self.__dragStartItem in self.sourceNodeWidget.channelAnchors: for anchor in self.sinkNodeWidget.channelAnchors: self.__updateAnchorState(anchor, [self.__dragStartItem]) else: for anchor in self.sourceNodeWidget.channelAnchors: self.__updateAnchorState(anchor, [self.__dragStartItem]) if self.__tmpLine: # Update the temp line line = self.__tmpLine.line() maybe_anchor = find_item_at(self.scene(), event.scenePos(), type=ChannelAnchor) # If hovering over anchor if maybe_anchor is not None and maybe_anchor.isEnabled(): target_pos = maybe_anchor.boundingRect().center() target_pos = self.mapFromItem(maybe_anchor, target_pos) line.setP2(target_pos) else: target_pos = event.pos() line.setP2(target_pos) self.__tmpLine.setLine(line) QGraphicsWidget.mouseMoveEvent(self, event)
def mouseMoveEvent(self, event): if event.buttons() & Qt.LeftButton: downPos = event.buttonDownPos(Qt.LeftButton) if not self.__tmpLine and self.__dragStartItem and \ (downPos - event.pos()).manhattanLength() > \ QApplication.instance().startDragDistance(): # Start a line drag line = LinkLineItem(self) start = self.__dragStartItem.boundingRect().center() start = self.mapFromItem(self.__dragStartItem, start) eventPos = event.pos() line.setLine(start.x(), start.y(), eventPos.x(), eventPos.y()) pen = QPen(self.palette().color(QPalette.Foreground), 4) pen.setCapStyle(Qt.RoundCap) line.setPen(pen) line.show() self.__tmpLine = line if self.__dragStartItem in self.sourceNodeWidget.channelAnchors: for anchor in self.sinkNodeWidget.channelAnchors: self.__updateAnchorState(anchor, [self.__dragStartItem]) else: for anchor in self.sourceNodeWidget.channelAnchors: self.__updateAnchorState(anchor, [self.__dragStartItem]) if self.__tmpLine: # Update the temp line line = self.__tmpLine.line() maybe_anchor = find_item_at(self.scene(), event.scenePos(), type=ChannelAnchor) # If hovering over anchor if maybe_anchor is not None and maybe_anchor.isEnabled(): target_pos = maybe_anchor.boundingRect().center() target_pos = self.mapFromItem(maybe_anchor, target_pos) line.setP2(target_pos) else: target_pos = event.pos() line.setP2(target_pos) self.__tmpLine.setLine(line) QGraphicsWidget.mouseMoveEvent(self, event)