Viewer.py
changeset 243 c5da8b706cde
parent 239 d12779e971bd
child 249 d8425712acef
equal deleted inserted replaced
242:5b3e1c4569e6 243:c5da8b706cde
   846         for element in self.GetElements():
   846         for element in self.GetElements():
   847             if element.HitTest(pos) or element.TestHandle(pos) != (0, 0):
   847             if element.HitTest(pos) or element.TestHandle(pos) != (0, 0):
   848                 return element
   848                 return element
   849         return None
   849         return None
   850     
   850     
   851     def FindBlockConnector(self, pos, exclude = True):
   851     def FindBlockConnector(self, pos, direction = None, exclude = True):
   852         for block in self.Blocks:
   852         for block in self.Blocks:
   853             result = block.TestConnector(pos, exclude)
   853             result = block.TestConnector(pos, direction, exclude)
   854             if result:
   854             if result:
   855                 return result
   855                 return result
   856         return None
   856         return None
   857     
   857     
   858     def FindElementById(self, id):
   858     def FindElementById(self, id):
  1114                 else:
  1114                 else:
  1115                     connector = None
  1115                     connector = None
  1116                 if self.DrawingWire:
  1116                 if self.DrawingWire:
  1117                     self.DrawingWire = False
  1117                     self.DrawingWire = False
  1118                     if self.SelectedElement is not None:
  1118                     if self.SelectedElement is not None:
       
  1119                         if element is None or element.TestHandle(pos) == (0, 0):
       
  1120                             connector = self.FindBlockConnector(pos, self.SelectedElement.GetConnectionDirection())
  1119                         if connector:
  1121                         if connector:
  1120                             event.Dragging = lambda : True
  1122                             event.Dragging = lambda : True
  1121                             self.SelectedElement.OnMotion(event, self.GetLogicalDC(), self.Scaling)
  1123                             self.SelectedElement.OnMotion(event, self.GetLogicalDC(), self.Scaling)
  1122                         if self.SelectedElement.EndConnected is not None:
  1124                         if self.SelectedElement.EndConnected is not None:
  1123                             self.SelectedElement.ResetPoints()
  1125                             self.SelectedElement.ResetPoints()
  1209                     wx.CallAfter(self.AddNewActionBlock, bbox)
  1211                     wx.CallAfter(self.AddNewActionBlock, bbox)
  1210         elif self.Mode == MODE_SELECTION and self.SelectedElement:
  1212         elif self.Mode == MODE_SELECTION and self.SelectedElement:
  1211             dc = self.GetLogicalDC()
  1213             dc = self.GetLogicalDC()
  1212             if self.DrawingWire:
  1214             if self.DrawingWire:
  1213                 pos = event.GetLogicalPosition(dc)
  1215                 pos = event.GetLogicalPosition(dc)
  1214                 connector = self.FindBlockConnector(pos)
  1216                 connector = self.FindBlockConnector(pos, self.SelectedElement.GetConnectionDirection())
  1215                 if self.SelectedElement.EndConnected is not None:
  1217                 if self.SelectedElement.EndConnected is not None:
  1216                     self.DrawingWire = False
  1218                     self.DrawingWire = False
  1217                     self.SelectedElement.StartConnected.HighlightParentBlock(False)
  1219                     self.SelectedElement.StartConnected.HighlightParentBlock(False)
  1218                     self.SelectedElement.EndConnected.HighlightParentBlock(False)
  1220                     self.SelectedElement.EndConnected.HighlightParentBlock(False)
  1219                     self.SelectedElement.ResetPoints()
  1221                     self.SelectedElement.ResetPoints()
  1285             self.HighlightedElement = highlighted
  1287             self.HighlightedElement = highlighted
  1286         if self.rubberBand.IsShown():
  1288         if self.rubberBand.IsShown():
  1287             self.rubberBand.OnMotion(event, dc, self.Scaling)
  1289             self.rubberBand.OnMotion(event, dc, self.Scaling)
  1288         elif self.Mode == MODE_SELECTION and self.SelectedElement:
  1290         elif self.Mode == MODE_SELECTION and self.SelectedElement:
  1289             if self.DrawingWire:
  1291             if self.DrawingWire:
  1290                 connector = self.FindBlockConnector(pos, False)
  1292                 connector = self.FindBlockConnector(pos, self.SelectedElement.GetConnectionDirection(), False)
  1291                 if not connector or self.SelectedElement.EndConnected == None:
  1293                 if not connector or self.SelectedElement.EndConnected == None:
  1292                     self.SelectedElement.ResetPoints()
  1294                     self.SelectedElement.ResetPoints()
  1293                     movex, movey = self.SelectedElement.OnMotion(event, dc, self.Scaling)
  1295                     movex, movey = self.SelectedElement.OnMotion(event, dc, self.Scaling)
  1294                     self.SelectedElement.GeneratePoints()
  1296                     self.SelectedElement.GeneratePoints()
  1295                     if movex != 0 or movey != 0:
  1297                     if movex != 0 or movey != 0: