--- a/Viewer.py Mon Aug 13 18:06:50 2007 +0200
+++ b/Viewer.py Tue Aug 14 14:53:06 2007 +0200
@@ -836,9 +836,9 @@
elif self.Mode == MODE_POWERRAIL:
wx.CallAfter(self.AddNewPowerRail, bbox)
elif self.Mode == MODE_INITIALSTEP:
- wx.CallAfter(self.AddNewInitialStep, bbox)
+ wx.CallAfter(self.AddNewStep, bbox, True)
elif self.Mode == MODE_STEP:
- wx.CallAfter(self.AddNewStep, bbox)
+ wx.CallAfter(self.AddNewStep, bbox, False)
elif self.Mode == MODE_TRANSITION:
wx.CallAfter(self.AddNewTransition, bbox)
elif self.Mode == MODE_DIVERGENCE:
@@ -903,6 +903,9 @@
self.SelectedElement.OnMotion(event, dc, self.Scaling)
self.SelectedElement.GeneratePoints()
self.Refresh()
+ event.Skip()
+
+ def UpdateScrollPos(self, event):
if (event.Dragging() and self.SelectedElement) or self.rubberBand.IsShown():
position = event.GetPosition()
move_window = wx.Point()
@@ -919,7 +922,6 @@
if move_window.x != 0 or move_window.y != 0:
self.Scroll(xstart + move_window.x, ystart + move_window.y)
self.RefreshScrollBars()
- event.Skip()
#-------------------------------------------------------------------------------
# Keyboard event functions
@@ -1145,6 +1147,39 @@
self.Refresh()
dialog.Destroy()
+ def AddNewStep(self, bbox, initial = False):
+ dialog = StepContentDialog(self.Parent, initial)
+ dialog.SetPouNames(self.Controler.GetProjectPouNames())
+ dialog.SetVariables(self.Controler.GetCurrentElementEditingInterfaceVars())
+ dialog.SetStepNames([block.GetName() for block in self.Blocks if isinstance(block, SFC_Step)])
+ dialog.SetMinStepSize((bbox.width, bbox.height))
+ if dialog.ShowModal() == wx.ID_OK:
+ id = self.GetNewId()
+ values = dialog.GetValues()
+ step = SFC_Step(self, values["name"], initial, id)
+ if values["input"]:
+ step.AddInput()
+ else:
+ step.RemoveInput()
+ if values["output"]:
+ step.AddOutput()
+ else:
+ step.RemoveOutput()
+ if values["action"]:
+ step.AddAction()
+ else:
+ step.RemoveAction()
+ step.SetPosition(bbox.x, bbox.y)
+ min_width, min_height = step.GetMinSize()
+ step.SetSize(max(bbox.width, min_width), max(bbox.height, min_height))
+ self.AddBlock(step)
+ self.Controler.AddCurrentElementEditingStep(id)
+ self.RefreshStepModel(step)
+ self.RefreshBuffer()
+ self.RefreshScrollBars()
+ self.Refresh()
+ dialog.Destroy()
+
def AddNewTransition(self, bbox):
dialog = TransitionContentDialog(self.Parent, self.GetDrawingMode() == FREEDRAWING_MODE)
dialog.SetTransitions(self.Controler.GetCurrentElementEditingTransitions())
@@ -1326,7 +1361,39 @@
self.Refresh()
dialog.Destroy()
-
+ def EditStepContent(self, step):
+ dialog = StepContentDialog(self.Parent, step.GetInitial())
+ dialog.SetPouNames(self.Controler.GetProjectPouNames())
+ dialog.SetVariables(self.Controler.GetCurrentElementEditingInterfaceVars())
+ dialog.SetStepNames([block.GetName() for block in self.Blocks if isinstance(block, SFC_Step) and block.GetName() != step.GetName()])
+ dialog.SetMinStepSize(step.GetSize())
+ values = {"name" : step.GetName()}
+ connectors = step.GetConnectors()
+ values["input"] = connectors["input"] != None
+ values["output"] = connectors["output"] != None
+ values["action"] = connectors["action"] != None
+ dialog.SetValues(values)
+ if dialog.ShowModal() == wx.ID_OK:
+ values = dialog.GetValues()
+ step.SetName(values["name"])
+ if values["input"]:
+ step.AddInput()
+ else:
+ step.RemoveInput()
+ if values["output"]:
+ step.AddOutput()
+ else:
+ step.RemoveOutput()
+ if values["action"]:
+ step.AddAction()
+ else:
+ step.RemoveAction()
+ step.UpdateSize(values["width"], values["height"])
+ step.RefreshModel()
+ self.RefreshBuffer()
+ self.RefreshScrollBars()
+ self.Refresh()
+
def EditTransitionContent(self, transition):
dialog = TransitionContentDialog(self.Parent, self.GetDrawingMode() == FREEDRAWING_MODE)
dialog.SetTransitions(self.Controler.GetCurrentElementEditingTransitions())