1268 connector.SetPosition(wx.Point(*input_connector["position"])) |
1268 connector.SetPosition(wx.Point(*input_connector["position"])) |
1269 if input_connector.get("negated", False): |
1269 if input_connector.get("negated", False): |
1270 connector.SetNegated(True) |
1270 connector.SetNegated(True) |
1271 if input_connector.get("edge", "none") != "none": |
1271 if input_connector.get("edge", "none") != "none": |
1272 connector.SetEdge(input_connector["edge"]) |
1272 connector.SetEdge(input_connector["edge"]) |
1273 self.CreateWires(connector, instance["id"], input_connector["links"], ids, selection) |
1273 if not self.CreateWires(connector, instance["id"], input_connector["links"], ids, selection): |
|
1274 element.RefreshModel() |
1274 element.RefreshConnectors() |
1275 element.RefreshConnectors() |
1275 if selection is not None and selection[0].get(instance["id"], False): |
1276 if selection is not None and selection[0].get(instance["id"], False): |
1276 self.SelectInGroup(element) |
1277 self.SelectInGroup(element) |
1277 |
1278 |
1278 def CreateWires(self, start_connector, id, links, ids, selection=None): |
1279 def CreateWires(self, start_connector, id, links, ids, selection=None): |
|
1280 links_connected = True |
1279 for link in links: |
1281 for link in links: |
1280 refLocalId = link["refLocalId"] |
1282 refLocalId = link["refLocalId"] |
1281 if refLocalId is not None: |
1283 if refLocalId is None: |
1282 if refLocalId not in ids: |
1284 links_connected = False |
1283 new_instance = self.Controler.GetEditedElementInstanceInfos(self.TagName, refLocalId, debug = self.Debug) |
1285 continue |
1284 if new_instance is not None: |
1286 |
1285 self.loadInstance(new_instance, ids, selection) |
1287 if refLocalId not in ids: |
1286 connected = self.FindElementById(refLocalId) |
1288 new_instance = self.Controler.GetEditedElementInstanceInfos(self.TagName, refLocalId, debug = self.Debug) |
1287 if connected is not None: |
1289 if new_instance is not None: |
1288 points = link["points"] |
1290 self.loadInstance(new_instance, ids, selection) |
1289 end_connector = connected.GetConnector(wx.Point(points[-1][0], points[-1][1]), link["formalParameter"]) |
1291 |
1290 if end_connector is not None: |
1292 connected = self.FindElementById(refLocalId) |
1291 wire = Wire(self) |
1293 if connected is None: |
1292 wire.SetPoints(points) |
1294 links_connected = False |
1293 start_connector.Connect((wire, 0), False) |
1295 continue |
1294 end_connector.Connect((wire, -1), False) |
1296 |
1295 wire.ConnectStartPoint(None, start_connector) |
1297 points = link["points"] |
1296 wire.ConnectEndPoint(None, end_connector) |
1298 end_connector = connected.GetConnector(wx.Point(points[-1][0], points[-1][1]), link["formalParameter"]) |
1297 connected.RefreshConnectors() |
1299 if end_connector is not None: |
1298 self.AddWire(wire) |
1300 wire = Wire(self) |
1299 if selection is not None and (\ |
1301 wire.SetPoints(points) |
1300 selection[1].get((id, refLocalId), False) or \ |
1302 start_connector.Connect((wire, 0), False) |
1301 selection[1].get((refLocalId, id), False)): |
1303 end_connector.Connect((wire, -1), False) |
1302 self.SelectInGroup(wire) |
1304 wire.ConnectStartPoint(None, start_connector) |
|
1305 wire.ConnectEndPoint(None, end_connector) |
|
1306 connected.RefreshConnectors() |
|
1307 self.AddWire(wire) |
|
1308 if selection is not None and (\ |
|
1309 selection[1].get((id, refLocalId), False) or \ |
|
1310 selection[1].get((refLocalId, id), False)): |
|
1311 self.SelectInGroup(wire) |
|
1312 else: |
|
1313 links_connected = False |
|
1314 |
|
1315 return links_connected |
1303 |
1316 |
1304 def IsOfType(self, type, reference): |
1317 def IsOfType(self, type, reference): |
1305 return self.Controler.IsOfType(type, reference, self.Debug) |
1318 return self.Controler.IsOfType(type, reference, self.Debug) |
1306 |
1319 |
1307 def IsEndType(self, type): |
1320 def IsEndType(self, type): |