def trigger(self, ui): """ Trigger this animation """ glyph = [ glyph for glyph in ui.scene.items() if hasattr(glyph, 'entity') and glyph.entity == self.mover ][0] if self.direction in (2, 3, 4): self.flipped = True self.offset = 32 if self.direction in (6, 7, 8): self.flipped = False self.offset = 0 if self.flipped: glyph.flipped = True glyph.setTransform(QTransform.fromScale(-1, 1)) else: glyph.flipped = False glyph.setTransform(QTransform.fromScale(1, 1)) if glyph.entity.artificial_intelligence: adapter = MapGlyphAdapter(ui, glyph) else: adapter = MapGlyphAdapter(ui, glyph, True) animation = QParallelAnimationGroup() move_y = QPropertyAnimation(adapter, 'y_location') move_y.setDuration(100) move_y.setStartValue(self.start[1] * 32) move_y.setEndValue(self.destination[1] * 32) move_x = QPropertyAnimation(adapter, 'x_location') move_x.setDuration(100) move_x.setStartValue(self.start[0] * 32 + self.offset) move_x.setEndValue(self.destination[0] * 32 + self.offset) animation.addAnimation(move_y) animation.addAnimation(move_x) ui.animations.append(animation) animation.finished.connect(ui.remove_finished_animation) animation.start()
def resizeEvent(self, event): w = self.view.width() - 10 h = self.view.height() - 10 transform = QTransform.fromScale(w, h) self.view.setTransform(transform) QWidget.resizeEvent(self, event)
def trigger(self, ui): """ Trigger this animation """ glyph = [glyph for glyph in ui.scene.items() if hasattr(glyph, 'entity') and glyph.entity == self.mover][0] if self.direction in (2, 3, 4): self.flipped = True self.offset = 32 if self.direction in (6, 7, 8): self.flipped = False self.offset = 0 if self.flipped: glyph.flipped = True glyph.setTransform(QTransform.fromScale(-1, 1)) else: glyph.flipped = False glyph.setTransform(QTransform.fromScale(1, 1)) if glyph.entity.artificial_intelligence: adapter = MapGlyphAdapter(ui, glyph) else: adapter = MapGlyphAdapter(ui, glyph, True) animation = QParallelAnimationGroup() move_y = QPropertyAnimation(adapter, 'y_location') move_y.setDuration(100) move_y.setStartValue(self.start[1] * 32) move_y.setEndValue(self.destination[1] * 32) move_x = QPropertyAnimation(adapter, 'x_location') move_x.setDuration(100) move_x.setStartValue(self.start[0] * 32 + self.offset) move_x.setEndValue(self.destination[0] * 32 + self.offset) animation.addAnimation(move_y) animation.addAnimation(move_x) ui.animations.append(animation) animation.finished.connect(ui.remove_finished_animation) animation.start()
def wheelEvent( self, event ): """ Mouse wheel event """ if QApplication.keyboardModifiers() == Qt.ControlModifier: factor = 1.41 ** ( -event.delta() / 240.0 ) self.__currentFactor *= factor self.setTransform( QTransform.fromScale( self.__currentFactor, self.__currentFactor ) ) Settings().flowScale = self.__currentFactor else: QGraphicsView.wheelEvent( self, event ) return
def wheelEvent(self, event): """ Mouse wheel event """ if QApplication.keyboardModifiers() == Qt.ControlModifier: factor = 1.41**(-event.delta() / 240.0) self.__currentFactor *= factor self.setTransform( QTransform.fromScale(self.__currentFactor, self.__currentFactor)) Settings().flowScale = self.__currentFactor else: QGraphicsView.wheelEvent(self, event) return
def _setup_scene(self): self._clear_plot() self.matrix_item = DistanceMapItem(self._sorted_matrix) # Scale the y axis to compensate for pg.ViewBox's y axis invert self.matrix_item.setTransform(QTransform.fromScale(1, -1), ) self.viewbox.addItem(self.matrix_item) # Set fixed view box range. h, w = self._sorted_matrix.shape self.viewbox.setRange(QRectF(0, -h, w, h), padding=0) self.matrix_item.selectionChanged.connect(self._invalidate_selection) if self.sorting == OWDistanceMap.NoOrdering: tree = None elif self.sorting == OWDistanceMap.Clustering: tree = self._cluster_tree() elif self.sorting == OWDistanceMap.OrderedClustering: tree = self._ordered_cluster_tree() self._set_displayed_dendrogram(tree) self._update_color()
def zoomTo( self, scale ): " Zooms to the specific factor " self.__currentFactor = scale self.setTransform( QTransform.fromScale( self.__currentFactor, self.__currentFactor ) ) return
def zoomTo(self, scale): " Zooms to the specific factor " self.__currentFactor = scale self.setTransform( QTransform.fromScale(self.__currentFactor, self.__currentFactor)) return