def render_backgrounds(img, mainRect, bg_layer, n2i, n2f): if img.mode == "c": max_r = mainRect.width()/2.0 else: max_r = mainRect.width() for node, item in n2i.iteritems(): if _leaf(node): first_c = n2i[node] last_c = n2i[node] else: first_c = n2i[node.children[0]] last_c = n2i[node.children[-1]] if img.mode == "c": h = item.effective_height angle_start = first_c.full_start angle_end = last_c.full_end parent_radius = getattr(n2i.get(node.up, None), "radius", 0) base = parent_radius + item.nodeRegion.width() if node.img_style["node_bgcolor"].upper() != "#FFFFFF": bg1 = crender._ArcItem() r = math.sqrt(base**2 + h**2) bg1.set_arc(0, 0, parent_radius, r, angle_start, angle_end) bg1.setParentItem(item.content.bg) bg1.setPen(QtGui.QPen(QtGui.QColor(node.img_style["node_bgcolor"]))) bg1.setBrush(QtGui.QBrush(QtGui.QColor(node.img_style["node_bgcolor"]))) if node.img_style["faces_bgcolor"].upper() != "#FFFFFF": bg2 = crender._ArcItem() r = math.sqrt(base**2 + h**2) bg2.set_arc(0, 0, parent_radius, item.radius, angle_start, angle_end) bg2.setParentItem(item.content) bg2.setPen(QtGui.QPen(QtGui.QColor(node.img_style["faces_bgcolor"]))) bg2.setBrush(QtGui.QBrush(QtGui.QColor(node.img_style["faces_bgcolor"]))) if node.img_style["bgcolor"].upper() != "#FFFFFF": bg = crender._ArcItem() bg.set_arc(0, 0, parent_radius, max_r, angle_start, angle_end) bg.setPen(QtGui.QPen(QtGui.QColor(node.img_style["bgcolor"]))) bg.setBrush(QtGui.QBrush(QtGui.QColor(node.img_style["bgcolor"]))) bg.setParentItem(bg_layer) bg.setZValue(item.zValue()) if img.mode == "r": if node.img_style["bgcolor"].upper() != "#FFFFFF": bg = QtGui.QGraphicsRectItem() pos = item.content.mapToScene(0, 0) bg.setPos(pos.x(), pos.y()) bg.setRect(0, 0, max_r-pos.x(), item.fullRegion.height()) bg.setPen(QtGui.QPen(QtGui.QColor(node.img_style["bgcolor"]))) bg.setBrush(QtGui.QBrush(QtGui.QColor(node.img_style["bgcolor"]))) bg.setParentItem(bg_layer) bg.setZValue(item.zValue())