--- a/LDViewer.py Fri Apr 06 18:06:00 2007 +0200
+++ b/LDViewer.py Tue Apr 10 18:02:40 2007 +0200
@@ -550,6 +550,10 @@
new_bbox = rung.GetBoundingBox()
self.RefreshRungs(new_bbox.height - old_bbox.height, rungindex + 1)
self.Refresh()
+ else:
+ message = wxMessageDialog(self, "You must select the wire where a contact should be added!", "Error", wxOK|wxICON_ERROR)
+ message.ShowModal()
+ message.Destroy()
def AddBranch(self):
blocks = []
@@ -645,7 +649,7 @@
right_elements = [element for element in infos["rights"]]
for right_element in right_elements:
if isinstance(right_element.GetParentBlock(), LD_PowerRail):
- infos["rights"].remove(tight_element)
+ infos["rights"].remove(right_element)
if "LD_PowerRail" not in infos["rights"]:
infos["rights"].append("LD_PowerRail")
infos["lefts"].sort()
@@ -688,7 +692,60 @@
rung.SelectElement(new_wire)
right_elements.reverse()
elif right_powerrail:
- pass
+ dialog = LDElementDialog(self.Parent, "coil")
+ varlist = []
+ vars = self.Controler.GetCurrentElementEditingInterfaceVars()
+ if vars:
+ for var in vars:
+ if var["Class"] != "Input" and var["Type"] == "BOOL":
+ varlist.append(var["Name"])
+ returntype = self.Controler.GetCurrentElementEditingInterfaceReturnType()
+ if returntype == "BOOL":
+ varlist.append(self.Controler.GetCurrentElementEditingName())
+ dialog.SetVariables(varlist)
+ dialog.SetValues({"name":"","type":COIL_NORMAL})
+ if dialog.ShowModal() == wxID_OK:
+ values = dialog.GetValues()
+ powerrail = right_elements[0].GetParentBlock()
+ index = 0
+ for right_element in right_elements:
+ index = max(index, powerrail.GetConnectorIndex(right_element))
+ if powerrail.IsNullConnector(index + 1):
+ powerrail.DeleteConnector(index + 1)
+ powerrail.InsertConnector(index + 1)
+ powerrail.RefreshModel()
+ connectors = powerrail.GetConnectors()
+ # Create Coil
+ id = self.GetNewId()
+ coil = LD_Coil(self, values["type"], values["name"], id)
+ pos = blocks[0].GetPosition()
+ coil.SetPosition(pos[0], pos[1] + LD_LINE_SIZE)
+ self.Elements.append(coil)
+ self.Blocks.append(coil)
+ rung.SelectElement(coil)
+ self.Controler.AddCurrentElementEditingCoil(id)
+ coil_connectors = coil.GetConnectors()
+ # Create Wire between LeftPowerRail and Coil
+ wire = Wire(self)
+ connectors[index + 1].Connect((wire, 0), False)
+ coil_connectors["output"].Connect((wire, -1), False)
+ wire.ConnectStartPoint(None, connectors[index + 1])
+ wire.ConnectEndPoint(None, coil_connectors["output"])
+ self.Wires.append(wire)
+ self.Elements.append(wire)
+ rung.SelectElement(wire)
+ for i, left_element in enumerate(left_elements):
+ # Create Wire between LeftPowerRail and Coil
+ new_wire = Wire(self)
+ coil_connectors["input"].Connect((new_wire, 0), False)
+ left_element.InsertConnect(left_index[i] + 1, (new_wire, -1), False)
+ new_wire.ConnectStartPoint(None, coil_connectors["input"])
+ new_wire.ConnectEndPoint(None, left_element)
+ self.Wires.append(new_wire)
+ self.Elements.append(new_wire)
+ rung.SelectElement(new_wire)
+ left_elements.reverse()
+ self.RefreshPosition(coil)
else:
left_elements.reverse()
right_elements.reverse()
@@ -720,6 +777,20 @@
new_bbox = rung.GetBoundingBox()
self.RefreshRungs(new_bbox.height - old_bbox.height, rungindex + 1)
self.Refresh()
+ else:
+ message = wxMessageDialog(self, "The group of block must be coherent!", "Error", wxOK|wxICON_ERROR)
+ message.ShowModal()
+ message.Destroy()
+ else:
+ message = wxMessageDialog(self, "You must select the block or group of blocks around which a branch should be added!", "Error", wxOK|wxICON_ERROR)
+ message.ShowModal()
+ message.Destroy()
+
+
+ def AddBlock(self):
+ message = wxMessageDialog(self, "This option isn't available yet!", "Warning", wxOK|wxICON_EXCLAMATION)
+ message.ShowModal()
+ message.Destroy()
#-------------------------------------------------------------------------------
# Delete element functions