650 |
650 |
651 # Changes the variable type |
651 # Changes the variable type |
652 def SetType(self, type, value_type): |
652 def SetType(self, type, value_type): |
653 if type != self.Type: |
653 if type != self.Type: |
654 self.Type = type |
654 self.Type = type |
655 self.Clean() |
|
656 self.Input = None |
|
657 self.Output = None |
|
658 # Create an input or output connector according to variable type |
655 # Create an input or output connector according to variable type |
659 if self.Type != INPUT: |
656 if self.Type != INPUT: |
660 self.Input = Connector(self, "", value_type, wx.Point(0, 0), WEST, onlyone = True) |
657 if self.Input is None: |
|
658 self.Input = Connector(self, "", value_type, wx.Point(0, 0), WEST, onlyone = True) |
|
659 elif self.Input: |
|
660 self.Input.UnConnect(delete = True) |
|
661 self.Input = None |
661 if self.Type != OUTPUT: |
662 if self.Type != OUTPUT: |
662 self.Output = Connector(self, "", value_type, wx.Point(0, 0), EAST) |
663 if self.Output is None: |
|
664 self.Output = Connector(self, "", value_type, wx.Point(0, 0), EAST) |
|
665 elif self.Output: |
|
666 self.Output.UnConnect(delete = True) |
|
667 self.Output = None |
663 self.RefreshConnectors() |
668 self.RefreshConnectors() |
664 elif value_type != self.ValueType: |
669 elif value_type != self.ValueType: |
665 if self.Input: |
670 if self.Input: |
666 self.Input.SetType(value_type) |
671 self.Input.SetType(value_type) |
667 if self.Output: |
672 if self.Output: |
668 self.Output.SetType(value_type) |
673 self.Output.SetType(value_type) |
669 self.RefreshConnectors() |
674 |
670 |
|
671 # Returns the variable type |
675 # Returns the variable type |
672 def GetType(self): |
676 def GetType(self): |
673 return self.Type |
677 return self.Type |
|
678 |
|
679 # Returns the variable value type |
|
680 def GetValueType(self): |
|
681 return self.ValueType |
674 |
682 |
675 # Changes the variable name |
683 # Changes the variable name |
676 def SetName(self, name): |
684 def SetName(self, name): |
677 self.Name = name |
685 self.Name = name |
678 self.RefreshNameSize() |
686 self.RefreshNameSize() |
703 else: |
711 else: |
704 return Graphic_Element.SetBestSize(self, scaling) |
712 return Graphic_Element.SetBestSize(self, scaling) |
705 |
713 |
706 # Method called when a LeftDClick event have been generated |
714 # Method called when a LeftDClick event have been generated |
707 def OnLeftDClick(self, event, dc, scaling): |
715 def OnLeftDClick(self, event, dc, scaling): |
708 # Edit the variable properties |
716 if event.ControlDown(): |
709 self.Parent.EditVariableContent(self) |
717 # Change variable type |
|
718 types = [INPUT, OUTPUT, INOUT] |
|
719 self.Parent.ChangeVariableType(self, |
|
720 types[(types.index(self.Type) + 1) % len(types)]) |
|
721 else: |
|
722 # Edit the variable properties |
|
723 self.Parent.EditVariableContent(self) |
710 |
724 |
711 # Method called when a RightUp event have been generated |
725 # Method called when a RightUp event have been generated |
712 def OnRightUp(self, event, dc, scaling): |
726 def OnRightUp(self, event, dc, scaling): |
713 self.Parent.PopupDefaultMenu() |
727 self.Parent.PopupVariableMenu() |
714 |
728 |
715 # Refreshes the variable model |
729 # Refreshes the variable model |
716 def RefreshModel(self, move=True): |
730 def RefreshModel(self, move=True): |
717 self.Parent.RefreshVariableModel(self) |
731 self.Parent.RefreshVariableModel(self) |
718 # If variable has moved and variable is not of type OUTPUT, refresh the model |
732 # If variable has moved and variable is not of type OUTPUT, refresh the model |
925 text_height += 1 |
939 text_height += 1 |
926 return text_width + text_height + 20, text_height + 10 |
940 return text_width + text_height + 20, text_height + 10 |
927 |
941 |
928 # Method called when a LeftDClick event have been generated |
942 # Method called when a LeftDClick event have been generated |
929 def OnLeftDClick(self, event, dc, scaling): |
943 def OnLeftDClick(self, event, dc, scaling): |
930 # Edit the connection properties |
944 if event.ControlDown(): |
931 self.Parent.EditConnectionContent(self) |
945 # Change connection type |
|
946 if self.Type == CONNECTOR: |
|
947 self.Parent.ChangeConnectionType(self, CONTINUATION) |
|
948 else: |
|
949 self.Parent.ChangeConnectionType(self, CONNECTOR) |
|
950 else: |
|
951 # Edit the connection properties |
|
952 self.Parent.EditConnectionContent(self) |
932 |
953 |
933 # Method called when a RightUp event have been generated |
954 # Method called when a RightUp event have been generated |
934 def OnRightUp(self, event, dc, scaling): |
955 def OnRightUp(self, event, dc, scaling): |
935 # Popup the default menu |
956 # Popup the default menu |
936 self.Parent.PopupDefaultMenu() |
957 self.Parent.PopupConnectionMenu() |
937 |
958 |
938 # Refreshes the connection model |
959 # Refreshes the connection model |
939 def RefreshModel(self, move=True): |
960 def RefreshModel(self, move=True): |
940 self.Parent.RefreshConnectionModel(self) |
961 self.Parent.RefreshConnectionModel(self) |
941 # If connection has moved and connection is of type CONTINUATION, refresh |
962 # If connection has moved and connection is of type CONTINUATION, refresh |