rename all corresponding SFC jumps when SFC step is renamed (but only in DRIVENDRAWING_MODE)
authorAndrey Skvortsov <andrej.skvortzov@gmail.com>
Tue, 20 Dec 2016 13:26:24 +0300
changeset 1607 f9c672ed8f9e
parent 1606 99a02c6161b6
child 1608 e8efeeb718ab
rename all corresponding SFC jumps when SFC step is renamed (but only in DRIVENDRAWING_MODE)
editors/Viewer.py
--- a/editors/Viewer.py	Wed Dec 14 13:14:45 2016 +0300
+++ b/editors/Viewer.py	Tue Dec 20 13:26:24 2016 +0300
@@ -2902,7 +2902,20 @@
         if dialog.ShowModal() == wx.ID_OK:
             values = dialog.GetValues()
             rect = step.GetRedrawRect(1, 1)
-            step.SetName(values["name"])
+
+            new_name = values["name"]
+            if self.GetDrawingMode() == DRIVENDRAWING_MODE:
+                old_name = step.GetName().upper()
+                if new_name.upper() != old_name:
+                    for block in self.Blocks.itervalues():
+                        if isinstance(block, SFC_Jump):
+                            if old_name == block.GetTarget().upper():
+                                block.SetTarget(new_name)
+                                block.RefreshModel()
+                                rect = rect.Union(block.GetRedrawRect())
+                                block.Refresh(rect)
+            step.SetName(new_name)
+            
             if values["input"]:
                 step.AddInput()
             else: