def _check_area(self): """ Check if the current layout added areas cover the entire rectangle. Rectangle given by the extreme points for the added areas. """ self._area_rects = [] height = self._rows + 1 area_float_rects = [] delta = 0.0001 for index, area in enumerate(self._areas): # These areas are used with a small delta to ensure if they are # next to each other they will not overlap. rectf = QRectF() rectf.setLeft(area["column"] + delta) rectf.setRight(area["column"] + area["col_span"] - delta) rectf.setTop(height - area["row"] - delta) rectf.setBottom(height - area["row"] - area["row_span"] + delta) rectf.index = index rectf.plugin_ids = area["plugin_ids"] area_float_rects.append(rectf) # These areas are used to calculate the actual total area rect = QRectF() rect.setLeft(area["column"]) rect.setRight(area["column"] + area["col_span"]) rect.setTop(height - area["row"]) rect.setBottom(height - area["row"] - area["row_span"]) rect.index = index rect.plugin_ids = area["plugin_ids"] self._area_rects.append(rect) # Check if areas are overlapping! for rect_1 in area_float_rects: for rect_2 in area_float_rects: if rect_1.index != rect_2.index: if rect_1.intersects(rect_2): raise SpyderAPIError( "Area with plugins {0} is overlapping area " "with plugins {1}".format(rect_1.plugin_ids, rect_2.plugin_ids)) # Check the total area (using corner points) versus the sum of areas total_area = 0 tops = [] rights = [] for index, rect in enumerate(self._area_rects): tops.append(rect.top()) rights.append(rect.right()) area = abs(rect.width() * rect.height()) total_area += area self._areas[index]["area"] = area if total_area != max(rights)*max(tops): raise SpyderAPIError( "Areas are not covering the entire section!\n" "Either an area is missing or col_span/row_span are " "not correctly set!" )