190 self.Inhibited = False |
190 self.Inhibited = False |
191 |
191 |
192 def Inhibit(self, inhibit): |
192 def Inhibit(self, inhibit): |
193 self.Inhibited = inhibit |
193 self.Inhibited = inhibit |
194 if not inhibit and self.LastValue is not None: |
194 if not inhibit and self.LastValue is not None: |
195 self.Forced = self.LastForced |
195 self.SetForced(self.LastForced) |
196 self.SetValue(self.LastValue) |
196 self.SetValue(self.LastValue) |
197 self.LastValue = None |
197 self.LastValue = None |
198 |
198 |
199 def NewValue(self, tick, value, forced=False): |
199 def NewValue(self, tick, value, forced=False): |
200 if self.Inhibited: |
200 if self.Inhibited: |
201 self.LastValue = value |
201 self.LastValue = value |
202 self.LastForced = forced |
202 self.LastForced = forced |
203 else: |
203 else: |
204 self.Forced = forced |
204 self.SetForced(forced) |
205 self.SetValue(value) |
205 self.SetValue(value) |
206 |
206 |
207 def SetValue(self, value): |
207 def SetValue(self, value): |
208 self.Value = value |
208 self.Value = value |
209 |
209 |
|
210 def SetForced(self, forced): |
|
211 self.Forced = forced |
|
212 |
210 def IsForced(self): |
213 def IsForced(self): |
211 return self.Forced |
214 return self.Forced |
212 |
215 |
213 #------------------------------------------------------------------------------- |
216 #------------------------------------------------------------------------------- |
214 # Debug Viewer Class |
217 # Debug Viewer Class |
1267 |
1271 |
1268 # Changes the connector name |
1272 # Changes the connector name |
1269 def SetName(self, name): |
1273 def SetName(self, name): |
1270 self.Name = name |
1274 self.Name = name |
1271 self.RefreshNameSize() |
1275 self.RefreshNameSize() |
|
1276 |
|
1277 def RefreshForced(self): |
|
1278 self.Forced = False |
|
1279 for wire, handle in self.Wires: |
|
1280 self.Forced |= wire.IsForced() |
1272 |
1281 |
1273 def RefreshValue(self): |
1282 def RefreshValue(self): |
1274 self.Value = self.ReceivingCurrent() |
1283 self.Value = self.ReceivingCurrent() |
1275 |
1284 |
1276 def RefreshValid(self): |
1285 def RefreshValid(self): |
1501 dc.SetBrush(wx.Brush(wx.Colour(255, 255, 0))) |
1510 dc.SetBrush(wx.Brush(wx.Colour(255, 255, 0))) |
1502 else: |
1511 else: |
1503 if not self.Valid: |
1512 if not self.Valid: |
1504 dc.SetPen(wx.RED_PEN) |
1513 dc.SetPen(wx.RED_PEN) |
1505 elif isinstance(self.Value, BooleanType) and self.Value: |
1514 elif isinstance(self.Value, BooleanType) and self.Value: |
1506 dc.SetPen(wx.GREEN_PEN) |
1515 if self.Forced: |
|
1516 dc.SetPen(wx.CYAN_PEN) |
|
1517 else: |
|
1518 dc.SetPen(wx.GREEN_PEN) |
1507 elif self.Value == "undefined": |
1519 elif self.Value == "undefined": |
1508 dc.SetPen(wx.Pen(wx.NamedColour("orange"))) |
1520 dc.SetPen(wx.Pen(wx.NamedColour("orange"))) |
|
1521 elif self.Forced: |
|
1522 dc.SetPen(wx.Pen(wx.BLUE)) |
1509 else: |
1523 else: |
1510 dc.SetPen(self.Pen) |
1524 dc.SetPen(self.Pen) |
1511 dc.SetBrush(wx.WHITE_BRUSH) |
1525 dc.SetBrush(wx.WHITE_BRUSH) |
1512 parent_pos = self.ParentBlock.GetPosition() |
1526 parent_pos = self.ParentBlock.GetPosition() |
1513 |
1527 |
1756 return self.StartConnected.IsCompatible(self.GetEndConnectedType()) |
1770 return self.StartConnected.IsCompatible(self.GetEndConnectedType()) |
1757 elif self.EndConnected: |
1771 elif self.EndConnected: |
1758 return True |
1772 return True |
1759 return False |
1773 return False |
1760 |
1774 |
|
1775 def SetForced(self, forced): |
|
1776 if self.Forced != forced: |
|
1777 self.Forced = forced |
|
1778 if self.StartConnected: |
|
1779 self.StartConnected.RefreshForced() |
|
1780 if self.EndConnected: |
|
1781 self.EndConnected.RefreshForced() |
|
1782 if self.Visible: |
|
1783 self.Parent.UpdateRefreshRect(self.GetRedrawRect()) |
|
1784 |
1761 def SetValue(self, value): |
1785 def SetValue(self, value): |
1762 if self.Value != value: |
1786 if self.Value != value: |
1763 self.Value = value |
1787 self.Value = value |
1764 if value is not None and not isinstance(value, BooleanType): |
1788 if value is not None and not isinstance(value, BooleanType): |
1765 if isinstance(value, StringType): |
1789 if isinstance(value, StringType): |
1810 if self.EndConnected: |
1834 if self.EndConnected: |
1811 self.EndConnected.SetPen(wx.BLACK_PEN) |
1835 self.EndConnected.SetPen(wx.BLACK_PEN) |
1812 # The segment selected is the first |
1836 # The segment selected is the first |
1813 elif segment == 0: |
1837 elif segment == 0: |
1814 if self.StartConnected: |
1838 if self.StartConnected: |
1815 self.StartConnected.SetPen(wx.BLUE_PEN) |
1839 self.StartConnected.SetPen(wx.Pen(wx.BLUE)) |
1816 if self.EndConnected: |
1840 if self.EndConnected: |
1817 # There is only one segment |
1841 # There is only one segment |
1818 if len(self.Segments) == 1: |
1842 if len(self.Segments) == 1: |
1819 self.EndConnected.SetPen(wx.BLUE_PEN) |
1843 self.EndConnected.SetPen(wx.Pen(wx.BLUE)) |
1820 else: |
1844 else: |
1821 self.EndConnected.SetPen(wx.BLACK_PEN) |
1845 self.EndConnected.SetPen(wx.BLACK_PEN) |
1822 # The segment selected is the last |
1846 # The segment selected is the last |
1823 elif segment == len(self.Segments) - 1: |
1847 elif segment == len(self.Segments) - 1: |
1824 if self.StartConnected: |
1848 if self.StartConnected: |
1825 self.StartConnected.SetPen(wx.BLACK_PEN) |
1849 self.StartConnected.SetPen(wx.BLACK_PEN) |
1826 if self.EndConnected: |
1850 if self.EndConnected: |
1827 self.EndConnected.SetPen(wx.BLUE_PEN) |
1851 self.EndConnected.SetPen(wx.Pen(wx.BLUE)) |
1828 self.SelectedSegment = segment |
1852 self.SelectedSegment = segment |
1829 self.Refresh() |
1853 self.Refresh() |
1830 |
1854 |
1831 def SetValid(self, valid): |
1855 def SetValid(self, valid): |
1832 self.Valid = valid |
1856 self.Valid = valid |
2628 Graphic_Element.Draw(self, dc) |
2652 Graphic_Element.Draw(self, dc) |
2629 if not self.Valid: |
2653 if not self.Valid: |
2630 dc.SetPen(wx.RED_PEN) |
2654 dc.SetPen(wx.RED_PEN) |
2631 dc.SetBrush(wx.RED_BRUSH) |
2655 dc.SetBrush(wx.RED_BRUSH) |
2632 elif isinstance(self.Value, BooleanType) and self.Value: |
2656 elif isinstance(self.Value, BooleanType) and self.Value: |
2633 dc.SetPen(wx.GREEN_PEN) |
2657 if self.Forced: |
2634 dc.SetBrush(wx.GREEN_BRUSH) |
2658 dc.SetPen(wx.CYAN_PEN) |
|
2659 dc.SetBrush(wx.CYAN_BRUSH) |
|
2660 else: |
|
2661 dc.SetPen(wx.GREEN_PEN) |
|
2662 dc.SetBrush(wx.GREEN_BRUSH) |
2635 elif self.Value == "undefined": |
2663 elif self.Value == "undefined": |
2636 dc.SetPen(wx.Pen(wx.NamedColour("orange"))) |
2664 dc.SetPen(wx.Pen(wx.NamedColour("orange"))) |
2637 dc.SetBrush(wx.Brush(wx.NamedColour("orange"))) |
2665 dc.SetBrush(wx.Brush(wx.NamedColour("orange"))) |
|
2666 elif self.Forced: |
|
2667 dc.SetPen(wx.Pen(wx.BLUE)) |
|
2668 dc.SetBrush(wx.BLUE_BRUSH) |
2638 else: |
2669 else: |
2639 dc.SetPen(wx.BLACK_PEN) |
2670 dc.SetPen(wx.BLACK_PEN) |
2640 dc.SetBrush(wx.BLACK_BRUSH) |
2671 dc.SetBrush(wx.BLACK_BRUSH) |
2641 # Draw the start and end points if they are not connected or the mouse is over them |
2672 # Draw the start and end points if they are not connected or the mouse is over them |
2642 if len(self.Points) > 0 and (not self.StartConnected or self.OverStart): |
2673 if len(self.Points) > 0 and (not self.StartConnected or self.OverStart): |