1379 wire_nums = len(self.Wires) |
1379 wire_nums = len(self.Wires) |
1380 |
1380 |
1381 connector_free = (wire_nums <= 0) |
1381 connector_free = (wire_nums <= 0) |
1382 connector_max_used = ((wire_nums > 0) and self.OneConnected) |
1382 connector_max_used = ((wire_nums > 0) and self.OneConnected) |
1383 if (self.Parent.CurrentLanguage in ["SFC", "LD"]) and (self.Type == "BOOL"): |
1383 if (self.Parent.CurrentLanguage in ["SFC", "LD"]) and (self.Type == "BOOL"): |
1384 connector_max_used = False; |
1384 connector_max_used = False |
1385 |
1385 |
1386 # connector is available for new connection |
1386 # connector is available for new connection |
1387 connect = connector_free or not connector_max_used |
1387 connect = connector_free or not connector_max_used |
1388 return connect, connector_max_used |
1388 return connect, connector_max_used |
1389 |
1389 |
1390 # Tests if the point given is near from the end point of this connector |
1390 # Tests if the point given is near from the end point of this connector |
1391 def TestPoint(self, pt, direction=None, exclude=True): |
1391 def TestPoint(self, pt, direction=None, exclude=True): |
1392 inside = False; |
1392 inside = False |
1393 check_point = (not exclude) and (direction is None or self.Direction == direction); |
1393 check_point = (not exclude) and (direction is None or self.Direction == direction) |
1394 |
1394 |
1395 if check_point: |
1395 if check_point: |
1396 # Calculate a square around the end point of this connector |
1396 # Calculate a square around the end point of this connector |
1397 parent_pos = self.ParentBlock.GetPosition() |
1397 parent_pos = self.ParentBlock.GetPosition() |
1398 x = parent_pos[0] + self.Pos.x + self.Direction[0] * CONNECTOR_SIZE - ANCHOR_DISTANCE |
1398 x = parent_pos[0] + self.Pos.x + self.Direction[0] * CONNECTOR_SIZE - ANCHOR_DISTANCE |
1399 y = parent_pos[1] + self.Pos.y + self.Direction[1] * CONNECTOR_SIZE - ANCHOR_DISTANCE |
1399 y = parent_pos[1] + self.Pos.y + self.Direction[1] * CONNECTOR_SIZE - ANCHOR_DISTANCE |
1400 width = ANCHOR_DISTANCE * 2 + abs(self.Direction[0]) * CONNECTOR_SIZE |
1400 width = ANCHOR_DISTANCE * 2 + abs(self.Direction[0]) * CONNECTOR_SIZE |
1401 height = ANCHOR_DISTANCE * 2 + abs(self.Direction[1]) * CONNECTOR_SIZE |
1401 height = ANCHOR_DISTANCE * 2 + abs(self.Direction[1]) * CONNECTOR_SIZE |
1402 rect = wx.Rect(x, y, width, height) |
1402 rect = wx.Rect(x, y, width, height) |
1403 inside = rect.InsideXY(pt.x, pt.y); |
1403 inside = rect.InsideXY(pt.x, pt.y) |
1404 |
1404 |
1405 return inside |
1405 return inside |
1406 |
1406 |
1407 # Draws the highlightment of this element if it is highlighted |
1407 # Draws the highlightment of this element if it is highlighted |
1408 def DrawHighlightment(self, dc): |
1408 def DrawHighlightment(self, dc): |