def create_shapes(self): """Precalculate relative coordinates.""" Element.create_shapes(self) self._sink_rot = None self._source_rot = None self._sink_coor = None self._source_coor = None #get the source coordinate try: connector_length = self.get_source().get_connector_length() except: return self.x1, self.y1 = Utils.get_rotated_coordinate((connector_length, 0), self.get_source().get_rotation()) #get the sink coordinate connector_length = self.get_sink().get_connector_length() + CONNECTOR_ARROW_HEIGHT self.x2, self.y2 = Utils.get_rotated_coordinate((-connector_length, 0), self.get_sink().get_rotation()) #build the arrow self.arrow = [(0, 0), Utils.get_rotated_coordinate((-CONNECTOR_ARROW_HEIGHT, -CONNECTOR_ARROW_BASE/2), self.get_sink().get_rotation()), Utils.get_rotated_coordinate((-CONNECTOR_ARROW_HEIGHT, CONNECTOR_ARROW_BASE/2), self.get_sink().get_rotation()), ] self._update_after_move() if not self.get_enabled(): self._arrow_color = Colors.CONNECTION_DISABLED_COLOR elif not self.is_valid(): self._arrow_color = Colors.CONNECTION_ERROR_COLOR else: self._arrow_color = Colors.CONNECTION_ENABLED_COLOR
def create_shapes(self): """Update the block, parameters, and ports when a change occurs.""" Element.create_shapes(self) if self.is_horizontal(): self.add_area((0, 0), (self.W, self.H)) elif self.is_vertical(): self.add_area((0, 0), (self.H, self.W))
def create_shapes(self): """Precalculate relative coordinates.""" Element.create_shapes(self) self._sink_rot = None self._source_rot = None self._sink_coor = None self._source_coor = None #get the source coordinate try: connector_length = self.get_source().get_connector_length() except: return self.x1, self.y1 = Utils.get_rotated_coordinate((connector_length, 0), self.get_source().get_rotation()) #get the sink coordinate connector_length = self.get_sink().get_connector_length() + CONNECTOR_ARROW_HEIGHT self.x2, self.y2 = Utils.get_rotated_coordinate((-connector_length, 0), self.get_sink().get_rotation()) #build the arrow self.arrow = [(0, 0), Utils.get_rotated_coordinate((-CONNECTOR_ARROW_HEIGHT, -CONNECTOR_ARROW_BASE/2), self.get_sink().get_rotation()), Utils.get_rotated_coordinate((-CONNECTOR_ARROW_HEIGHT, CONNECTOR_ARROW_BASE/2), self.get_sink().get_rotation()), ] source_domain = self.get_source().get_domain() sink_domain = self.get_sink().get_domain() self.line_attributes[0] = 2 if source_domain != sink_domain else 0 self.line_attributes[1] = gtk.gdk.LINE_DOUBLE_DASH \ if not source_domain == sink_domain == GR_MESSAGE_DOMAIN \ else gtk.gdk.LINE_ON_OFF_DASH get_domain_color = lambda d: Colors.get_color(( self.get_parent().get_parent().get_domain(d) or {} ).get('color') or Colors.DEFAULT_DOMAIN_COLOR_CODE) self._color = get_domain_color(source_domain) self._bg_color = get_domain_color(sink_domain) self._arrow_color = self._bg_color if self.is_valid() else Colors.CONNECTION_ERROR_COLOR self._update_after_move()
def create_shapes(self): """Precalculate relative coordinates.""" Element.create_shapes(self) self._sink_rot = None self._source_rot = None self._sink_coor = None self._source_coor = None #get the source coordinate connector_length = self.get_source().get_connector_length() self.x1, self.y1 = Utils.get_rotated_coordinate( (connector_length, 0), self.get_source().get_rotation()) #get the sink coordinate connector_length = self.get_sink().get_connector_length( ) + CONNECTOR_ARROW_HEIGHT self.x2, self.y2 = Utils.get_rotated_coordinate( (-connector_length, 0), self.get_sink().get_rotation()) #build the arrow self.arrow = [ (0, 0), Utils.get_rotated_coordinate( (-CONNECTOR_ARROW_HEIGHT, -CONNECTOR_ARROW_BASE / 2), self.get_sink().get_rotation()), Utils.get_rotated_coordinate( (-CONNECTOR_ARROW_HEIGHT, CONNECTOR_ARROW_BASE / 2), self.get_sink().get_rotation()), ] self._update_after_move() if not self.get_enabled(): self._arrow_color = Colors.CONNECTION_DISABLED_COLOR elif not self.is_valid(): self._arrow_color = Colors.CONNECTION_ERROR_COLOR else: self._arrow_color = Colors.CONNECTION_ENABLED_COLOR
def create_shapes(self): """Create new areas and labels for the port.""" Element.create_shapes(self) if self.get_hide(): return # this port is hidden, no need to create shapes if self.get_domain() == GR_MESSAGE_DOMAIN: pass elif self.get_domain() != DEFAULT_DOMAIN: self.line_attributes[0] = 2 #get current rotation rotation = self.get_rotation() #get all sibling ports if self.is_source(): ports = self.get_parent().get_sources_gui() elif self.is_sink(): ports = self.get_parent().get_sinks_gui() #get the max width self.W = max([port.W for port in ports] + [PORT_MIN_WIDTH]) W = self.W if not self._label_hidden() else PORT_LABEL_HIDDEN_WIDTH #get a numeric index for this port relative to its sibling ports try: index = ports.index(self) except: if hasattr(self, '_connector_length'): del self._connector_length return length = len(filter(lambda p: not p.get_hide(), ports)) #reverse the order of ports for these rotations if rotation in (180, 270): index = length - index - 1 offset = (self.get_parent().H - (length - 1) * PORT_SEPARATION - self.H) / 2 #create areas and connector coordinates if (self.is_sink() and rotation == 0) or (self.is_source() and rotation == 180): x = -1 * W y = PORT_SEPARATION * index + offset self.add_area((x, y), (W, self.H)) self._connector_coordinate = (x - 1, y + self.H / 2) elif (self.is_source() and rotation == 0) or (self.is_sink() and rotation == 180): x = self.get_parent().W y = PORT_SEPARATION * index + offset self.add_area((x, y), (W, self.H)) self._connector_coordinate = (x + 1 + W, y + self.H / 2) elif (self.is_source() and rotation == 90) or (self.is_sink() and rotation == 270): y = -1 * W x = PORT_SEPARATION * index + offset self.add_area((x, y), (self.H, W)) self._connector_coordinate = (x + self.H / 2, y - 1) elif (self.is_sink() and rotation == 90) or (self.is_source() and rotation == 270): y = self.get_parent().W x = PORT_SEPARATION * index + offset self.add_area((x, y), (self.H, W)) self._connector_coordinate = (x + self.H / 2, y + 1 + W) #the connector length self._connector_length = CONNECTOR_EXTENSION_MINIMAL + CONNECTOR_EXTENSION_INCREMENT * index
def create_shapes(self): """Create new areas and labels for the port.""" Element.create_shapes(self) if self.get_hide(): return # this port is hidden, no need to create shapes if self.get_domain() == GR_MESSAGE_DOMAIN: pass elif self.get_domain() != DEFAULT_DOMAIN: self.line_attributes[0] = 2 #get current rotation rotation = self.get_rotation() #get all sibling ports if self.is_source(): ports = self.get_parent().get_sources_gui() elif self.is_sink(): ports = self.get_parent().get_sinks_gui() #get the max width self.W = max([port.W for port in ports] + [PORT_MIN_WIDTH]) W = self.W if not self._label_hidden() else PORT_LABEL_HIDDEN_WIDTH #get a numeric index for this port relative to its sibling ports try: index = ports.index(self) except: if hasattr(self, '_connector_length'): del self._connector_length return length = len(filter(lambda p: not p.get_hide(), ports)) #reverse the order of ports for these rotations if rotation in (180, 270): index = length-index-1 port_separation = PORT_SEPARATION \ if self.get_parent().has_busses[self.is_source()] \ else max([port.H for port in ports]) + PORT_SPACING offset = (self.get_parent().H - (length-1)*port_separation - self.H)/2 #create areas and connector coordinates if (self.is_sink() and rotation == 0) or (self.is_source() and rotation == 180): x = -W y = port_separation*index+offset self.add_area((x, y), (W, self.H)) self._connector_coordinate = (x-1, y+self.H/2) elif (self.is_source() and rotation == 0) or (self.is_sink() and rotation == 180): x = self.get_parent().W y = port_separation*index+offset self.add_area((x, y), (W, self.H)) self._connector_coordinate = (x+1+W, y+self.H/2) elif (self.is_source() and rotation == 90) or (self.is_sink() and rotation == 270): y = -W x = port_separation*index+offset self.add_area((x, y), (self.H, W)) self._connector_coordinate = (x+self.H/2, y-1) elif (self.is_sink() and rotation == 90) or (self.is_source() and rotation == 270): y = self.get_parent().W x = port_separation*index+offset self.add_area((x, y), (self.H, W)) self._connector_coordinate = (x+self.H/2, y+1+W) #the connector length self._connector_length = CONNECTOR_EXTENSION_MINIMAL + CONNECTOR_EXTENSION_INCREMENT*index
def create_shapes(self): """Create new areas and labels for the port.""" Element.create_shapes(self) #get current rotation rotation = self.get_rotation() #get all sibling ports if self.is_source(): ports = self.get_parent().get_sources_gui() elif self.is_sink(): ports = self.get_parent().get_sinks_gui() #get the max width self.W = max([port.W for port in ports] + [PORT_MIN_WIDTH]) #get a numeric index for this port relative to its sibling ports try: index = ports.index(self) except: if hasattr(self, '_connector_length'): del self._connector_length return length = len(ports) #reverse the order of ports for these rotations if rotation in (180, 270): index = length - index - 1 offset = (self.get_parent().H - length * self.H - (length - 1) * PORT_SEPARATION) / 2 #create areas and connector coordinates if (self.is_sink() and rotation == 0) or (self.is_source() and rotation == 180): x = -1 * self.W y = (PORT_SEPARATION + self.H) * index + offset self.add_area((x, y), (self.W, self.H)) self._connector_coordinate = (x - 1, y + self.H / 2) elif (self.is_source() and rotation == 0) or (self.is_sink() and rotation == 180): x = self.get_parent().W y = (PORT_SEPARATION + self.H) * index + offset self.add_area((x, y), (self.W, self.H)) self._connector_coordinate = (x + 1 + self.W, y + self.H / 2) elif (self.is_source() and rotation == 90) or (self.is_sink() and rotation == 270): y = -1 * self.W x = (PORT_SEPARATION + self.H) * index + offset self.add_area((x, y), (self.H, self.W)) self._connector_coordinate = (x + self.H / 2, y - 1) elif (self.is_sink() and rotation == 90) or (self.is_source() and rotation == 270): y = self.get_parent().W x = (PORT_SEPARATION + self.H) * index + offset self.add_area((x, y), (self.H, self.W)) self._connector_coordinate = (x + self.H / 2, y + 1 + self.W) #the connector length self._connector_length = CONNECTOR_EXTENSION_MINIMAL + CONNECTOR_EXTENSION_INCREMENT * index
def create_shapes(self): """Create new areas and labels for the port.""" Element.create_shapes(self) #get current rotation rotation = self.get_rotation() #get all sibling ports if self.is_source(): ports = self.get_parent().get_sources_gui() elif self.is_sink(): ports = self.get_parent().get_sinks_gui() #get the max width self.W = max([port.W for port in ports] + [PORT_MIN_WIDTH]) #get a numeric index for this port relative to its sibling ports try: index = ports.index(self) except: if hasattr(self, '_connector_length'): del self._connector_length; return length = len(ports) #reverse the order of ports for these rotations if rotation in (180, 270): index = length-index-1 offset = (self.get_parent().H - length*self.H - (length-1)*PORT_SEPARATION)/2 #create areas and connector coordinates if (self.is_sink() and rotation == 0) or (self.is_source() and rotation == 180): x = -1*self.W y = (PORT_SEPARATION+self.H)*index+offset self.add_area((x, y), (self.W, self.H)) self._connector_coordinate = (x-1, y+self.H/2) elif (self.is_source() and rotation == 0) or (self.is_sink() and rotation == 180): x = self.get_parent().W y = (PORT_SEPARATION+self.H)*index+offset self.add_area((x, y), (self.W, self.H)) self._connector_coordinate = (x+1+self.W, y+self.H/2) elif (self.is_source() and rotation == 90) or (self.is_sink() and rotation == 270): y = -1*self.W x = (PORT_SEPARATION+self.H)*index+offset self.add_area((x, y), (self.H, self.W)) self._connector_coordinate = (x+self.H/2, y-1) elif (self.is_sink() and rotation == 90) or (self.is_source() and rotation == 270): y = self.get_parent().W x = (PORT_SEPARATION+self.H)*index+offset self.add_area((x, y), (self.H, self.W)) self._connector_coordinate = (x+self.H/2, y+1+self.W) #the connector length self._connector_length = CONNECTOR_EXTENSION_MINIMAL + CONNECTOR_EXTENSION_INCREMENT*index
def create_shapes(self): """Precalculate relative coordinates.""" Element.create_shapes(self) self._sink_rot = None self._source_rot = None self._sink_coor = None self._source_coor = None #get the source coordinate try: connector_length = self.get_source().get_connector_length() except: return self.x1, self.y1 = Utils.get_rotated_coordinate( (connector_length, 0), self.get_source().get_rotation()) #get the sink coordinate connector_length = self.get_sink().get_connector_length( ) + CONNECTOR_ARROW_HEIGHT self.x2, self.y2 = Utils.get_rotated_coordinate( (-connector_length, 0), self.get_sink().get_rotation()) #build the arrow self.arrow = [ (0, 0), Utils.get_rotated_coordinate( (-CONNECTOR_ARROW_HEIGHT, -CONNECTOR_ARROW_BASE / 2), self.get_sink().get_rotation()), Utils.get_rotated_coordinate( (-CONNECTOR_ARROW_HEIGHT, CONNECTOR_ARROW_BASE / 2), self.get_sink().get_rotation()), ] source_domain = self.get_source().get_domain() sink_domain = self.get_sink().get_domain() self.line_attributes[0] = 2 if source_domain != sink_domain else 0 self.line_attributes[1] = gtk.gdk.LINE_DOUBLE_DASH \ if not source_domain == sink_domain == GR_MESSAGE_DOMAIN \ else gtk.gdk.LINE_ON_OFF_DASH get_domain_color = lambda d: Colors.get_color( (self.get_parent().get_parent().get_domain(d) or {}).get( 'color') or Colors.DEFAULT_DOMAIN_COLOR_CODE) self._color = get_domain_color(source_domain) self._bg_color = get_domain_color(sink_domain) self._arrow_color = self._bg_color if self.is_valid( ) else Colors.CONNECTION_ERROR_COLOR self._update_after_move()