def show_arbiter_masters(self): if len(self.arbiter_boxes) > 0: return print "show_arbiter_masters()" count = self.s.module_arbiter_count(self.box_name) print "%d arbiters" % count #print "Add %d arbiter boxes" % num_m #setup the start position for the case where there is only one master position = QPointF(self.pos()) rect = QRectF(self.rect) arb_x = position.x() + rect.width() + ARB_MASTER_HORIZONTAL_SPACING arb_y = position.y() + rect.height() / 2 arb_y -= (count - 1) * ARB_MASTER_VERTICAL_SPACING arb_y -= ((count - 1) * ARB_MASTER_RECT.height()) / 2 arb_pos = QPointF(arb_x, arb_y) #for i in range(0, len(self.arbiter_masters)): for name in self.s.arbiter_master_names(self.box_name): #print "Add Arbiter %s" % self.arbiter_masters[i] arb_rect = QRectF(ARB_MASTER_RECT) #am = ArbiterMaster(name = self.arbiter_masters[i], am = ArbiterMaster(name = name, position = arb_pos, y_pos = position.y(), scene = self.scene(), slave = self) #am.movable(False) self.arbiter_boxes.append(am) al = Link(self, am, self.scene(), lt.arbiter_master) al.from_box_side(st.right) al.to_box_side(st.left) al.en_bezier_connections(True) self.links[am] = al #Progress the position arb_pos = QPointF(arb_pos.x(), arb_pos.y() + arb_rect.height() + ARB_MASTER_VERTICAL_SPACING) self.update_links()
def arbiter_master_selected(self, arbiter_master): self.dbg = True if self.dbg: print "PS: arbiter_master_selected()" if self.ignore_selection: return self.ignore_selection = True self.s.clearSelection() #Maybe this is to remove other arbiter masters! self.remove_arbiter_masters() position = QPointF(self.pos()) rect = QRectF(self.rect) arb_x = position.x() + rect.width() + ARB_MASTER_HORIZONTAL_SPACING arb_y = position.y() + (rect.height() / 2) - (ARB_MASTER_ACT_RECT.height() / 2) arb_pos = QPointF(arb_x, arb_y) #print "Adding arbiter master" am = ArbiterMaster(name = arbiter_master, position = arb_pos, y_pos = arb_y, scene = self.scene(), slave = self) am.set_activate(True) am.update_view() self.arbiter_boxes.append(am) al = Link(self, am, self.scene(), lt.arbiter_master) al.from_box_side(st.right) al.to_box_side(st.left) al.en_bezier_connections(True) self.links[am] = al #print "update links" self.update_links() self.ignore_selection = False self.s.invalidate(self.s.sceneRect()) self.dbg = True