377 |
377 |
378 """ |
378 """ |
379 Class that implements the graphic representation of a contact |
379 Class that implements the graphic representation of a contact |
380 """ |
380 """ |
381 |
381 |
382 class LD_Contact(Graphic_Element): |
382 class LD_Contact(Graphic_Element, DebugDataConsumer): |
383 |
383 |
384 # Create a new contact |
384 # Create a new contact |
385 def __init__(self, parent, type, name, id = None): |
385 def __init__(self, parent, type, name, id = None): |
386 Graphic_Element.__init__(self, parent) |
386 Graphic_Element.__init__(self, parent) |
|
387 DebugDataConsumer.__init__(self) |
387 self.Type = type |
388 self.Type = type |
388 self.Name = name |
389 self.Name = name |
389 self.Id = id |
390 self.Id = id |
390 self.Size = wx.Size(LD_ELEMENT_SIZE[0], LD_ELEMENT_SIZE[1]) |
391 self.Size = wx.Size(LD_ELEMENT_SIZE[0], LD_ELEMENT_SIZE[1]) |
391 self.Errors = {} |
392 self.Errors = {} |
392 # Create an input and output connector |
393 # Create an input and output connector |
393 self.Input = Connector(self, "", "BOOL", wx.Point(0, self.Size[1] / 2 + 1), WEST) |
394 self.Input = Connector(self, "", "BOOL", wx.Point(0, self.Size[1] / 2 + 1), WEST) |
394 self.Output = Connector(self, "", "BOOL", wx.Point(self.Size[0], self.Size[1] / 2 + 1), EAST) |
395 self.Output = Connector(self, "", "BOOL", wx.Point(self.Size[0], self.Size[1] / 2 + 1), EAST) |
395 self.Value = None |
|
396 self.PreviousValue = False |
396 self.PreviousValue = False |
397 self.PreviousSpreading = False |
397 self.PreviousSpreading = False |
398 self.RefreshNameSize() |
398 self.RefreshNameSize() |
399 self.RefreshTypeSize() |
399 self.RefreshTypeSize() |
400 |
400 |
408 |
408 |
409 def SetValue(self, value): |
409 def SetValue(self, value): |
410 self.PreviousValue = self.Value |
410 self.PreviousValue = self.Value |
411 self.Value = value |
411 self.Value = value |
412 if self.Value != self.PreviousValue: |
412 if self.Value != self.PreviousValue: |
413 self.Refresh() |
413 self.Parent.UpdateRefreshRect(self.GetRedrawRect()) |
414 self.SpreadCurrent() |
414 self.SpreadCurrent() |
415 |
415 |
416 def SpreadCurrent(self): |
416 def SpreadCurrent(self): |
417 if self.Parent.Debug: |
417 if self.Parent.Debug: |
418 if self.Value is None: |
418 if self.Value is None: |
715 if self.Value and not self.PreviousValue: |
715 if self.Value and not self.PreviousValue: |
716 self.Output.SpreadCurrent(True) |
716 self.Output.SpreadCurrent(True) |
717 elif not self.Value and self.PreviousValue: |
717 elif not self.Value and self.PreviousValue: |
718 self.Output.SpreadCurrent(False) |
718 self.Output.SpreadCurrent(False) |
719 if self.Value != self.PreviousValue: |
719 if self.Value != self.PreviousValue: |
720 self.Refresh() |
720 self.Parent.UpdateRefreshRect(self.GetRedrawRect()) |
721 |
721 |
722 # Make a clone of this LD_Coil |
722 # Make a clone of this LD_Coil |
723 def Clone(self, parent, id = None, pos = None): |
723 def Clone(self, parent, id = None, pos = None): |
724 coil = LD_Coil(parent, self.Type, self.Name, id) |
724 coil = LD_Coil(parent, self.Type, self.Name, id) |
725 coil.SetSize(self.Size[0], self.Size[1]) |
725 coil.SetSize(self.Size[0], self.Size[1]) |