def mouseReleaseEvent(self, event: QGraphicsSceneMouseEvent):
     if event.button() == Qt.LeftButton:
         self.__selection_rect.setVisible(False)
         self.__sel_action = None
         self.__selected_attrs = self.__selected_attrs_current
         self.selection_changed.emit(self.__selected_attrs)
         event.accept()
 def mouseReleaseEvent(self, event: QGraphicsSceneMouseEvent) -> None:
     if self._orientation == Qt.Vertical:
         self.setValue(event.pos().y())
     else:
         self.setValue(event.pos().x())
     self.lineReleased.emit()
     event.accept()
 def mouseReleaseEvent(self, event: QGraphicsSceneMouseEvent):
     x1 = event.buttonDownPos(Qt.LeftButton).x()
     x2 = event.pos().x()
     if x1 > x2:
         x2, x1 = x1, x2
     x1, x2 = self._values_from_pixels(np.array([x1, x2]))
     self.selection_changed.emit(x1, x2, self._attr_name)
     event.accept()
 def mouseMoveEvent(self, event: QGraphicsSceneMouseEvent) -> None:
     pos = event.pos()
     if self._orientation == Qt.Vertical:
         self.setValue(pos.y())
     else:
         self.setValue(pos.x())
     self.lineMoved.emit()
     event.accept()
 def mouseMoveEvent(self, event: QGraphicsSceneMouseEvent):
     if event.buttons() & Qt.LeftButton:
         rect = QRectF(event.buttonDownPos(Qt.LeftButton),
                       event.pos()).normalized()
         self.__selection_rect.setRect(rect)
         self.__selection_rect.setVisible(True)
         if rect.width():
             self.select(None)
         event.accept()
 def mouseMoveEvent(self, event: QGraphicsSceneMouseEvent):
     if event.buttons() & Qt.LeftButton:
         if self._selection_rect is None:
             self._selection_rect = ViolinItem.SelectionRect(
                 self, self._width, self._height)
         x = event.buttonDownPos(Qt.LeftButton).x()
         rect = QRectF(x, 0, event.pos().x() - x, self._height).normalized()
         rect = rect.intersected(self.contentsRect())
         self._selection_rect.setRect(rect)
         event.accept()
 def mousePressEvent(self, event: QGraphicsSceneMouseEvent) -> None:
     flags = self.textInteractionFlags()
     if flags & Qt.LinksAccessibleByMouse \
             and not flags & Qt.TextSelectableByMouse \
             and self.document().documentLayout().anchorAt(event.pos()):
         # QGraphicsTextItem ignores the press event without
         # Qt.TextSelectableByMouse flag set. This causes the
         # corresponding mouse release to never get to this item
         # and therefore no linkActivated/openUrl ...
         super().mousePressEvent(event)
         if not event.isAccepted():
             event.accept()
     else:
         super().mousePressEvent(event)
Beispiel #8
0
    def cursor_event(self, ev: QGraphicsSceneMouseEvent):
        if self.__curve is None:
            return False
        if self._state == States.HOLDING_CURVE:
            return False

        pos = self.__curve.mapFromScene(ev.scenePos())
        if self._state == States.MOVING_CURVE:
            self.curve_moved.emit(pos.x() - self._initial_x,
                                  pos.y() - self._initial_y)
            self._initial_x = pos.x()
            self._initial_y = pos.y()
            return False

        if self._on_curve(pos.x(), pos.y()):
            self._initial_x = pos.x()
            self._initial_y = pos.y()
            if self._state == States.WAITING:
                self._state = States.ON_CURVE
                self.getViewBox().setCursor(Qt.SizeAllCursor)
        else:
            self.getViewBox().setCursor(Qt.ArrowCursor)
            if self._state == States.ON_CURVE:
                self._state = States.WAITING
        return False
 def mousePressEvent(self, event: QGraphicsSceneMouseEvent):
     if event.buttons() & Qt.LeftButton:
         if event.modifiers() & Qt.ControlModifier:
             self.__sel_action = self.SelectAction.Toggle
         elif event.modifiers() & Qt.AltModifier:
             self.__sel_action = self.SelectAction.Deselect
         elif event.modifiers() & Qt.ShiftModifier:
             self.__sel_action = self.SelectAction.Select
         else:
             self.__sel_action = self.SelectAction.ClearSelect
         self.select(event.pos())
         event.accept()
 def mousePressEvent(self, event: QGraphicsSceneMouseEvent):
     event.accept()
 def mousePressEvent(self, event: QGraphicsSceneMouseEvent) -> None:
     self.mousePressed.emit(event.pos(), event.button())
     super().mousePressEvent(event)
     event.accept()
 def mousePressEvent(self, event: QGraphicsSceneMouseEvent) -> None:
     event.accept()
     self.linePressed.emit()
 def mousePressEvent(self, ev: QGraphicsSceneMouseEvent):
     keys = QApplication.keyboardModifiers()
     if self.__state == SELECT and not keys & Qt.ShiftModifier:
         ev.accept()
         self.sigDeselect.emit()
     super().mousePressEvent(ev)