682 self.Name = name |
682 self.Name = name |
683 self.Type = type |
683 self.Type = type |
684 self.Pos = position |
684 self.Pos = position |
685 self.Direction = direction |
685 self.Direction = direction |
686 self.Wires = [] |
686 self.Wires = [] |
687 self.Negated = negated |
687 if IsOfType("BOOL", type): |
688 self.Edge = edge |
688 self.Negated = negated |
|
689 self.Edge = edge |
|
690 else: |
|
691 self.Negated = False |
|
692 self.Edge = "none" |
689 self.OneConnected = onlyone |
693 self.OneConnected = onlyone |
690 self.Pen = wx.BLACK_PEN |
694 self.Pen = wx.BLACK_PEN |
691 self.RefreshNameSize() |
695 self.RefreshNameSize() |
692 |
696 |
693 # Change the connector pen |
697 # Change the connector pen |
705 |
709 |
706 # Returns the connector type |
710 # Returns the connector type |
707 def GetType(self): |
711 def GetType(self): |
708 if IsEndType(self.Type): |
712 if IsEndType(self.Type): |
709 return self.Type |
713 return self.Type |
|
714 elif (self.Negated or self.Edge != "none") and IsOfType("BOOL", self.Type): |
|
715 return "BOOL" |
710 else: |
716 else: |
711 return self.ParentBlock.GetConnectionResultType(self) |
717 return self.ParentBlock.GetConnectionResultType(self, self.Type) |
712 |
718 |
713 # Returns the connector type |
719 # Returns the connector type |
714 def GetConnectedType(self): |
720 def GetConnectedType(self): |
715 if IsEndType(self.Type): |
721 if IsEndType(self.Type): |
716 return self.Type |
722 return self.Type |
733 |
739 |
734 # Changes the connector name |
740 # Changes the connector name |
735 def SetName(self, name): |
741 def SetName(self, name): |
736 self.Name = name |
742 self.Name = name |
737 self.RefreshNameSize() |
743 self.RefreshNameSize() |
|
744 |
|
745 def SetValue(self, value): |
|
746 for wire, handle in self.Wires: |
|
747 wire.SetValue(value) |
738 |
748 |
739 # Changes the connector name size |
749 # Changes the connector name size |
740 def RefreshNameSize(self): |
750 def RefreshNameSize(self): |
741 if self.Name != "": |
751 if self.Name != "": |
742 dc = wx.ClientDC(self.ParentBlock.Parent) |
752 dc = wx.ClientDC(self.ParentBlock.Parent) |
872 def IsNegated(self): |
882 def IsNegated(self): |
873 return self.Negated |
883 return self.Negated |
874 |
884 |
875 # Changes the connector negated property |
885 # Changes the connector negated property |
876 def SetNegated(self, negated): |
886 def SetNegated(self, negated): |
877 self.Negated = negated |
887 if IsOfType("BOOL", self.Type): |
878 self.Edge = "none" |
888 self.Negated = negated |
|
889 self.Edge = "none" |
879 |
890 |
880 # Returns the connector edge property |
891 # Returns the connector edge property |
881 def GetEdge(self): |
892 def GetEdge(self): |
882 return self.Edge |
893 return self.Edge |
883 |
894 |
884 # Changes the connector edge property |
895 # Changes the connector edge property |
885 def SetEdge(self, edge): |
896 def SetEdge(self, edge): |
886 self.Edge = edge |
897 if IsOfType("BOOL", self.Type): |
887 self.Negated = False |
898 self.Edge = edge |
|
899 self.Negated = False |
888 |
900 |
889 # Tests if the point given is near from the end point of this connector |
901 # Tests if the point given is near from the end point of this connector |
890 def TestPoint(self, pt, exclude = True): |
902 def TestPoint(self, pt, exclude = True): |
891 parent_pos = self.ParentBlock.GetPosition() |
903 parent_pos = self.ParentBlock.GetPosition() |
892 if not (len(self.Wires) > 0 and self.OneConnected and exclude): |
904 if not (len(self.Wires) > 0 and self.OneConnected and exclude): |
1010 if self.StartConnected: |
1023 if self.StartConnected: |
1011 return self.StartConnected.IsCompatible(self.GetEndConnectedType()) |
1024 return self.StartConnected.IsCompatible(self.GetEndConnectedType()) |
1012 elif self.EndConnected: |
1025 elif self.EndConnected: |
1013 return True |
1026 return True |
1014 return False |
1027 return False |
|
1028 |
|
1029 def SetValue(self, value): |
|
1030 self.Value = value |
1015 |
1031 |
1016 # Unconnect the start and end points |
1032 # Unconnect the start and end points |
1017 def Clean(self): |
1033 def Clean(self): |
1018 if self.StartConnected: |
1034 if self.StartConnected: |
1019 self.UnConnectStartPoint() |
1035 self.UnConnectStartPoint() |