editors/Viewer.py
changeset 1544 2969c2123105
parent 1498 b11045a2f17c
child 1556 32e9d0ef30dc
equal deleted inserted replaced
1543:61f0f31ef296 1544:2969c2123105
  1460             if element.HitTest(pos, connectors) or element.TestHandle(event) != (0, 0):
  1460             if element.HitTest(pos, connectors) or element.TestHandle(event) != (0, 0):
  1461                 return element
  1461                 return element
  1462         return None
  1462         return None
  1463 
  1463 
  1464     def FindBlockConnector(self, pos, direction = None, exclude = None):
  1464     def FindBlockConnector(self, pos, direction = None, exclude = None):
       
  1465         result, error = self.FindBlockConnectorWithError(pos, direction, exclude)
       
  1466         return result
       
  1467 
       
  1468     def FindBlockConnectorWithError(self, pos, direction = None, exclude = None):
       
  1469         error = False        
  1465         for block in self.Blocks.itervalues():
  1470         for block in self.Blocks.itervalues():
  1466             result = block.TestConnector(pos, direction, exclude)
  1471             connector = block.TestConnector(pos, direction, exclude)
  1467             if result:
  1472             if connector:
  1468                 return result
  1473                 avail, error = connector.ConnectionAvailable(direction, exclude)
  1469         return None
  1474                 if not avail:
  1470 
  1475                     connector = None
       
  1476                 return connector, error
       
  1477         return None, error
       
  1478     
  1471     def FindElementById(self, id):
  1479     def FindElementById(self, id):
  1472         block = self.Blocks.get(id, None)
  1480         block = self.Blocks.get(id, None)
  1473         if block is not None:
  1481         if block is not None:
  1474             return block
  1482             return block
  1475         comment = self.Comments.get(id, None)
  1483         comment = self.Comments.get(id, None)
  2271                 self.HighlightedElement = highlighted
  2279                 self.HighlightedElement = highlighted
  2272             if self.rubberBand.IsShown():
  2280             if self.rubberBand.IsShown():
  2273                 self.rubberBand.OnMotion(event, dc, self.Scaling)
  2281                 self.rubberBand.OnMotion(event, dc, self.Scaling)
  2274             elif not self.Debug and self.Mode == MODE_SELECTION and self.SelectedElement is not None:
  2282             elif not self.Debug and self.Mode == MODE_SELECTION and self.SelectedElement is not None:
  2275                 if self.DrawingWire:
  2283                 if self.DrawingWire:
  2276                     connector = self.FindBlockConnector(pos, self.SelectedElement.GetConnectionDirection(), self.SelectedElement.EndConnected)
  2284                     connector, errorHighlight = self.FindBlockConnectorWithError(pos, self.SelectedElement.GetConnectionDirection(), self.SelectedElement.EndConnected)
       
  2285                     self.SelectedElement.ErrHighlight = errorHighlight;
  2277                     if not connector or self.SelectedElement.EndConnected == None:
  2286                     if not connector or self.SelectedElement.EndConnected == None:
  2278                         self.SelectedElement.ResetPoints()
  2287                         self.SelectedElement.ResetPoints()
  2279                         movex, movey = self.SelectedElement.OnMotion(event, dc, self.Scaling)
  2288                         movex, movey = self.SelectedElement.OnMotion(event, dc, self.Scaling)
  2280                         self.SelectedElement.GeneratePoints()
  2289                         self.SelectedElement.GeneratePoints()
  2281                         if movex != 0 or movey != 0:
  2290                         if movex != 0 or movey != 0: