51 def __init__(self, parent): |
51 def __init__(self, parent): |
52 wx.TextDropTarget.__init__(self) |
52 wx.TextDropTarget.__init__(self) |
53 self.ParentWindow = parent |
53 self.ParentWindow = parent |
54 |
54 |
55 def OnDropText(self, x, y, data): |
55 def OnDropText(self, x, y, data): |
|
56 x, y = self.ParentWindow.CalcUnscrolledPosition(x, y) |
56 values = eval(data) |
57 values = eval(data) |
57 if values[1] == "program": |
58 if values[1] == "program": |
58 message = wx.MessageDialog(self.ParentWindow, "Programs can't be used by other POUs!", "Error", wx.OK|wx.ICON_ERROR) |
59 message = wx.MessageDialog(self.ParentWindow, "Programs can't be used by other POUs!", "Error", wx.OK|wx.ICON_ERROR) |
59 message.ShowModal() |
60 message.ShowModal() |
60 message.Destroy() |
61 message.Destroy() |
1284 self.RefreshBuffer() |
1285 self.RefreshBuffer() |
1285 self.RefreshScrollBars() |
1286 self.RefreshScrollBars() |
1286 self.Refresh(False) |
1287 self.Refresh(False) |
1287 dialog.Destroy() |
1288 dialog.Destroy() |
1288 |
1289 |
|
1290 def AddNewJump(self, bbox): |
|
1291 choices = [] |
|
1292 for block in self.Blocks: |
|
1293 if isinstance(block, SFC_Step): |
|
1294 choices.append(block.GetName()) |
|
1295 dialog = wx.SingleChoiceDialog(self.ParentWindow, "Add a new jump", "Please choose a target", choices, wx.OK|wx.CANCEL) |
|
1296 if dialog.ShowModal() == wx.ID_OK: |
|
1297 id = self.GetNewId() |
|
1298 value = dialog.GetStringSelection() |
|
1299 jump = SFC_Jump(self, value, id) |
|
1300 jump.SetPosition(bbox.x, bbox.y) |
|
1301 min_width, min_height = jump.GetMinSize() |
|
1302 jump.SetSize(max(bbox.width, min_width), max(bbox.height, min_height)) |
|
1303 self.AddBlock(jump) |
|
1304 self.Controler.AddCurrentElementEditingJump(id) |
|
1305 self.RefreshJumpModel(jump) |
|
1306 self.RefreshBuffer() |
|
1307 self.RefreshScrollBars() |
|
1308 self.Refresh() |
|
1309 dialog.Destroy() |
|
1310 |
|
1311 def AddNewActionBlock(self, bbox): |
|
1312 dialog = ActionBlockDialog(self.ParentWindow) |
|
1313 dialog.SetQualifierList(self.Controler.GetQualifierTypes()) |
|
1314 dialog.SetActionList(self.Controler.GetCurrentElementEditingActions()) |
|
1315 dialog.SetVariableList(self.Controler.GetCurrentElementEditingInterfaceVars()) |
|
1316 if dialog.ShowModal() == wx.ID_OK: |
|
1317 actions = dialog.GetValues() |
|
1318 id = self.GetNewId() |
|
1319 actionblock = SFC_ActionBlock(self, actions, id) |
|
1320 actionblock.SetPosition(bbox.x, bbox.y) |
|
1321 min_width, min_height = actionblock.GetMinSize() |
|
1322 actionblock.SetSize(max(bbox.width, min_width), max(bbox.height, min_height)) |
|
1323 self.AddBlock(actionblock) |
|
1324 self.Controler.AddCurrentElementEditingActionBlock(id) |
|
1325 self.RefreshActionBlockModel(actionblock) |
|
1326 self.RefreshBuffer() |
|
1327 self.RefreshScrollBars() |
|
1328 self.Refresh() |
|
1329 dialog.Destroy() |
1289 |
1330 |
1290 #------------------------------------------------------------------------------- |
1331 #------------------------------------------------------------------------------- |
1291 # Edit element content functions |
1332 # Edit element content functions |
1292 #------------------------------------------------------------------------------- |
1333 #------------------------------------------------------------------------------- |
1293 |
1334 |
1714 if powerrail.GetType() == LEFTRAIL: |
1755 if powerrail.GetType() == LEFTRAIL: |
1715 for connector in powerrail.GetConnectors(): |
1756 for connector in powerrail.GetConnectors(): |
1716 for element in connector.GetConnectedBlocks(): |
1757 for element in connector.GetConnectedBlocks(): |
1717 if element not in elements: |
1758 if element not in elements: |
1718 elements.append(element) |
1759 elements.append(element) |
1719 powerrrail.Clean() |
1760 powerrail.Clean() |
1720 self.RemoveBlock(powerrrail) |
1761 self.RemoveBlock(powerrail) |
1721 self.Controler.RemoveCurrentElementEditingInstance(powerrrail.GetId()) |
1762 self.Controler.RemoveCurrentElementEditingInstance(powerrail.GetId()) |
1722 for element in elements: |
1763 for element in elements: |
1723 element.RefreshModel() |
1764 element.RefreshModel() |
1724 |
1765 |
1725 def DeleteStep(self, step): |
1766 def DeleteStep(self, step): |
1726 elements = [] |
1767 elements = [] |