712 # Change the connector pen |
712 # Change the connector pen |
713 def SetPen(self, pen): |
713 def SetPen(self, pen): |
714 self.Pen = pen |
714 self.Pen = pen |
715 |
715 |
716 # Make a clone of the connector |
716 # Make a clone of the connector |
717 def Clone(self): |
717 def Clone(self, parent = None): |
718 return Connector(self.ParentBlock, self.Name, self.Type, wx.Point(self.Pos[0], self.Pos[1]), |
718 if parent is None: |
|
719 parent = self.ParentBlock |
|
720 return Connector(parent, self.Name, self.Type, wx.Point(self.Pos[0], self.Pos[1]), |
719 self.Direction, self.Negated) |
721 self.Direction, self.Negated) |
720 |
722 |
721 # Returns the connector parent block |
723 # Returns the connector parent block |
722 def GetParentBlock(self): |
724 def GetParentBlock(self): |
723 return self.ParentBlock |
725 return self.ParentBlock |
724 |
726 |
725 # Returns the connector type |
727 # Returns the connector type |
726 def GetType(self): |
728 def GetType(self, raw = False): |
727 if IsEndType(self.Type): |
729 if IsEndType(self.Type) or raw: |
728 return self.Type |
730 return self.Type |
729 elif (self.Negated or self.Edge != "none") and IsOfType("BOOL", self.Type): |
731 elif (self.Negated or self.Edge != "none") and IsOfType("BOOL", self.Type): |
730 return "BOOL" |
732 return "BOOL" |
731 else: |
733 else: |
732 return self.ParentBlock.GetConnectionResultType(self, self.Type) |
734 return self.ParentBlock.GetConnectionResultType(self, self.Type) |
1560 |
1562 |
1561 # Moves the wire segment given by its index |
1563 # Moves the wire segment given by its index |
1562 def MoveSegment(self, idx, movex, movey): |
1564 def MoveSegment(self, idx, movex, movey): |
1563 if 0 < idx < len(self.Segments) - 1: |
1565 if 0 < idx < len(self.Segments) - 1: |
1564 if self.Segments[idx] in (NORTH, SOUTH): |
1566 if self.Segments[idx] in (NORTH, SOUTH): |
|
1567 start_x = self.Points[idx].x |
1565 self.Points[idx].x += movex |
1568 self.Points[idx].x += movex |
1566 self.Points[idx + 1].x += movex |
1569 self.Points[idx + 1].x += movex |
|
1570 self.GeneratePoints() |
|
1571 if start_x != self.Points[idx].x: |
|
1572 return True, False |
1567 elif self.Segments[idx] in (EAST, WEST): |
1573 elif self.Segments[idx] in (EAST, WEST): |
|
1574 start_y = self.Points[idx].y |
1568 self.Points[idx].y += movey |
1575 self.Points[idx].y += movey |
1569 self.Points[idx + 1].y += movey |
1576 self.Points[idx + 1].y += movey |
1570 self.GeneratePoints() |
1577 self.GeneratePoints() |
|
1578 if start_y != self.Points[idx].y: |
|
1579 return False, True |
|
1580 return False, False |
1571 |
1581 |
1572 # Adds two points in the middle of the handled segment |
1582 # Adds two points in the middle of the handled segment |
1573 def AddSegment(self): |
1583 def AddSegment(self): |
1574 handle_type, handle = self.Handle |
1584 handle_type, handle = self.Handle |
1575 if handle_type == HANDLE_SEGMENT: |
1585 if handle_type == HANDLE_SEGMENT: |
1707 self.UnConnectEndPoint() |
1717 self.UnConnectEndPoint() |
1708 self.MoveEndPoint(new_pos) |
1718 self.MoveEndPoint(new_pos) |
1709 return True, True |
1719 return True, True |
1710 # A segment has been handled, move a segment |
1720 # A segment has been handled, move a segment |
1711 elif handle_type == HANDLE_SEGMENT: |
1721 elif handle_type == HANDLE_SEGMENT: |
1712 self.MoveSegment(handle[0], movex, movey) |
1722 return self.MoveSegment(handle[0], movex, movey) |
1713 return True, True |
|
1714 # Execute the default method for a graphic element |
1723 # Execute the default method for a graphic element |
1715 else: |
1724 else: |
1716 return Graphic_Element.ProcessDragging(self, movex, movey) |
1725 return Graphic_Element.ProcessDragging(self, movex, movey) |
1717 |
1726 |
1718 # Refreshes the wire model |
1727 # Refreshes the wire model |
1759 Graphic_Element.__init__(self, parent) |
1768 Graphic_Element.__init__(self, parent) |
1760 self.Id = id |
1769 self.Id = id |
1761 self.Content = content |
1770 self.Content = content |
1762 self.Pos = wx.Point(0, 0) |
1771 self.Pos = wx.Point(0, 0) |
1763 self.Size = wx.Size(0, 0) |
1772 self.Size = wx.Size(0, 0) |
|
1773 |
|
1774 # Make a clone of this comment |
|
1775 def Clone(self, id = None): |
|
1776 comment = Comment(self.Parent, self.Content, id) |
|
1777 comment.SetSize(self.Size[0], self.Size[1]) |
|
1778 return comment |
1764 |
1779 |
1765 # Method for keeping compatibility with others |
1780 # Method for keeping compatibility with others |
1766 def Clean(self): |
1781 def Clean(self): |
1767 pass |
1782 pass |
1768 |
1783 |