--- a/graphics/SFC_Objects.py Fri Oct 19 10:15:23 2007 +0200
+++ b/graphics/SFC_Objects.py Fri Oct 19 17:08:08 2007 +0200
@@ -371,8 +371,9 @@
self.Move(movex, 0)
self.RefreshInputPosition()
self.RefreshOutputPosition()
- else:
- Graphic_Element.ProcessDragging(self, movex, movey)
+ return True, False
+ else:
+ return Graphic_Element.ProcessDragging(self, movex, movey)
# Refresh input element model
def RefreshInputModel(self):
@@ -699,8 +700,9 @@
self.Move(movex, 0)
self.RefreshInputPosition()
self.RefreshOutputPosition()
- else:
- Graphic_Element.ProcessDragging(self, movex, movey)
+ return True, False
+ else:
+ return Graphic_Element.ProcessDragging(self, movex, movey)
# Refresh input element model
def RefreshInputModel(self):
@@ -839,11 +841,11 @@
# Remove a branch from the divergence
def RemoveBranch(self, connector):
if self.Type in [SELECTION_DIVERGENCE, SIMULTANEOUS_DIVERGENCE]:
- if connector in self.Outputs:
+ if connector in self.Outputs and len(self.Outputs) > 2:
self.Outputs.remove(connector)
self.MoveConnector(self.Outputs[0], 0)
elif self.Type in [SELECTION_CONVERGENCE, SIMULTANEOUS_CONVERGENCE]:
- if connector in self.Inputs:
+ if connector in self.Inputs and len(self.Inputs) > 2:
self.Inputs.remove(connector)
self.MoveConnector(self.Inputs[0], 0)
@@ -903,6 +905,8 @@
for output in self.Outputs:
output_pos = output.GetRelPosition()
output.SetPosition(wx.Point(output_pos.x - minx, output_pos.y))
+ self.Inputs.sort(lambda x, y: x.Pos.x.__cmp__(y.Pos.x))
+ self.Outputs.sort(lambda x, y: x.Pos.x.__cmp__(y.Pos.x))
self.Pos.x += minx
self.Size[0] = maxx - minx
connector.MoveConnected()
@@ -967,11 +971,17 @@
self.RefreshBoundingBox()
# Returns the divergence minimum size
- def GetMinSize(self):
+ def GetMinSize(self, default=False):
+ width = 0
+ if default:
+ if self.Type in [SELECTION_DIVERGENCE, SIMULTANEOUS_DIVERGENCE]:
+ width = (len(self.Outputs) - 1) * SFC_DEFAULT_SEQUENCE_INTERVAL
+ elif self.Type in [SELECTION_CONVERGENCE, SIMULTANEOUS_CONVERGENCE]:
+ width = (len(self.Inputs) - 1) * SFC_DEFAULT_SEQUENCE_INTERVAL
if self.Type in [SELECTION_DIVERGENCE, SELECTION_CONVERGENCE]:
- return 0, 1
+ return width, 1
elif self.Type in [SIMULTANEOUS_DIVERGENCE, SIMULTANEOUS_CONVERGENCE]:
- return 0, 3
+ return width, 3
return 0, 0
# Refresh the position of the block connected to connector
@@ -1093,8 +1103,10 @@
self.MoveConnector(handle, movex)
if self.Parent.GetDrawingMode() != FREEDRAWING_MODE:
self.RefreshConnectedPosition(handle)
+ return True, False
elif self.Parent.GetDrawingMode() == FREEDRAWING_MODE:
- Graphic_Element.ProcessDragging(self, movex, movey)
+ return Graphic_Element.ProcessDragging(self, movex, movey)
+ return False, False
# Refresh output element model
def RefreshOutputModel(self, move=False):
@@ -1265,8 +1277,9 @@
if self.Parent.GetDrawingMode() != FREEDRAWING_MODE:
self.Move(movex, 0)
self.RefreshInputPosition()
- else:
- Graphic_Element.ProcessDragging(self, movex, movey)
+ return True, False
+ else:
+ return Graphic_Element.ProcessDragging(self, movex, movey)
# Refresh input element model
def RefreshInputModel(self):
@@ -1441,10 +1454,12 @@
input_pos = wires[0][0].EndConnected.GetPosition(False)
if self.Pos.x - input_pos.x + movex >= SFC_WIRE_MIN_SIZE:
self.Move(movex, 0)
+ return True, False
+ return False, False
else:
- Graphic_Element.ProcessDragging(self, movex, movey)
- else:
- Graphic_Element.ProcessDragging(self, movex, movey)
+ return Graphic_Element.ProcessDragging(self, movex, movey)
+ else:
+ return Graphic_Element.ProcessDragging(self, movex, movey)
# Refreshes the action block model