(self)
Update the selection rects.
Update the selection rects.
Update the selection rects .
def update_selection_rects(self):
        """ Update the selection rects.
        """
        def group_selections(selections):
            """Group selections along with heatmaps.
            """
            rows2hm = self.rows_to_heatmaps()
            selections = iter(selections)
            try:
                start = end = next(selections)
            except StopIteration:
                return
            end_heatmaps = rows2hm[end]
            try:
                while True:
                    new_end = next(selections)
                    new_end_heatmaps = rows2hm[new_end]
                    if new_end > end + 1 or new_end_heatmaps != end_heatmaps:
                        yield start, end, end_heatmaps
                        start = end = new_end
                        end_heatmaps = new_end_heatmaps
                    else:
                        end = new_end

            except StopIteration:
                yield start, end, end_heatmaps

        def selection_rect(start, end, heatmaps):
            rect = QRectF()
            for heatmap in heatmaps:
                h_start, _ = self._heatmap_ranges[heatmap]
                rect |= heatmap.mapToScene(heatmap.rowRect(start - h_start)).boundingRect()
                rect |= heatmap.mapToScene(heatmap.rowRect(end - h_start)).boundingRect()
            return rect

        self.selection_rects = []
        for start, end, heatmaps in group_selections(self.selections):
            rect = selection_rect(start, end, heatmaps)
            self.selection_rects.append(rect)
def update_selection_rects ( self ) : def group_selections ( selections ) : """Group selections along with heatmaps.
            """ rows2hm = self . rows_to_heatmaps ( ) selections = iter ( selections ) try : start = end = next ( selections ) except StopIteration : return end_heatmaps = rows2hm [ end ] try : while True : new_end = next ( selections ) new_end_heatmaps = rows2hm [ new_end ] if new_end > end + 1 or new_end_heatmaps != end_heatmaps : yield start , end , end_heatmaps start = end = new_end end_heatmaps = new_end_heatmaps else : end = new_end except StopIteration : yield start , end , end_heatmaps def selection_rect ( start , end , heatmaps ) : rect = QRectF ( ) for heatmap in heatmaps : h_start , _ = self . _heatmap_ranges [ heatmap ] rect |= heatmap . mapToScene ( heatmap . rowRect ( start - h_start ) ) . boundingRect ( ) rect |= heatmap . mapToScene ( heatmap . rowRect ( end - h_start ) ) . boundingRect ( ) return rect self . selection_rects = [ ] for start , end , heatmaps in group_selections ( self . selections ) : rect = selection_rect ( start , end , heatmaps ) self . selection_rects . append ( rect )