def append_item(self, item: QGraphicsItem) -> None: self.items.append(item) col = self.next_col row = self.next_row x = col * (self.style.tile_width + self.style.spacing_x) + self.style.padding_x y = row * (self.style.tile_height + self.style.spacing_y) + self.style.padding_y item.setPos(self.x + x + self.center_x_off, self.y + y) bottom_y = y + self.style.tile_height + self.style.padding_y # calculate next items position if self.style.arrangement == TileStyle.Arrangement.ROWS: col += 1 if col == self.columns: col = 0 row += 1 else: row += 1 if row == self.rows: row = 0 col += 1 self.next_col = col self.next_row = row self.height = bottom_y
def append_item(self, item: QGraphicsItem) -> None: self.items.append(item) col = self.next_col row = self.next_row x = col * (self.style.tile_width + self.style.spacing_x) + self.style.padding_x y = row * (self.style.tile_height + self.style.spacing_y) + self.style.padding_y item.setPos(self.x + x + self.center_x_off, self.y + y) bottom_y = y + self.style.tile_height + self.style.padding_y # calculate next items position if self.style.arrangement == TileStyle.Arrangement.ROWS: col += 1 if col == self.columns: col = 0 row += 1 else: row += 1 if row == self.rows: row = 0 col += 1 self.next_col = col self.next_row = row self.height = bottom_y
def add_animation(self, item: QGraphicsItem, position: int): item.setParentItem(self) item.setPos(self.source_point) item.update() animated_object = AnimatedObject() animated_object.item = item animated_object.position = position self.animations.append(animated_object)
def addAnnotationItem(self, item: QGraphicsItem, pos: QPointF): scene = self.scene() if scene is None: return if isinstance(item, (ArrowItem, RectItem, EllipseItem)): item.setPen( QPen(Qt.black, scene.getDefaultPenSizeFromRect(), Qt.SolidLine)) self._undo_stack.push(AddCommand(item, scene)) item.setPos(pos) scene.annotationAdded.emit(item) return item