def update_avoid(self, *args, **kw): rectangle = avoid.AvoidRectangle( avoid.Point(self.x, self.y), avoid.Point(self.x + self.width, self.y + self.height)) if self.avoid_shape is None: self.avoid_shape = avoid.ShapeRef(router, rectangle) else: router.moveShape(self.avoid_shape, rectangle) router.processTransaction()
def _update_avoid(self): self.set_modified() if self.parentItem(): avoid_router = self.parentItem().avoid_router r = self.rect() # Header area avoid_rect = avoid.AvoidRectangle( avoid.Point(self.x(), self.y()), avoid.Point(self.x() + r.width(), self.y() + self._header_height)) if self._header_avoid_shape is None: self._header_avoid_shape = avoid.ShapeRef( avoid_router, avoid_rect) else: avoid_router.moveShape(self._header_avoid_shape, avoid_rect) # Row areas occupied_cols = self._get_occupied_cols() n_avoid_rows = len(self._row_avoid_shapes) n_visible_rows = self._receptors.get_num_visible_rows() for ri in range(n_visible_rows): if (not ri in occupied_cols or len(occupied_cols[ri]) == 0 or 1 in occupied_cols[ri]): x = self.x() w = r.width() elif len(occupied_cols[ri]) > 1: w = r.width() / 2.0 x = self.x() + w / 2.0 elif 2 in occupied_cols[ri]: x = self.x() w = r.width() / 2.0 elif 0 in occupied_cols[ri]: w = r.width() / 2.0 x = self.x() + w avoid_rect = avoid.AvoidRectangle( avoid.Point( x, self.y() + self._header_height + ri * self._row_height), avoid.Point( x + w, self.y() + self._header_height + (ri + 1) * self._row_height)) divider_avoid_rect = avoid.AvoidRectangle( avoid.Point( self.x() - self.parentItem().pin_length, self.y() + self._header_height + ri * self._row_height), avoid.Point( self.x() + r.width() + self.parentItem().pin_length, self.y() + self._header_height + ri * self._row_height + 2)) if ri >= n_avoid_rows: self._row_avoid_shapes.append( avoid.ShapeRef(avoid_router, avoid_rect)) self._row_divider_avoid_shapes.append( avoid.ShapeRef(avoid_router, divider_avoid_rect)) else: avoid_router.moveShape(self._row_avoid_shapes[ri], avoid_rect) avoid_router.moveShape(self._row_divider_avoid_shapes[ri], divider_avoid_rect) for ri in range(n_avoid_rows): if ri >= n_visible_rows: avoid_rect = avoid.AvoidRectangle( avoid.Point(self.x(), self.y()), avoid.Point(self.x(), self.y())) avoid_router.moveShape(self._row_avoid_shapes[ri], avoid_rect) avoid_router.moveShape(self._row_divider_avoid_shapes[ri], avoid_rect) # Footer area avoid_rect = avoid.AvoidRectangle( avoid.Point(self.x() - self.parentItem().pin_length, self.y() + r.height() - self._footer_height), avoid.Point( self.x() + r.width() + self.parentItem().pin_length, self.y() + r.height())) if self._footer_avoid_shape is None: self._footer_avoid_shape = avoid.ShapeRef( avoid_router, avoid_rect) else: avoid_router.moveShape(self._footer_avoid_shape, avoid_rect) # Full block avoid_rect = avoid.AvoidRectangle( avoid.Point(self.x(), self.y()), avoid.Point(self.x() + r.width(), self.y() + r.height())) if self._avoid_shape is None: self._avoid_shape = avoid.ShapeRef(avoid_router, avoid_rect) else: avoid_router.moveShape(self._avoid_shape, avoid_rect) self.parentItem().process_avoid_updates()