# HG changeset patch # User lbessard # Date 1216384446 -7200 # Node ID 8ce5c2635976ec7f40c6292e0f4a61b8f9dafb27 # Parent 25f2b49243472b0d2d5ecfdd0b6316e4e9f710a1 Adding support for underlying type incompatible wire loaded instead of removing them diff -r 25f2b4924347 -r 8ce5c2635976 Viewer.py --- a/Viewer.py Fri Jul 11 17:16:08 2008 +0200 +++ b/Viewer.py Fri Jul 18 14:34:06 2008 +0200 @@ -528,13 +528,10 @@ self.loadInstance(instance, ids) self.RefreshScrollBars() - to_delete = [] for wire in self.Wires: if not wire.IsConnectedCompatible(): - to_delete.append(wire) - for wire in to_delete: - wire.Delete() - + wire.MarkAsInvalid() + self.Refresh(False) def GetMaxSize(self): diff -r 25f2b4924347 -r 8ce5c2635976 graphics/GraphicCommons.py --- a/graphics/GraphicCommons.py Fri Jul 11 17:16:08 2008 +0200 +++ b/graphics/GraphicCommons.py Fri Jul 18 14:34:06 2008 +0200 @@ -1186,6 +1186,7 @@ self.Points = [] self.Segments = [] self.SelectedSegment = None + self.Valid = True self.Value = None self.OverStart = False self.OverEnd = False @@ -1286,11 +1287,11 @@ # The segment selected is the first elif segment == 0: if self.StartConnected: - self.StartConnected.SetPen(wx.RED_PEN) + self.StartConnected.SetPen(wx.BLUE_PEN) if self.EndConnected: # There is only one segment if len(self.Segments) == 1: - self.EndConnected.SetPen(wx.RED_PEN) + self.EndConnected.SetPen(wx.BLUE_PEN) else: self.EndConnected.SetPen(wx.BLACK_PEN) # The segment selected is the last @@ -1298,10 +1299,18 @@ if self.StartConnected: self.StartConnected.SetPen(wx.BLACK_PEN) if self.EndConnected: - self.EndConnected.SetPen(wx.RED_PEN) + self.EndConnected.SetPen(wx.BLUE_PEN) self.SelectedSegment = segment self.Refresh() + # Select a segment and not the whole wire. It's useful for Ladder Diagram + def MarkAsInvalid(self): + self.Valid = False + if self.StartConnected: + self.StartConnected.SetPen(wx.RED_PEN) + if self.EndConnected: + self.EndConnected.SetPen(wx.RED_PEN) + # Reinitialize the wire points def ResetPoints(self): if self.StartPoint and self.EndPoint: @@ -2029,7 +2038,10 @@ # Draws the wire lines and points def Draw(self, dc): Graphic_Element.Draw(self, dc) - dc.SetPen(wx.BLACK_PEN) + if self.Valid: + dc.SetPen(wx.BLACK_PEN) + else: + dc.SetPen(wx.RED_PEN) dc.SetBrush(wx.BLACK_BRUSH) # Draw the start and end points if they are not connected or the mouse is over them if len(self.Points) > 0 and (not self.StartConnected or self.OverStart):