def __createRubberBand(self, event): """Creates the rubber band rectangle and shows it""" self.lmbOrigin = event.scenePos().toPoint() self.rubberBand = RubberBandItem(self.parent().cflowSettings) self.addItem(self.rubberBand) self.rubberBand.setGeometry(QRect(self.lmbOrigin, QSize())) self.rubberBand.hide()
def __createRubberBand(self, event): """Creates the rubber band rectangle and shows it""" # Canvas == None means that there is no module item on the canvas # which is a case when there is exactly nothing drawn. The only # possiblity is that a broken file was open so there is nothing to # select anyway canvas = self.__getCanvas() if canvas is not None: self.lmbOrigin = event.scenePos().toPoint() self.rubberBand = RubberBandItem(canvas) self.addItem(self.rubberBand) self.rubberBand.setGeometry(QRect(self.lmbOrigin, QSize())) self.rubberBand.hide()
def mouseMoveEvent(self, event): """Handles mouse movement""" if self.lmbOrigin and self.rubberBand: # Draw the rubber band selection rectangle rect = QRect(self.lmbOrigin, event.scenePos().toPoint()) self.rubberBand.setGeometry(rect.normalized()) if not self.__isRubberBandVisible(): if abs(rect.left() - rect.right()) >= RUBBER_BAND_MIN_SIZE or \ abs(rect.top() - rect.bottom()) >= RUBBER_BAND_MIN_SIZE: self.rubberBand.show() QGraphicsScene.mouseMoveEvent(self, event)
def __createRubberBand(self, event): self.rubberBand = RubberBandItem() self.addItem(self.rubberBand) self.origin = event.scenePos().toPoint() self.rubberBand.setGeometry(QRect(self.origin, QSize())) self.rubberBand.show()
def mouseMoveEvent(self, event): if self.origin is not None: if self.rubberBand: rect = QRect(self.origin, event.scenePos().toPoint()) self.rubberBand.setGeometry(rect.normalized()) QGraphicsScene.mouseMoveEvent(self, event)